Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('performs right-to-left function composition', () => {
// f :: (String, Number?) -> ([Number] -> [Number])
const f = R.compose(R.map, R.multiply, parseInt)
eq(f.length, 2)
eq(f('10')([ 1, 2, 3 ]), [ 10, 20, 30 ])
eq(f('10', 2)([ 1, 2, 3 ]), [ 2, 4, 6 ])
})
it('passes context to functions', () => {
it('with passed type', () => {
const fn = both( // $ExpectType Predicate
x => {
return x > 1
},
x => {
return x % 2 === 0
},
);
const result = fn(2) // $ExpectType boolean
result // $ExpectType boolean
});
it('no type passed', () => {
it('happy with curry', () => {
const fn = defaultTo('foo')
const x = fn(undefined, 'bar', null); // $ExpectType string
x // $ExpectType string
const y = fn(undefined); // $ExpectType string
y // $ExpectType string
});
it('with two types', () => {
const x = defaultTo('foo',undefined, 1, null, 2, 'bar'); // $ExpectType string | number
x // $ExpectType string | number
});
});
it('with one type', () => {
const x = defaultTo('foo','bar'); // $ExpectType string
x // $ExpectType string
});
it('with two types', () => {
it('fallback', () => {
const x = defaultTo('foo',undefined); // $ExpectType "foo"
x // $ExpectType "foo"
const y = defaultTo('foo','bar'); // $ExpectType "foo" | "bar"
y // $ExpectType "foo" | "bar"
});
it('with one type', () => {
it('with two types', () => {
const x = defaultTo('foo',1); // $ExpectType string | number
x // $ExpectType string | number
});
});
it('happy', () => {
const x = defaultTo('foo',undefined, 'bar'); // $ExpectType string
x // $ExpectType string
});
it('fallback', () => {
const x = defaultTo('foo',undefined); // $ExpectType "foo"
x // $ExpectType "foo"
const y = defaultTo('foo','bar'); // $ExpectType "foo" | "bar"
y // $ExpectType "foo" | "bar"
});
it('with one type', () => {
it('fallback with index', () => {
const result = reduce((acc, val, i) => {
acc // $ExpectType number
i // $ExpectType number
return acc + val
}, 1,[ 1, 2, 3 ])
result // $ExpectType number
});