Skip to content

Latest commit

 

History

History
164 lines (86 loc) · 5.81 KB

changes.MD

File metadata and controls

164 lines (86 loc) · 5.81 KB

Changes to package by version

version 1.0.0

  1. setClass() allows a reference class to be set for a sequence of steps using class methods in a promise chain

  2. clearClass() clears a reference class

  3. async functions can now be wrapped in same way as generators eg am(async function( .. ){ .. }) or am (async ( .. )=>{ .. })

  4. 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

  5. Arrays and objects of async functions can be used in am.waterfall(), am.all()/am.parallel(), am.forEach()

Fixes

Changed README docuemtnation for am.forEach(array || object) as previously incorrect

version 0.2.15

  1. 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
  1. ** 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

next(methodName,class,...), error(methodName,class,...),

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.

twoPrev(methodName,class,...), threePrev(methodName,class,...)

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.

  1. Added tests for above feature

Version 0.2.5

Changes to functionality

  1. 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

  1. 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

Testing

  1. added tests for .twoPrev() and .threePrev()

Version 0.2.4

Changes to functionality

  1. 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)

Version 0.2.0

Extended Promise Extensions enabled

  1. am._extend(ExtendedPromise) method added

  2. am-sample-extend.js module added as template

ES6 Classes with aysnc/await supported

  1. Methods am.isClass(), am.argumentsHaveClass() utitlity added

  2. am(method,class) detects and applies detects anonymous class with normal or async methods

  3. am(initial) detects anonymous or named class and executes the constructor with any arguments

Testing

  1. Test for am.race() (Generators) changed
  2. mocha-wepack deprecated in favour of vanilla mocha
  3. Tests added for am.isClass(), am.argumentsHaveClass()
  4. Tests added for sample extension
  5. Tests added for use of named and anonymous classes in next(), forEach(), map(), mapFilter() and filter()

Version 0.1.0

Changes to functionality

  1. Changed behaviour of tolerant in map() to push passing items rather than assign to original index (same behaviour as .mapFilter() )

  2. Added ExtendedPromise property to am for testing of type

  3. Changed behaviour of error() to a) mirror .catch when non function given as argument and b) when nothing returned from function (resolves to undefined)

  4. Changed behaviour of next() to mirror .then() when non function given as argument - resolves to original value.

Fixes

  1. Fixed second argument in .forEach and .filter (affects map, mapFilter) - i or attr values correctly passed

  2. Corrected error in .forEach() documentation (resolved array is same as initial array)

  3. Fixed issue with next() whereby an error in source Extended Promise was not passed through

  4. Fix for wrapping generator - any additional arguments now passed to generator function

Tests

  1. Added test suite using mocha and webpack-mocha

  2. Removed old tests

Re-factor

  1. Removed ';' from statement ends

  2. Internally, .next() and .error() used instead of .then() and .catch()

  3. AM class renamed to ExtendedPromise