How to use the filter function from ramda

Find comprehensive JavaScript ramda.filter code examples handpicked from public code repositorys.

297
298
299
300
301
302
303
304
305
306
    return deleteResources(gremlinClient, args.resourceIds);
case 'getLinkedNodesHierarchy':
    if (!isArn(args.id)) throw new Error('The id parameter must be a valid ARN.');
    return getLinkedNodesHierarchy(gremlinClient, args.id);
case 'batchGetLinkedNodesHierarchy':
    const invalidArns = R.filter(id => !isArn(id), args.ids);
    if (!R.isEmpty(invalidArns)) {
        logger.error({invalidArns}, 'Invalid ARNs provided. ');
        throw new Error('The following ARNs are invalid: ' + invalidArns);
    }
fork icon65
star icon620
watch icon0

156
157
158
159
160
161
162
163
164
165
  tile: [],
};

let tiles = R.compose(
  R.uniq,
  R.filter(R.propEq("color", color)),
  R.map(getTile)
)(R.keys(game.tiles));

R.mapObjIndexed((dups, id) => {
fork icon52
star icon51
watch icon0

211
212
213
214
215
216
217
218
219
220
        }
      )
  }, files)
}

const filesWithExtension = (extension, files) => R.filter((f) => R.path(['extension'], f) === extension, files)

const cp = (fromDir, toDir) => {
  if (exists(fromDir) && exists(toDir)) {
    const files = filesFromDir(cdw(fromDir))
fork icon3
star icon44
watch icon6

+ 5 other calls in file

43
44
45
46
47
48
49
50
51
52
53
54


const enumDef = (e, values) => `enum ${e} {
\t${camelToSnakeCase(e).toUpperCase()}_UNSPECIFIED = 0;
${mapIndexed(
  (v, idx) => `\t${camelToSnakeCase(extractValue(v)).toUpperCase()} = ${idx + 1};`,
  R.filter((v) => extractValue(v).indexOf('UNSPECIFIED') < 1, values)
).join(EOL)}
}`


const messageDef = ({ name, fields, directives }, _isRequiredProps, isArrayProps, isEnumProps, _stringFormatter) => {
fork icon3
star icon44
watch icon6

654
655
656
657
658
659
660
661
662
663
  R.join(", ")
);

const getHtmlHintErrors = R.pipe(
  R.keys,
  R.filter((x) => HTMLERRORS.indexOf(x) >= 0)
);

htmlIssuesSummary &&
  consoleBox("HtmlHint issues: " + getSummaryText(htmlIssuesSummary), "red");
fork icon2
star icon5
watch icon0

+ 3 other calls in file

20
21
22
23
24
25
26
27
28
29
const nameToContent = (acc, name) => R.assoc(shortName(name), R.trim(readFile(name)), acc);

const loadSql = (location) => {
  const files = fs.readdirSync(location);
  const load = R.pipe(
    R.filter(sqlFile),
    R.map(join(location)),
    R.reduce(nameToContent, {})
  );
  return load(files);
fork icon1
star icon6
watch icon0

+ 3 other calls in file

46
47
48
49
50
51
52
53
54
55
const getEventsByAdmin = async (adminId = null) => {
  const events = await getEvents(adminId);
  if (events) {
    const notClosed = event => event.status !== eventStatuses.CLOSED;
    const pickProps = items => items.map(item => R.pick(eventPublicProps, item));
    return R.filter(notClosed, sortByCreatedAt(pickProps(Object.values(events))));
  }
  return null;
};

fork icon12
star icon5
watch icon0

367
368
369
370
371
372
373
374
375
376
377
});
exports.getChart = getChart;


var getHotelsMarkers = function getHotelsMarkers() {
  return (0, _reselect.createSelector)(getFlattenPrices(), _selectors2.hotelsHub, function (prices, hotels) {
    return R.filter(Boolean, R.map(R.pipe(function (_ref23) {
      var hotelID = _ref23.hotelID,
          _ref23$offers = _slicedToArray(_ref23.offers, 1),
          offerID = _ref23$offers[0];

fork icon0
star icon3
watch icon4

+ 83 other calls in file

198
199
200
201
202
203
204
205
206
207
    'salary': 1000000
}

function transform(input) {
    const pairs = _.toPairs(input)
    const filteredPairs = _.filter(_.compose(_.is(Number), _.view(_.lensIndex(1))), pairs)
    return _.fromPairs(filteredPairs)
}

console.log("transform=", transform(input)) // output
fork icon1
star icon2
watch icon0

+ 7 other calls in file

130
131
132
133
134
135
136
137
138
139
    R.map(R.pipe(
      R.trim,
      R.match(/Run #\d+: ActivityRecord{\w+ \w+ ([\w\.\/]+)/),
      it => it ? it[1] : null,
    )),
    R.filter(R.identity),
  )();
}

get isWake () {
fork icon1
star icon1
watch icon0

714
715
716
717
718
719
720
721
722
723
724
725
  var isDir = _fsExtra.default.existsSync(sourcePath) && _fsExtra.default.lstatSync(sourcePath).isDirectory();


  return (0, _normalizePath.default)(_path.default.relative(process.cwd(), sourcePath), false) + (isDir ? "/" : "");
}


var cleanObsolete = R.filter(function (message) {
  return !message.obsolete;
});
exports.cleanObsolete = cleanObsolete;

fork icon1
star icon0
watch icon0

211
212
213
214
215
216
217
218
219
220
221
 */
/* eslint-disable  no-underscore-dangle */
export function getCanChooseAbox(ABOXES = [], allCharts = [], selected = []) {
  return R.compose(
    R.innerJoin((a, b) => a.componentName == b.component_id, R.__, allCharts),
    R.filter(x => selected.indexOf(x.ChartId) < 0)
  )(ABOXES);
}


export function getCanChooseBbox(BBOXES, allCharts, selected) {
fork icon1
star icon0
watch icon0

+ 5 other calls in file

187
188
189
190
191
192
193
194
195
196
//
// Pick the instantiate function
//

const initSelector = R.pipe(
  R.filter((c) => c.label === 'default' || c.label === 'new'),
  R.sortBy((c) => c.args.length),
  i => R.head(i),
  (i) => i ? i.selector : undefined,
)(contractFile.V3.spec.constructors)
fork icon1
star icon0
watch icon1

+ 339 other calls in file

50
51
52
53
54
55
56
57
58
59
R.groupBy(o => o.source),
R.map(o => ({
  date: new Date(o.updated),
  title: o.document.title,
  source: o.target[0].source,
  content: R.filter(R.complement(R.isNil), R.pluck('exact', o.target[0].selector))[0],
  text: o.text
})),
R.reverse(),
R.filter(e => dateInBetween(new Date(e.updated), beg, end))
fork icon0
star icon6
watch icon0

+ 2 other calls in file

10
11
12
13
14
15
16
17
18
19
20
21


const getJson = url => fetch(url).then(response => response.json())


const transformTunes = R.pipe(
  // there are bugs in the data, ignore records where the tune id is not a number
  R.filter(tune => parseInt(tune.tune).toString() === tune.tune),
  R.map(tune => ({
    id: tune.tune,
    type: tune.type,
    names: [tune.name],
fork icon0
star icon4
watch icon0

114
115
116
117
118
119
120
121
122
123
124
125


exports.getOffersEntitiesMap = getOffersEntitiesMap;


var getUnusedPrices = function getUnusedPrices(nextPrices, unusedPrices) {
  return R.call(R.pipe(getHotelsIDsFromPrices, function (usedHotels) {
    return R.filter(function (_ref7) {
      var hotelID = _ref7.hotelID;
      return !R.includes(hotelID, usedHotels);
    }, unusedPrices);
  }), nextPrices);
fork icon0
star icon3
watch icon0

131
132
133
134
135
136
137
138
139
140
141
142
143
};


exports.getOperator = getOperator;


var getActiveOperators = function getActiveOperators() {
  return (0, _reselect.createSelector)(getOperators(), R.filter(R.prop('active')));
};


exports.getActiveOperators = getActiveOperators;
var getCountriesByImmutableStructure = (0, _reselect.createSelector)(domain, function (geo) {
fork icon0
star icon3
watch icon0

61
62
63
64
65
66
67
68
69
70
71
  JSON.stringify,
  R.when(
    R.compose(R.equals(0), R.view(lens.attempts)),
    R.omit(['attempts'])
  ),
  R.filter(isUseful)
)


module.exports = {
  fromString,
fork icon0
star icon4
watch icon0

27
28
29
30
31
32
33
34
35
36
var pipeline = redis.pipeline();
var user = obj.metadata.user;
var elements = obj.elements;

// Only process ways
var ways = R.filter(R.propEq('type', 'way'), elements);

var geojsonDiff = {
  'type': 'FeatureCollection',
  'features': [],
fork icon4
star icon1
watch icon44

90
91
92
93
94
95
96
97
98
99
      i,
      dup: !!_.find(userPeriods, claim),
      claim
    }
  }),
  R.filter((claim) => {
    return !claim.dup
  })
)
const extra = filter(claimData)
fork icon0
star icon1
watch icon6

Other functions in ramda

Sorted by popularity

function icon

ramda.clone is the most popular function in ramda (30311 examples)