Small utilities by zakodium for zakodium.
npm install @zakodium/utilsimport { assertDefinedNotNull } from '@zakodium/utils';
const value: object | string | boolean | number | null | undefined = JSON.parse(someJsonString);
assertDefinedNotNull(value); // throws if value is null or undefined
// value type is object | string | boolean | numberWith types mutations.
function assert(value: unknown, message?: string | (() => string)): asserts value;function assertUnreachable(value: never): never;function assertDefined<T>(value: T): asserts value is Exclude<T, undefined>;function assertDefinedNotNull<T>(value: T): asserts value is Exclude<T, null | undefined>;
function is<Output>(value: unknown, condition: boolean): value is Output;function cast<Output>(value: unknown): asserts value is Output;
- Iterable helpers like
map,filterand so on. Could be useful when IteratorHelpers is not available. Or add some more niche helpers likechunkify. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator - functional helpers like
pipeand so on. Could be useful until the pipe operator is not available. https://github.com/tc39/proposal-pipeline-operator