mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-23 19:06:31 +00:00
Enable long stack support when process.env.CI is true
This commit is contained in:
+44
-43
@@ -2,34 +2,35 @@ var Q = require('q');
|
||||
var Immutable = require('immutable');
|
||||
|
||||
// Debugging for long stack traces
|
||||
if (global.__DEV__ || process.env.DEBUG) {
|
||||
if (process.env.DEBUG || process.env.CI) {
|
||||
Q.longStackSupport = true;
|
||||
}
|
||||
|
||||
/**
|
||||
Reduce an array to a promise
|
||||
|
||||
@param {Array|List} arr
|
||||
@param {Function(value, element, index)}
|
||||
@return {Promise<Mixed>}
|
||||
*/
|
||||
* Reduce an array to a promise
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)}
|
||||
* @return {Promise<Mixed>}
|
||||
*/
|
||||
function reduce(arr, iter, base) {
|
||||
arr = Immutable.Iterable.isIterable(arr)? arr : Immutable.List(arr);
|
||||
|
||||
return arr.reduce(function(prev, elem, key) {
|
||||
return prev.then(function(val) {
|
||||
return prev
|
||||
.then(function(val) {
|
||||
return iter(val, elem, key);
|
||||
});
|
||||
}, Q(base));
|
||||
}
|
||||
|
||||
/**
|
||||
Iterate over an array using an async iter
|
||||
|
||||
@param {Array|List} arr
|
||||
@param {Function(value, element, index)}
|
||||
@return {Promise}
|
||||
*/
|
||||
* Iterate over an array using an async iter
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)}
|
||||
* @return {Promise}
|
||||
*/
|
||||
function forEach(arr, iter) {
|
||||
return reduce(arr, function(val, el, key) {
|
||||
return iter(el, key);
|
||||
@@ -37,12 +38,12 @@ function forEach(arr, iter) {
|
||||
}
|
||||
|
||||
/**
|
||||
Transform an array
|
||||
|
||||
@param {Array|List} arr
|
||||
@param {Function(value, element, index)}
|
||||
@return {Promise}
|
||||
*/
|
||||
* Transform an array
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)}
|
||||
* @return {Promise}
|
||||
*/
|
||||
function serie(arr, iter, base) {
|
||||
return reduce(arr, function(before, item, key) {
|
||||
return Q(iter(item, key))
|
||||
@@ -54,12 +55,12 @@ function serie(arr, iter, base) {
|
||||
}
|
||||
|
||||
/**
|
||||
Iter over an array and return first result (not null)
|
||||
|
||||
@param {Array|List} arr
|
||||
@param {Function(element, index)}
|
||||
@return {Promise<Mixed>}
|
||||
*/
|
||||
* Iter over an array and return first result (not null)
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(element, index)}
|
||||
* @return {Promise<Mixed>}
|
||||
*/
|
||||
function some(arr, iter) {
|
||||
arr = Immutable.List(arr);
|
||||
|
||||
@@ -73,12 +74,12 @@ function some(arr, iter) {
|
||||
}
|
||||
|
||||
/**
|
||||
Map an array using an async (promised) iterator
|
||||
|
||||
@param {Array|List} arr
|
||||
@param {Function(element, index)}
|
||||
@return {Promise<List>}
|
||||
*/
|
||||
* Map an array using an async (promised) iterator
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(element, index)}
|
||||
* @return {Promise<List>}
|
||||
*/
|
||||
function mapAsList(arr, iter) {
|
||||
return reduce(arr, function(prev, entry, i) {
|
||||
return Q(iter(entry, i))
|
||||
@@ -90,12 +91,12 @@ function mapAsList(arr, iter) {
|
||||
}
|
||||
|
||||
/**
|
||||
Map an array or map
|
||||
|
||||
@param {Array|List|Map|OrderedMap} arr
|
||||
@param {Function(element, key)}
|
||||
@return {Promise<List|Map|OrderedMap>}
|
||||
*/
|
||||
* Map an array or map
|
||||
*
|
||||
* @param {Array|List|Map|OrderedMap} arr
|
||||
* @param {Function(element, key)}
|
||||
* @return {Promise<List|Map|OrderedMap>}
|
||||
*/
|
||||
function map(arr, iter) {
|
||||
if (Immutable.Map.isMap(arr)) {
|
||||
var type = 'Map';
|
||||
@@ -122,11 +123,11 @@ function map(arr, iter) {
|
||||
|
||||
|
||||
/**
|
||||
Wrap a function in a promise
|
||||
|
||||
@param {Function} func
|
||||
@return {Funciton}
|
||||
*/
|
||||
* Wrap a function in a promise
|
||||
*
|
||||
* @param {Function} func
|
||||
* @return {Funciton}
|
||||
*/
|
||||
function wrap(func) {
|
||||
return function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
|
||||
Reference in New Issue
Block a user