Skip to main content
Version: 0.17

@orbit/utils

Interfaces​

Type aliases​

RequireProperty​

Ƭ RequireProperty<T, K>: Required<Pick<T, K>> & Omit<T, K>

A type to narrow an interface by requiring a specific property or properties that are optional in the base interface.

Type parameters​

NameType
TT
Kextends keyof T

Defined in​

types.ts:12

Functions​

camelize​

â–¸ camelize(str): string

Convert underscored, dasherized, or space-delimited words into lowerCamelCase.

deprecated since v0.17

Parameters​

NameType
strstring

Returns​

string

Defined in​

strings.ts:19


capitalize​

â–¸ capitalize(str): string

Uppercase the first letter of a string, but don't change the remainder.

deprecated since v0.17

Parameters​

NameType
strstring

Returns​

string

Defined in​

strings.ts:6


clone​

â–¸ clone(obj): any

Clones a value. If the value is an object, a deeply nested clone will be created.

Traverses all object properties (but not prototype properties).

Parameters​

NameType
objany

Returns​

any

Defined in​

objects.ts:9


dasherize​

â–¸ dasherize(str): string

Dasherize words that are underscored, space-delimited, or camelCased.

deprecated since v0.17

Parameters​

NameType
strstring

Returns​

string

Defined in​

strings.ts:49


decamelize​

â–¸ decamelize(str): string

Converts a camelized string into all lowercase separated by underscores.

deprecated since v0.17

Parameters​

NameType
strstring

Returns​

string

Defined in​

strings.ts:37


deepGet​

â–¸ deepGet(obj, path): any

Retrieves a value from a nested path on an object.

Returns any falsy value encountered while traversing the path.

Parameters​

NameType
objany
pathstring[]

Returns​

any

Defined in​

objects.ts:180


deepMerge​

â–¸ deepMerge(object, ...sources): any

Merges properties from other objects into a base object, traversing and merging any objects that are encountered.

Properties that resolve to undefined will not overwrite properties on the base object that already exist.

Parameters​

NameType
objectany
...sourcesany[]

Returns​

any

Defined in​

objects.ts:153


deepSet​

â–¸ deepSet(obj, path, value): boolean

Sets a value on an object at a nested path.

This function will create objects along the path if necessary to allow setting a deeply nested value.

Returns false only if the current value is already strictly equal to the requested value argument. Otherwise returns true.

Parameters​

NameType
objany
pathstring[]
valueany

Returns​

boolean

Defined in​

objects.ts:203


eq​

â–¸ eq(a, b): boolean

eq checks the equality of two objects.

The properties belonging to objects (but not their prototypes) will be traversed deeply and compared.

Includes special handling for strings, numbers, dates, booleans, regexes, and arrays

Parameters​

NameType
aany
bany

Returns​

boolean

Defined in​

eq.ts:12


every​

â–¸ every(array, predicate): boolean

Like the Lodash _.every function, this function takes an array and a predicate function and returns true or false depending on whether the predicate is true for every item in the array.

Parameters​

NameType
arrayany[]
predicate(member: any, index: number) => boolean

Returns​

boolean

Defined in​

arrays.ts:6


expose​

â–¸ expose(destination, source): void

Expose properties and methods from one object on another.

Methods will be called on source and will maintain source as the context.

deprecated since v0.17

Parameters​

NameType
destinationany
sourceany

Returns​

void

Defined in​

objects.ts:53


extend​

â–¸ extend(destination, ...sources): any

Extend an object with the properties of one or more other objects.

deprecated since v0.17

Parameters​

NameType
destinationany
...sourcesany[]

Returns​

any

Defined in​

objects.ts:77


firstResult​

â–¸ firstResult(array, valueFn): any

This function is similar to Array.prototype.find, but it returns the result of calling the value function rather than an item of the array.

deprecated since v0.17, remove in v0.18

Parameters​

NameType
arrayany[]
valueFn(member: any, index: number) => any

Returns​

any

Defined in​

arrays.ts:49


isNone​

â–¸ isNone(obj): boolean

Checks whether an object is null or undefined

export

Parameters​

NameType
objunknown

Returns​

boolean

Defined in​

objects.ts:121


isObject​

â–¸ isObject(obj): boolean

Checks whether a value is a non-null object

export

Parameters​

NameType
objunknown

Returns​

boolean

Defined in​

objects.ts:110


merge​

â–¸ merge(object, ...sources): any

Merges properties from other objects into a base object. Properties that resolve to undefined will not overwrite properties on the base object that already exist.

deprecated since v0.17

Parameters​

NameType
objectany
...sourcesany[]

Returns​

any

Defined in​

objects.ts:132


objectValues​

â–¸ objectValues(obj): any[]

Find an array of values that correspond to the keys of an object.

This is a ponyfill for Object.values, which is still experimental.

Parameters​

NameType
objany

Returns​

any[]

Defined in​

objects.ts:227


some​

â–¸ some(array, predicate): boolean

Like the Lodash _.some function, this function takes an array and a predicate function and returns true or false depending on whether the predicate is true for any of the items in the array.

Parameters​

NameType
arrayany[]
predicate(member: any, index: number) => boolean

Returns​

boolean

Defined in​

arrays.ts:27


toArray​

â–¸ toArray(obj): any[]

Converts an object to an Array if it's not already.

export

Parameters​

NameType
objunknown

Returns​

any[]

Defined in​

objects.ts:95


underscore​

â–¸ underscore(str): string

Underscore words that are dasherized, space-delimited, or camelCased.

deprecated since v0.17

Parameters​

NameType
strstring

Returns​

string

Defined in​

strings.ts:61


uuid​

â–¸ uuid(): string

uuid generates a Version 4 UUID using Jeff Ward's high performance generator.

Returns​

string

Defined in​

uuid.ts:18