Template Upload

This commit is contained in:
SOUTHERNCO\x2mjbyrn
2017-05-17 13:45:25 -04:00
parent 415b9c25f3
commit 7efe7605b8
11476 changed files with 2170865 additions and 34 deletions

65
node_modules/slide/lib/async-map-ordered.js generated vendored Normal file
View File

@ -0,0 +1,65 @@
throw new Error("TODO: Not yet implemented.")
/*
usage:
Like asyncMap, but only can take a single cb, and guarantees
the order of the results.
*/
module.exports = asyncMapOrdered
function asyncMapOrdered (list, fn, cb_) {
if (typeof cb_ !== "function") throw new Error(
"No callback provided to asyncMapOrdered")
if (typeof fn !== "function") throw new Error(
"No map function provided to asyncMapOrdered")
if (list === undefined || list === null) return cb_(null, [])
if (!Array.isArray(list)) list = [list]
if (!list.length) return cb_(null, [])
var errState = null
, l = list.length
, a = l
, res = []
, resCount = 0
, maxArgLen = 0
function cb (index) { return function () {
if (errState) return
var er = arguments[0]
var argLen = arguments.length
maxArgLen = Math.max(maxArgLen, argLen)
res[index] = argLen === 1 ? [er] : Array.apply(null, arguments)
// see if any new things have been added.
if (list.length > l) {
var newList = list.slice(l)
a += (list.length - l)
var oldLen = l
l = list.length
process.nextTick(function () {
newList.forEach(function (ar, i) { fn(ar, cb(i + oldLen)) })
})
}
if (er || --a === 0) {
errState = er
cb_.apply(null, [errState].concat(flip(res, resCount, maxArgLen)))
}
}}
// expect the supplied cb function to be called
// "n" times for each thing in the array.
list.forEach(function (ar) {
steps.forEach(function (fn, i) { fn(ar, cb(i)) })
})
}
function flip (res, resCount, argLen) {
var flat = []
// res = [[er, x, y], [er, x1, y1], [er, x2, y2, z2]]
// return [[x, x1, x2], [y, y1, y2], [undefined, undefined, z2]]

54
node_modules/slide/lib/async-map.js generated vendored Normal file
View File

@ -0,0 +1,54 @@
/*
usage:
// do something to a list of things
asyncMap(myListOfStuff, function (thing, cb) { doSomething(thing.foo, cb) }, cb)
// do more than one thing to each item
asyncMap(list, fooFn, barFn, cb)
*/
module.exports = asyncMap
function asyncMap () {
var steps = Array.prototype.slice.call(arguments)
, list = steps.shift() || []
, cb_ = steps.pop()
if (typeof cb_ !== "function") throw new Error(
"No callback provided to asyncMap")
if (!list) return cb_(null, [])
if (!Array.isArray(list)) list = [list]
var n = steps.length
, data = [] // 2d array
, errState = null
, l = list.length
, a = l * n
if (!a) return cb_(null, [])
function cb (er) {
if (er && !errState) errState = er
var argLen = arguments.length
for (var i = 1; i < argLen; i ++) if (arguments[i] !== undefined) {
data[i - 1] = (data[i - 1] || []).concat(arguments[i])
}
// see if any new things have been added.
if (list.length > l) {
var newList = list.slice(l)
a += (list.length - l) * n
l = list.length
process.nextTick(function () {
newList.forEach(function (ar) {
steps.forEach(function (fn) { fn(ar, cb) })
})
})
}
if (--a === 0) cb_.apply(null, [errState].concat(data))
}
// expect the supplied cb function to be called
// "n" times for each thing in the array.
list.forEach(function (ar) {
steps.forEach(function (fn) { fn(ar, cb) })
})
}

16
node_modules/slide/lib/bind-actor.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
module.exports = bindActor
function bindActor () {
var args =
Array.prototype.slice.call
(arguments) // jswtf.
, obj = null
, fn
if (typeof args[0] === "object") {
obj = args.shift()
fn = args.shift()
if (typeof fn === "string")
fn = obj[ fn ]
} else fn = args.shift()
return function (cb) {
fn.apply(obj, args.concat(cb)) }
}

20
node_modules/slide/lib/chain.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
module.exports = chain
var bindActor = require("./bind-actor.js")
chain.first = {} ; chain.last = {}
function chain (things, cb) {
var res = []
;(function LOOP (i, len) {
if (i >= len) return cb(null,res)
if (Array.isArray(things[i]))
things[i] = bindActor.apply(null,
things[i].map(function(i){
return (i===chain.first) ? res[0]
: (i===chain.last)
? res[res.length - 1] : i }))
if (!things[i]) return LOOP(i + 1, len)
things[i](function (er, data) {
if (er) return cb(er, res)
if (data !== undefined) res = res.concat(data)
LOOP(i + 1, len)
})
})(0, things.length) }

3
node_modules/slide/lib/slide.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
exports.asyncMap = require("./async-map")
exports.bindActor = require("./bind-actor")
exports.chain = require("./chain")