is-in-list

0.2.1 • Public • Published

Is in list? Build Status npm version

Returns whether a certain item is in the provided list.

Install

$ npm i is-in-list

Usage

'use strict';
var isInList = require('is-in-list');
 
var listOfAwesomePeople = [
  { name: 'Sabrina' },
  { name: 'Gustav' },
  { name: 'Mattias' },
];
 
console.log('is Sabrina awesome?', isInList(listOfAwesomePeople, { name: 'Sabrina' }));

With curry-ing:

'use strict';
var not = require('not');
var isInList = require('is-in-list');
 
var paramsBlackList = [
  'skip',
  'link',
  'page',
  'sort',
  'embed',
  'limit',
  'fields',
  'pagination',
];
 
var query = {
  foo: 'bar',
  baz: 'qnx',
  sort: '-foo',
};
 
var acceptedParams = Object
.keys(query)
.filter(not(isInList(paramsBlackList)));
 
console.log('accepted param keys are:', acceptedParams);

Reasoning

Why use this and not underscore / lodash / ramda / <insert functional library here>

Because what I'm looking for is simpler than what any of those libraries have to offer. Please think of this library as a simple experiment of re-inventing the wheel to see how it works :)

Package Sidebar

Install

npm i is-in-list

Weekly Downloads

4

Version

0.2.1

License

ISC

Last publish

Collaborators

  • francisbrito