Skip to main content
Module

x/rambda/includes.js

Faster and smaller alternative to Ramda
Go to Latest
File
import { _isArray } from './_internals/_isArray'import { equals } from './equals'
export function includesArray(valueToFind, input){ let index = -1
while (++index < input.length){ if (equals(input[ index ], valueToFind)){ return true } }
return false}
export function includes(valueToFind, input){ if (arguments.length === 1) return _input => includes(valueToFind, _input) if (typeof input === 'string'){ return input.includes(valueToFind) } if (!input){ throw new TypeError(`Cannot read property \'indexOf\' of ${ input }`) } if (!_isArray(input)) return false
return includesArray(valueToFind, input)}