diff --git a/Promise.js b/Promise.js index ef4ac4d..b28e78d 100644 --- a/Promise.js +++ b/Promise.js @@ -160,19 +160,8 @@ object.Constructor('IterablePromise', Promise, { .reverse(), 'raw') }, - // XXX do we need these? - // .pop() - // .shift() - // .first() / .last() - // ...would be nice if these could stop everything that's not - // needed to execute... - // XXX these can change the "resolved" state... - // ...i.e. return a pending promise when called from a fulfilled - // promise.... - // .concat(..) - // .push(..) - // .unshift(..) - // .first(..) / .last(..) + // NOTE: these can create an unresolved promise from a resolved + // promise... // XXX EXPEREMENTAL... // ....can we remove a level of indirection here??? // would be better to use the raw mode... @@ -199,11 +188,17 @@ object.Constructor('IterablePromise', Promise, { 'raw') }, push: function(elem){ return this.concat([elem]) }, - // XXX this can be written in the same style as .concat(..) unshift: function(elem){ return this.constructor([elem]) .concat(this) }, + // XXX do we need these? + // .pop() + // .shift() + // .first() / .last() + // ...would be nice if these could stop everything that's not + // needed to execute... + // Overload .then(..), .catch(..) and .finally(..) to return a plain // Promise instnace... diff --git a/README.md b/README.md index 8200ede..00a90f7 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ Library of JavaScript type extensions, types and utilities. - [`.map(..)` / `.filter(..)` / `.reduce(..)`](#promise-itermap--promise-iterfilter--promise-iterreduce) - [`.flat(..)`](#promise-iterflat) - [`.reverse()`](#promise-iterreverse) + - [`.concat(..)`](#promise-iterconcat) + - [`.push(..)` / `.unshift(..)`](#promise-iterpush--promise-iterunshift) - [`.then(..)` / `.catch(..)` / `.finally(..)`](#promise-iterthen--promise-itercatch--promise-iterfinally) - [Advanced handler](#advanced-handler) - [Promise proxies](#promise-proxies) @@ -1619,6 +1621,31 @@ but rather a _reversed copy_ will be created. This is similar to [`.reverse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse) see it for more info. +#### `.concat(..)` + +```bnf +.concat() + -> +``` + +This is similar to [`.concat(..)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) see it for more info. + + +#### `.push(..)` / `.unshift(..)` + +```bnf +.push() + -> + +.unshift() + -> +``` + +These are similar to [`.push(..)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) +and [`.unshift(..)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift) +see them for more info. + + #### `.then(..)` / `.catch(..)` / `.finally(..)` An extension to