is-in-list

Determine if an item is contained in a list.

Usage no npm install needed!

<script type="module">
  import isInList from 'https://cdn.skypack.dev/is-in-list';
</script>

README

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 :)