UNPKG

1.86 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.isSymbol = exports.isEmpty = exports.isNil = exports.isConstructor = exports.isString = exports.isFunction = exports.validatePath = exports.addLeadingSlash = exports.isPlainObject = exports.isObject = exports.isUndefined = void 0;
4/* eslint-disable @typescript-eslint/no-use-before-define */
5const isUndefined = (obj) => typeof obj === 'undefined';
6exports.isUndefined = isUndefined;
7const isObject = (fn) => !exports.isNil(fn) && typeof fn === 'object';
8exports.isObject = isObject;
9const isPlainObject = (fn) => {
10 if (!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};
24exports.isPlainObject = isPlainObject;
25const addLeadingSlash = (path) => path ? (path.charAt(0) !== '/' ? '/' + path : path) : '';
26exports.addLeadingSlash = addLeadingSlash;
27/**
28 * Deprecated. Use the "addLeadingSlash" function instead.
29 * @deprecated
30 */
31exports.validatePath = exports.addLeadingSlash;
32const isFunction = (fn) => typeof fn === 'function';
33exports.isFunction = isFunction;
34const isString = (fn) => typeof fn === 'string';
35exports.isString = isString;
36const isConstructor = (fn) => fn === 'constructor';
37exports.isConstructor = isConstructor;
38const isNil = (obj) => exports.isUndefined(obj) || obj === null;
39exports.isNil = isNil;
40const isEmpty = (array) => !(array && array.length > 0);
41exports.isEmpty = isEmpty;
42const isSymbol = (fn) => typeof fn === 'symbol';
43exports.isSymbol = isSymbol;