How to use the rambda.map 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 farwayer / mst-decorators / src / index.js View on Github external
name = Class.name,
  options = {auto: false},
) => {
  if (is.obj(name)) {
    options = merge(options, name)
    name = Class.name
  }

  const {preProcessSnapshot, postProcessSnapshot} = Class
  // TS class property initializers and defaults from constructor
  const values = new Class()
  const {onSnapshot, onPatch, onAction} = values

  let props = extractTaggedProps(Class, PropsKey)
  props = pipe(
    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) => {
github terascope / teraslice / packages / elasticsearch-store / src / utils / errors.ts View on Github external
import * as R from 'rambda';
import * as ts from '@terascope/utils';
import ajv from 'ajv';

export const getErrorMessages: (errors: ErrorLike[]) => string = R.pipe(
    R.map(getErrorMessage),
    R.join(', ')
);

export function throwValidationError(errors: ErrorLike[] | null | undefined): string | null {
    if (errors == null) return null;
    if (!errors.length) return null;

    const errorMsg = getErrorMessages(errors);

    const error = new ts.TSError(errorMsg, {
        statusCode: 400,
    });

    Error.captureStackTrace(error, throwValidationError);
    throw error;
}
github farwayer / mst-decorators / src / index.js View on Github external
function convertValuesToMst(obj) {
  return rdMap(val => getMstType(val) || val)(obj)
}
github jpgorman / react-append-to-body / src / render-subtree.js View on Github external
export function renderSubtree(registry) {
  return map(injectSubtree.bind(null, registry), uniqueContainers(registry))
}