@6river/reason-guard
Advanced tools
Comparing version 1.2.0 to 1.2.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const trueGuard = (input, _errs, confs = []) => { | ||
confs.push('true'); | ||
return true; | ||
}; | ||
const falseGuard = (input, errs = []) => { | ||
try { | ||
throw new Error('false'); | ||
} | ||
catch (err) { | ||
errs.push(err); | ||
return false; | ||
} | ||
}; | ||
const Checker_1 = require("./Checker"); | ||
const trueGuard = Checker_1.checkerToGuard(() => 'true'); | ||
const falseGuard = Checker_1.checkerToGuard(() => { | ||
throw new Error('false'); | ||
}); | ||
exports.constantGuards = (result) => result ? trueGuard : falseGuard; | ||
//# sourceMappingURL=constantGuards.js.map |
@@ -58,3 +58,3 @@ { | ||
}, | ||
"version": "1.2.0" | ||
"version": "1.2.1" | ||
} |
import {ReasonGuard} from './ReasonGuard'; | ||
import {checkerToGuard} from './Checker'; | ||
const trueGuard: ReasonGuard<unknown, unknown> = (input, _errs, confs = []): input is unknown => { | ||
confs.push('true'); | ||
return true; | ||
}; | ||
const falseGuard: ReasonGuard<unknown, never> = (input, errs = []): input is never => { | ||
try { | ||
const trueGuard: ReasonGuard<unknown, unknown> = | ||
checkerToGuard(() => 'true'); | ||
const falseGuard: ReasonGuard<unknown, never> = | ||
checkerToGuard(() => { | ||
throw new Error('false'); | ||
} catch (err) { | ||
errs.push(err); | ||
return false; | ||
} | ||
}; | ||
}); | ||
export const constantGuards: (result: boolean) => ReasonGuard<unknown, unknown> = | ||
(result: boolean) => result ? trueGuard : falseGuard; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174814
1179