equals
Value equality with Object.is semantics; suitable for precise comparisons.
import { equals } from 'is-kit';// Object.is semantics are preservedequals(NaN)(NaN); // true// Literal guards narrow discriminated unionsconst isDone = equals('done' as const);// isDone: (value: unknown) => value is 'done'type Status = 'draft' | 'in-progress' | 'done';function isFinished(status: Status) {if (isDone(status)) {// Narrowed to the literal type 'done' inside this branchreturn true;}return false;}isFinished('draft'); // falseisFinished('done'); // true
equalsBy / equalsKey
Compare by derived values or by property keys when building guards.
import { equalsBy, equalsKey, isString } from 'is-kit';// Build a comparator in two steps for clarityconst lengthOfString = equalsBy(isString)((s) => s.length);const isLength3 = lengthOfString(3 as const);isLength3('foo'); // true// Key-based equality guardconst hasId1 = equalsKey('id', 1 as const);hasId1({ id: 1 }); // true