chimpanzee
Advanced tools
Comparing version 0.0.16 to 0.0.17
@@ -44,3 +44,6 @@ "use strict"; | ||
const completed = function completed(result, needle) { | ||
return results.length >= min && (!max || results.length <= max) ? { result: new _results.Match(results.concat(result ? [result.value] : [])), needle } : { result: new _results.Skip("Incorrect number of matches.") }; | ||
return results.length >= min && (!max || results.length <= max) ? { | ||
result: new _results.Match(results.concat(result ? [result.value] : [])), | ||
needle | ||
} : { result: new _results.Skip("Incorrect number of matches.") }; | ||
}; | ||
@@ -47,0 +50,0 @@ |
@@ -53,5 +53,7 @@ "use strict"; | ||
return x === what; | ||
}, undefined, params, { skipMessage: function skipMessage(x) { | ||
}, undefined, params, { | ||
skipMessage: function skipMessage(x) { | ||
return `Expected value to be ${ what } but got ${ x }.`; | ||
} }); | ||
} | ||
}); | ||
} | ||
@@ -58,0 +60,0 @@ |
@@ -77,3 +77,6 @@ "use strict"; | ||
const childSchema = schema[key]; | ||
const childUnmodified = childSchema.params && childSchema.params.unmodified || { object: false, property: false }; | ||
const childUnmodified = childSchema.params && childSchema.params.unmodified || { | ||
object: false, | ||
property: false | ||
}; | ||
@@ -83,4 +86,12 @@ 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]; | ||
return { | ||
task: traverse(childSchema, { value: params.value, modifiers: { property: params.modifiers.property, value: params.modifiers.value } }, true).fn(childItem, getSchemaType(childSchema) === "object" ? context : { parent: context }, key), | ||
params: childSchema.params ? _extends({}, childSchema.params, { key: childSchema.params.key || key }) : { key } | ||
task: traverse(childSchema, { | ||
value: params.value, | ||
modifiers: { | ||
property: params.modifiers.property, | ||
value: params.modifiers.value | ||
} | ||
}, true).fn(childItem, getSchemaType(childSchema) === "object" ? context : { parent: context }, key), | ||
params: childSchema.params ? _extends({}, childSchema.params, { | ||
key: childSchema.params.key || key | ||
}) : { key } | ||
}; | ||
@@ -97,3 +108,9 @@ }).reduce(function (acc, x) { | ||
return { | ||
task: traverse(rhs, { value: params.value, modifiers: { property: params.modifiers.property, value: params.modifiers.value } }, false).fn(obj[i], { parent: context }), | ||
task: traverse(rhs, { | ||
value: params.value, | ||
modifiers: { | ||
property: params.modifiers.property, | ||
value: params.modifiers.value | ||
} | ||
}, false).fn(obj[i], { parent: context }), | ||
params: schema.params | ||
@@ -128,3 +145,7 @@ }; | ||
return _lazily.Seq.of(finished).reduce(function (acc, { result, params }) { | ||
return result instanceof _results.Match ? !(result instanceof _results.Empty) ? Object.assign(acc, params.replace ? { state: _extends({}, acc.state || {}, result.value) } : { state: _extends({}, acc.state || {}, { [params.key]: result.value }) }) : acc : { invalidResult: result }; | ||
return result instanceof _results.Match ? !(result instanceof _results.Empty) ? Object.assign(acc, params.replace ? { state: _extends({}, acc.state || {}, result.value) } : { | ||
state: _extends({}, acc.state || {}, { | ||
[params.key]: result.value | ||
}) | ||
}) : acc : { invalidResult: result }; | ||
}, context, function (acc, { result }) { | ||
@@ -140,3 +161,5 @@ return !(result instanceof _results.Match); | ||
return _lazily.Seq.of(finished).reduce(function (acc, { result, params }) { | ||
return result instanceof _results.Match ? !(result instanceof _results.Empty) ? Object.assign(acc, { state: (acc.state || []).concat([result.value]) }) : acc : { invalidResult: result }; | ||
return result instanceof _results.Match ? !(result instanceof _results.Empty) ? Object.assign(acc, { | ||
state: (acc.state || []).concat([result.value]) | ||
}) : acc : { invalidResult: result }; | ||
}, context, function (acc, { result }) { | ||
@@ -161,19 +184,19 @@ return !(result instanceof _results.Match); | ||
const methods = { | ||
"function": { | ||
function: { | ||
mergeChildTasks: mergeChildTasks, | ||
getChildTasks: getFunctionTasks | ||
}, | ||
"schema": { | ||
schema: { | ||
mergeChildTasks: mergeChildTasks, | ||
getChildTasks: getSchemaTasks | ||
}, | ||
"object": { | ||
object: { | ||
mergeChildTasks: mergeObjectChildTasks, | ||
getChildTasks: getObjectTasks | ||
}, | ||
"array": { | ||
array: { | ||
mergeChildTasks: mergeArrayChildTasks, | ||
getChildTasks: getArrayTasks | ||
}, | ||
"native": { | ||
native: { | ||
mergeChildTasks: mergeNativeTypeChildTasks, | ||
@@ -192,3 +215,9 @@ getChildTasks: getNativeTypeTasks | ||
const { finished, unfinished } = _lazily.Seq.of(runnables).reduce(function (acc, { task, params }) { | ||
return typeof task === "function" ? { finished: acc.finished, unfinished: acc.unfinished.concat({ task: task(), params }) } : { finished: acc.finished.concat({ result: task, params }), unfinished: acc.unfinished }; | ||
return typeof task === "function" ? { | ||
finished: acc.finished, | ||
unfinished: acc.unfinished.concat({ task: task(), params }) | ||
} : { | ||
finished: acc.finished.concat({ result: task, params }), | ||
unfinished: acc.unfinished | ||
}; | ||
}, { finished: [], unfinished: [] }); | ||
@@ -195,0 +224,0 @@ |
{ | ||
"name": "chimpanzee", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"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
138258
922