1 | "use strict";
|
2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3 | if (k2 === undefined) k2 = k;
|
4 | var desc = Object.getOwnPropertyDescriptor(m, k);
|
5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6 | desc = { enumerable: true, get: function() { return m[k]; } };
|
7 | }
|
8 | Object.defineProperty(o, k2, desc);
|
9 | }) : (function(o, m, k, k2) {
|
10 | if (k2 === undefined) k2 = k;
|
11 | o[k2] = m[k];
|
12 | }));
|
13 | var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15 | };
|
16 | Object.defineProperty(exports, "__esModule", { value: true });
|
17 | exports._ = void 0;
|
18 | exports.stripSlashes = stripSlashes;
|
19 | exports.isPromise = isPromise;
|
20 | exports.createSymbol = createSymbol;
|
21 |
|
22 | function stripSlashes(name) {
|
23 | return name.replace(/^(\/+)|(\/+)$/g, '');
|
24 | }
|
25 |
|
26 | exports._ = {
|
27 | each(obj, callback) {
|
28 | if (obj && typeof obj.forEach === 'function') {
|
29 | obj.forEach(callback);
|
30 | }
|
31 | else if (exports._.isObject(obj)) {
|
32 | Object.keys(obj).forEach((key) => callback(obj[key], key));
|
33 | }
|
34 | },
|
35 | some(value, callback) {
|
36 | return Object.keys(value)
|
37 | .map((key) => [value[key], key])
|
38 | .some(([val, key]) => callback(val, key));
|
39 | },
|
40 | every(value, callback) {
|
41 | return Object.keys(value)
|
42 | .map((key) => [value[key], key])
|
43 | .every(([val, key]) => callback(val, key));
|
44 | },
|
45 | keys(obj) {
|
46 | return Object.keys(obj);
|
47 | },
|
48 | values(obj) {
|
49 | return exports._.keys(obj).map((key) => obj[key]);
|
50 | },
|
51 | isMatch(obj, item) {
|
52 | return exports._.keys(item).every((key) => obj[key] === item[key]);
|
53 | },
|
54 | isEmpty(obj) {
|
55 | return exports._.keys(obj).length === 0;
|
56 | },
|
57 | isObject(item) {
|
58 | return typeof item === 'object' && !Array.isArray(item) && item !== null;
|
59 | },
|
60 | isObjectOrArray(value) {
|
61 | return typeof value === 'object' && value !== null;
|
62 | },
|
63 | extend(first, ...rest) {
|
64 | return Object.assign(first, ...rest);
|
65 | },
|
66 | omit(obj, ...keys) {
|
67 | const result = exports._.extend({}, obj);
|
68 | keys.forEach((key) => delete result[key]);
|
69 | return result;
|
70 | },
|
71 | pick(source, ...keys) {
|
72 | return keys.reduce((result, key) => {
|
73 | if (source[key] !== undefined) {
|
74 | result[key] = source[key];
|
75 | }
|
76 | return result;
|
77 | }, {});
|
78 | },
|
79 |
|
80 | merge(target, source) {
|
81 | if (exports._.isObject(target) && exports._.isObject(source)) {
|
82 | Object.keys(source).forEach((key) => {
|
83 | if (exports._.isObject(source[key])) {
|
84 | if (!target[key]) {
|
85 | Object.assign(target, { [key]: {} });
|
86 | }
|
87 | exports._.merge(target[key], source[key]);
|
88 | }
|
89 | else {
|
90 | Object.assign(target, { [key]: source[key] });
|
91 | }
|
92 | });
|
93 | }
|
94 | return target;
|
95 | }
|
96 | };
|
97 |
|
98 | function isPromise(result) {
|
99 | return exports._.isObject(result) && typeof result.then === 'function';
|
100 | }
|
101 | function createSymbol(name) {
|
102 | return typeof Symbol !== 'undefined' ? Symbol.for(name) : name;
|
103 | }
|
104 | __exportStar(require("./debug"), exports);
|
105 |
|
\ | No newline at end of file |