Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fnflow

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fnflow - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

8

lib/task.js

@@ -22,5 +22,6 @@ var util = require('util');

Task.prototype.defaultTo = function(value) {
Task.prototype.defaultTo = function(name) {
this.requires(name);
this.onComplete(function(result, results){
if(result.value === null || result.value === undefined) result.value = value;
if(result.value === null || result.value === undefined) result.value = results[name];
});

@@ -36,3 +37,3 @@ return this;

err = new errors.ArgumentNull(self.name);
err.message = 'Not Found: ' + self.toString(results.value);
err.message = 'Not Found: ' + self.toString(results);
throw err;

@@ -178,3 +179,2 @@ }

result = { value: result };
results = { value: results };
var err;

@@ -181,0 +181,0 @@ try {

@@ -6,3 +6,3 @@ {

"author": "David Fenster <david@dfenster.com>",
"version": "0.4.1",
"version": "0.5.0",
"repository": {

@@ -9,0 +9,0 @@ "type": "git",

@@ -116,5 +116,5 @@ fnflow

### task.defaultTo(value)
### task.defaultTo(task_name)
Default the result of a task to a specified value if it did not yield one (undefined or null).
Default the result of a task to the result of a task or data if it did not yield one (undefined or null).

@@ -125,6 +125,6 @@ __Example__

book: new Task(Book.findByTitle, 'title'),
author_name: new Task(Author.getNameById, 'book.author_id').defaultTo('unknown')
author_name: new Task(Author.getNameById, 'book.author_id').defaultTo('unknown_title')
});
flow.execute({ title: 'Beowulf' }, function(err, results){
flow.execute({ title: 'Beowulf', unknown_title: 'unknown' }, function(err, results){
if(err) return console.error(err);

@@ -131,0 +131,0 @@ console.log(results.author_name + " wrote " + results.title); //prints "unknown wrote Beowulf"

@@ -20,5 +20,6 @@ var Flow = require('../lib/fnFlow').Flow, Task = Flow.Task;

new Flow({
book: new Task(Book.getById, 'bookId').defaultTo("none")
book: new Task(Book.getById, 'bookId').defaultTo("default_book")
}).execute({
bookId: 100
bookId: 100,
default_book: 'none'
}, function(err, results){

@@ -33,5 +34,6 @@ test.ok(!err, 'no error');

new Flow({
book: new Task(Book.getById, 'bookId').defaultTo("none")
book: new Task(Book.getById, 'bookId').defaultTo("default_book")
}).execute({
bookId: 1
bookId: 1,
default_book: 'none'
}, function(err, results){

@@ -38,0 +40,0 @@ test.ok(!err, 'no error');

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