How to use the rambda.filter 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 / filter-spec.ts View on Github external
it('2', () => {
    const x = filter((a, b)=> { // $ExpectType number[]
      a // $ExpectType number
      return a > 1
    },[1,2,3]);
    x // $ExpectType number[]
  });
})
github farwayer / mst-decorators / src / index.js View on Github external
rdMap(args => args[0]),
    convertValuesToMst,
  )(props)

  const propKeys = Object.keys(props)
  const viewKeys = Object.keys(extractTaggedProps(Class, ViewsKey))
  const ownKeys = Object.getOwnPropertyNames(values)
  const omitKeys = ExcludeKeys.concat(propKeys).concat(viewKeys)
  const descs = getOwnPropertyDescriptors(Class.prototype)

  const views = pick(viewKeys, descs)
  const volatile = omit(omitKeys, pick(ownKeys, values))
  const actions = {}

  pipe(
    filter((desc, key) => !omitKeys.includes(key)),
    forEach((desc, key) => {
      const {get, set, value} = desc
      if (get || set) return views[key] = desc
      if (is.fn(value)) return actions[key] = value
    }),
  )(descs)

  const mstType = getMstType(Class) // es6 extending
  let Model = mstType
    ? mstType.named(name).props(props)
    : MstTypes.model(name, props)

  Model = isEmpty(volatile) ? Model : Model.volatile(() => volatile)
  Model = isEmpty(actions) ? Model : modelActions(Model)(() => actions)
  Model = isEmpty(views) ? Model : Model.views(viewBinder(views))
github terascope / teraslice / packages / elasticsearch-store / src / utils / elasticsearch.ts View on Github external
R.has(field),
        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}\*$/, '');
github terascope / teraslice / packages / elasticsearch-store / src / utils / fp.ts View on Github external
R.has('statusCode'),
        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(
github jpgorman / react-append-to-body / src / render-subtree.js View on Github external
function injectSubtree(registry, selector) {
  return compose(
    partial(appendToDOM, [selector]),
    reduce(
      (arrayOfElements, item) => (
        arrayOfElements.push(item.element), arrayOfElements
      ),
      []
    ),
    filter(propEq("selector", selector))
  )(covertToArray(registry))
}
github jpgorman / react-append-to-body / demo / complex.js View on Github external
removeModal(names) {
    const modals = filter(name => !contains(name, names), this.state.modals);
    this.setState({
      modals
    });
  }