-
setClass() allows a reference class to be set for a sequence of steps using class methods in a promise chain
-
clearClass() clears a reference class
-
async functions can now be wrapped in same way as generators eg am(async function( .. ){ .. }) or am (async ( .. )=>{ .. })
-
async functions can now be used in .next(fn), .error(fn), .mapFilter(fn), .map(fn), .filter(fn), .forEach(fn), .twoPrev(fn) and .threePrev(fn). The await keyword can be used similarly to yield
-
Arrays and objects of async functions can be used in am.waterfall(), am.all()/am.parallel(), am.forEach()
Changed README docuemtnation for am.forEach(array || object) as previously incorrect
- am.extend(extensionPackageList)
async-methods can niow be extended progressively using am.extend() static mmthod. Some new standard extensions are due for release soon, but applicastion developers can create their own and reference them by a filepath as well as by an npm module name.
let am = require('am-mongo')
am.extend(['../../am-axios.js', '../../am-cron.js'])
// as well as additional am.xxx() static methods
// am with now be extended with am-mongo, am-axios and am-cron methods available in the chain
This would have the same effect:
let am = require('async-methods')
am.extend(['am-mongo',../../am-axios.js', '../../am-cron.js'])
// am with now be extended with am-mongo, am-axios and am-cron methods available in the chain
// as well as additional am.xxx() static methods
- ** Additonal arguments for class methods) When wrapping a class and specifying a method name, arguments to be passed to the method can be added can be added as arguments of the wrappimg am(). The same is now true for anonymous and named classes used as arguments to
Additional arguments added to next(methodName,class,...) are prepended to the resolved result of previous step and appled as arguments to the method. Thiis si useful if you don'tt want the result to be used by the method but wish to apply other arguments.
Additional arguments added to twoPrev(methodName,class,...) are appended to the resolved result of previous two steps and appled as arguments to the method. The main purpose of twoPrev is to pass two results to a method. If additional arguments are required they can be added in this way.
Additional arguments added to threePrev(methodName,class,...) are appended to the resolved result of previous three steps and appled as arguments to the method. The main purpose of threePrev is to pass three results to a method. If additional arguments are required they can be added in this way.
- Added tests for above feature
- added .twoPrev(<generator|function|class>)
passes two arguments - last result and previous result in chain
returns Extended Promise resolving to an array of two latest resolved values in chain
- added .threePrev(<generator|function|class>)
passes three arguments - last result, previous result and previous result in chain
returns Extended Promise resolving to an array of three latest resolved values in chain
- added tests for .twoPrev() and .threePrev()
- made class methods invokeable with a context (used in api-responder to pass state)
eg
am.ExtendedPromise._applyResultToClass
.apply(context, [argsHaveClass])
.then(result => {
resolve(result)
})
.catch(reject)
-
am._extend(ExtendedPromise) method added
-
am-sample-extend.js module added as template
-
Methods am.isClass(), am.argumentsHaveClass() utitlity added
-
am(method,class) detects and applies detects anonymous class with normal or async methods
-
am(initial) detects anonymous or named class and executes the constructor with any arguments
- Test for am.race() (Generators) changed
- mocha-wepack deprecated in favour of vanilla mocha
- Tests added for am.isClass(), am.argumentsHaveClass()
- Tests added for sample extension
- Tests added for use of named and anonymous classes in next(), forEach(), map(), mapFilter() and filter()
-
Changed behaviour of tolerant in map() to push passing items rather than assign to original index (same behaviour as .mapFilter() )
-
Added ExtendedPromise property to am for testing of type
-
Changed behaviour of error() to a) mirror .catch when non function given as argument and b) when nothing returned from function (resolves to undefined)
-
Changed behaviour of next() to mirror .then() when non function given as argument - resolves to original value.
-
Fixed second argument in .forEach and .filter (affects map, mapFilter) - i or attr values correctly passed
-
Corrected error in .forEach() documentation (resolved array is same as initial array)
-
Fixed issue with next() whereby an error in source Extended Promise was not passed through
-
Fix for wrapping generator - any additional arguments now passed to generator function
-
Added test suite using mocha and webpack-mocha
-
Removed old tests
-
Removed ';' from statement ends
-
Internally, .next() and .error() used instead of .then() and .catch()
-
AM class renamed to ExtendedPromise