@6river/reason-guard
Advanced tools
Comparing version 1.1.0 to 1.2.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkerToGuard = ((checker) => (input, e, c) => { | ||
exports.checkerToGuard = ((checker) => (input, e = [], c = []) => { | ||
try { | ||
@@ -5,0 +5,0 @@ c.push(checker(input)); |
@@ -14,3 +14,3 @@ "use strict"; | ||
exports.notGuard = ((inner) => { | ||
return (input, errors, confirmations) => { | ||
return (input, errors = [], confirmations = []) => { | ||
try { | ||
@@ -34,3 +34,3 @@ const innerErrors = []; | ||
exports.orGuard = ((left, right) => { | ||
return (input, output, confirmations) => { | ||
return (input, output = [], confirmations = []) => { | ||
try { | ||
@@ -37,0 +37,0 @@ const innerErrors = []; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const trueGuard = (input, _errs, confs) => { | ||
const trueGuard = (input, _errs, confs = []) => { | ||
confs.push('true'); | ||
return true; | ||
}; | ||
const falseGuard = (input, errs) => { | ||
const falseGuard = (input, errs = []) => { | ||
try { | ||
@@ -9,0 +9,0 @@ throw new Error('false'); |
@@ -46,3 +46,3 @@ "use strict"; | ||
// type PropertyGuardBuilder<FROM, TO extends FROM> = (definition: PropertyGuards<FROM, TO>) => ReasonGuard<FROM, TO>; | ||
exports.objectHasDefinition = ((definition) => (input, output, confirmations) => checkDefinition(definition, input, output, confirmations)); | ||
exports.objectHasDefinition = ((definition) => (input, output = [], confirmations = []) => checkDefinition(definition, input, output, confirmations)); | ||
//# sourceMappingURL=objectGuards.js.map |
@@ -71,3 +71,3 @@ "use strict"; | ||
const values = new Set(keys); | ||
return (input, es, cs) => { | ||
return (input, es = [], cs = []) => { | ||
try { | ||
@@ -74,0 +74,0 @@ if (!literableGuard(input, es, cs)) { |
@@ -10,2 +10,3 @@ "use strict"; | ||
chai_1.assert.isAtLeast(cs.length, 1, 'no confirmation reason for successful guard'); | ||
chai_1.assert.isTrue(guard(value), 'guard provides default values for detail arrays'); | ||
} | ||
@@ -17,4 +18,5 @@ function assertGuardFailed(guard, value) { | ||
chai_1.assert.isAtLeast(es.length, 1, 'no error reason for failed guard'); | ||
chai_1.assert.isFalse(guard(value), 'guard provides default values for detail arrays'); | ||
} | ||
exports.assertGuards = (result) => result ? assertGuardConfirmed : assertGuardFailed; | ||
//# sourceMappingURL=assertGuards.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("mocha"); | ||
const assertGuards_1 = require("./assertGuards"); | ||
@@ -5,0 +4,0 @@ const instanceGuards_1 = require("../src/instanceGuards"); |
@@ -58,3 +58,3 @@ { | ||
}, | ||
"version": "1.1.0" | ||
"version": "1.2.0" | ||
} |
@@ -6,3 +6,3 @@ import {ReasonGuard} from './ReasonGuard'; | ||
export const checkerToGuard = <(<FROM, TO extends FROM>(checker: Checker<FROM>) => | ||
ReasonGuard<FROM, TO>)>((checker) => (input, e, c) => { | ||
ReasonGuard<FROM, TO>)>((checker) => (input, e = [], c = []) => { | ||
try { | ||
@@ -9,0 +9,0 @@ c.push(checker(input)); |
@@ -22,3 +22,3 @@ import {ReasonGuard} from './ReasonGuard'; | ||
ReasonGuard<FROM, Exclude<FROM, TO>>)>((inner) => { | ||
return (input, errors, confirmations) => { | ||
return (input, errors = [], confirmations = []) => { | ||
try { | ||
@@ -43,3 +43,3 @@ const innerErrors: Error[] = []; | ||
ReasonGuard<FROM, TO>)>((left, right) => { | ||
return (input, output, confirmations) => { | ||
return (input, output = [], confirmations = []) => { | ||
try { | ||
@@ -46,0 +46,0 @@ const innerErrors: Error[] = []; |
import {ReasonGuard} from './ReasonGuard'; | ||
const trueGuard: ReasonGuard<unknown, unknown> = (input, _errs, confs): input is unknown => { | ||
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 => { | ||
const falseGuard: ReasonGuard<unknown, never> = (input, errs = []): input is never => { | ||
try { | ||
@@ -9,0 +9,0 @@ throw new Error('false'); |
@@ -78,3 +78,4 @@ import {ReasonGuard} from './ReasonGuard'; | ||
<(<FROM extends Object, TO extends FROM>(definition: PropertyGuards<FROM, TO>) => ReasonGuard<FROM, TO>)>( | ||
(definition) => (input, output, confirmations) => checkDefinition(definition, input, output, confirmations) | ||
(definition) => | ||
(input, output = [], confirmations = []) => checkDefinition(definition, input, output, confirmations) | ||
); |
@@ -1,1 +0,5 @@ | ||
export type ReasonGuard<FROM, TO extends FROM> = (input: FROM, output: Error[], confirmations: string[]) => input is TO; | ||
export type ReasonGuard<FROM, TO extends FROM> = ( | ||
input: FROM, | ||
output?: Error[], | ||
confirmations?: string[], | ||
) => input is TO; |
@@ -131,3 +131,3 @@ import {checkerToGuard} from './Checker'; | ||
return (input, es, cs): input is ArrayLiteralCheck<T, typeof keys> => { | ||
return (input, es = [], cs = []): input is ArrayLiteralCheck<T, typeof keys> => { | ||
try { | ||
@@ -134,0 +134,0 @@ if (!literableGuard(input, es, cs)) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
175120
58
1192