chimpanzee
Advanced tools
Comparing version 0.0.28 to 0.0.29
@@ -28,11 +28,11 @@ "use strict"; | ||
function fn(obj, context, key) { | ||
function fn(obj, context, key, parents, parentKeys) { | ||
return schemas.length ? function run(schemas, nonMatching = []) { | ||
const newContext = _extends({}, context); | ||
return (0, _utils.waitForSchema)(schemas[0], obj, newContext, key, function (result) { | ||
return (0, _utils.waitForSchema)(schemas[0], obj, newContext, key, parents, parentKeys, function (result) { | ||
return result instanceof _results.Match ? result : schemas.length > 1 ? function () { | ||
return run(schemas.slice(1), nonMatching.concat(result)); | ||
} : new _results.Skip("None of the items matched.", { obj, context, key, nonMatching }, meta); | ||
} : new _results.Skip("None of the items matched.", { obj, context, key, parents, parentKeys, nonMatching }, meta); | ||
}); | ||
}(schemas) : new _results.Empty({ obj, context, key }, meta); | ||
}(schemas) : new _results.Empty({ obj, context, key, parents, parentKeys }, meta); | ||
} | ||
@@ -39,0 +39,0 @@ |
@@ -43,14 +43,14 @@ "use strict"; | ||
return new ArrayItem(function (needle) { | ||
return new _schema3.default(function (obj, context, key) { | ||
return new _schema3.default(function (obj, context, key, parents, parentKeys) { | ||
return function run(items, results, needle) { | ||
const completed = function completed(result, needle) { | ||
return results.length >= min && (!max || results.length <= max) ? { | ||
result: new _results.Match(results.concat(result ? [result.value] : []), { obj, context, key }, meta), | ||
result: new _results.Match(results.concat(result ? [result.value] : []), { obj, context, key, parents, parentKeys }, meta), | ||
needle | ||
} : { | ||
result: new _results.Skip("Incorrect number of matches.", { obj, context, key }, meta) | ||
result: new _results.Skip("Incorrect number of matches.", { obj, context, key, parents, parentKeys }, meta) | ||
}; | ||
}; | ||
return (0, _utils.waitForSchema)(schema(needle), items, context, key, function ({ result, needle }) { | ||
return (0, _utils.waitForSchema)(schema(needle), items, context, key, parents, parentKeys, function ({ result, needle }) { | ||
return result instanceof _results.Skip || result instanceof _results.Fault ? completed(undefined, needle) : items.length > needle ? run(items, results.concat([result.value]), needle) : completed(result, needle); | ||
@@ -76,7 +76,7 @@ }); | ||
return new ArrayItem(function (needle) { | ||
return new _schema3.default(function (obj, context, key) { | ||
return new _schema3.default(function (obj, context, key, parents, parentKeys) { | ||
return function run(items, i) { | ||
return (0, _utils.waitForSchema)(schema(i), items, context, key, function ({ result }) { | ||
return (0, _utils.waitForSchema)(schema(i), items, context, key, parents, parentKeys, function ({ result }) { | ||
return result instanceof _results.Match ? { result, needle } : items.length > i ? run(items, i + 1) : { | ||
result: new _results.Skip(`Unordered item was not found.`, { obj, context, key }, meta), | ||
result: new _results.Skip(`Unordered item was not found.`, { obj, context, key, parents, parentKeys }, meta), | ||
needle | ||
@@ -100,5 +100,8 @@ }; | ||
return new ArrayItem(function (needle) { | ||
return new _schema3.default(function (obj, context, key) { | ||
return (0, _utils.waitForSchema)(schema(needle), obj, context, key, function ({ result }) { | ||
return result instanceof _results.Match ? { result, needle: needle + 1 } : { result: new _results.Empty({ obj, context, key }, meta), needle }; | ||
return new _schema3.default(function (obj, context, key, parents, parentKeys) { | ||
return (0, _utils.waitForSchema)(schema(needle), obj, context, key, parents, parentKeys, function ({ result }) { | ||
return result instanceof _results.Match ? { result, needle: needle + 1 } : { | ||
result: new _results.Empty({ obj, context, key, parents, parentKeys }, meta), | ||
needle | ||
}; | ||
}); | ||
@@ -115,4 +118,4 @@ }); | ||
return function (needle) { | ||
return new _schema3.default(function (obj, context, key) { | ||
return (0, _utils.waitForSchema)(schema, obj[needle], context, key, function (result) { | ||
return new _schema3.default(function (obj, context, key, parents, parentKeys) { | ||
return (0, _utils.waitForSchema)(schema, obj[needle], context, `${ key }.${ needle }`, parents.concat(obj), parentKeys.concat(key), function (result) { | ||
return result instanceof _results.Match ? { result, needle: needle + 1 } : { result, needle }; | ||
@@ -135,9 +138,9 @@ }); | ||
params = typeof params === "string" ? { key: params } : params; | ||
const fn = function fn(obj, context, key) { | ||
const fn = function fn(obj, context, key, parents, parentKeys) { | ||
return Array.isArray(obj) ? function run(list, results, needle) { | ||
const schema = toNeedledSchema(list[0]); | ||
return (0, _utils.waitForSchema)(schema(needle), obj, { parent: context }, key, function ({ result, needle }) { | ||
return result instanceof _results.Skip || result instanceof _results.Fault ? result : list.length > 1 ? run(list.slice(1), results.concat(result instanceof _results.Empty ? [] : [result.value]), needle) : new _results.Match(results.concat(result.value), { obj, context, key }, meta); | ||
return (0, _utils.waitForSchema)(schema(needle), obj, { parent: context }, key, parents, parentKeys, function ({ result, needle }) { | ||
return result instanceof _results.Skip || result instanceof _results.Fault ? result.updateEnv({ needle }) : list.length > 1 ? run(list.slice(1), results.concat(result instanceof _results.Empty ? [] : [result.value]), needle) : new _results.Match(results.concat(result.value), { obj, context, key, parents, parentKeys }, meta); | ||
}); | ||
}(schemas, [], 0) : new _results.Fault(`Expected array but got ${ typeof obj }.`, { obj, context, key }, meta); | ||
}(schemas, [], 0) : new _results.Fault(`Expected array but got ${ typeof obj }.`, { obj, context, key, parents, parentKeys }, meta); | ||
}; | ||
@@ -144,0 +147,0 @@ return new _schema3.default(fn, params); |
@@ -65,6 +65,6 @@ "use strict"; | ||
function fn(obj, context, key) { | ||
return predicate(obj) ? typeof schema !== "undefined" ? (0, _utils.waitForSchema)(schema, obj, context, key, function (result) { | ||
return result instanceof _results.Match ? new _results.Match(_extends({}, obj, options.modifier ? options.modifier(result.value) : result.value), { obj, context, key }, meta) : new _results.Skip("Capture failed in inner schema.", { obj, context, key }, meta); | ||
}) : new _results.Match(options.modifier ? options.modifier(obj) : obj, { obj, context, key }, meta) : new _results.Skip(options.skipMessage ? options.skipMessage(obj) : "Predicate returned false.", { obj, context, key }, meta); | ||
function fn(obj, context, key, parents, parentKeys) { | ||
return predicate(obj) ? typeof schema !== "undefined" ? (0, _utils.waitForSchema)(schema, obj, context, key, parents, parentKeys, function (result) { | ||
return result instanceof _results.Match ? new _results.Match(_extends({}, obj, options.modifier ? options.modifier(result.value) : result.value), { obj, context, key, parents, parentKeys }, meta) : new _results.Skip("Capture failed in inner schema.", { obj, context, key, parents, parentKeys }, meta); | ||
}) : new _results.Match(options.modifier ? options.modifier(obj) : obj, { obj, context, key, parents, parentKeys }, meta) : new _results.Skip(options.skipMessage ? options.skipMessage(obj) : `Predicate returned false. Predicate was ${ predicate.toString() }`, { obj, context, key, parents, parentKeys }, meta); | ||
} | ||
@@ -71,0 +71,0 @@ |
@@ -231,5 +231,5 @@ "use strict"; | ||
function match(schema, args) { | ||
return _match(schema.fn(args, {})); | ||
function match(schema, input) { | ||
return _match(schema.fn(input, {}, "__INIT__", [], [])); | ||
} | ||
//# sourceMappingURL=chimpanzee.js.map |
@@ -57,8 +57,8 @@ "use strict"; | ||
function fn(obj, context, key) { | ||
function fn(obj, context, key, parents, parentKeys) { | ||
return schemas.length ? function run(schemas) { | ||
return (0, _utils.waitForSchema)(schemas[0], obj, context, key, function (result) { | ||
return (0, _utils.waitForSchema)(schemas[0], obj, context, key, parents, parentKeys, function (result) { | ||
return result instanceof _results.Match ? schemas.length > 1 ? run(schemas.slice(1)) : result : result; | ||
}); | ||
}(schemas) : new _results.Empty({ obj, context, key }, meta); | ||
}(schemas) : new _results.Empty({ obj, context, key, parents, parentKeys }, meta); | ||
} | ||
@@ -65,0 +65,0 @@ |
@@ -25,17 +25,17 @@ "use strict"; | ||
function fn(obj, context, key) { | ||
function fn(obj, context, key, parents, parentKeys) { | ||
function traverseObject(keys) { | ||
return keys.length ? (0, _utils.waitForSchema)(deep(schema), obj[keys[0]], context, key, function (result) { | ||
return keys.length ? (0, _utils.waitForSchema)(deep(schema), obj[keys[0]], context, key, parents.concat(obj), parentKeys.concat(keys[0]), function (result) { | ||
return result instanceof _results.Match ? result : traverseObject(keys.slice(1)); | ||
}) : new _results.Skip("Not found in deep.", { obj, context, key }, meta); | ||
}) : new _results.Skip("Not found in deep.", { obj, context, key, parents, parentKeys }, meta); | ||
} | ||
function traverseArray(items) { | ||
return items.length ? (0, _utils.waitForSchema)(deep(schema, options), items[0], context, key, function (result) { | ||
return items.length ? (0, _utils.waitForSchema)(deep(schema, options), items[0], context, key, parents, parentKeys, function (result) { | ||
return result instanceof _results.Match ? result : traverseArray(items.slice(1)); | ||
}) : new _results.Skip("Not found in deep.", { obj, context, key }, meta); | ||
}) : new _results.Skip("Not found in deep.", { obj, context, key, parents, parentKeys }, meta); | ||
} | ||
return (0, _utils.waitForSchema)(schema, obj, context, key, function (result) { | ||
return result instanceof _results.Match ? result : typeof obj === "object" ? traverseObject(Object.keys(obj)) : Array.isArray(obj) ? traverseArray(obj) : new _results.Skip("Not found in deep.", { obj, context, key }, meta); | ||
return (0, _utils.waitForSchema)(schema, obj, context, key, parents, parentKeys, function (result) { | ||
return result instanceof _results.Match ? result : typeof obj === "object" ? traverseObject(Object.keys(obj)) : Array.isArray(obj) ? traverseArray(obj) : new _results.Skip("Not found in deep.", { obj, context, key, parents, parentKeys }, meta); | ||
}); | ||
@@ -42,0 +42,0 @@ } |
@@ -19,4 +19,4 @@ "use strict"; | ||
function fn(obj, context, key) { | ||
return obj === undefined ? new _results.Empty({ obj, context, key }, meta) : new _results.Skip("Not empty.", { obj, context, key }, meta); | ||
function fn(obj, context, key, parents, parentKeys) { | ||
return obj === undefined ? new _results.Empty({ obj, context, key, parents, parentKeys }, meta) : new _results.Skip("Not empty.", { obj, context, key, parents, parentKeys }, meta); | ||
} | ||
@@ -23,0 +23,0 @@ |
@@ -27,6 +27,6 @@ "use strict"; | ||
function fn(obj, context, key) { | ||
return predicate(obj) ? schema ? (0, _utils.waitForSchema)(schema, obj, context, key, function (inner) { | ||
function fn(obj, context, key, parents, parentKeys) { | ||
return predicate(obj) ? schema ? (0, _utils.waitForSchema)(schema, obj, context, key, parents, parentKeys, function (inner) { | ||
return inner; | ||
}) : new _results.Empty({ obj, context, key }, meta) : new _results.Skip("Does not exist.", { obj, context, key }, meta); | ||
}) : new _results.Empty({ obj, context, key, parents, parentKeys }, meta) : new _results.Skip("Does not exist.", { obj, context, key, parents, parentKeys }, meta); | ||
} | ||
@@ -33,0 +33,0 @@ |
@@ -25,5 +25,5 @@ "use strict"; | ||
function fn(obj, context, key) { | ||
return (0, _utils.waitForSchema)(schema, obj, context, key, function (result) { | ||
return result instanceof _results.Match ? new _results.Match(mapper(result.value), { obj, context, key }, meta) : result; | ||
function fn(obj, context, key, parents, parentKeys) { | ||
return (0, _utils.waitForSchema)(schema, obj, context, key, parents, parentKeys, function (result) { | ||
return result instanceof _results.Match ? new _results.Match(mapper(result.value), { obj, context, key, parents, parentKeys }, meta) : result; | ||
}); | ||
@@ -30,0 +30,0 @@ } |
@@ -23,5 +23,5 @@ "use strict"; | ||
function fn(obj, context, key) { | ||
return (0, _utils.waitForSchema)(schema, obj, context, key, function (result) { | ||
return result instanceof _results.Match ? result : result instanceof Error ? params.swallowErrors ? new _results.Empty({ obj, context, key }, meta) : result : result instanceof _results.Skip ? new _results.Empty({ obj, context, key }, meta) : new _results.Fault(`Unknown result ${ result.type }.`, { obj, context, key }, meta); | ||
function fn(obj, context, key, parents, parentKeys) { | ||
return (0, _utils.waitForSchema)(schema, obj, context, key, parents, parentKeys, function (result) { | ||
return result instanceof _results.Match ? result : result instanceof Error ? params.swallowErrors ? new _results.Empty({ obj, context, key, parents, parentKeys }, meta) : result : result instanceof _results.Skip ? new _results.Empty({ obj, context, key, parents, parentKeys }, meta) : new _results.Fault(`Unknown result ${ result.type }.`, { obj, context, key, parents, parentKeys }, meta); | ||
}); | ||
@@ -28,0 +28,0 @@ } |
@@ -25,7 +25,7 @@ "use strict"; | ||
function fn(obj, context, key) { | ||
function fn(obj, context, key, parents, parentKeys) { | ||
return (0, _utils.waitForSchema)((0, _capture.captureIf)(function (obj) { | ||
return typeof regex === "string" ? typeof obj === "string" && new RegExp(regex).test(obj) : typeof obj === "string" && regex.test(obj); | ||
}, params), obj, context, key, function (result) { | ||
return result instanceof _results.Skip ? new _results.Skip(`Did not match regex.`, { obj, context, key }, meta) : result; | ||
}, params), obj, context, key, parents, parentKeys, function (result) { | ||
return result instanceof _results.Skip ? new _results.Skip(`Did not match regex.`, { obj, context, key, parents, parentKeys }, meta) : result; | ||
}); | ||
@@ -32,0 +32,0 @@ } |
@@ -7,2 +7,4 @@ "use strict"; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _match = require("./match"); | ||
@@ -17,5 +19,14 @@ | ||
super(undefined, env, meta); | ||
//Unit test support | ||
if (global.__chimpanzeeTestContext) { | ||
global.__chimpanzeeTestContext.push(this); | ||
} | ||
} | ||
updateEnv(args) { | ||
return new Empty(_extends({}, this.env, args), this.meta); | ||
} | ||
} | ||
exports.default = Empty; | ||
//# sourceMappingURL=empty.js.map |
@@ -6,2 +6,5 @@ "use strict"; | ||
}); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
class Fault { | ||
@@ -12,5 +15,14 @@ constructor(message, env, meta) { | ||
this.meta = meta; | ||
//Unit test support | ||
if (global.__chimpanzeeTestContext) { | ||
global.__chimpanzeeTestContext.push(this); | ||
} | ||
} | ||
updateEnv(args) { | ||
return new Fault(this.message, _extends({}, this.env, args), this.meta); | ||
} | ||
} | ||
exports.default = Fault; | ||
//# sourceMappingURL=fault.js.map |
@@ -6,2 +6,5 @@ "use strict"; | ||
}); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
class Match { | ||
@@ -12,5 +15,14 @@ constructor(value, env, meta) { | ||
this.meta = meta; | ||
//Unit test support | ||
if (global.__chimpanzeeTestContext) { | ||
global.__chimpanzeeTestContext.push(this); | ||
} | ||
} | ||
updateEnv(args) { | ||
return new Match(this.value, _extends({}, this.env, args), this.meta); | ||
} | ||
} | ||
exports.default = Match; | ||
//# sourceMappingURL=match.js.map |
@@ -6,2 +6,5 @@ "use strict"; | ||
}); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
class Skip { | ||
@@ -12,5 +15,14 @@ constructor(message, env, meta) { | ||
this.meta = meta; | ||
//Unit test support | ||
if (global.__chimpanzeeTestContext) { | ||
global.__chimpanzeeTestContext.push(this); | ||
} | ||
} | ||
updateEnv(args) { | ||
return new Skip(this.message, _extends({}, this.env, args), this.meta); | ||
} | ||
} | ||
exports.default = Skip; | ||
//# sourceMappingURL=skip.js.map |
@@ -36,3 +36,3 @@ "use strict"; | ||
function fn(originalObj, context = {}, key) { | ||
function fn(originalObj, context = {}, key, parents, parentKeys) { | ||
const obj = params.modifiers.object ? params.modifiers.object(originalObj) : originalObj; | ||
@@ -42,3 +42,3 @@ | ||
const task = function fn() { | ||
const readyToRun = !builder.precondition || builder.precondition(obj, context, key); | ||
const readyToRun = !builder.precondition || builder.precondition(obj, context, key, parents, parentKeys); | ||
return readyToRun ? function () { | ||
@@ -49,3 +49,3 @@ const predicates = !builder.predicates ? [] : builder.predicates.map(function (p) { | ||
invalid: function invalid() { | ||
return new _results.Skip(p.message || `Predicate returned false.`, { obj, context, key }, meta); | ||
return new _results.Skip(p.message || `Predicate returned false.`, { obj, context, key, parents, parentKeys }, meta); | ||
} | ||
@@ -59,3 +59,3 @@ }; | ||
invalid: function invalid() { | ||
return new _results.Fault(a.error, { obj, context, key }, meta); | ||
return new _results.Fault(a.error, { obj, context, key, parents, parentKeys }, meta); | ||
} | ||
@@ -66,10 +66,10 @@ }; | ||
return _lazily.Seq.of(predicates.concat(assertions)).map(function (predicate) { | ||
return predicate.fn(obj, context, key) ? undefined : predicate.invalid(); | ||
return predicate.fn(obj, context, key, parents, parentKeys) ? undefined : predicate.invalid(); | ||
}).first(function (x) { | ||
return x; | ||
}) || function () { | ||
const result = builder.get(obj, context, key); | ||
const result = builder.get(obj, context, key, parents, parentKeys); | ||
return [_results.Match, _results.Skip, _results.Fault].some(function (resultType) { | ||
return result instanceof resultType; | ||
}) ? result : new _results.Match(result, { obj, context, key }, meta); | ||
}) ? result : new _results.Match(result, { obj, context, key, parents, parentKeys }, meta); | ||
}(); | ||
@@ -84,9 +84,9 @@ }() : fn; | ||
return schema !== comparand ? [{ | ||
task: new _results.Skip(`Expected ${ schema } but got ${ comparand }.`, { obj, context, key }, meta) | ||
}] : [{ task: new _results.Empty({ obj, context, key }, meta) }]; | ||
task: new _results.Skip(`Expected ${ schema } but got ${ comparand }.`, { obj, context, key, parents, parentKeys }, meta) | ||
}] : [{ task: new _results.Empty({ obj, context, key, parents, parentKeys }, meta) }]; | ||
} | ||
function getObjectTasks() { | ||
return typeof obj !== "undefined" ? _lazily.Seq.of(Object.keys(schema)).map(function (key) { | ||
const childSchema = schema[key]; | ||
return typeof obj !== "undefined" ? _lazily.Seq.of(Object.keys(schema)).map(function (childKey) { | ||
const childSchema = schema[childKey]; | ||
const childUnmodified = childSchema.params && childSchema.params.unmodified || { | ||
@@ -97,3 +97,3 @@ object: false, | ||
const childItem = childUnmodified.object ? childUnmodified.property ? originalObj[key] : params.modifiers.propertyOnUnmodified ? params.modifiers.propertyOnUnmodified(originalObj, key) : params.modifiers.property ? params.modifiers.property(originalObj, key) : originalObj[key] : childUnmodified.property ? obj[key] : params.modifiers.property ? params.modifiers.property(obj, key) : obj[key]; | ||
const childItem = childUnmodified.object ? childUnmodified.property ? originalObj[childKey] : params.modifiers.propertyOnUnmodified ? params.modifiers.propertyOnUnmodified(originalObj, childKey) : params.modifiers.property ? params.modifiers.property(originalObj, childKey) : originalObj[childKey] : childUnmodified.property ? obj[childKey] : params.modifiers.property ? params.modifiers.property(obj, childKey) : obj[childKey]; | ||
@@ -107,6 +107,6 @@ return { | ||
} | ||
}, true).fn(childItem, getSchemaType(childSchema) === "object" ? context : { parent: context }, key), | ||
}, true).fn(childItem, getSchemaType(childSchema) === "object" ? context : { parent: context }, childKey, parents.concat(originalObj), parentKeys.concat(key)), | ||
params: childSchema.params ? _extends({}, childSchema.params, { | ||
key: childSchema.params.key || key | ||
}) : { key } | ||
key: childSchema.params.key || childKey | ||
}) : { key: childKey } | ||
}; | ||
@@ -118,3 +118,3 @@ }).reduce(function (acc, x) { | ||
}) : [{ | ||
task: new _results.Skip(`Cannot traverse undefined.`, { obj, context, key }, meta) | ||
task: new _results.Skip(`Cannot traverse undefined.`, { obj, context, key, parents, parentKeys }, meta) | ||
}]; | ||
@@ -124,3 +124,3 @@ } | ||
function getArrayTasks() { | ||
return Array.isArray(obj) ? schema.length !== obj.length ? new _results.Skip(`Expected array of length ${ schema.length } but got ${ obj.length }.`, { obj, context, key }, meta) : _lazily.Seq.of(schema).map(function (rhs, i) { | ||
return Array.isArray(obj) ? schema.length !== obj.length ? new _results.Skip(`Expected array of length ${ schema.length } but got ${ obj.length }.`, { obj, context, key, parents, parentKeys }, meta) : _lazily.Seq.of(schema).map(function (rhs, i) { | ||
return { | ||
@@ -133,14 +133,14 @@ task: traverse(rhs, { | ||
} | ||
}, false).fn(obj[i], { parent: context }), | ||
}, false).fn(obj[i], { parent: context }, `${ key }.${ i }`, parents.concat(originalObj), parentKeys.concat(key)), | ||
params: schema.params | ||
}; | ||
}).toArray() : [new _results.Skip(`Schema is an array but property is a non-array.`, { obj, context, key }, meta)]; | ||
}).toArray() : [new _results.Skip(`Schema is an array but property is a non-array.`, { obj, context, key, parents, parentKeys }, meta)]; | ||
} | ||
function getSchemaTasks() { | ||
return [{ task: schema.fn(obj, context, key) }]; | ||
return [{ task: schema.fn(obj, context, key, parents, parentKeys) }]; | ||
} | ||
function getFunctionTasks() { | ||
return [{ task: schema(obj, context, key) }]; | ||
return [{ task: schema(obj, context, key, parents, parentKeys) }]; | ||
} | ||
@@ -246,3 +246,3 @@ | ||
return run([], unfinished); | ||
} : (schemaType !== "object" || !inner) && typeof state !== "undefined" ? new _results.Match(state, { obj, context, key }, meta) : new _results.Empty({ obj, context, key }, meta); | ||
} : (schemaType !== "object" || !inner) && typeof state !== "undefined" ? new _results.Match(state, { obj, context, key, parents, parentKeys }, meta) : new _results.Empty({ obj, context, key, parents, parentKeys }, meta); | ||
} | ||
@@ -252,3 +252,3 @@ | ||
return !mustRun ? new _results.Skip(`Predicate returned false.`, { obj, context, key }, meta) : function () { | ||
return !mustRun ? new _results.Skip(`Predicate returned false.`, { obj, context, key, parents, parentKeys }, meta) : function () { | ||
const tasks = _lazily.Seq.of(params.builders).map(function (builder) { | ||
@@ -255,0 +255,0 @@ return getTask(builder); |
@@ -49,7 +49,7 @@ "use strict"; | ||
function fn(obj, context, key) { | ||
function fn(obj, context, key, parents, parentKeys) { | ||
return (0, _utils.waitForSchema)((0, _capture.captureIf)(function (obj) { | ||
return typeof obj === type; | ||
}, params), obj, context, key, function (result) { | ||
return result instanceof _results.Skip ? new _results.Skip(`Expected ${ type } but got ${ typeof obj }.`, { obj, context, key }, meta) : result; | ||
}, params), obj, context, key, parents, parentKeys, function (result) { | ||
return result instanceof _results.Skip ? new _results.Skip(`Expected ${ type } but got ${ typeof obj }.`, { obj, context, key, parents, parentKeys }, meta) : result; | ||
}); | ||
@@ -56,0 +56,0 @@ } |
@@ -30,5 +30,5 @@ "use strict"; | ||
function waitForSchema(schema, obj, context, key, then) { | ||
return waitFor((0, _traverse.traverse)(schema).fn(obj, context, key), then); | ||
function waitForSchema(schema, obj, context, key, parents, parentKeys, then) { | ||
return waitFor((0, _traverse.traverse)(schema).fn(obj, context, key, parents, parentKeys), then); | ||
} | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "chimpanzee", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"author": "Jeswin<jeswinpk@agilehead.com>", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
161460
1001