Collection of common TS utility types, interfaces and utils.
npm install @luolapeikko/ts-common
Loadable type to handle loadable value (e.g. value, value Promise, callback function returning value).NonEmptyArray and NonEmptyReadonlyArray.RecordHaveReadonlyKeys and RecordHaveWritableKeys.OneOf type to handle one of types (non-union way).IToString, IToJSON.ArrayCore, ErrorCore, IterCore, LoadableCore, NumberCore, RecordCore, UndefCore] for easier access.import {NumberCore as N} from '@luolapeikko/ts-common';
N.isInteger(1); // true
N.isFloat(1); // false
import {RecordCore as R} from '@luolapeikko/ts-common';
const data: Data = {demo: 'hello', value: null};
const output: Pick<Data, 'value'> = R.pick(['value'], data);
const dataArray: Data[] = [{demo: 'hello', value: null}];
const output: Pick<Data, 'demo'>[] = dataArray.map(R.pick(['demo']));
import {UndefCore as U} from '@luolapeikko/ts-common';
U.isUndef(null); // true
U.isNull(null); // true
U.isNullish(null); // true
U.assertNull('test'); // throws
See more features on Package documentation