How to use the ramda.pipe function in ramda

To help you get started, we’ve selected a few ramda 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 circuitsim / circuit-simulator / src / circuit / CircuitUpdater.js View on Github external
export function toNodes(views) {
  const groundIDs = R.pipe(
    R.values,
    R.filter(v => v.typeID === Models.Ground.typeID),
    R.map(v => ({
      viewID: v.id,
      index: 1 // implicit second connector connected to GROUND_NODE
    }))
  )(views);

  return R.pipe(
    R.values,
    R.chain(toConnectors), // chain === flatMap
    R.groupBy(position),
    R.values,
    R.map(merge),
    R.insert(GROUND_NODE, groundIDs)
  )(views);
github Ryanair / linters / packages / eslint-plugin / lib / rules / no-element-directive.js View on Github external
/**
 * @fileoverview Prefer use of component over element directive
 * @author Patryk Galuszka
 */
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const { pipe, prop } = require('ramda');
const { getObjectPropertyValue } = require('../helpers/ast-utils');
const { getDirectiveConfig, isModuleRegister } = require('../helpers/angularJs');

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
const getRestict = pipe(
  getDirectiveConfig,
  getObjectPropertyValue('restrict')
);

const hasElementSymbol = (node) => {
  const value = prop('value', node);
  return value && (value.indexOf('E') > -1);
};

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
  meta: {
    docs: {
      description: 'Prefer use of component over element directive',
github alanbo / serverless-cms / admin / src / components / inputs / pages / PageInput.tsx View on Github external
function toLabelValue(fragments = {}, type) {
  return R.pipe(
    // @ts-ignore
    R.values(),
    // @ts-ignore
    R.filter(fg => fg.type === type),
    // @ts-ignore
    R.groupBy(item => item.type),
    R.mapObjIndexed(
      R.map(obj => ({
        // @ts-ignore
        label: obj.name,
        // @ts-ignore
        value: obj.id
      })),
    ),
    R.prop(type)
  )(fragments);
github bnankiewicz / organic / src / sagas.js View on Github external
if (changes.length === 0) return;

  const fileId = changes[0].fileId;
  const changesDict = R.indexBy(R.prop("id"), changes);

  /* ------------- update data ------------- */
  yield put(OrgDataRedux.updateLoadedNodes(changesDict));

  /* ------------- reorder ids ------------- */
  const newIds = R.sortBy(
    id =>
      changesDict[id] ? changesDict[id].position : loadedNodesData[id].position,
    loadedNodesIds
  );

  const newTOC = R.pipe(
    R.filter(
      id =>
        changesDict[id]
          ? changesDict[id].level === 1
          : loadedNodesData[id].level === 1
    )
  )(newIds);

  yield put(OrgDataRedux.updateFileIds(fileId, newIds, newTOC));

  yield* markFilesAsChanged([ids[0]])

  /* ------------- update realm database ------------- */

  for (var i = 0; i < changes.length; i++) {
    yield call(
github flow-typed / flow-typed / definitions / npm / ramda_v0.x.x / flow_v0.28.x-v0.30.x / test_ramda_v0.x.x_functions.js View on Github external
}
const getMetrics = _.applySpec(spec)
const apspec: $Shape = getMetrics(2, 2)

const cmp: (x: Object, y: Object) => number = _.comparator((a, b) => a.age < b.age)
const compf: number = _.compose(_.inc, _.negate)(2)

const fn = compose(_.add)
const fn1: (n: number) => number = fn(2)
const add2 = _.compose(_.add(2))
const four: number = add2(2)
const str0: Array = _.compose(_.match(/2/), _.toLower, _.trim)(' 1,2,3 ')
const str1: Array = _.compose(_.split(','), _.toLower, _.trim)(' 1,2,3 ')
const str2: string = _.compose(_.replace('3', '4'), _.toLower, _.trim)(' 1,2,3 ')

const fn2:(n: number) => (n: number) => number = pipe(_.add)
const fn3: (n: number) => number = fn2(2)
const add2p = _.pipe(_.add(2))
const b: number = add2(2)
const fail: string = _.pipe(_.trim)('h')
const str3: Array = _.pipe(_.toLower, _.trim, _.match(/2/))(' 1,2,3 ')
const str4: Array = _.pipe(_.toLower, _.trim, _.split(','))(' 1,2,3 ')
const str5: string = _.pipe(_.replace('3', '4'), _.toLower, _.trim)(' 1,2,3 ')

const currfn: (y: number) => number = _.curry((x: number, y: number): number => x + y)(2)
const currfn1: (y: number) => number = _.curryN(2, (x: number, y: number): number => x + y)(2)

const flipped: (x: number, y: boolean, z: string) => number = _.flip((x: boolean, y: number, z: string) => 1)
const flipped2: (x: number, y: boolean) => (z: string) => number = _.flip((x: boolean, y: number, z: string) => 1)
const obb = {
  doStuff(x: string, y: number, z: boolean) {
    return 1
github infinitered / reactotron / package.js View on Github external
exec("npm list electron --depth 0 --dev", (err, stdout) => {
    if (err) {
      DEFAULT_OPTS.electronVersion = "3.0.3"
    } else {
      DEFAULT_OPTS.electronVersion = R.pipe(
        R.split(/\s/),
        R.find(RS.startsWith("electron@")),
        R.split("@"),
        R.last
      )(stdout)
    }
    doEverything()
  })
}
github goldwasserexchange / serverless-plugin-webpack / src / lib / service.js View on Github external
const R = require('ramda');

const makeRelative = R.replace(/[^!]+$/, R.concat('../'));
const makeAllRelative = p => R.when(R.prop(p), R.over(R.lensProp(p), R.map(makeRelative)));
const makePackageRelative = R.compose(makeAllRelative('include'), makeAllRelative('exclude'));

const setPackage = R.pipe(
  R.defaultTo({}),
  makePackageRelative,
  R.over(R.lensProp('exclude'), R.append('**')),
  R.assoc('individually', true)
);

const fnPath = R.compose(R.replace(/\.[^.]+$/, '.js'), R.prop('handler'));

const setFnsPackage = R.map(R.pipe(
  R.when(R.prop('package'), R.over(R.lensProp('package'), makePackageRelative)),
  R.converge(
    R.over(R.lensPath(['package', 'include'])),
    [R.compose(R.append, fnPath), R.identity]
  )
));

const setFnsArtifacts = (serverlessPath, fns) => R.map(
  R.over(
    R.lensPath(['package', 'artifact']),
    artifact => path.join(serverlessPath, path.basename(artifact))
  ),
  fns
);

module.exports = {
github OpenCTI-Platform / opencti / opencti-front / src / private / components / stix_observable / StixObservableEditionOverview.js View on Github external
}).then((data) => {
      const markingDefinitions = pipe(
        pathOr([], ['markingDefinitions', 'edges']),
        map(n => ({ label: n.node.definition, value: n.node.id })),
      )(data);
      this.setState({
        markingDefinitions: union(
          this.state.markingDefinitions,
          markingDefinitions,
        ),
      });
    });
  }
github intraxia / wp-gistpen / client / components / EditPage / Description.js View on Github external
name="description" size="30"
                    id="title" spellCheck="true"
                    autoComplete="off" />
            
            <div>
                {stream$.thru(view(props =&gt; props.loading)).map((loading: boolean) =&gt; (
                    loading ?  : null
                ))}
            </div>
        
    
);

export default toJunction({
    events: {
        onDescriptionChange: R.map(R.pipe(R.path(['target', 'value']), editorDescriptionChange))
    }
})(Description);