1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.objToKey = objToKey;
|
5 | exports.isPromiseLike = isPromiseLike;
|
6 | exports.compact = compact;
|
7 |
|
8 | var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
|
9 |
|
10 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
11 |
|
12 | function 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 |
|
24 | function isPromiseLike(value) {
|
25 | return value != null && typeof value.then === 'function';
|
26 | }
|
27 |
|
28 | function 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 |