@yookue/ts-lang-utils
Version:
Common lang utilities for typescript
40 lines (38 loc) • 1.56 kB
JavaScript
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/util/ArrayUtils/isTypeof.ts
var isTypeof_exports = {};
__export(isTypeof_exports, {
isTypeof: () => isTypeof
});
module.exports = __toCommonJS(isTypeof_exports);
var import_equalsAny = require("../StringUtils/equalsAny");
var import_isBlank = require("../StringUtils/isBlank");
var import_isEmpty = require("./isEmpty");
function isTypeof(array, type, relaxed = false) {
if ((0, import_isEmpty.isEmpty)(array) || (0, import_isBlank.isBlank)(type)) {
return false;
}
return array == null ? void 0 : array.every((item) => {
return typeof item === type || relaxed && item === null && (0, import_equalsAny.equalsAny)(type, ["string", "object"]);
});
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
isTypeof
});