diff --git a/README.md b/README.md index 36c02a3..eb4746f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ > * Extensible. easily add additional *Extended Promise* methods -## Changes in version 0.2.5 +## Changes in version 0.2.15 [changes.MD](https://github.com/ingenious/async-methods/blob/master/changes.MD) @@ -89,7 +89,7 @@ In package.json ```javascript - "async-methods":"^0.2.9" + "async-methods":"^0.2.15" ``` @@ -109,6 +109,12 @@ In code ``` +## Node versions and support for async/await + +**async/await** is only available from version 7.6 of node.js. If you are using an earlier version you will not be able to use the async/await features of **async-methods**. **async-methods** will still work for wrapping generators and classes with normal functions and generator functions in versions earlier than 7.6. + +Generators have been supported in nmodejs since at lease version 4.8.7 + ## Handling Promise rejections NodeJS requires all rejections in a Promise chain to be handled or an exception is thrown. @@ -133,7 +139,7 @@ at the end of the chain (see examples below). That way errors will be trapped a ### Wrap ES6 Class with methods -#### am( methodName , class { methodName { ... }}) +#### am( methodName , class { methodName { ... }}, args ...) ```javascript @@ -178,7 +184,7 @@ let ep = am( ### Wrap Newed Class -#### am(methodName, new class(args...)) +#### am(methodName, new class {methodName (){}}(),args..) ```javascript @@ -245,6 +251,45 @@ Create *ExtendedPromise* that returns an array. }) +``` + +### Wrap generator + +#### am(generator) + +Creates *ExtendedPromise* (in same way as to 'co') + +```javascript + + am(function* () { + + return yield { + + b: Promise.resolve('bb'), + a: { + b: Promise.resolve('bb'), + a: { + b: Promise.resolve('bb'), + c: Promise.resolve('cc') + } + } + }; + + }) + + .log() + + // logs: + // yield object with async attributes { b: 'bb', a: { b: 'bb', a: { b: 'bb', c: 'cc' } } }​​​​​ + + .error(err=>{ + + // handle errors at end of chain + + }) + + + ``` #### Wrapping non-object @@ -359,45 +404,6 @@ Creates *ExtendedPromise* that returns arguments of the callback and passes any }) -``` - -### Wrap generator - -#### am(generator) - -Creates *ExtendedPromise* (in same way as to 'co') - -```javascript - - am(function* () { - - return yield { - - b: Promise.resolve('bb'), - a: { - b: Promise.resolve('bb'), - a: { - b: Promise.resolve('bb'), - c: Promise.resolve('cc') - } - } - }; - - }) - - .log() - - // logs: - // yield object with async attributes { b: 'bb', a: { b: 'bb', a: { b: 'bb', c: 'cc' } } }​​​​​ - - .error(err=>{ - - // handle errors at end of chain - - }) - - - ``` ### Wrap Promises @@ -1454,6 +1460,22 @@ Identical to **.catch()** but returns a chainable *ExtendedPromise*. If want **fn** to be a generator or class use **.error()** +#### Additional Arguments passed to 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 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. + +
+ ## Static methods >All static methods return a chainable Extended Promise @@ -1750,13 +1772,52 @@ These methods have same functionality as their Promise equivalents but return a ### async-methods Extensions -You can now roll-your-own Extended Promise, adding more methods or changing functionality of exiting methods! +Developerts can roll-their-own Extended Promise, adding more methods or changing functionality of exiting methods! See ***am-sample-ext.js*** and check out this Mongo extension: [am-mongo](https://github.com/ingenious/am-mongo) +In application code, **async-methods (am)** can 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. + +```javascript + + 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: + +```javascript + + 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 + +``` + +A single extension can be specified also + + +```javascript + + let am = require('async-methods') + + am.extend('am-mongo') + + // am with now be extended with am-mongo, methods available in the chain + // as well as additional am.xxx() static methods + +``` ### am._extend(ExtendedPromise) -#### For use in creating an extension +#### For use internally in creating an extension See **am-sample-ext.js** for more explanation diff --git a/am.js b/am.js index 612a85e..c86e232 100644 --- a/am.js +++ b/am.js @@ -54,9 +54,14 @@ class ExtendedPromise extends Promise { }) .error(reject) } else if (argsHaveClass) { - let newResult + let newResult, + args = [result] + if (argsHaveClass.args) { + // prepend any arguments added in method arguments to resolved value from previous step(s) in chain + args = argsHaveClass.args.concat([result]) + } try { - newResult = am.ExtendedPromise._applyResultToClass(argsHaveClass, [result]) + newResult = am.ExtendedPromise._applyResultToClass(argsHaveClass, args) // in case newResult is Promise am(newResult) @@ -110,7 +115,8 @@ class ExtendedPromise extends Promise { argsHaveClass = am.argumentsHaveClass(arguments), applyResultToClass = am.ExtendedPromise._applyResultToClass, mapFilter = true, - newContext = {} + newContext = {}, + args for (var attr in self._state_) { newContext[attr] = self._state_[attr] } @@ -121,7 +127,12 @@ class ExtendedPromise extends Promise { reject(err) } else if (argsHaveClass && !am.isArray(result) && !am.isObject(result)) { //non-object/array applied to class (synchronous/asynchronous) - applyResultToClass(argsHaveClass, [result]) + args = [result] + if (argsHaveClass.args) { + // prepend any arguments added in method arguments to resolved value from previous step(s) in chain + args = argsHaveClass.args.concat([result]) + } + applyResultToClass(argsHaveClass, args) .next(resolve) .catch(reject) } else if (!argsHaveClass && !am.isGenerator(fn) && am.isObject(result)) { @@ -529,7 +540,8 @@ class ExtendedPromise extends Promise { let self = this, argsHaveClass = am.argumentsHaveClass(arguments), applyResultToClass = am.ExtendedPromise._applyResultToClass, - newContext = {} + newContext = {}, + args for (var attr in self._state_) { newContext[attr] = self._state_[attr] } @@ -557,7 +569,12 @@ class ExtendedPromise extends Promise { }) .error(reject) } else if (argsHaveClass) { - applyResultToClass(argsHaveClass, [err]) + args = [err] + if (argsHaveClass.args) { + // prepend any arguments added in method arguments to resolved value from previous step(s) in chain + args = argsHaveClass.args.concat([err]) + } + applyResultToClass(argsHaveClass, args) .next(function(newResult) { // pass through if nothing returned if (newResult === undefined) { @@ -606,18 +623,33 @@ class ExtendedPromise extends Promise { // class with specified method (new first) try { newedClass = new argsHaveClass.classFn() - wrappedNewResult = am(newedClass[argsHaveClass.methodName].apply(self, args)) + if (!newedClass[argsHaveClass.methodName]) { + wrappedNewResult = am.reject( + argsHaveClass.methodName + ' is not a methodName of the specified Class' + ) + } else { + wrappedNewResult = am(newedClass[argsHaveClass.methodName].apply(self, args)) + } } catch (e) { wrappedNewResult = am.reject(e) } } else if (argsHaveClass.classObject && argsHaveClass.methodName) { // newed class with specified method - try { - wrappedNewResult = am( - argsHaveClass.classObject[argsHaveClass.methodName].apply(argsHaveClass.classObject, args) + if (!argsHaveClass.classObject[argsHaveClass.methodName]) { + wrappedNewResult = am.reject( + argsHaveClass.methodName + ' is not a methodName of the specified Class' ) - } catch (e) { - wrappedNewResult = am.reject(e) + } else { + try { + wrappedNewResult = am( + argsHaveClass.classObject[argsHaveClass.methodName].apply( + argsHaveClass.classObject, + args + ) + ) + } catch (e) { + wrappedNewResult = am.reject(e) + } } } else if (argsHaveClass.classFn) { // .next(Class) @@ -660,6 +692,11 @@ class ExtendedPromise extends Promise { .next(function(args) { if (argsHaveClass) { let newResult + + // append any additional arguments passed to threePrev*() to the last 3 results + if (argsHaveClass.args) { + args = args.concat(argsHaveClass.args) + } try { am.ExtendedPromise._applyResultToClass(argsHaveClass, args) .next(function(newResult) { @@ -735,6 +772,11 @@ class ExtendedPromise extends Promise { .next(function(args) { if (argsHaveClass) { let newResult + + // append any additional arguments passed to threePrev*() to the last 3 results + if (argsHaveClass.args) { + args = args.concat(argsHaveClass.args) + } try { am.ExtendedPromise._applyResultToClass(argsHaveClass, args) .next(function(newResult) { @@ -772,7 +814,6 @@ class ExtendedPromise extends Promise { reject(e) } } else { - console.log(756) am(args) .next(resolve) .error(reject) @@ -1365,6 +1406,27 @@ am.sfFn = function(initial) { ) } +// add one or more extensions to an existing instance +am.extend = function(extensionPackageList) { + if (!am.isArray(extensionPackageList)) { + extensionPackageList = [extensionPackageList] + } + extensionPackageList.forEach(function(extensionPackage) { + let amVersion = require(extensionPackage) + try { + for (var method in amVersion) { + if (!am[method]) { + am[method] = amVersion[method] + } + } + + am._extend(amVersion.ExtendedPromise) + } catch (e) { + console.log(1397, 'Problem extending am with ', extensionPackage, e) + } + }) + return am +} am._extend = function(extendedPromise) { // back extend async methods ExtendedPromise class let superMethodNames = am.methodNames diff --git a/changes.MD b/changes.MD index 37a9996..4605b21 100644 --- a/changes.MD +++ b/changes.MD @@ -1,3 +1,49 @@ +# Changes to package by version + +## 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. + +```javascript + + 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: + +```javascript + + 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 + +``` + +2. ** 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. + +3. Added tests for above feature + ### Version 0.2.5 #### Changes to functionality @@ -16,7 +62,7 @@ returns Extended Promise resolving to an array of three latest resolved values i #### Testing -1. added tests for .twoPrev() and .threePrev() +3. added tests for .twoPrev() and .threePrev() ### Version 0.2.4 @@ -45,21 +91,21 @@ returns Extended Promise resolving to an array of three latest resolved values i #### ES6 Classes with aysnc/await supported -1. Methods am.isClass(), am.argumentsHaveClass() utitlity added +3. Methods am.isClass(), am.argumentsHaveClass() utitlity added -2. am(method,class) detects and applies detects anonymous class with normal or async methods +4. 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 +5. 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() +6. Test for am.race() (Generators) changed +7. mocha-wepack deprecated in favour of vanilla mocha +8. Tests added for am.isClass(), am.argumentsHaveClass() +9. Tests added for sample extension +10. Tests added for use of named and anonymous classes in next(), forEach(), map(), mapFilter() and filter() ### Version 0.1.0 @@ -93,10 +139,10 @@ returns Extended Promise resolving to an array of three latest resolved values i #### Re-factor -11. Removed ';' from statement ends +11. Removed ';' from statement ends -12. Internally, .next() and .error() used instead of .then() and .catch() +12. Internally, .next() and .error() used instead of .then() and .catch() -13. AM class renamed to ExtendedPromise +13. AM class renamed to ExtendedPromise diff --git a/extend-test/extend.js b/extend-test/extend.js new file mode 100644 index 0000000..caea82b --- /dev/null +++ b/extend-test/extend.js @@ -0,0 +1,23 @@ +var am = require('../am.js'), + join = require('path').join, + assert = require('assert') + +describe('Test adding extensions using .extend()', function() { + describe('extend async-methods', function() { + it('should add additional static methods to am and new chainable methods to ExtendedPromise', function(done) { + am.extend('am-mongo') + // check new methods revealed + assert.ok(am.connect) + assert.ok(am().connect) + done() + }) + it('should add additional methods when extension is a filepath and in an array', function(done) { + am.extend([join(__dirname, '../am-sample-ext.js')]) + + // check new methods revealed + assert.ok(am.trivial) + assert.ok(am().twoPrevious) + done() + }) + }) +}) diff --git a/package-lock.json b/package-lock.json index efd146b..18141ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,25 @@ { "name": "async-methods", - "version": "0.2.0", + "version": "0.2.15", "lockfileVersion": 1, "requires": true, "dependencies": { + "am-mongo": { + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/am-mongo/-/am-mongo-0.0.11.tgz", + "integrity": "sha512-eZ/3opFEDSdoVznxgqYdTCDQniOOfZNzcOvH0Vmb0mIo8TswC+koaJ4+eDouxY3A4McGmm61gqCib4211H3SlA==", + "dev": true, + "requires": { + "async-methods": "0.2.14", + "mongodb": "3.0.1" + } + }, + "async-methods": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/async-methods/-/async-methods-0.2.14.tgz", + "integrity": "sha512-cGuf6UBNTpxurlJoTYCLQNwvrtLOy/tTSQD4NnhLYc/WYZm3C/BFmmUGwSWsvLnQqh8cmz6dfXJ9VmBQDkUm8w==", + "dev": true + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -26,6 +42,12 @@ "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", "dev": true }, + "bson": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.4.tgz", + "integrity": "sha1-k8ENOeqltYQVy8QFLz5T5WKwtyw=", + "dev": true + }, "commander": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", @@ -217,6 +239,25 @@ } } }, + "mongodb": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.0.1.tgz", + "integrity": "sha1-J47oAGJX7CJ5hZSmJZVGgl1t4bI=", + "dev": true, + "requires": { + "mongodb-core": "3.0.1" + } + }, + "mongodb-core": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.0.1.tgz", + "integrity": "sha1-/23Dbulv9ZaVPYCmhA1nMbyS7+0=", + "dev": true, + "requires": { + "bson": "1.0.4", + "require_optional": "1.0.1" + } + }, "ms": { "version": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", @@ -237,6 +278,28 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "require_optional": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", + "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", + "dev": true, + "requires": { + "resolve-from": "2.0.0", + "semver": "5.5.0" + } + }, + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=", + "dev": true + }, + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + }, "supports-color": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", diff --git a/package.json b/package.json index d5d2207..4d34a65 100644 --- a/package.json +++ b/package.json @@ -29,16 +29,17 @@ "url": "https://github.com/ingenious/async-methods.git" }, "description": "co-like wrapper for chaining asyncronous and syncronous processes in nodejs with support for generators/yield and async/await", - "version": "0.2.14", + "version": "0.2.15", "main": "am.js", "dependencies": {}, "devDependencies": { + "am-mongo": "*", "intercept-stdout": "^0.1.2", "mocha": "^4.0.1" }, "readmeFilename": "README.md", "scripts": { - "test": " mocha ./tests", - "test-extend": "mocha ./tests/_extend.js" + "test": " mocha ./tests && mocha ./extend-test/extend.js", + "test-extend": "mocha ./extend-test/extend.js" } } diff --git a/tests/next.js b/tests/next.js index 8b970aa..be39620 100644 --- a/tests/next.js +++ b/tests/next.js @@ -81,10 +81,12 @@ describe('.next()', function() { .next( 'test', class { - async test(value) { + async test(methodArg, value) { + assert.equal(methodArg, 'method argument') return await Promise.resolve(89 + (value || 0)) } - } + }, + 'method argument' ) .next(r => { assert.ok(ep instanceof am.ExtendedPromise) @@ -105,10 +107,12 @@ describe('.next()', function() { .next( 'test', new class { - async test(value) { + async test(methodArg, value) { + assert.equal(methodArg, 'method argument') return await Promise.resolve(89 + (value || 0)) } - }() + }(), + 'method argument' ) .next(r => { assert.ok(ep instanceof am.ExtendedPromise) diff --git a/tests/threePrev.js b/tests/threePrev.js index e9e48c6..06e816d 100644 --- a/tests/threePrev.js +++ b/tests/threePrev.js @@ -170,7 +170,8 @@ describe('.threePrev()', function() { describe('\n Named Class', function() { it('should return extended promise resolving or rejecting to returned value of anonymous class', function(done) { let sample = class { - async test(value, prev, first) { + async test(value, prev, first, extraArg) { + assert.equal(extraArg, 'extra argument') assert.deepEqual(prev, { a: 56 }) assert.deepEqual(first, { b: 6 }) return await Promise.resolve(89 + (value || 0)) @@ -183,7 +184,7 @@ describe('.threePrev()', function() { .next(function*(items) { return yield Promise.resolve(56) }) - .threePrev('test', sample) + .threePrev('test', sample, 'extra argument') .next(r => { assert.ok(ep instanceof am.ExtendedPromise) @@ -203,7 +204,8 @@ describe('.threePrev()', function() { constructor(type) { this.type = type } - async test(value, prev, first) { + async test(value, prev, first, extraArg) { + assert.equal(extraArg, 'extra argument') assert.deepEqual(prev, { a: 56 }) assert.deepEqual(first, { b: 6 }) return await Promise.resolve(89 + (this.type || 0) + (value || 0)) @@ -216,7 +218,7 @@ describe('.threePrev()', function() { .next(function*(items) { return yield Promise.resolve(56) }) - .threePrev('test', new sample(45)) + .threePrev('test', new sample(45), 'extra argument') .next(r => { assert.ok(ep instanceof am.ExtendedPromise) assert.equal(r, 190) diff --git a/tests/twoPrev.js b/tests/twoPrev.js index 6c19edc..aa7348e 100644 --- a/tests/twoPrev.js +++ b/tests/twoPrev.js @@ -63,7 +63,7 @@ describe('.twoPrev()', function() { assert.deepStrictEqual(r, [{ second: 897 }, [5, 6, 7]]) done() }) - .catch(err => { + .error(err => { assert.fail('Promise rejected', err) }) .catch(done) @@ -99,12 +99,14 @@ describe('.twoPrev()', function() { .twoPrev( 'test', class { - async test(value, previous) { + async test(value, previous, extraArg) { + assert.equal(extraArg, 'extra argument') assert.deepEqual(value, { a: 2 }) assert.deepEqual(previous, 56) return await Promise.resolve(89 + (previous || 0)) } - } + }, + 'extra argument' ) .next(r => { assert.deepEqual(r, 145) @@ -128,15 +130,21 @@ describe('.twoPrev()', function() { } }() ) - .twoPrev((r, p) => { - assert.ok(ep instanceof am.ExtendedPromise) - - assert.equal(r, 145) - assert.equal(p, 56) - done() - }) + .twoPrev( + 'test', + new class { + test(r, p, extraArg) { + assert.ok(ep instanceof am.ExtendedPromise) + assert.equal(extraArg, 'extra argument') + assert.equal(r, 145) + assert.equal(p, 56) + done() + } + }(), + 'extra argument' + ) .next(r => { - assert.deepEqual(r, [145, 56]) + assert.deepEqual(r, [145, 56, 'extra argument']) }) .error(err => { console.log(err) diff --git a/tests/wrapping.js b/tests/wrapping.js index 49c61d5..5366a6d 100644 --- a/tests/wrapping.js +++ b/tests/wrapping.js @@ -335,12 +335,14 @@ describe('Wrapping', function() { it('should return extended promise resolving or rejecting to returned value of name class', function(done) { // named class class sample { - async test() { + async test(methodArg1, methodArg2) { + assert.equal(methodArg1, 'method argument 1') + assert.equal(methodArg2, 'method argument 2') return await Promise.resolve(56789) } } - let ep = am('test', sample).next(r => { + let ep = am('test', sample, 'method argument 1', 'method argument 2').next(r => { assert.ok(ep instanceof am.ExtendedPromise) assert.equal(r, 56789) done() @@ -360,6 +362,7 @@ describe('Wrapping', function() { return await Promise.resolve(5 + (self.value || 0) + (arg || 0)) } } + // call emthod with let ep = am('test', new sample(12), 17) .next(r => {