1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.isSymbol = exports.isEmpty = exports.isNil = exports.isConstructor = exports.isNumber = exports.isString = exports.isFunction = exports.stripEndSlash = exports.normalizePath = exports.addLeadingSlash = exports.isPlainObject = exports.isObject = exports.isUndefined = void 0;
|
4 |
|
5 | const isUndefined = (obj) => typeof obj === 'undefined';
|
6 | exports.isUndefined = isUndefined;
|
7 | const isObject = (fn) => !(0, exports.isNil)(fn) && typeof fn === 'object';
|
8 | exports.isObject = isObject;
|
9 | const isPlainObject = (fn) => {
|
10 | if (!(0, exports.isObject)(fn)) {
|
11 | return false;
|
12 | }
|
13 | const proto = Object.getPrototypeOf(fn);
|
14 | if (proto === null) {
|
15 | return true;
|
16 | }
|
17 | const ctor = Object.prototype.hasOwnProperty.call(proto, 'constructor') &&
|
18 | proto.constructor;
|
19 | return (typeof ctor === 'function' &&
|
20 | ctor instanceof ctor &&
|
21 | Function.prototype.toString.call(ctor) ===
|
22 | Function.prototype.toString.call(Object));
|
23 | };
|
24 | exports.isPlainObject = isPlainObject;
|
25 | const addLeadingSlash = (path) => path && typeof path === 'string'
|
26 | ? path.charAt(0) !== '/'
|
27 | ? '/' + path
|
28 | : path
|
29 | : '';
|
30 | exports.addLeadingSlash = addLeadingSlash;
|
31 | const normalizePath = (path) => path
|
32 | ? path.startsWith('/')
|
33 | ? ('/' + path.replace(/\/+$/, '')).replace(/\/+/g, '/')
|
34 | : '/' + path.replace(/\/+$/, '')
|
35 | : '/';
|
36 | exports.normalizePath = normalizePath;
|
37 | const stripEndSlash = (path) => path[path.length - 1] === '/' ? path.slice(0, path.length - 1) : path;
|
38 | exports.stripEndSlash = stripEndSlash;
|
39 | const isFunction = (val) => typeof val === 'function';
|
40 | exports.isFunction = isFunction;
|
41 | const isString = (val) => typeof val === 'string';
|
42 | exports.isString = isString;
|
43 | const isNumber = (val) => typeof val === 'number';
|
44 | exports.isNumber = isNumber;
|
45 | const isConstructor = (val) => val === 'constructor';
|
46 | exports.isConstructor = isConstructor;
|
47 | const isNil = (val) => (0, exports.isUndefined)(val) || val === null;
|
48 | exports.isNil = isNil;
|
49 | const isEmpty = (array) => !(array && array.length > 0);
|
50 | exports.isEmpty = isEmpty;
|
51 | const isSymbol = (val) => typeof val === 'symbol';
|
52 | exports.isSymbol = isSymbol;
|