Skip to main content

@terascope/core-utils / deps

deps

Collection

multiFieldSort()

const multiFieldSort: {<T>(collection, ...iteratees?): T[]; <T>(collection, ...iteratees): T[keyof T][]; } = sortBy

Defined in: packages/core-utils/src/deps.ts:20

Call Signature

<T>(collection, ...iteratees?): T[]

Creates an array of elements, sorted in ascending order by the results of running each element in a collection through each iteratee. This method performs a stable sort, that is, it preserves the original sort order of equal elements. The iteratees are invoked with one argument: (value).

Type Parameters
Type Parameter
T
Parameters
ParameterTypeDescription
collectionList<T> | null | undefinedThe collection to iterate over.
...iteratees?Many<ListIteratee<T>>[]The iteratees to sort by, specified individually or in arrays.
Returns

T[]

Returns the new sorted array.

Example
var users = [
{ 'user': 'fred', 'age': 48 },
{ 'user': 'barney', 'age': 36 },
{ 'user': 'fred', 'age': 42 },
{ 'user': 'barney', 'age': 34 }
];

_.sortBy(users, function(o) { return o.user; });
// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]

_.sortBy(users, ['user', 'age']);
// => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]]

_.sortBy(users, 'user', function(o) {
return Math.floor(o.age / 10);
});
// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]

Call Signature

<T>(collection, ...iteratees): T[keyof T][]

Type Parameters
Type Parameter
T extends object
Parameters
ParameterType
collectionT | null | undefined
...iterateesMany<ObjectIteratee<T>>[]
Returns

T[keyof T][]

See

_.sortBy

Other

clone()

clone(input): any

Defined in: packages/core-utils/src/deps.ts:42

Shallow clone an object

Parameters

ParameterType
inputunknown

Returns

any


cloneDeep()

cloneDeep<T>(input): T

Defined in: packages/core-utils/src/deps.ts:70

Type Parameters

Type ParameterDefault type
Tany

Parameters

ParameterType
inputT

Returns

T


escapeString()

escapeString(input): string

Defined in: packages/core-utils/src/deps.ts:109

Escape characters in string and avoid double escaping

Parameters

ParameterType
inputstring | number

Returns

string


getTypeOf()

getTypeOf(val): string

Defined in: packages/core-utils/src/deps.ts:81

Determine the type of an input

Parameters

ParameterType
valany

Returns

string

a human friendly string that describes the input


isPlainObject()

isPlainObject(input): boolean

Defined in: packages/core-utils/src/deps.ts:33

Detect if value is a plain object, that is, an object created by the Object constructor or one via Object.create(null)

Parameters

ParameterType
inputunknown

Returns

boolean