async-args: concepts

node v4.9.1
version: 5.0.0
endpointsharetweet
The following example shows conceptually what async-args is doing. Think of it as a factory that produces async functions that will alter the arguments being passed in the desired way. In this first example, we define what the arguments will be, to the exclusion of other arguments
var AsyncArgs = require("async-args") AsyncArgs.constants('test1C')('test1V', function(err, constant){ console.log('constant:' + constant) })
In the next example, the async function produced from the factory will append arguments to the existing argument list.
var AsyncArgs = require("async-args") AsyncArgs.appendConstants('test2C')('test2V', function(err, value, constant){ console.log('value: ' + value) console.log('constant: ' + constant) })
Same thing, but the constant is prepended instead of appended
var AsyncArgs = require("async-args") AsyncArgs.prependConstants('test2C')('test2V', function(err, constant, value){ console.log('value: ' + value) console.log('constant: ' + constant) })
Created from: https://tonicdev.com/npm/async-args
Loading…

no comments

    sign in to comment