typescanner
Version:
A simple library for implementing type guard in TypeScript.
23 lines • 877 B
JavaScript
;
exports.__esModule = true;
exports.scanner = void 0;
var typeGuard_1 = require("../typeGuard");
var scanner = function (fields, option) {
return function (value) {
if (!(0, typeGuard_1.isObject)(value)) {
if (option === null || option === void 0 ? void 0 : option.outputLog)
console.error("value is not object");
return false;
}
// check each value
return Object.entries(fields).every(function (_a) {
var key = _a[0], condition = _a[1];
var isMeet = condition(value[key]);
if (!isMeet && (option === null || option === void 0 ? void 0 : option.outputLog))
console.error("value.".concat(key, " does not meet the condition."));
return isMeet;
});
};
};
exports.scanner = scanner;
//# sourceMappingURL=index.js.map