UNPKG

edgerender

Version:
42 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.escape_regex = exports.smart_typeof = exports.SmartType = void 0; var SmartType; (function (SmartType) { SmartType["Null"] = "Null"; SmartType["Undefined"] = "Undefined"; SmartType["Number"] = "Number"; SmartType["Boolean"] = "Boolean"; SmartType["Date"] = "Date"; SmartType["RegExp"] = "RegExp"; SmartType["String"] = "String"; SmartType["Array"] = "Array"; SmartType["Object"] = "Object"; SmartType["Function"] = "Function"; SmartType["Promise"] = "Promise"; SmartType["JsxChunk"] = "JsxChunk"; SmartType["Fragment"] = "Fragment"; SmartType["RawHtml"] = "RawHtml"; })(SmartType = exports.SmartType || (exports.SmartType = {})); const smart_typeof = (obj) => { /** * Helper to get the type of object, including classes */ if (obj === null) { return "Null" /* Null */; } else if (obj === undefined) { return "Undefined" /* Undefined */; } else { return Object.getPrototypeOf(obj).constructor.name; } }; exports.smart_typeof = smart_typeof; /* * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping * $& means the whole matched string */ const escape_regex = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); exports.escape_regex = escape_regex; //# sourceMappingURL=index.js.map