"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/slide/lib/chain.js" (8 Mar 2017, 660 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 module.exports = chain
    2 var bindActor = require("./bind-actor.js")
    3 chain.first = {} ; chain.last = {}
    4 function chain (things, cb) {
    5   var res = []
    6   ;(function LOOP (i, len) {
    7     if (i >= len) return cb(null,res)
    8     if (Array.isArray(things[i]))
    9       things[i] = bindActor.apply(null,
   10         things[i].map(function(i){
   11           return (i===chain.first) ? res[0]
   12            : (i===chain.last)
   13              ? res[res.length - 1] : i }))
   14     if (!things[i]) return LOOP(i + 1, len)
   15     things[i](function (er, data) {
   16       if (er) return cb(er, res)
   17       if (data !== undefined) res = res.concat(data)
   18       LOOP(i + 1, len)
   19     })
   20   })(0, things.length) }