How to use the ramda.propEq 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 flow-typed / flow-typed / definitions / npm / ramda_v0.x.x / flow_v0.49.x-v0.61.x / test_ramda_v0.x.x_list.js View on Github external
// Ramda doesn't strictly break if you pass it an object, but it always
  // returns undefined.
  // $ExpectError
  const findObj = find(o => o == "bar", { foo: "bar" });

  const findxs2: ?{ [k: string]: number | string } = _.findLast(
    _.propEq("a", 2),
    os
  );
  const findxs3: ?{ [k: string]: number | string } = _.findLast(
    _.propEq("a", 4)
  )(os);
  const findxs4: number = _.findIndex(_.propEq("a", 2), os);
  const findxs5: number = _.findIndex(_.propEq("a", 4))(os);
  const findxs6: number = _.findLastIndex(_.propEq("a", 2), os);
  const findxs7: number = _.findLastIndex(_.propEq("a", 4))(os);

  const s: Array = filter(x => x > 1, [1, 2]);
  const s1: Array = _.filter(x => x === "2", ["2", "3"]);
  const s3: { [key: string]: string } = _.filter(x => x === "2", {
    a: "2",
    b: "3"
  });
  const s4 = _.find(x => x === "2", ["1", "2"]);
  //$ExpectError
  const s5: ?{ [key: string]: string } = _.find(x => x === "2", { a: 1, b: 2 });
  const s6: number = _.findIndex(x => x === "2", ["1", "2"]);
  const s7: number = _.findIndex(x => x === "2", { a: "1", b: "2" });
  const forEachxs = _.forEach(x => console.log(x), ns);

  const forEachObj = _.forEachObjIndexed((value, key) => {}, { x: 1, y: 2 });
github flow-typed / flow-typed / definitions / npm / ramda_v0.x.x / flow_v0.28.x-v0.30.x / test_ramda_v0.x.x_relation.js View on Github external
const _max: number = _.max(2, 1)
const _min: number = _.min(2, 1)

const _maxBy: number = _.maxBy(Math.abs)(2, 1)
const _minBy: number = _.minBy(Math.abs, 2, 1)

const _identical: boolean = _.identical(2, 1)

const inters: Array = _.intersection(ns, ns)

const interBy:Array = _.intersectionWith(_.eqBy(Math.abs), ns, ns)

const pathEqObj: boolean = _.pathEq([ 'hello' ], 1, obj)
const pathEqObj2: boolean = _.pathEq([ 'hello' ])(1)(obj)

const propEqObj: boolean = _.propEq('hello', 1, obj)
const propEqObj2: boolean = _.propEq('hello')(1)(obj)

const sortByFirstItem = _.sortBy(_.nth(0))
const pairs = [ [ -1, 1 ], [ -2, 2 ], [ -3, 3 ] ]
const sorted: Array<[number,number]> = sortByFirstItem(pairs)

const eqA = _.eqBy(_.prop('a'))
const ls1: Array<{[k:string]:number}> = [ { a: 1 }, { a: 2 }, { a: 3 }, { a: 4 } ]
const ls2: Array<{[k:string]:number}> = [ { a: 3 }, { b: 4 }, { a: 5 }, { a: 6 } ]
const symW: Array<{[k:string]:number}> = _.symmetricDifferenceWith(eqA, ls1, ls2)
const sym: Array = _.symmetricDifference([ 1,2,3,4 ], [ 7,6,5,4,3 ])

const un: Array = _.union([ 1, 2, 3 ])([ 2, 3, 4 ])
const un1: Array<{[k:string]:number}> = _.unionWith(eqA, ls1, ls2)
github envkey / envkey-app / envkey-react / src / components / versions / version_manager.js View on Github external
_renderActionButtons(version){
    if (R.findIndex(R.propEq('envUpdateId', this.state.selectedEnvUpdateId), this.props.versions) > 0){
      const versionStr = versionToVersionStr(version)
      return <div>
        <button> this.setState({revertPreview: true})}&gt;Revert To {versionStr} - Preview Changes</button>
      </div>
    }
  }
github zerobias / speak-r / app / core / string-preprocess.js View on Github external
const _drops = (a,b)=>R.allPass([
    R.propEq('type','operator'),
    R.propEq('obj',','),
    R.eqProps('obj',R.__,b)
  ])(a)
  const drops = R.dropRepeatsWith(_drops)
github plotly / falcon / backend / persistent / Queries.js View on Github external
export function deleteQuery(fid) {
    const queries = getQueries();
    const index = findIndex(propEq('fid', fid), queries);

    if (index > -1) {
        queries.splice(index, 1);
        fs.writeFileSync(getSetting('QUERIES_PATH'), YAML.stringify(queries, 4));
    }
}
github hoschi / yode / src / js / store / fileStorage.js View on Github external
let getFunctionById = R.curry((functions, searchId) => (
R.find(R.propEq('customId', searchId), functions)
))
github pagarme / artis / src / containers / Checkout / index.js View on Github external
true,
      ['apiData', 'configs', 'antifraud'],
      this.props
    )
    const page = getActiveStep(value)
    const tangible = prop('tangible')
    const cartItems = pathOr([], ['apiData', 'cart', 'items'], this.props)

    const isAllItemsTangible = any(tangible, cartItems)

    if (
      page === 'addresses' &&
      hasRequiredPageData(page, this.props, 'billing') &&
      (!isAllItemsTangible && !antifraud)
    ) {
      const haveAddresses = propEq('page', 'addresses')
      this.setState({
        steps: reject(haveAddresses, this.state.steps),
      })

      this.navigateNextPage()

      return
    }

    if (!hasRequiredPageData(page, this.props)) {
      ReactGA.pageview(`/${page}`)
      return
    }

    this.setState({
      steps: filter(pipe(
github viddo / atom-textual-velocity / lib / view-ctrl.js View on Github external
const newKeyS = keyCode => this._keyDownBus
      .filter(R.propEq('keyCode', keyCode))
      .doAction(ev => {
        ev.preventDefault()
        ev.stopPropagation()
      })
    this.keyDownS = newKeyS(40)
github homify-iot / homify / services / gateway / core / homify.ts View on Github external
public addComponent(device) {
    device.register();
    const index = R.findIndex(R.propEq("entityId", device.entityId))(this.config.entities);
    if (index === -1) {
      log("Found new device! ", device);
    }
    this.components.push(device);
  }
github apiko-dev / Perfi / app / screens / categories / categoriesList / CategoriesListContainer.js View on Github external
const mapStateToProps = ({ categories }, { type }) => {
  const hasSpecifiedType = R.propEq('type', type);
  const getSpecifiedCategories = R.pipe(
    R.filter(hasSpecifiedType),
    R.values,
  );

  return {
    categories: getSpecifiedCategories(categories.byId),
  };
};