How to use rambda - 10 common examples

To help you get started, we’ve selected a few rambda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github selfrefactor / rambda / files / failing_ramda_tests / compose.js View on Github external
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', () => {
github selfrefactor / rambda / _typings_tests / both-spec.ts View on Github external
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', () => {
github selfrefactor / rambda / _typings_tests / defaultTo-spec.ts View on Github external
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
  });
github selfrefactor / rambda / _typings_tests / defaultTo-spec.ts View on Github external
it('with two types', () => {
    const x = defaultTo('foo',undefined, 1, null, 2, 'bar'); // $ExpectType string | number
    x // $ExpectType string | number
  });
});
github selfrefactor / rambda / _typings_tests / defaultTo-spec.ts View on Github external
it('with one type', () => {
    const x = defaultTo('foo','bar'); // $ExpectType string
    x // $ExpectType string
  });
  it('with two types', () => {
github selfrefactor / rambda / _typings_tests / defaultTo-spec.ts View on Github external
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', () => {
github selfrefactor / rambda / _typings_tests / defaultTo-spec.ts View on Github external
it('with two types', () => {
    const x = defaultTo('foo',1); // $ExpectType string | number
    x // $ExpectType string | number
  });
});
github selfrefactor / rambda / _typings_tests / defaultTo-spec.ts View on Github external
it('happy', () => {
    const x = defaultTo('foo',undefined, 'bar'); // $ExpectType string
    x // $ExpectType string
  });
github selfrefactor / rambda / _typings_tests / defaultTo-spec.ts View on Github external
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', () => {
github selfrefactor / rambda / _typings_tests / reduce-spec.ts View on Github external
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
  });