ts-cast
Version:
Runtime typechecking
12 lines (11 loc) • 579 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var names_1 = require("../helpers/names");
var guards_1 = require("./guards");
var throw_type_error_1 = require("./throw-type-error");
var map = function (caster, transform) { return (0, names_1.withName)(function (value, context, reportError) {
if (reportError === void 0) { reportError = throw_type_error_1.throwTypeError; }
var casted = caster(value, context, reportError);
return (0, guards_1.isNotEmpty)(casted) ? transform(casted) : casted;
}, caster.name); };
exports.default = map;