@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​
Name | Type |
---|---|
T | T |
K | extends keyof T |
Defined in​
Functions​
camelize​
â–¸ camelize(str
): string
Convert underscored, dasherized, or space-delimited words into lowerCamelCase.
deprecated
since v0.17
Parameters​
Name | Type |
---|---|
str | string |
Returns​
string
Defined in​
capitalize​
â–¸ capitalize(str
): string
Uppercase the first letter of a string, but don't change the remainder.
deprecated
since v0.17
Parameters​
Name | Type |
---|---|
str | string |
Returns​
string
Defined in​
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​
Name | Type |
---|---|
obj | any |
Returns​
any
Defined in​
dasherize​
â–¸ dasherize(str
): string
Dasherize words that are underscored, space-delimited, or camelCased.
deprecated
since v0.17
Parameters​
Name | Type |
---|---|
str | string |
Returns​
string
Defined in​
decamelize​
â–¸ decamelize(str
): string
Converts a camelized string into all lowercase separated by underscores.
deprecated
since v0.17
Parameters​
Name | Type |
---|---|
str | string |
Returns​
string
Defined in​
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​
Name | Type |
---|---|
obj | any |
path | string [] |
Returns​
any
Defined in​
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​
Name | Type |
---|---|
object | any |
...sources | any [] |
Returns​
any
Defined in​
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​
Name | Type |
---|---|
obj | any |
path | string [] |
value | any |
Returns​
boolean
Defined in​
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​
Name | Type |
---|---|
a | any |
b | any |
Returns​
boolean
Defined in​
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​
Name | Type |
---|---|
array | any [] |
predicate | (member : any , index : number ) => boolean |
Returns​
boolean
Defined in​
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​
Name | Type |
---|---|
destination | any |
source | any |
Returns​
void
Defined in​
extend​
â–¸ extend(destination
, ...sources
): any
Extend an object with the properties of one or more other objects.
deprecated
since v0.17
Parameters​
Name | Type |
---|---|
destination | any |
...sources | any [] |
Returns​
any
Defined in​
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​
Name | Type |
---|---|
array | any [] |
valueFn | (member : any , index : number ) => any |
Returns​
any
Defined in​
isNone​
â–¸ isNone(obj
): boolean
Checks whether an object is null or undefined
export
Parameters​
Name | Type |
---|---|
obj | unknown |
Returns​
boolean
Defined in​
isObject​
â–¸ isObject(obj
): boolean
Checks whether a value is a non-null object
export
Parameters​
Name | Type |
---|---|
obj | unknown |
Returns​
boolean
Defined in​
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​
Name | Type |
---|---|
object | any |
...sources | any [] |
Returns​
any
Defined in​
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​
Name | Type |
---|---|
obj | any |
Returns​
any
[]
Defined in​
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​
Name | Type |
---|---|
array | any [] |
predicate | (member : any , index : number ) => boolean |
Returns​
boolean
Defined in​
toArray​
â–¸ toArray(obj
): any
[]
Converts an object to an Array
if it's not already.
export
Parameters​
Name | Type |
---|---|
obj | unknown |
Returns​
any
[]
Defined in​
underscore​
â–¸ underscore(str
): string
Underscore words that are dasherized, space-delimited, or camelCased.
deprecated
since v0.17
Parameters​
Name | Type |
---|---|
str | string |
Returns​
string
Defined in​
uuid​
â–¸ uuid(): string
uuid
generates a Version 4 UUID using Jeff Ward's high performance
generator.
Returns​
string