code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
function loadShould () {
// explicitly define this method as function as to have it's name to include as `ssfi`
function shouldGetter() {
if (this instanceof String || this instanceof Number) {
return new Assertion(this.constructor(this), null, shouldGetter);
} else if (this instanceof Boole... | ### .fail(actual, expected, [message], [operator])
Throw a failure.
@name fail
@param {Mixed} actual
@param {Mixed} expected
@param {String} message
@param {String} operator
@api public | loadShould | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function shouldGetter() {
if (this instanceof String || this instanceof Number) {
return new Assertion(this.constructor(this), null, shouldGetter);
} else if (this instanceof Boolean) {
return new Assertion(this == true, null, shouldGetter);
}
return new Assertion(this, null, sho... | ### .fail(actual, expected, [message], [operator])
Throw a failure.
@name fail
@param {Mixed} actual
@param {Mixed} expected
@param {String} message
@param {String} operator
@api public | shouldGetter | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function shouldSetter(value) {
// See https://github.com/chaijs/chai/issues/86: this makes
// `whatever.should = someValue` actually set `someValue`, which is
// especially useful for `global.should = require('chai').should()`.
//
// Note that we have to use [[DefineProperty]] instead of [... | ### .fail(actual, expected, [message], [operator])
Throw a failure.
@name fail
@param {Mixed} actual
@param {Mixed} expected
@param {String} message
@param {String} operator
@api public | shouldSetter | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
assert = function assert() {
var old_ssfi = flag(this, 'ssfi');
if (old_ssfi && config.includeStack === false)
flag(this, 'ssfi', assert);
var result = chainableBehavior.method.apply(this, arguments);
return result === undefined ? this : result;
} | ### addChainableMethod (ctx, name, method, chainingBehavior)
Adds a method to an object, such that the method can also be chained.
utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
var obj = utils.flag(this, 'object');
new chai.Assertion(obj).to.be.equal(str);
});
Can als... | assert | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function parsePath (path) {
var str = path.replace(/\[/g, '.[')
, parts = str.match(/(\\\.|[^.]+?)+/g);
return parts.map(function (value) {
var re = /\[(\d+)\]$/
, mArr = re.exec(value);
if (mArr) return { i: parseFloat(mArr[1]) };
else return { p: value };
});
} | ### .getPathInfo(path, object)
This allows the retrieval of property info in an
object given a string path.
The path info consists of an object with the
following properties:
* parent - The parent object of the property referenced by `path`
* name - The name of the final property, a number if it was an array indexer... | parsePath | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function _getPathValue (parsed, obj, index) {
var tmp = obj
, res;
index = (index === undefined ? parsed.length : index);
for (var i = 0, l = index; i < l; i++) {
var part = parsed[i];
if (tmp) {
if ('undefined' !== typeof part.p)
tmp = tmp[part.p];
else if ('undefined' !== typeo... | ### .getPathInfo(path, object)
This allows the retrieval of property info in an
object given a string path.
The path info consists of an object with the
following properties:
* parent - The parent object of the property referenced by `path`
* name - The name of the final property, a number if it was an array indexer... | _getPathValue | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function addProperty(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
} | ### .getProperties(object)
This allows the retrieval of property names of an object, enumerable or not,
inherited or not.
@param {Object} object
@returns {Array}
@name getProperties
@api public | addProperty | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function inspect(obj, showHidden, depth, colors) {
var ctx = {
showHidden: showHidden,
seen: [],
stylize: function (str) { return str; }
};
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | inspect | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
isDOMElement = function (object) {
if (typeof HTMLElement === 'object') {
return object instanceof HTMLElement;
} else {
return object &&
typeof object === 'object' &&
object.nodeType === 1 &&
typeof object.nodeName === 'string';
}
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | isDOMElement | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function formatValue(ctx, value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (value && typeof value.inspect === 'function' &&
// Filter out the util module, it's inspect function is special
value.inspect !==... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | formatValue | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function formatPrimitive(ctx, value) {
switch (typeof value) {
case 'undefined':
return ctx.stylize('undefined', 'undefined');
case 'string':
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
.replace(/'/g, "\\'")
... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | formatPrimitive | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function formatError(value) {
return '[' + Error.prototype.toString.call(value) + ']';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | formatError | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];
for (var i = 0, l = value.length; i < l; ++i) {
if (Object.prototype.hasOwnProperty.call(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
} else {
... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | formatArray | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
var name, str;
if (value.__lookupGetter__) {
if (value.__lookupGetter__(key)) {
if (value.__lookupSetter__(key)) {
str = ctx.stylize('[Getter/Setter]', 'special');
} else {
str = ctx.stylize('[Getter]', 'spe... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | formatProperty | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function reduceToSingleString(output, base, braces) {
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if (cur.indexOf('\n') >= 0) numLinesEst++;
return prev + cur.length + 1;
}, 0);
if (length > 60) {
return braces[0] +
(base === '' ? '' : base + ... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | reduceToSingleString | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function isArray(ar) {
return Array.isArray(ar) ||
(typeof ar === 'object' && objectToString(ar) === '[object Array]');
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | isArray | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function isRegExp(re) {
return typeof re === 'object' && objectToString(re) === '[object RegExp]';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | isRegExp | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function isDate(d) {
return typeof d === 'object' && objectToString(d) === '[object Date]';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | isDate | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function isError(e) {
return typeof e === 'object' && objectToString(e) === '[object Error]';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | isError | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function objectToString(o) {
return Object.prototype.toString.call(o);
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Boolean} showHidden Flag that shows hidden (not enumerable)
properties of objects.
@param {Number} depth Depth in which to descend in object. Default is 2.... | objectToString | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function all(promises) {
/*jshint validthis:true */
var Promise = this;
if (!isArray(promises)) {
throw new TypeError('You must pass an array to all.');
}
return new Promise(function(resolve, reject) {
var results = [], remaining = promises.length,
promise;
... | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | all | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function resolver(index) {
return function(value) {
resolveAll(index, value);
};
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | resolver | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function resolveAll(index, value) {
results[index] = value;
if (--remaining === 0) {
resolve(results);
}
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | resolveAll | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function useNextTick() {
return function() {
process.nextTick(flush);
};
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | useNextTick | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function useMutationObserver() {
var iterations = 0;
var observer = new BrowserMutationObserver(flush);
var node = document.createTextNode('');
observer.observe(node, { characterData: true });
return function() {
node.data = (iterations = ++iterations % 2);
};
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | useMutationObserver | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function useSetTimeout() {
return function() {
local.setTimeout(flush, 1);
};
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | useSetTimeout | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function flush() {
for (var i = 0; i < queue.length; i++) {
var tuple = queue[i];
var callback = tuple[0], arg = tuple[1];
callback(arg);
}
queue = [];
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | flush | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function asap(callback, arg) {
var length = queue.push([callback, arg]);
if (length === 1) {
// If length is 1, that means that we need to schedule an async flush.
// If additional callbacks are queued before the queue is flushed, they
// will be processed by this flush that we are s... | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | asap | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function configure(name, value) {
if (arguments.length === 2) {
config[name] = value;
} else {
return config[name];
}
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | configure | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function polyfill() {
var local;
if (typeof global !== 'undefined') {
local = global;
} else if (typeof window !== 'undefined' && window.document) {
local = window;
} else {
local = self;
}
var es6PromiseSupport =
"Promise" in local &&
// So... | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | polyfill | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function Promise(resolver) {
if (!isFunction(resolver)) {
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
}
if (!(this instanceof Promise)) {
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, t... | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | Promise | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function invokeResolver(resolver, promise) {
function resolvePromise(value) {
resolve(promise, value);
}
function rejectPromise(reason) {
reject(promise, reason);
}
try {
resolver(resolvePromise, rejectPromise);
} catch(e) {
rejectPromise(e);
}... | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | invokeResolver | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function resolvePromise(value) {
resolve(promise, value);
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | resolvePromise | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function rejectPromise(reason) {
reject(promise, reason);
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | rejectPromise | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function invokeCallback(settled, promise, callback, detail) {
var hasCallback = isFunction(callback),
value, error, succeeded, failed;
if (hasCallback) {
try {
value = callback(detail);
succeeded = true;
} catch(e) {
failed = true;
error = e... | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | invokeCallback | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function subscribe(parent, child, onFulfillment, onRejection) {
var subscribers = parent._subscribers;
var length = subscribers.length;
subscribers[length] = child;
subscribers[length + FULFILLED] = onFulfillment;
subscribers[length + REJECTED] = onRejection;
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | subscribe | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function publish(promise, settled) {
var child, callback, subscribers = promise._subscribers, detail = promise._detail;
for (var i = 0; i < subscribers.length; i += 3) {
child = subscribers[i];
callback = subscribers[i + settled];
invokeCallback(settled, child, callback, detail);
... | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | publish | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function handleThenable(promise, value) {
var then = null,
resolved;
try {
if (promise === value) {
throw new TypeError("A promises callback cannot return that same promise.");
}
if (objectOrFunction(value)) {
then = value.then;
if (isFunction(t... | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | handleThenable | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function resolve(promise, value) {
if (promise === value) {
fulfill(promise, value);
} else if (!handleThenable(promise, value)) {
fulfill(promise, value);
}
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | resolve | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function fulfill(promise, value) {
if (promise._state !== PENDING) { return; }
promise._state = SEALED;
promise._detail = value;
config.async(publishFulfillment, promise);
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | fulfill | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function reject(promise, reason) {
if (promise._state !== PENDING) { return; }
promise._state = SEALED;
promise._detail = reason;
config.async(publishRejection, promise);
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | reject | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function publishFulfillment(promise) {
publish(promise, promise._state = FULFILLED);
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | publishFulfillment | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function publishRejection(promise) {
publish(promise, promise._state = REJECTED);
} | Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The return promise
is fulfilled with an array that gives all the values in the order they were
passed in the `promises` array argument.
Example:
```javascript
... | publishRejection | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function race(promises) {
/*jshint validthis:true */
var Promise = this;
if (!isArray(promises)) {
throw new TypeError('You must pass an array to race.');
}
return new Promise(function(resolve, reject) {
var results = [], promise;
for (var i = 0; i < promises.leng... | `RSVP.race` allows you to watch a series of promises and act as soon as the
first promise given to the `promises` argument fulfills or rejects.
Example:
```javascript
var promise1 = new RSVP.Promise(function(resolve, reject){
setTimeout(function(){
resolve("promise 1");
... | race | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function reject(reason) {
/*jshint validthis:true */
var Promise = this;
return new Promise(function (resolve, reject) {
reject(reason);
});
} | `RSVP.reject` returns a promise that will become rejected with the passed
`reason`. `RSVP.reject` is essentially shorthand for the following:
```javascript
var promise = new RSVP.Promise(function(resolve, reject){
reject(new Error('WHOOPS'));
});
promise.then(function(value){
... | reject | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function resolve(value) {
/*jshint validthis:true */
if (value && typeof value === 'object' && value.constructor === this) {
return value;
}
var Promise = this;
return new Promise(function(resolve) {
resolve(value);
});
} | `RSVP.reject` returns a promise that will become rejected with the passed
`reason`. `RSVP.reject` is essentially shorthand for the following:
```javascript
var promise = new RSVP.Promise(function(resolve, reject){
reject(new Error('WHOOPS'));
});
promise.then(function(value){
... | resolve | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function objectOrFunction(x) {
return isFunction(x) || (typeof x === "object" && x !== null);
} | `RSVP.reject` returns a promise that will become rejected with the passed
`reason`. `RSVP.reject` is essentially shorthand for the following:
```javascript
var promise = new RSVP.Promise(function(resolve, reject){
reject(new Error('WHOOPS'));
});
promise.then(function(value){
... | objectOrFunction | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function isFunction(x) {
return typeof x === "function";
} | `RSVP.reject` returns a promise that will become rejected with the passed
`reason`. `RSVP.reject` is essentially shorthand for the following:
```javascript
var promise = new RSVP.Promise(function(resolve, reject){
reject(new Error('WHOOPS'));
});
promise.then(function(value){
... | isFunction | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function isArray(x) {
return Object.prototype.toString.call(x) === "[object Array]";
} | `RSVP.reject` returns a promise that will become rejected with the passed
`reason`. `RSVP.reject` is essentially shorthand for the following:
```javascript
var promise = new RSVP.Promise(function(resolve, reject){
reject(new Error('WHOOPS'));
});
promise.then(function(value){
... | isArray | javascript | louischatriot/nedb | browser-version/test/localforage.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/localforage.js | MIT |
function isArray(obj) {
return '[object Array]' == {}.toString.call(obj);
} | Check if `obj` is an array. | isArray | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function Hook(title, fn) {
Runnable.call(this, title, fn);
this.type = 'hook';
} | Initialize a new `Hook` with the given `title` and callback `fn`.
@param {String} title
@param {Function} fn
@api private | Hook | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function visit(obj) {
var suite;
for (var key in obj) {
if ('function' == typeof obj[key]) {
var fn = obj[key];
switch (key) {
case 'before':
suites[0].beforeAll(fn);
break;
case 'after':
suites[0].afterAll(fn);
break;
... | TDD-style interface:
exports.Array = {
'#indexOf()': {
'should return -1 when the value is not present': function(){
},
'should return the correct index when the value is present': function(){
}
}
}; | visit | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function image(name) {
return __dirname + '/../images/' + name + '.png';
} | Return image `name` path.
@param {String} name
@return {String}
@api private | image | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function Mocha(options) {
options = options || {};
this.files = [];
this.options = options;
this.grep(options.grep);
this.suite = new exports.Suite('', new exports.Context);
this.ui(options.ui);
this.reporter(options.reporter);
if (options.timeout) this.timeout(options.timeout);
if (options.slow) this... | Setup mocha with `options`.
Options:
- `ui` name "bdd", "tdd", "exports" etc
- `reporter` reporter instance, defaults to `mocha.reporters.Dot`
- `globals` array of accepted globals
- `timeout` timeout in milliseconds
- `slow` milliseconds to wait before considering a test slow
- `ignoreLeaks` ignore globa... | Mocha | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function parse(str) {
var m = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(str);
if (!m) return;
var n = parseFloat(m[1]);
var type = (m[2] || 'ms').toLowerCase();
switch (type) {
case 'years':
case 'year':
case 'y':
return n * 31557600000;
case 'days... | Parse the given `str` and return milliseconds.
@param {String} str
@return {Number}
@api private | parse | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function format(ms) {
if (ms == d) return (ms / d) + ' day';
if (ms > d) return (ms / d) + ' days';
if (ms == h) return (ms / h) + ' hour';
if (ms > h) return (ms / h) + ' hours';
if (ms == m) return (ms / m) + ' minute';
if (ms > m) return (ms / m) + ' minutes';
if (ms == s) return (ms / s) + ' second';
... | Format the given `ms`.
@param {Number} ms
@return {String}
@api public | format | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function Base(runner) {
var self = this
, stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 }
, failures = this.failures = [];
if (!runner) return;
this.runner = runner;
runner.on('start', function(){
stats.start = new Date;
});
runner.on('suite', function(suite){... | Initialize a new `Base` reporter.
All other reporters generally
inherit from this reporter, providing
stats such as test duration, number
of tests passed / failed etc.
@param {Runner} runner
@api public | Base | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function pluralize(n) {
return 1 == n ? 'test' : 'tests';
} | Output common epilogue used by many of
the bundled reporters.
@api public | pluralize | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function pad(str, len) {
str = String(str);
return Array(len - str.length + 1).join(' ') + str;
} | Pad the given `str` to `len`.
@param {String} str
@param {String} len
@return {String}
@api private | pad | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function errorDiff(err, type) {
return diff['diff' + type](err.actual, err.expected).map(function(str){
str.value = str.value
.replace(/\t/g, '<tab>')
.replace(/\r/g, '<CR>')
.replace(/\n/g, '<LF>\n');
if (str.added) return colorLines('diff added', str.value);
if (str.removed) return col... | Return a character diff for `err`.
@param {Error} err
@return {String}
@api private | errorDiff | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function colorLines(name, str) {
return str.split('\n').map(function(str){
return color(name, str);
}).join('\n');
} | Color lines for `str`, using the color `name`.
@param {String} name
@param {String} str
@return {String}
@api private | colorLines | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function Doc(runner) {
Base.call(this, runner);
var self = this
, stats = this.stats
, total = runner.total
, indents = 2;
function indent() {
return Array(indents).join(' ');
}
runner.on('suite', function(suite){
if (suite.root) return;
++indents;
console.log('%s<section class... | Initialize a new `Doc` reporter.
@param {Runner} runner
@api public | Doc | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function indent() {
return Array(indents).join(' ');
} | Initialize a new `Doc` reporter.
@param {Runner} runner
@api public | indent | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function HTMLCov(runner) {
var jade = require('jade')
, file = __dirname + '/templates/coverage.jade'
, str = fs.readFileSync(file, 'utf8')
, fn = jade.compile(str, { filename: file })
, self = this;
JSONCov.call(this, runner, false);
runner.on('end', function(){
process.stdout.write(fn({
... | Initialize a new `JsCoverage` reporter.
@param {Runner} runner
@api public | HTMLCov | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function coverageClass(n) {
if (n >= 75) return 'high';
if (n >= 50) return 'medium';
if (n >= 25) return 'low';
return 'terrible';
} | Return coverage class for `n`.
@return {String}
@api private | coverageClass | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function HTML(runner, root) {
Base.call(this, runner);
var self = this
, stats = this.stats
, total = runner.total
, stat = fragment(statsTemplate)
, items = stat.getElementsByTagName('li')
, passes = items[1].getElementsByTagName('em')[0]
, passesLink = items[1].getElementsByTagName('a')[0... | Initialize a new `Doc` reporter.
@param {Runner} runner
@api public | HTML | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function on(el, event, fn) {
if (el.addEventListener) {
el.addEventListener(event, fn, false);
} else {
el.attachEvent('on' + event, fn);
}
} | Listen on `event` with callback `fn`. | on | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function JSONCov(runner, output) {
var self = this
, output = 1 == arguments.length ? true : output;
Base.call(this, runner);
var tests = []
, failures = []
, passes = [];
runner.on('test end', function(test){
tests.push(test);
});
runner.on('pass', function(test){
passes.push(test);... | Initialize a new `JsCoverage` reporter.
@param {Runner} runner
@param {Boolean} output
@api public | JSONCov | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function map(cov) {
var ret = {
instrumentation: 'node-jscoverage'
, sloc: 0
, hits: 0
, misses: 0
, coverage: 0
, files: []
};
for (var filename in cov) {
var data = coverage(filename, cov[filename]);
ret.files.push(data);
ret.hits += data.hits;
ret.misses += data.misse... | Map jscoverage data to a JSON structure
suitable for reporting.
@param {Object} cov
@return {Object}
@api private | map | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function coverage(filename, data) {
var ret = {
filename: filename,
coverage: 0,
hits: 0,
misses: 0,
sloc: 0,
source: {}
};
data.source.forEach(function(line, num){
num++;
if (data[num] === 0) {
ret.misses++;
ret.sloc++;
} else if (data[num] !== undefined) {
... | Map jscoverage data for a single source file
to a JSON structure suitable for reporting.
@param {String} filename name of the source file
@param {Object} data jscoverage coverage data
@return {Object}
@api private | coverage | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function clean(test) {
return {
title: test.title
, fullTitle: test.fullTitle()
, duration: test.duration
}
} | Return a plain-object representation of `test`
free of cyclic properties etc.
@param {Object} test
@return {Object}
@api private | clean | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function List(runner) {
Base.call(this, runner);
var self = this
, stats = this.stats
, total = runner.total;
runner.on('start', function(){
console.log(JSON.stringify(['start', { total: total }]));
});
runner.on('pass', function(test){
console.log(JSON.stringify(['pass', clean(test)]));
... | Initialize a new `List` test reporter.
@param {Runner} runner
@api public | List | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function clean(test) {
return {
title: test.title
, fullTitle: test.fullTitle()
, duration: test.duration
}
} | Return a plain-object representation of `test`
free of cyclic properties etc.
@param {Object} test
@return {Object}
@api private | clean | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function JSONReporter(runner) {
var self = this;
Base.call(this, runner);
var tests = []
, failures = []
, passes = [];
runner.on('test end', function(test){
tests.push(test);
});
runner.on('pass', function(test){
passes.push(test);
});
runner.on('fail', function(test){
failures.... | Initialize a new `JSON` reporter.
@param {Runner} runner
@api public | JSONReporter | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function clean(test) {
return {
title: test.title
, fullTitle: test.fullTitle()
, duration: test.duration
}
} | Return a plain-object representation of `test`
free of cyclic properties etc.
@param {Object} test
@return {Object}
@api private | clean | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function runway() {
var buf = Array(width).join('-');
return ' ' + color('runway', buf);
} | Initialize a new `Landing` reporter.
@param {Runner} runner
@api public | runway | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function Markdown(runner) {
Base.call(this, runner);
var self = this
, stats = this.stats
, total = runner.total
, level = 0
, buf = '';
function title(str) {
return Array(level).join('#') + ' ' + str;
}
function indent() {
return Array(level).join(' ');
}
function mapTOC(suit... | Initialize a new `Markdown` reporter.
@param {Runner} runner
@api public | Markdown | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function title(str) {
return Array(level).join('#') + ' ' + str;
} | Initialize a new `Markdown` reporter.
@param {Runner} runner
@api public | title | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function indent() {
return Array(level).join(' ');
} | Initialize a new `Markdown` reporter.
@param {Runner} runner
@api public | indent | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function mapTOC(suite, obj) {
var ret = obj;
obj = obj[suite.title] = obj[suite.title] || { suite: suite };
suite.suites.forEach(function(suite){
mapTOC(suite, obj);
});
return ret;
} | Initialize a new `Markdown` reporter.
@param {Runner} runner
@api public | mapTOC | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function stringifyTOC(obj, level) {
++level;
var buf = '';
var link;
for (var key in obj) {
if ('suite' == key) continue;
if (key) link = ' - [' + key + '](#' + utils.slug(obj[key].suite.fullTitle()) + ')\n';
if (key) buf += Array(level).join(' ') + link;
buf += stringifyTOC(obj... | Initialize a new `Markdown` reporter.
@param {Runner} runner
@api public | stringifyTOC | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function generateTOC(suite) {
var obj = mapTOC(suite, {});
return stringifyTOC(obj, 0);
} | Initialize a new `Markdown` reporter.
@param {Runner} runner
@api public | generateTOC | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function Min(runner) {
Base.call(this, runner);
runner.on('start', function(){
// clear screen
process.stdout.write('\u001b[2J');
// set cursor position
process.stdout.write('\u001b[1;3H');
});
runner.on('end', this.epilogue.bind(this));
} | Initialize a new `Min` minimal test reporter (best used with --watch).
@param {Runner} runner
@api public | Min | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function NyanCat(runner) {
Base.call(this, runner);
var self = this
, stats = this.stats
, width = Base.window.width * .75 | 0
, rainbowColors = this.rainbowColors = self.generateColors()
, colorIndex = this.colorIndex = 0
, numerOfLines = this.numberOfLines = 4
, trajectories = this.trajec... | Initialize a new `Dot` matrix test reporter.
@param {Runner} runner
@api public | NyanCat | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function draw(color, n) {
write(' ');
write('\u001b[' + color + 'm' + n + '\u001b[0m');
write('\n');
} | Draw the "scoreboard" showing the number
of passes, failures and pending tests.
@api private | draw | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function indent() {
return Array(indents).join(' ')
} | Initialize a new `Spec` test reporter.
@param {Runner} runner
@api public | indent | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function TAP(runner) {
Base.call(this, runner);
var self = this
, stats = this.stats
, n = 1;
runner.on('start', function(){
var total = runner.grepTotal(runner.suite);
console.log('%d..%d', 1, total);
});
runner.on('test end', function(){
++n;
});
runner.on('pending', function(tes... | Initialize a new `TAP` reporter.
@param {Runner} runner
@api public | TAP | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function title(test) {
return test.fullTitle().replace(/#/g, '');
} | Return a TAP-safe title of `test`
@param {Object} test
@return {String}
@api private | title | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function Teamcity(runner) {
Base.call(this, runner);
var stats = this.stats;
runner.on('start', function() {
console.log("##teamcity[testSuiteStarted name='mocha.suite']");
});
runner.on('test', function(test) {
console.log("##teamcity[testStarted name='" + escape(test.fullTitle()) + "']");
});
... | Initialize a new `Teamcity` reporter.
@param {Runner} runner
@api public | Teamcity | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function XUnit(runner) {
Base.call(this, runner);
var stats = this.stats
, tests = []
, self = this;
runner.on('pass', function(test){
tests.push(test);
});
runner.on('fail', function(test){
tests.push(test);
});
runner.on('end', function(){
console.log(tag('testsuite', {
... | Initialize a new `XUnit` reporter.
@param {Runner} runner
@api public | XUnit | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function test(test) {
var attrs = {
classname: test.parent.fullTitle()
, name: test.title
, time: test.duration / 1000
};
if ('failed' == test.state) {
var err = test.err;
attrs.message = escape(err.message);
console.log(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(e... | Output tag for the given `test.` | test | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function Runnable(title, fn) {
this.title = title;
this.fn = fn;
this.async = fn && fn.length;
this.sync = ! this.async;
this._timeout = 2000;
this._slow = 75;
this.timedOut = false;
} | Initialize a new `Runnable` with the given `title` and callback `fn`.
@param {String} title
@param {Function} fn
@api private | Runnable | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function multiple(err) {
if (emitted) return;
emitted = true;
self.emit('error', err || new Error('done() called multiple times'));
} | Run the test and invoke `fn(err)`.
@param {Function} fn
@api private | multiple | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function done(err) {
if (self.timedOut) return;
if (finished) return multiple(err);
self.clearTimeout();
self.duration = new Date - start;
finished = true;
fn(err);
} | Run the test and invoke `fn(err)`.
@param {Function} fn
@api private | done | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function Runner(suite) {
var self = this;
this._globals = [];
this.suite = suite;
this.total = suite.total();
this.failures = 0;
this.on('test end', function(test){ self.checkGlobals(test); });
this.on('hook end', function(hook){ self.checkGlobals(hook); });
this.grep(/.*/);
this.globals(utils.keys(gl... | Initialize a `Runner` for the given `suite`.
Events:
- `start` execution started
- `end` execution complete
- `suite` (suite) test suite execution started
- `suite end` (suite) all tests (and sub-suites) have finished
- `test` (test) test execution started
- `test end` (test) test completed
- `hoo... | Runner | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function next(i) {
var hook = hooks[i];
if (!hook) return fn();
self.currentRunnable = hook;
self.emit('hook', hook);
hook.on('error', function(err){
self.failHook(hook, err);
});
hook.run(function(err){
hook.removeAllListeners('error');
var testError = hook.error();
... | Run hook `name` callbacks and then invoke `fn()`.
@param {String} name
@param {Function} function
@api private | next | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function next(suite) {
self.suite = suite;
if (!suite) {
self.suite = orig;
return fn();
}
self.hook(name, function(err){
if (err) {
self.suite = orig;
return fn(err);
}
next(suites.pop());
});
} | Run hook `name` for the given array of `suites`
in order, and callback `fn(err)`.
@param {String} name
@param {Array} suites
@param {Function} fn
@api private | next | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function next(err) {
// if we bail after first err
if (self.failures && suite._bail) return fn();
// next test
test = tests.shift();
// all done
if (!test) return fn();
// grep
var match = self._grep.test(test.fullTitle());
if (self._invert) match = !match;
if (!match) return ... | Run tests in the given `suite` and invoke
the callback `fn()` when complete.
@param {Suite} suite
@param {Function} fn
@api private | next | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function next() {
var curr = suite.suites[i++];
if (!curr) return done();
self.runSuite(curr, next);
} | Run the given `suite` and invoke the
callback `fn()` when complete.
@param {Suite} suite
@param {Function} fn
@api private | next | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
function done() {
self.suite = suite;
self.hook('afterAll', function(){
self.emit('suite end', suite);
fn();
});
} | Run the given `suite` and invoke the
callback `fn()` when complete.
@param {Suite} suite
@param {Function} fn
@api private | done | javascript | louischatriot/nedb | browser-version/test/mocha.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/mocha.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.