Skip to main content

isNotIn()

isNotIn<T>(array): (...args) => boolean

Creates a predicate function that determines if a value does not exist in a given array.

Type Parameters

T

T

The type of the array elements and value

Parameters

array

T[]

The array to search within

Returns

(...args): boolean

Parameters

args

...[T]

Returns

boolean

Remarks

  • Pure function with no side effects
  • Negation of isIn using functional composition
  • Uses strict equality (===) for element comparison
  • Works with any type that can be compared with strict equality

Example

const isInvalidStatus = isNotIn(['pending', 'approved', 'rejected']);
isInvalidStatus('unknown'); // true
isInvalidStatus('pending'); // false

const isNotPrime = isNotIn([2, 3, 5, 7, 11, 13]);
isNotPrime(10); // true
isNotPrime(7); // false

// Useful with arrays
const allowedIds = [101, 102, 103];
const allRequests = [101, 104, 102, 105];
const unauthorized = allRequests.filter(isNotIn(allowedIds)); // [104, 105]