UNPKG

@yookue/ts-lang-utils

Version:

Common lang utilities for typescript

13 lines 588 B
import _typeof from "@babel/runtime/helpers/esm/typeof"; import { equalsAny } from "../StringUtils/equalsAny"; import { isBlank } from "../StringUtils/isBlank"; import { isEmpty } from "./isEmpty"; export function isTypeof(array, type) { var relaxed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; if (isEmpty(array) || isBlank(type)) { return false; } return array === null || array === void 0 ? void 0 : array.every(function (item) { return _typeof(item) === type || relaxed && item === null && equalsAny(type, ['string', 'object']); }); }