const extractAlternateLabels = period => R.map( ([ language, value ]) => Value.Anonymous({ language, value }), R.difference( // exclude original label extractIndex('localizedLabels', period), [ R.pair(period.language, period.label) ] ) )
const appender = (a, b) => [ a + b, a + b ] const mapacc:[number, Array<number>] = _.mapAccum(appender, 0, ns) const mapacc1:[number, Array<number>] = _.mapAccumRight(appender, 0, ns) const nxs: boolean = _.none(x => x > 1, ns) const nthxs: ?string = _.nth(2, [ 'curry' ]) const nthxs1: ?string = _.nth(2)([ 'curry' ]) //$ExpectError const nthxs2: string = _.nth(2, [ 1, 2, 3 ]) const xxs: Array<number> = _.append(1, [ 1, 2, 3 ]) const xxxs: Array<number> = _.intersperse(1, [ 1, 2, 3 ]) const pairxs:[number,string] = _.pair(2, 'str') const partxs:[Array<string>,Array<string>] = _.partition(_.contains('s'), [ 'sss', 'ttt', 'foo', 'bars' ]) const partxs1: [{[k:string]:string}, {[k:string]:string}] = _.partition(_.contains('s'), { a: 'sss', b: 'ttt', foo: 'bars' }) const pl:Array<number|string> = _.pluck('a')([ { a: '1' }, { a: 2 } ]) const pl1:Array<number> = _.pluck(0)([ [ 1, 2 ], [ 3, 4 ] ]) const rxs: Array<number> = _.range(1, 10) const remxs: Array<string> = _.remove(0, 2, ss) const remxs1: Array<string> = _.remove(0, 2)(ss) const remxs2: Array<string> = _.remove(0)(2)(ss) const remxs3: Array<string> = _.remove(0)(2, ss) const ys4: Array<string> = _.repeat('1', 10)
const appender = (a, b) => [a + b, a + b]; const mapacc: [number, Array<number>] = _.mapAccum(appender, 0, ns); const mapacc1: [number, Array<number>] = _.mapAccumRight(appender, 0, ns); const nxs: boolean = _.none(x => x > 1, ns); const nthxs: ?string = _.nth(2, ["curry"]); const nthxs1: ?string = _.nth(2)(["curry"]); //$ExpectError const nthxs2: string = _.nth(2, [1, 2, 3]); const xxs: Array<number> = _.append(1, [1, 2, 3]); const xxxs: Array<number> = _.intersperse(1, [1, 2, 3]); const pairxs: [number, string] = _.pair(2, "str"); const partxs: [Array<string>, Array<string>] = _.partition(_.contains("s"), [ "sss", "ttt", "foo", "bars" ]); const partxs1: [ { [k: string]: string }, { [k: string]: string } ] = _.partition(_.contains("s"), { a: "sss", b: "ttt", foo: "bars" }); const pl: Array<number | string> = _.pluck("a")([{ a: "1" }, { a: 2 }]); const pl1: Array<number> = _.pluck(0)([[1, 2], [3, 4]]);
const aside = fn => ifElse( is(Array), over(lensIndex(0), wrapCompose(fn)), pair(fn) );
site => [R.pair(site.name, site.homepage)]);
/** * * @param whiteList [*] * @param value * * * @returns {[boolean, *]} */ function allow(whiteList, value) { return R.pair(whiteList.includes(value), value) }
const R = require('ramda') , { FieldList, extract, as } = require('./Field') , { LinkValue , TextValue , LinkifiedTextValue , AgentValue } = require('./Value') const extractFirstOf = keysOrPaths => R.pipe( R.of, R.ap(R.map(extract, keysOrPaths)), R.find(R.compose(R.not, R.isEmpty)), R.ifElse(R.identity, R.identity, R.always([])), ) const orPartOf = R.converge(R.concat, [R.identity, R.map(R.pair('partOf'))]) const SOURCE_FIELDS = [ { label: 'Title', values: as('text')(extractFirstOf(orPartOf([ 'title' ]))), component: TextValue }, { label: 'Creators', values: extractFirstOf(orPartOf([ 'creators' ])), component: AgentValue }, { label: 'Contributors', values: extractFirstOf(orPartOf([ 'contributors' ])),
R.chain(([ k, vs ]) => vs.map(R.pair(k))),
const addIndexToError = (v, i) => pair( head(v).leftMap(map(concat(`index ${i.toString()}: Key: `))), last(v).leftMap(map(concat(`index ${i.toString()}: Value: `))) );