mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-20 15:00:42 -07:00
chore(TypeScript): refactor objects into classes
fix: `Nil`(null, undefined) now renders as empty string change: `parser.parseValue()` renamed to `parser.parseOutput` change: registered tags/filters become static and shared across different liquid instances
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Call functions in serial until someone resolved.
|
||||
* @param iterable the array to iterate with.
|
||||
* @param iteratee returns a new promise.
|
||||
* The iteratee is invoked with three arguments: (value, index, iterable).
|
||||
*/
|
||||
export function anySeries (iterable, iteratee) {
|
||||
let ret: Promise<any> = Promise.reject(new Error('init'))
|
||||
iterable.forEach(function (item, idx) {
|
||||
ret = ret.catch(e => iteratee(item, idx, iterable))
|
||||
})
|
||||
return ret
|
||||
}
|
||||
|
||||
/*
|
||||
* Call functions in serial until someone rejected.
|
||||
* @param {Array} iterable the array to iterate with.
|
||||
* @param {Array} iteratee returns a new promise.
|
||||
* The iteratee is invoked with three arguments: (value, index, iterable).
|
||||
*/
|
||||
export function mapSeries (iterable, iteratee) {
|
||||
let ret: Promise<any> = Promise.resolve('init')
|
||||
const result = []
|
||||
iterable.forEach(function (item, idx) {
|
||||
ret = ret
|
||||
.then(() => iteratee(item, idx, iterable))
|
||||
.then(x => result.push(x))
|
||||
})
|
||||
return ret.then(() => result)
|
||||
}
|
||||
Reference in New Issue
Block a user