Get the type of element that will be sorted as [object ${TYPE}]
Examples:
getSortType([{a: 1}], "a"); // [object Number]
getSortType([{a: "b"}], "a"); // [object String]
getSortType([{a: new Date()}], "a"); // [object Date]
getSortType([{a: []}], "a"); // [object Array]
getSortType([{a: {}}], "a"); // [object Object]
Array to check for type, will not send back a type if null or undefined
field name to check against
Checks current element if it empty
Examples:
isEmpty({}); // true
isEmpty([]); // true
isEmpty(""); // true
isEmpty(null); // true
isEmpty(undefined); // true
Sort array of documents using MergeSort
Examples:
let docs = [{n: 1}, {n: 6}, {n: 5}];
let sort = {n: -1};
let key = Object.keys(sort)[0]; // "n"
let val = sort[key]; // -1
let type = getSortType(docs, key); // "[object Number]"
mergeSort(docs, key, val, type); // [{n: 6}, {n: 5}, {n: 1}]
array of documents to sort
field name as string from documents
numeric -1 for descending and 1 for ascending sort order
one of the results of Object.prototype.toString.call(obj[field])
Remove duplicate objects from array comparing certain unique field.
Example:
let a = [{_id: 1, name: "ch"}, {_id: 1, name: "ch"}]
rmDups(a, "_id"); // [{_id: 1, name: "ch"}]
Generated using TypeDoc
Get value given the Path as "path.to.nested" string