guardz
Version:
A simple and lightweight TypeScript type guard library for runtime type validation.
19 lines (18 loc) • 620 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.by = by;
/**
* Creates an array-compatible version of a type guard that can be used directly
* with array methods like filter, map, find, etc.
*
* This wrapper handles the parameter mismatch between array methods (which pass
* value, index, array) and our type guards (which expect value, config).
*
* @param typeGuard - The type guard function to wrap
* @returns A function that can be used directly with array methods
*/
function by(typeGuard) {
return function (value) {
return typeGuard(value, null);
};
}