UNPKG

593 BJavaScriptView Raw
1import isPlainObject from 'lodash/isPlainObject';
2export function objToKey(obj) {
3 if (!isPlainObject(obj)) {
4 return obj;
5 }
6
7 var sortedObj = Object.keys(obj).sort().reduce(function (result, key) {
8 result[key] = objToKey(obj[key]);
9 return result;
10 }, {});
11 return JSON.stringify(sortedObj);
12}
13export function isPromiseLike(value) {
14 return value != null && typeof value.then === 'function';
15}
16export function compact(obj) {
17 return Object.keys(obj).reduce(function (acc, key) {
18 if (obj[key] !== undefined) {
19 acc[key] = obj[key];
20 }
21
22 return acc;
23 }, {});
24}
\No newline at end of file