How to use the rambda.all function in rambda

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 / _typings_tests / all-spec.ts View on Github external
it('happy', () => {
    const x = all(y => {
      y // $ExpectType number
      return y > 0
    })([1, 2,3 ]);
    x // $ExpectType boolean

    const q = all(y => y > 0,[1, 2,3 ]); // $ExpectType boolean

    q // $ExpectType boolean
  });
});
github terascope / teraslice / packages / elasticsearch-store / src / utils / elasticsearch.ts View on Github external
R.pipe(
            R.path(field as any),
            (input: any) => new Date(input).getTime()
        ),
        () => Date.now()
    );
}

export function shardsPath(index: string): (stats: any) => i.Shard[] {
    return R.pathOr([], [index, 'shards']);
}

export const verifyIndexShards: (shards: i.Shard[]) => boolean = R.pipe(
    // @ts-ignore
    R.filter((shard: i.Shard) => shard.primary),
    R.all((shard: i.Shard) => shard.stage === 'DONE')
);

export function timeseriesIndex(index: string, timeSeriesFormat: i.TimeSeriesFormat = 'monthly'): string {
    const formatter = {
        daily: 10,
        monthly: 7,
        yearly: 4,
    };

    const format = formatter[timeSeriesFormat];
    if (!format) throw new Error(`Unsupported format "${timeSeriesFormat}"`);

    const dateStr = new Date().toISOString();
    // remove -* or * at the end of the index name
    const indexName = index.replace(/\-{0,1}\*$/, '');
    return `${indexName}-${dateStr.slice(0, format).replace(/-/g, '.')}`;
github terascope / teraslice / packages / elasticsearch-store / src / utils / fp.ts View on Github external
R.path('statusCode'),
        R.path('status')
    ),
    R.defaultTo(500)
);

type Shard = { primary: boolean, stage: string };

export function shardsPath(index: string): (stats: any) => Shard[] {
    return R.pathOr([], [index, 'shards']);
}

export const verifyIndexShards: (shards: Shard[]) => boolean = R.pipe(
    // @ts-ignore
    R.filter((shard: Shard) => shard.primary),
    R.all((shard: Shard) => shard.stage === 'DONE')
);

export const getRolloverFrequency = R.pathOr('monthly', ['indexSchema', 'rollover_frequency']);

type indexFn = (config?: i.IndexSchema) => boolean;

export const isSimpleIndex: indexFn = R.both(
    isNotNil,
    R.both(
        R.has('mapping'),
        R.pipe(R.path('template'), R.isNil)
    )
);

export const isTemplatedIndex: indexFn = R.both(
    isNotNil,
github selfrefactor / rambda / files / failing_ramda_tests / compose.js View on Github external
jsv.property('associative', jsv.fn(), jsv.fn(), jsv.fn(), jsv.nat, (f, g, h, x) => {
    const result = f(g(h(x)))

    return R.all(R.equals(result), [
      R.compose(f, g, h)(x),
      R.compose(f, R.compose(g, h))(x),
      R.compose(R.compose(f, g), h)(x),
    ])
  })
})
github selfrefactor / rambda / files / failing_ramda_tests / curry.js View on Github external
jsv.property('curries with placeholder', funcN(3), jsv.json, jsv.json, jsv.json, (f, a, b, c) => {
    const _ = {
      '@@functional/placeholder' : true,
      'x'                        : Math.random(),
    }
    const g = R.curry(f)

    return R.all(R.equals(f(a, b, c)), [
      g(_, _, c)(a, b),
      g(a, _, c)(b),
      g(_, b, c)(a),
      g(a, _, _)(_, c)(b),
      g(a, b, _)(c),
    ])
  })
})