UNPKG

cerceis-lib

Version:

Contains list of quality of life functions that is written in TypeScript and es6

93 lines (91 loc) 3.26 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/is/index.ts var is_exports = {}; __export(is_exports, { Is: () => Is }); module.exports = __toCommonJS(is_exports); // src/is/is.ts var Is = { object: (x) => Object.prototype.toString.call(x) === "[object Object]", emptyObject: (x) => { if (!Is.object(x)) return false; for (let i in x) return false; return true; }, string: (x) => typeof x === "string" || x instanceof String, emptyString: (x) => { if (!Is.string(x)) return false; for (let i in x) return false; return true; }, number: (x) => Object.prototype.toString.call(x) === "[object Number]", boolean: (x) => Object.prototype.toString.call(x) === "[object Boolean]", array: (x) => Array.isArray(x), null: (x) => x === null, undefined: (x) => x === void 0, falseValue: (x) => { let emptyCount = 0; if (Is.emptyString(x)) emptyCount++; if (Is.number(x) && x === 0) emptyCount++; if (Is.null(x)) emptyCount++; if (Is.undefined(x)) emptyCount++; if (Is.boolean(x) && x === false) emptyCount++; return emptyCount > 0 ? true : false; }, email: (x) => { if (!x) return false; if (!/.+@.+\..+/.test(x)) return false; return true; }, alphanumeric: (x) => { if (!x) return false; const alphanumeric = /^[0-9a-zA-Z]+$/; if (!alphanumeric.test(x)) return false; return true; }, UUIDv4: (x) => { if (!x) return false; const uuidv4 = /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i; if (!uuidv4.test(x)) return false; return true; }, sameAs: (x, y) => { if (x === y) return true; return false; }, noSpecials: (x, space = true, extendJpn = false) => { if (!x) return true; let format = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/; if (!space) format = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/; if (extendJpn) format = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~`!@#$%^&*()_+ー=「」『』;’:”\|、。<>・?〜]/; if (!space && extendJpn) format = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~ `!@#$%^&*()_+ー=「」『』;’:”\|、。<>・?〜]/; if (format.test(x)) return false; return true; }, aFunction(x) { return Object.prototype.toString.call(x) == "[object Function]"; } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Is }); //# sourceMappingURL=index.js.map