@tsupc/array
v0.1.0
Published
Small, tree-shakeable array helpers for TypeScript and JavaScript.
Readme
@tsupc/array
Small, tree-shakeable array helpers for TypeScript and JavaScript.
Install
npm install @tsupc/arrayUsage
import { contains } from "@tsupc/array";
contains([1, 2, 3], 2);
// => true
contains(["1", "2", "3"], 2);
// => falseCommonJS is supported as well:
const { contains } = require("@tsupc/array");API
contains(array, item)
Returns true when array contains item using strict equality (===).
contains([1, 2, 3], 2);
// => trueImportant behavior:
- No type coercion is performed, so
1and"1"are treated as different values. NaNdoes not match itself because the helper uses===.- The input array is never modified.
License
MIT
