@terascope/utils / deps
deps
Collection
multiFieldSort()
constmultiFieldSort: {<T>(collection, ...iteratees?):T[]; <T>(collection, ...iteratees):T[keyofT][]; } =sortBy
Defined in: packages/utils/src/deps.ts:22
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
| Parameter | Type | Description |
|---|---|---|
collection | undefined | null | List<T> | The 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[keyofT][]
Type Parameters
| Type Parameter |
|---|
T extends object |
Parameters
| Parameter | Type |
|---|---|
collection | undefined | null | T |
...iteratees | Many<ObjectIteratee<T>>[] |
Returns
T[keyof T][]
See
_.sortBy
Other
geoHash
geoHash:
object
Defined in: types/latlon-geohash/index.d.ts:34
Type Declaration
adjacent()
adjacent: (
geoHash,direction) =>any
Parameters
| Parameter | Type |
|---|---|
geoHash | string |
direction | "N" | "S" | "E" | "W" |
Returns
any
adjacent cell to given geohash in specified direction (N/S/E/W).
bounds()
bounds: (
geoHash) =>object
Parameters
| Parameter | Type |
|---|---|
geoHash | string |
Returns
object
bounds of given geohash.
ne
ne:
number
sw
sw:
number
decode()
decode: (
geoHash) =>object
Parameters
| Parameter | Type |
|---|---|
geoHash | string |
Returns
object
of centre of given geohash, to appropriate precision.
lat
lat:
number
lon
lon:
number
encode()
encode: (
lat,lon,precision?) =>string
encode latitude/longitude point to geohash of given precision (number of characters in resulting geohash); if precision is not specified, it is inferred from precision of latitude/longitude values.
Parameters
| Parameter | Type |
|---|---|
lat | number |
lon | number |
precision? | number |
Returns
string
neighbours()
neighbours: (
geoHash) =>object
Parameters
| Parameter | Type |
|---|---|
geoHash | string |
Returns
object
all 8 adjacent cells (n/ne/e/se/s/sw/w/nw) to given geohash.
n
n:
number
ne
ne:
number
nw
nw:
number
s
s:
number
se
se:
number
sw
sw:
number
w
w:
number
clone()
clone(
input):any
Defined in: packages/utils/src/deps.ts:44
Shallow clone an object
Parameters
| Parameter | Type |
|---|---|
input | unknown |
Returns
any
cloneDeep()
cloneDeep<
T>(input):T
Defined in: packages/utils/src/deps.ts:76
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type |
|---|---|
input | T |
Returns
T
escapeString()
escapeString(
input):string
Defined in: packages/utils/src/deps.ts:115
Escape characters in string and avoid double escaping
Parameters
| Parameter | Type |
|---|---|
input | string | number |
Returns
string
getTypeOf()
getTypeOf(
val):string
Defined in: packages/utils/src/deps.ts:87
Determine the type of an input
Parameters
| Parameter | Type |
|---|---|
val | any |
Returns
string
a human friendly string that describes the input
isPlainObject()
isPlainObject(
input):boolean
Defined in: packages/utils/src/deps.ts:35
Detect if value is a plain object, that is, an object created by the Object constructor or one via Object.create(null)
Parameters
| Parameter | Type |
|---|---|
input | unknown |
Returns
boolean