machinepack-util
Advanced tools
Comparing version 7.0.0-1 to 7.0.0-2
@@ -79,4 +79,5 @@ module.exports = { | ||
// Import `async`. | ||
// Import `async` and `rttc`. | ||
var async = require('async'); | ||
var rttc = require('rttc'); | ||
@@ -86,2 +87,6 @@ // Put a reference to `inputs.initialData` into a var for convenience. | ||
// Get an exemplar of the initial value so that we can coerce any | ||
// updated data to be the same type after each iteration. | ||
var initialValueTypeSchema = rttc.infer(rttc.coerceExemplar(inputs.initialData)); | ||
// Use `async.during` to perform a fully asynchronous "while" loop | ||
@@ -115,4 +120,8 @@ // (In `async.whilst`, the test must be performed synchronously). | ||
success: function(updatedData) { | ||
data = updatedData; | ||
// Keep track of accumulated result so far, and make sure it validates | ||
// against the initial value's type. | ||
data = rttc.coerce(initialValueTypeSchema, updatedData); | ||
return cb(); | ||
}, | ||
@@ -119,0 +128,0 @@ // If the operation returned through its `error` exit, |
{ | ||
"name": "machinepack-util", | ||
"version": "7.0.0-1", | ||
"version": "7.0.0-2", | ||
"description": "Miscellaneous utilities for everyday tasks with arrays, dictionaries, strings, etc.", | ||
@@ -25,4 +25,5 @@ "scripts": { | ||
"lodash": "3.10.1", | ||
"machine": "^13.0.0-7", | ||
"resolve": "1.1.7" | ||
"machine": "^13.0.0-11", | ||
"resolve": "1.1.7", | ||
"rttc": "^9.8.2" | ||
}, | ||
@@ -46,3 +47,4 @@ "repository": { | ||
"whilst", | ||
"pretty-print" | ||
"pretty-print", | ||
"get-calculated-value" | ||
], | ||
@@ -49,0 +51,0 @@ "testsUrl": "https://travis-ci.org/treelinehq/machinepack-util" |
@@ -12,4 +12,24 @@ { | ||
"returns": 0 | ||
}, | ||
{ | ||
"using": { | ||
"test": "function(inputs, exits) {if (inputs.data === 0) {return exits.stop();} return exits.success();}", | ||
"operation": "function(inputs, exits) {console.log(inputs.data); return exits.success(inputs.data + 'foo');}", | ||
"initialData": 5 | ||
}, | ||
"outcome": "success", | ||
"returns": 0 | ||
}, | ||
{ | ||
"using": { | ||
"test": "function(inputs, exits) {if (inputs.data.length === 10) {return exits.stop();} return exits.success();}", | ||
"operation": "function(inputs, exits) {return exits.success(inputs.data.concat(inputs.data.length));}", | ||
"initialData": [] | ||
}, | ||
"outcome": "success", | ||
"returns": [0,1,2,3,4,5,6,7,8,9] | ||
} | ||
] | ||
} |
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
29856
23
783
7
+ Addedrttc@^9.8.2
Updatedmachine@^13.0.0-11