New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

worksmith

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

worksmith - npm Package Compare versions

Comparing version 0.1.8 to 0.2.2

Interpolation.md

56

index.js

@@ -18,2 +18,4 @@ var debug = require('debug')('workflow:common')

var interpolate = require('./src/interpolation').interpolate
var worksmith

@@ -54,5 +56,2 @@

var args = (context.get(step.arguments) || [])
.map(function(arg) {
return context.get(arg);
})
var result = method.apply(object, args)

@@ -120,7 +119,7 @@ done(undefined, result);

if (!context.initialized) {
context.get = function(name) {
return workflow.readValue(name, context)
context.get = function(name, interpolate) {
return workflow.readValue(name, this, interpolate)
},
context.set = function(name, value) {
return workflow.setValue(context, name, value)
return workflow.setValue(this, name, value)
}

@@ -138,7 +137,13 @@ context.initialized = true;

execute.inject && (annotations.inject = execute.inject);
annotations.inject && annotations.inject.forEach(function(name) {
annotations.inject && annotations.inject.forEach(function(injectable) {
if ("string" === typeof injectable) {
injectable = {
name: injectable,
interpolationPolicy: true,
}
}
var arg;
switch(name[0]) {
case '@': arg = context.get(name); break;
default: arg = context.get(workflowDefinition[name]); break;
switch(injectable.name[0]) {
case '@': arg = context.get(injectable.name); break;
default: arg = context.get(workflowDefinition[injectable.name],injectable.interpolationPolicy); break;
}

@@ -271,33 +276,6 @@ args.push(arg)

readContextPath: function (context, path) {
path = path.replace(/\[/g, ".").replace(/\]/g, "")
var parts = path.split('.');
var data = context;
var part;
while (part = parts.shift()) {
data = data[part];
if (data === undefined) {
return undefined;
}
}
return data;
readValue: function(pathOrValue, context, interpolationPolicy) {
return interpolate(context, pathOrValue, interpolationPolicy)
},
readValue: function (pathOrValue, context) {
if ("@" == pathOrValue) return context;
if ("string" === typeof pathOrValue && pathOrValue[0] == '@') {
return module.exports.readContextPath(context, pathOrValue.slice(1))
}
if ("object" === typeof pathOrValue && "template" in pathOrValue) {
var template = pathOrValue.template;
var compiled = handlebars.compile(template);
return compiled(context);
}
return pathOrValue;
},
setValue: function (object, path, value) {

@@ -304,0 +282,0 @@ var parts = path.split('.');

{
"name": "worksmith",
"version": "0.1.8",
"version": "0.2.2",
"description": "A purely functional workflow engine ",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,3 +8,3 @@ # worksmith

For a step by step tutorial click [here](https://github.com/guidesmiths/worksmith/blob/master/TUTORIAL.md)
[Interpolation features](https://github.com/guidesmiths/worksmith/blob/master/Interpolation.md)
[Release notes](https://github.com/guidesmiths/worksmith/blob/master/ReleaseNotes.md)

@@ -11,0 +11,0 @@

@@ -6,5 +6,4 @@ var workflow = require('../')

return function (context) {
var subflowName = context.get(node.subflow)
var subflow = workflow(subflowName)
return function(done) {
execute.inject = [{name: "subflow", interpolationPolicy: false } ]
function execute(subflow, done) {
var items = context.get(node.items)

@@ -16,6 +15,7 @@ var itemKey = context.get(node.itemKey) || 'item'

subContext.set(itemKey, item)
subflow(context, cb)
workflow(subflow)(subContext, cb)
})
}, done)
}
return execute;
}

@@ -22,0 +22,0 @@ }

@@ -6,4 +6,4 @@ var workflow = require('../')

return function (context) {
return function(done) {
var subflow = context.get(node.subflow)
execute.inject = [{name: "subflow", interpolationPolicy: false } ]
function execute(subflow, done) {
var result

@@ -24,2 +24,3 @@ async.whilst(function() {

}
return execute;
}

@@ -26,0 +27,0 @@ }

@@ -8,3 +8,3 @@ var workflow = require('../')

it("should iterate over a list of items", function (done) {
var context = { count: 0 };
var context = { counter: {count: 0 }};

@@ -18,3 +18,3 @@ var wi = workflow({

return function(done) {
context.count++
context.counter.count++
done()

@@ -29,3 +29,3 @@ }

assert.ifError(err)
assert.equal(context.count, 3)
assert.equal(context.counter.count, 3)
done()

@@ -37,8 +37,8 @@ })

this.timeout(10000)
var context = { count: 0 }
this.timeout(20000)
var context = { counter: { count: 0 } }
var wi = workflow({
task: "eachSeries",
items: _.range(0, 999999),
items: _.range(0, 99999),
subflow: {

@@ -48,3 +48,3 @@ task: function(definition) {

return function(done) {
context.count++
context.counter.count++
done()

@@ -59,3 +59,3 @@ }

assert.ifError(err)
assert.equal(context.count, 999999)
assert.equal(context.counter.count, 99999)
done()

@@ -66,3 +66,3 @@ })

it("should work in nested loops", function (done) {
var context = { count: 0 };
var context = { counter: {count: 0 } };

@@ -79,3 +79,3 @@ var wi = workflow({

return function(done) {
context.count++
context.counter.count++
done()

@@ -91,3 +91,3 @@ }

assert.ifError(err)
assert.equal(context.count, 9)
assert.equal(context.counter.count, 9)
done()

@@ -94,0 +94,0 @@ })

@@ -14,3 +14,3 @@ var assert = require('assert')

"source":"./test/workflow1.js",
"context": innerContext
"context": { _np_: innerContext }
})({}, function (err, result) {

@@ -17,0 +17,0 @@ assert.equal(innerContext.result, "hello", "inner context field must match")

@@ -232,2 +232,32 @@ var assert = require('assert')

it("should handle injecting arrays ", function(done) {
var flags = {};
var def = {
task: function(def) {
function build(context) {
function execute(f1, f2, done) {
flags.f1 = f1;
flags.f2 = f2;
done();
}
execute.annotations = { inject:["f1","f2"] }
return execute
}
return build
},
f1: "@field1",
f2: "@field2"
};
var wf = workflow(def)
var context = { field1:"value1", field2:["a","b","c"] };
var wi = wf(context);
wi(function(err, res) {
assert.equal(flags.f1,"value1", "injected must be passed correctly")
assert.equal(flags.f2, context.field2, "injected must be passed correctly")
done();
})
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc