UNPKG

857 BJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.objToKey = objToKey;
5exports.isPromiseLike = isPromiseLike;
6exports.compact = compact;
7
8var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
9
10function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
12function objToKey(obj) {
13 if (!(0, _isPlainObject["default"])(obj)) {
14 return obj;
15 }
16
17 var sortedObj = Object.keys(obj).sort().reduce(function (result, key) {
18 result[key] = objToKey(obj[key]);
19 return result;
20 }, {});
21 return JSON.stringify(sortedObj);
22}
23
24function isPromiseLike(value) {
25 return value != null && typeof value.then === 'function';
26}
27
28function compact(obj) {
29 return Object.keys(obj).reduce(function (acc, key) {
30 if (obj[key] !== undefined) {
31 acc[key] = obj[key];
32 }
33
34 return acc;
35 }, {});
36}
\No newline at end of file