How to use the rambda.both 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 / 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 terascope / teraslice / packages / elasticsearch-store / src / utils / fp.ts View on Github external
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,
    R.both(
        R.has('mapping'),
        R.propEq('template', true),
    )
);

export const isTimeSeriesIndex: indexFn = R.both(
github terascope / teraslice / packages / elasticsearch-store / src / utils / fp.ts View on Github external
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,
    R.both(
        R.has('mapping'),
        R.propEq('template', true),
    )
);

export const isTimeSeriesIndex: indexFn = R.both(
    isTemplatedIndex,
    R.propEq('timeseries', true)
github terascope / teraslice / packages / elasticsearch-store / src / utils / fp.ts View on Github external
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,
    R.both(
        R.has('mapping'),
        R.propEq('template', true),
    )
);

export const isTimeSeriesIndex: indexFn = R.both(
    isTemplatedIndex,
    R.propEq('timeseries', true)
);

export function isValidClient(input: any): input is es.Client {
    if (input == null) return false;

    const reqKeys = [
        'indices',
        'index',
github terascope / teraslice / packages / elasticsearch-store / src / utils / validation.ts View on Github external
type indexFn = (config?: 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, R.both(R.has('mapping'), R.propEq('template', true)));

export const isTimeSeriesIndex: indexFn = R.both(isTemplatedIndex, R.propEq('timeseries', true));
github terascope / teraslice / packages / elasticsearch-store / src / utils / fp.ts View on Github external
isNotNil,
    R.both(
        R.has('mapping'),
        R.pipe(R.path('template'), R.isNil)
    )
);

export const isTemplatedIndex: indexFn = R.both(
    isNotNil,
    R.both(
        R.has('mapping'),
        R.propEq('template', true),
    )
);

export const isTimeSeriesIndex: indexFn = R.both(
    isTemplatedIndex,
    R.propEq('timeseries', true)
);

export function isValidClient(input: any): input is es.Client {
    if (input == null) return false;

    const reqKeys = [
        'indices',
        'index',
        'get',
        'search',
    ];

    return reqKeys.every((key) => input[key] != null);
}
github terascope / teraslice / packages / elasticsearch-store / src / utils / fp.ts View on Github external
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,
    R.both(
        R.has('mapping'),
        R.propEq('template', true),
    )
);

export const isTimeSeriesIndex: indexFn = R.both(
    isTemplatedIndex,
    R.propEq('timeseries', true)
);

export function isValidClient(input: any): input is es.Client {
    if (input == null) return false;

    const reqKeys = [
github terascope / teraslice / packages / elasticsearch-store / src / utils / validation.ts View on Github external
return true;
}

export function isValidClient(input: any): input is es.Client {
    if (input == null) return false;

    const reqKeys = ['indices', 'index', 'get', 'search'];

    return reqKeys.every((key) => input[key] != null);
}

type indexFn = (config?: 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, R.both(R.has('mapping'), R.propEq('template', true)));

export const isTimeSeriesIndex: indexFn = R.both(isTemplatedIndex, R.propEq('timeseries', true));