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 |
|---|---|---|---|---|---|---|---|
doParallelLimit = function(limit, fn) {
return function () {
var args = Array.prototype.slice.call(arguments);
return fn.apply(null, [_eachLimit(limit)].concat(args));
};
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | doParallelLimit | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
doSeries = function (fn) {
return function () {
var args = Array.prototype.slice.call(arguments);
return fn.apply(null, [async.eachSeries].concat(args));
};
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | doSeries | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
_asyncMap = function (eachfn, arr, iterator, callback) {
var results = [];
arr = _map(arr, function (x, i) {
return {index: i, value: x};
});
eachfn(arr, function (x, callback) {
iterator(x.value, function (err, v) {
results[x.index] = v;
... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | _asyncMap | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
_mapLimit = function(limit) {
return doParallelLimit(limit, _asyncMap);
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | _mapLimit | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
_filter = function (eachfn, arr, iterator, callback) {
var results = [];
arr = _map(arr, function (x, i) {
return {index: i, value: x};
});
eachfn(arr, function (x, callback) {
iterator(x.value, function (v) {
if (v) {
results.p... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | _filter | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
_reject = function (eachfn, arr, iterator, callback) {
var results = [];
arr = _map(arr, function (x, i) {
return {index: i, value: x};
});
eachfn(arr, function (x, callback) {
iterator(x.value, function (v) {
if (!v) {
results.... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | _reject | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
_detect = function (eachfn, arr, iterator, main_callback) {
eachfn(arr, function (x, callback) {
iterator(x, function (result) {
if (result) {
main_callback(x);
main_callback = function () {};
}
else {
... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | _detect | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
fn = function (left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0;
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | fn | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
removeListener = function (fn) {
for (var i = 0; i < listeners.length; i += 1) {
if (listeners[i] === fn) {
listeners.splice(i, 1);
return;
}
}
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | removeListener | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
taskComplete = function () {
_each(listeners.slice(0), function (fn) {
fn();
});
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | taskComplete | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
taskCallback = function (err) {
var args = Array.prototype.slice.call(arguments, 1);
if (args.length <= 1) {
args = args[0];
}
if (err) {
var safeResults = {};
_each(_keys(results), function(rkey)... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | taskCallback | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
ready = function () {
return _reduce(requires, function (a, x) {
return (a && results.hasOwnProperty(x));
}, true) && !results.hasOwnProperty(k);
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | ready | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
listener = function () {
if (ready()) {
removeListener(listener);
task[task.length - 1](taskCallback, results);
}
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | listener | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
wrapIterator = function (iterator) {
return function (err) {
if (err) {
callback.apply(null, arguments);
callback = function () {};
}
else {
var args = Array.prototype.slice.call(arguments, 1);
... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | wrapIterator | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
_parallel = function(eachfn, tasks, callback) {
callback = callback || function () {};
if (tasks.constructor === Array) {
eachfn.map(tasks, function (fn, callback) {
if (fn) {
fn(function (err) {
var args = Array.prototype.slice.cal... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | _parallel | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
makeCallback = function (index) {
var fn = function () {
if (tasks.length) {
tasks[index].apply(null, arguments);
}
return fn.next();
};
fn.next = function () {
return (index < tasks.length - 1) ? mak... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | makeCallback | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
fn = function () {
if (tasks.length) {
tasks[index].apply(null, arguments);
}
return fn.next();
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | fn | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
_concat = function (eachfn, arr, fn, callback) {
var r = [];
eachfn(arr, function (x, cb) {
fn(x, function (err, y) {
r = r.concat(y || []);
cb(err);
});
}, function (err) {
callback(err, r);
});
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | _concat | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function _insert(q, data, pos, callback) {
if(data.constructor !== Array) {
data = [data];
}
_each(data, function(task) {
var item = {
data: task,
callback: typeof callback === 'function' ? callback : null
};
... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | _insert | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
next = function () {
workers -= 1;
if (task.callback) {
task.callback.apply(task, arguments);
}
if (q.drain && q.tasks.length + workers === 0) {
q.drain();
... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | next | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
_console_fn = function (name) {
return function (fn) {
var args = Array.prototype.slice.call(arguments, 1);
fn.apply(null, args.concat([function (err) {
var args = Array.prototype.slice.call(arguments, 1);
if (typeof console !== 'undefined') {
... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | _console_fn | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
memoized = function () {
var args = Array.prototype.slice.call(arguments);
var callback = args.pop();
var key = hasher.apply(null, args);
if (key in memo) {
callback.apply(null, memo[key]);
}
else if (key in queues) {
... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | memoized | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
_applyEach = function (eachfn, fns /*args...*/) {
var go = function () {
var that = this;
var args = Array.prototype.slice.call(arguments);
var callback = args.pop();
return eachfn(fns, function (fn, cb) {
fn.apply(that, args.concat([cb]));
... | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | _applyEach | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
go = function () {
var that = this;
var args = Array.prototype.slice.call(arguments);
var callback = args.pop();
return eachfn(fns, function (fn, cb) {
fn.apply(that, args.concat([cb]));
},
callback);
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | go | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function next(err) {
if (err) {
if (callback) {
return callback(err);
}
throw err;
}
fn(next);
} | Way data is stored for this database
For a Node.js/Node Webkit database it's the file system
For a browser-side database it's localforage, which uses the best backend available (IndexedDB then WebSQL then localStorage)
This version is the browser version | next | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function AVLTree (options) {
this.tree = new _AVLTree(options);
} | Constructor
We can't use a direct pointer to the root node (as in the simple binary search tree)
as the root will change during tree rotations
@param {Boolean} options.unique Whether to enforce a 'unique' constraint on the key or not
@param {Function} options.compareKeys Initialize this BST's compareKeys | AVLTree | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function _AVLTree (options) {
options = options || {};
this.left = null;
this.right = null;
this.parent = options.parent !== undefined ? options.parent : null;
if (options.hasOwnProperty('key')) { this.key = options.key; }
this.data = options.hasOwnProperty('value') ? [options.value] : [];
this.unique = ... | Constructor of the internal AVLTree
@param {Object} options Optional
@param {Boolean} options.unique Whether to enforce a 'unique' constraint on the key or not
@param {Key} options.key Initialize this BST's key with key
@param {Value} options.value Initialize this BST's data with [value]
@param {Function} opti... | _AVLTree | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function BinarySearchTree (options) {
options = options || {};
this.left = null;
this.right = null;
this.parent = options.parent !== undefined ? options.parent : null;
if (options.hasOwnProperty('key')) { this.key = options.key; }
this.data = options.hasOwnProperty('value') ? [options.value] : [];
this.u... | Constructor
@param {Object} options Optional
@param {Boolean} options.unique Whether to enforce a 'unique' constraint on the key or not
@param {Key} options.key Initialize this BST's key with key
@param {Value} options.value Initialize this BST's data with [value]
@param {Function} options.compareKeys Initiali... | BinarySearchTree | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function append (array, toAppend) {
var i;
for (i = 0; i < toAppend.length; i += 1) {
array.push(toAppend[i]);
}
} | Return a function that tells whether a given key matches an upper bound | append | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function getRandomArray (n) {
var res, next;
if (n === 0) { return []; }
if (n === 1) { return [0]; }
res = getRandomArray(n - 1);
next = Math.floor(Math.random() * n);
res.splice(next, 0, n - 1); // Add n-1 at a random position in the array
return res;
} | Return an array with the numbers from 0 to n-1, in a random order | getRandomArray | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function defaultCompareKeysFunction (a, b) {
if (a < b) { return -1; }
if (a > b) { return 1; }
if (a === b) { return 0; }
var err = new Error("Couldn't compare elements");
err.a = a;
err.b = b;
throw err;
} | Return an array with the numbers from 0 to n-1, in a random order | defaultCompareKeysFunction | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function defaultCheckValueEquality (a, b) {
return a === b;
} | Check whether two values are equal (used in non-unique deletion) | defaultCheckValueEquality | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function resolve(child) {
if (child.charAt(0) !== '.') { return child; }
var parts = child.split("/");
var parentBase = name.split("/").slice(0, -1);
for (var i=0, l=parts.length; i<l; i++) {
var part = parts[i];
if (part === '..') { parentBase.pop(); }
else if (part ==... | Check whether two values are equal (used in non-unique deletion) | resolve | javascript | louischatriot/nedb | browser-version/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.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/out/nedb.js | https://github.com/louischatriot/nedb/blob/master/browser-version/out/nedb.js | MIT |
function require(name) {
var module = require.modules[name];
if (!module) throw new Error('failed to require "' + name + '"');
if (!('exports' in module) && typeof module.definition === 'function') {
module.client = module.component = true;
module.definition.call(this, module.exports = {}, module);
d... | Require the module at `name`.
@param {String} name
@return {Object} exports
@api public | require | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function showError(name) {
throw new Error('failed to find latest module of "' + name + '"');
} | Find and require a module which name starts with the provided name.
If multiple modules exists, the highest semver is used.
This function can only be used for remote dependencies.
@param {String} name - module name: `user~repo`
@param {Boolean} returnPath - returns the canonical require path if true,
... | showError | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function exclude () {
var excludes = [].slice.call(arguments);
function excludeProps (res, obj) {
Object.keys(obj).forEach(function (key) {
if (!~excludes.indexOf(key)) res[key] = obj[key];
});
}
return function extendExclude () {
var args = [].slice.call(arguments)
, i = 0
, res... | Define a module's exports immediately with `exports`.
@param {String} name
@param {Generic} exports
@api private | exclude | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function excludeProps (res, obj) {
Object.keys(obj).forEach(function (key) {
if (!~excludes.indexOf(key)) res[key] = obj[key];
});
} | Define a module's exports immediately with `exports`.
@param {String} name
@param {Generic} exports
@api private | excludeProps | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function AssertionError (message, _props, ssf) {
var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON')
, props = extend(_props || {});
// default values
this.message = message || 'Unspecified AssertionError';
this.showDiff = false;
// copy from properties
for (var key in props) {
... | ### AssertionError
An extension of the JavaScript `Error` constructor for
assertion and validation scenarios.
@param {String} message
@param {Object} properties to include (optional)
@param {callee} start stack function (optional) | AssertionError | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function getType (obj) {
var str = Object.prototype.toString.call(obj);
if (natives[str]) return natives[str];
if (obj === null) return 'null';
if (obj === undefined) return 'undefined';
if (obj === Object(obj)) return 'object';
return typeof obj;
} | ### typeOf (obj)
Use several different techniques to determine
the type of object being tested.
@param {Mixed} object
@return {String} object type
@api public | getType | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function Library () {
this.tests = {};
} | ### Library
Create a repository for custom type detection.
```js
var lib = new type.Library;
``` | Library | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function deepEqual(a, b, m) {
if (sameValue(a, b)) {
return true;
} else if ('date' === type(a)) {
return dateEqual(a, b);
} else if ('regexp' === type(a)) {
return regexpEqual(a, b);
} else if (Buffer.isBuffer(a)) {
return bufferEqual(a, b);
} else if ('arguments' === type(a)) {
return ar... | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | deepEqual | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function sameValue(a, b) {
if (a === b) return a !== 0 || 1 / a === 1 / b;
return a !== a && b !== b;
} | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | sameValue | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function typeEqual(a, b) {
return type(a) === type(b);
} | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | typeEqual | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function dateEqual(a, b) {
if ('date' !== type(b)) return false;
return sameValue(a.getTime(), b.getTime());
} | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | dateEqual | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function regexpEqual(a, b) {
if ('regexp' !== type(b)) return false;
return sameValue(a.toString(), b.toString());
} | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | regexpEqual | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function argumentsEqual(a, b, m) {
if ('arguments' !== type(b)) return false;
a = [].slice.call(a);
b = [].slice.call(b);
return deepEqual(a, b, m);
} | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | argumentsEqual | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function enumerable(a) {
var res = [];
for (var key in a) res.push(key);
return res;
} | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | enumerable | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function iterableEqual(a, b) {
if (a.length !== b.length) return false;
var i = 0;
var match = true;
for (; i < a.length; i++) {
if (a[i] !== b[i]) {
match = false;
break;
}
}
return match;
} | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | iterableEqual | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function bufferEqual(a, b) {
if (!Buffer.isBuffer(b)) return false;
return iterableEqual(a, b);
} | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | bufferEqual | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function isValue(a) {
return a !== null && a !== undefined;
} | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | isValue | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function objectEqual(a, b, m) {
if (!isValue(a) || !isValue(b)) {
return false;
}
if (a.prototype !== b.prototype) {
return false;
}
var i;
if (m) {
for (i = 0; i < m.length; i++) {
if ((m[i][0] === a && m[i][1] === b)
|| (m[i][0] === b && m[i][1] === a)) {
return true;
... | Assert super-strict (egal) equality between
two objects of any type.
@param {Mixed} a
@param {Mixed} b
@param {Array} memoised (optional)
@return {Boolean} equal match | objectEqual | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function Assertion (obj, msg, stack) {
flag(this, 'ssfi', stack || arguments.callee);
flag(this, 'object', obj);
flag(this, 'message', msg);
} | # .use(function)
Provides a way to extend the internals of Chai
@param {Function}
@returns {this} for chaining
@api public | Assertion | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function an (type, msg) {
if (msg) flag(this, 'message', msg);
type = type.toLowerCase();
var obj = flag(this, 'object')
, article = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(type.charAt(0)) ? 'an ' : 'a ';
this.assert(
type === _.type(obj)
, 'expected #{this} to be ' + article + type
... | ### .a(type)
The `a` and `an` assertions are aliases that can be
used either as language chains or to assert a value's
type.
// typeof
expect('test').to.be.a('string');
expect({ foo: 'bar' }).to.be.an('object');
expect(null).to.be.a('null');
expect(undefined).to.be.an('undefined');
// languag... | an | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function includeChainingBehavior () {
flag(this, 'contains', true);
} | ### .include(value)
The `include` and `contain` assertions can be used as either property
based language chains or as methods to assert the inclusion of an object
in an array or a substring in a string. When used as language chains,
they toggle the `contains` flag for the `keys` assertion.
expect([1,2,3]).to.incl... | includeChainingBehavior | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function include (val, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
var expected = false;
if (_.type(obj) === 'array' && _.type(val) === 'object') {
for (var i in obj) {
if (_.eql(obj[i], val)) {
expected = true;
break;
}
}
... | ### .include(value)
The `include` and `contain` assertions can be used as either property
based language chains or as methods to assert the inclusion of an object
in an array or a substring in a string. When used as language chains,
they toggle the `contains` flag for the `keys` assertion.
expect([1,2,3]).to.incl... | include | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function checkArguments () {
var obj = flag(this, 'object')
, type = Object.prototype.toString.call(obj);
this.assert(
'[object Arguments]' === type
, 'expected #{this} to be arguments but got ' + type
, 'expected #{this} to not be arguments'
);
} | ### .arguments
Asserts that the target is an arguments object.
function test () {
expect(arguments).to.be.arguments;
}
@name arguments
@alias Arguments
@api public | checkArguments | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertEqual (val, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
if (flag(this, 'deep')) {
return this.eql(val);
} else {
this.assert(
val === obj
, 'expected #{this} to equal #{exp}'
, 'expected #{this} to not equal #{exp}'
... | ### .equal(value)
Asserts that the target is strictly equal (`===`) to `value`.
Alternately, if the `deep` flag is set, asserts that
the target is deeply equal to `value`.
expect('hello').to.equal('hello');
expect(42).to.equal(42);
expect(1).to.not.equal(true);
expect({ foo: 'bar' }).to.not.equal({ fo... | assertEqual | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertEql(obj, msg) {
if (msg) flag(this, 'message', msg);
this.assert(
_.eql(obj, flag(this, 'object'))
, 'expected #{this} to deeply equal #{exp}'
, 'expected #{this} to not deeply equal #{exp}'
, obj
, this._obj
, true
);
} | ### .eql(value)
Asserts that the target is deeply equal to `value`.
expect({ foo: 'bar' }).to.eql({ foo: 'bar' });
expect([ 1, 2, 3 ]).to.eql([ 1, 2, 3 ]);
@name eql
@alias eqls
@param {Mixed} value
@param {String} message _optional_
@api public | assertEql | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertAbove (n, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
if (flag(this, 'doLength')) {
new Assertion(obj, msg).to.have.property('length');
var len = obj.length;
this.assert(
len > n
, 'expected #{this} to have a length above #{e... | ### .above(value)
Asserts that the target is greater than `value`.
expect(10).to.be.above(5);
Can also be used in conjunction with `length` to
assert a minimum length. The benefit being a
more informative error message than if the length
was supplied directly.
expect('foo').to.have.length.above(2);
expe... | assertAbove | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertLeast (n, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
if (flag(this, 'doLength')) {
new Assertion(obj, msg).to.have.property('length');
var len = obj.length;
this.assert(
len >= n
, 'expected #{this} to have a length at least... | ### .least(value)
Asserts that the target is greater than or equal to `value`.
expect(10).to.be.at.least(10);
Can also be used in conjunction with `length` to
assert a minimum length. The benefit being a
more informative error message than if the length
was supplied directly.
expect('foo').to.have.length.of... | assertLeast | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertBelow (n, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
if (flag(this, 'doLength')) {
new Assertion(obj, msg).to.have.property('length');
var len = obj.length;
this.assert(
len < n
, 'expected #{this} to have a length below #{e... | ### .below(value)
Asserts that the target is less than `value`.
expect(5).to.be.below(10);
Can also be used in conjunction with `length` to
assert a maximum length. The benefit being a
more informative error message than if the length
was supplied directly.
expect('foo').to.have.length.below(4);
expect(... | assertBelow | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertMost (n, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
if (flag(this, 'doLength')) {
new Assertion(obj, msg).to.have.property('length');
var len = obj.length;
this.assert(
len <= n
, 'expected #{this} to have a length at most #... | ### .most(value)
Asserts that the target is less than or equal to `value`.
expect(5).to.be.at.most(5);
Can also be used in conjunction with `length` to
assert a maximum length. The benefit being a
more informative error message than if the length
was supplied directly.
expect('foo').to.have.length.of.at.mos... | assertMost | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertInstanceOf (constructor, msg) {
if (msg) flag(this, 'message', msg);
var name = _.getName(constructor);
this.assert(
flag(this, 'object') instanceof constructor
, 'expected #{this} to be an instance of ' + name
, 'expected #{this} to not be an instance of ' + name
);
... | ### .instanceof(constructor)
Asserts that the target is an instance of `constructor`.
var Tea = function (name) { this.name = name; }
, Chai = new Tea('chai');
expect(Chai).to.be.an.instanceof(Tea);
expect([ 1, 2, 3 ]).to.be.instanceof(Array);
@name instanceof
@param {Constructor} constructor
@par... | assertInstanceOf | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertOwnProperty (name, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
this.assert(
obj.hasOwnProperty(name)
, 'expected #{this} to have own property ' + _.inspect(name)
, 'expected #{this} to not have own property ' + _.inspect(name)
);
} | ### .ownProperty(name)
Asserts that the target has an own property `name`.
expect('test').to.have.ownProperty('length');
@name ownProperty
@alias haveOwnProperty
@param {String} name
@param {String} message _optional_
@api public | assertOwnProperty | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertLengthChain () {
flag(this, 'doLength', true);
} | ### .length(value)
Asserts that the target's `length` property has
the expected value.
expect([ 1, 2, 3]).to.have.length(3);
expect('foobar').to.have.length(6);
Can also be used as a chain precursor to a value
comparison for the length property.
expect('foo').to.have.length.above(2);
expect([ 1, 2, ... | assertLengthChain | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertLength (n, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
new Assertion(obj, msg).to.have.property('length');
var len = obj.length;
this.assert(
len == n
, 'expected #{this} to have a length of #{exp} but got #{act}'
, 'expected #{this... | ### .length(value)
Asserts that the target's `length` property has
the expected value.
expect([ 1, 2, 3]).to.have.length(3);
expect('foobar').to.have.length(6);
Can also be used as a chain precursor to a value
comparison for the length property.
expect('foo').to.have.length.above(2);
expect([ 1, 2, ... | assertLength | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertKeys (keys) {
var obj = flag(this, 'object')
, str
, ok = true
, mixedArgsMsg = 'keys must be given single argument of Array|Object|String, or multiple String arguments';
switch (_.type(keys)) {
case "array":
if (arguments.length > 1) throw (new Error(mixedArgsMsg... | ### .keys(key1, [key2], [...])
Asserts that the target contains any or all of the passed-in keys.
Use in combination with `any`, `all`, `contains`, or `have` will affect
what will pass.
When used in conjunction with `any`, at least one key that is passed
in must exist in the target object. This is regardless whethe... | assertKeys | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function isSubsetOf(subset, superset, cmp) {
return subset.every(function(elem) {
if (!cmp) return superset.indexOf(elem) !== -1;
return superset.some(function(elem2) {
return cmp(elem, elem2);
});
})
} | ### .closeTo(expected, delta)
Asserts that the target is equal `expected`, to within a +/- `delta` range.
expect(1.5).to.be.closeTo(1, 0.5);
@name closeTo
@param {Number} expected
@param {Number} delta
@param {String} message _optional_
@api public | isSubsetOf | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertChanges (object, prop, msg) {
if (msg) flag(this, 'message', msg);
var fn = flag(this, 'object');
new Assertion(object, msg).to.have.property(prop);
new Assertion(fn).is.a('function');
var initial = object[prop];
fn();
this.assert(
initial !== object[prop]
, 'exp... | ### .change(function)
Asserts that a function changes an object property
var obj = { val: 10 };
var fn = function() { obj.val += 3 };
var noChangeFn = function() { return 'foo' + 'bar'; }
expect(fn).to.change(obj, 'val');
expect(noChangFn).to.not.change(obj, 'val')
@name change
@alias changes
@al... | assertChanges | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertIncreases (object, prop, msg) {
if (msg) flag(this, 'message', msg);
var fn = flag(this, 'object');
new Assertion(object, msg).to.have.property(prop);
new Assertion(fn).is.a('function');
var initial = object[prop];
fn();
this.assert(
object[prop] - initial > 0
, ... | ### .increase(function)
Asserts that a function increases an object property
var obj = { val: 10 };
var fn = function() { obj.val = 15 };
expect(fn).to.increase(obj, 'val');
@name increase
@alias increases
@alias Increase
@param {String} object
@param {String} property name
@param {String} message _optio... | assertIncreases | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
function assertDecreases (object, prop, msg) {
if (msg) flag(this, 'message', msg);
var fn = flag(this, 'object');
new Assertion(object, msg).to.have.property(prop);
new Assertion(fn).is.a('function');
var initial = object[prop];
fn();
this.assert(
object[prop] - initial < 0
, ... | ### .decrease(function)
Asserts that a function decreases an object property
var obj = { val: 10 };
var fn = function() { obj.val = 5 };
expect(fn).to.decrease(obj, 'val');
@name decrease
@alias decreases
@alias Decrease
@param {String} object
@param {String} property name
@param {String} message _option... | assertDecreases | javascript | louischatriot/nedb | browser-version/test/chai.js | https://github.com/louischatriot/nedb/blob/master/browser-version/test/chai.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.