StaticassertStaticassertAsserts that the given value is not an Record.
The value to check.
StaticbuildStaticentriesType-safe Object.entries() with overload for NonEmptyArray
The object shape
The object shape to get the values from
Array of tuples with key and value
const result1: NonEmptyReadonlyArray<['key', 'value']> = RecordCore.entries({key: 'value'} as const);
const result2: Array<['key', string]> = RecordCore.entries({key: 'value'});
const result3: Array<[string, string]> = RecordCore.entries<Record<string, string>>({key: 'value'});
const result4: [] = RecordCore.entries({});
StaticisStaticisChecks if the given value is not an Record.
The value to check.
True if the value is not an object; otherwise, false.
StatickeysType-safe Object.keys() with overload for NonEmptyArray
The object shape
The object shape to get the values from
Array of object keys
StaticomitOmit function to omit keys from an object or use as map function to omit keys from an array
Omit keys
Object type
omitted object or map function
type Data = {demo: string, value: number|null};
const data: Data = {demo: 'hello', value: null};
const output: Omit<Data, 'value'> = RecordCore.omit(['value'], data);
const dataArray: Data[] = [{demo: 'hello', value: null}];
const output: Omit<Data, 'demo'>[] = dataArray.map(RecordCore.omit(['demo']));
Use RecordMapper.omit for omit mapping.
StaticonCreates a function that selects a specific property value from an object.
Useful for use with arrays map function when extracting a single property from each object.
Object target from which the property will be selected
Property name in target that will be selected
The property name to select
select value by key from the target
Use RecordMapper.prop instead
Use RecordMapper.prop instead
StaticonCreates a predicate function that checks whether a given object's property equals the specified value.
Supports both strictly typed object structures and looser records with optional properties.
Useful for filtering arrays of objects based on property values.
The object type with known keys (strict overload).
The key of the property to compare.
A predicate for use with arrays of type T.
use RecordPredicate.propEq instead.
// Strict object structure
const isAdmin = RecordCore.onKeyEqual<User, 'role'>('role', 'admin');
const admins = users.filter(isAdmin);
use RecordPredicate.propEq instead
StaticonCreates a predicate function that checks whether a given object's property does not equal the specified value.
Supports both strictly typed object structures and looser records with optional properties.
Useful for filtering arrays of objects where you want to exclude items with a certain property value.
The object type with known keys (strict overload).
The key of the property to compare.
A predicate function returning true when obj[key] !== value.
use RecordPredicate.propNotEq instead.
// Strict object structure
const isNotAdmin = RecordCore.onKeyNotEqual<User, 'role'>('role', 'admin');
const nonAdmins = users.filter(isNotAdmin);
use RecordPredicate.propNotEq instead
StaticpickPick function to pick keys from an object or use as map function to pick keys from an array
Pick keys
Object type
picked object or map function
type Data = {demo: string, value: number|null};
const data: Data = {demo: 'hello', value: null};
const output: Pick<Data, 'value'> = RecordCore.pick(['value'], data);
const dataArray: Data[] = [{demo: 'hello', value: null}];
const output: Pick<Data, 'demo'>[] = dataArray.map(RecordCore.pick(['demo']));
Use RecordMapper.pick for pick mapping.
StaticresultCreates a CoreResult object which contains the result of the validation check.
The type of the value to check.
The value to check.
Core Result object.
StaticvaluesType-safe Object.values() with overload for NonEmptyArray
The object shape
The object shape to get the values from
Array of object values
The core Object functions
Since
v1.0.0