repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
mapbox/cheap-ruler
index.js
function (p, dist, bearing) { var a = bearing * Math.PI / 180; return this.offset(p, Math.sin(a) * dist, Math.cos(a) * dist); }
javascript
function (p, dist, bearing) { var a = bearing * Math.PI / 180; return this.offset(p, Math.sin(a) * dist, Math.cos(a) * dist); }
[ "function", "(", "p", ",", "dist", ",", "bearing", ")", "{", "var", "a", "=", "bearing", "*", "Math", ".", "PI", "/", "180", ";", "return", "this", ".", "offset", "(", "p", ",", "Math", ".", "sin", "(", "a", ")", "*", "dist", ",", "Math", "."...
Returns a new point given distance and bearing from the starting point. @param {Array<number>} p point [longitude, latitude] @param {number} dist distance @param {number} bearing @returns {Array<number>} point [longitude, latitude] @example var point = ruler.destination([30.5, 50.5], 0.1, 90); //=point
[ "Returns", "a", "new", "point", "given", "distance", "and", "bearing", "from", "the", "starting", "point", "." ]
d078203640f66e4d2d3bd04b61c1e734a3aead90
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L119-L124
train
mapbox/cheap-ruler
index.js
function (line, dist) { var sum = 0; if (dist <= 0) return line[0]; for (var i = 0; i < line.length - 1; i++) { var p0 = line[i]; var p1 = line[i + 1]; var d = this.distance(p0, p1); sum += d; if (sum > dist) return interpolate(p0, p1...
javascript
function (line, dist) { var sum = 0; if (dist <= 0) return line[0]; for (var i = 0; i < line.length - 1; i++) { var p0 = line[i]; var p1 = line[i + 1]; var d = this.distance(p0, p1); sum += d; if (sum > dist) return interpolate(p0, p1...
[ "function", "(", "line", ",", "dist", ")", "{", "var", "sum", "=", "0", ";", "if", "(", "dist", "<=", "0", ")", "return", "line", "[", "0", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "line", ".", "length", "-", "1", ";", "...
Returns the point at a specified distance along the line. @param {Array<Array<number>>} line @param {number} dist distance @returns {Array<number>} point [longitude, latitude] @example var point = ruler.along(line, 2.5); //=point
[ "Returns", "the", "point", "at", "a", "specified", "distance", "along", "the", "line", "." ]
d078203640f66e4d2d3bd04b61c1e734a3aead90
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L200-L214
train
mapbox/cheap-ruler
index.js
function (start, stop, line) { var sum = 0; var slice = []; for (var i = 0; i < line.length - 1; i++) { var p0 = line[i]; var p1 = line[i + 1]; var d = this.distance(p0, p1); sum += d; if (sum > start && slice.length === 0) { ...
javascript
function (start, stop, line) { var sum = 0; var slice = []; for (var i = 0; i < line.length - 1; i++) { var p0 = line[i]; var p1 = line[i + 1]; var d = this.distance(p0, p1); sum += d; if (sum > start && slice.length === 0) { ...
[ "function", "(", "start", ",", "stop", ",", "line", ")", "{", "var", "sum", "=", "0", ";", "var", "slice", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "line", ".", "length", "-", "1", ";", "i", "++", ")", "{", "va...
Returns a part of the given line between the start and the stop points indicated by distance along the line. @param {number} start distance @param {number} stop distance @param {Array<Array<number>>} line @returns {Array<Array<number>>} line part of a line @example var line2 = ruler.lineSliceAlong(10, 20, line1); //=l...
[ "Returns", "a", "part", "of", "the", "given", "line", "between", "the", "start", "and", "the", "stop", "points", "indicated", "by", "distance", "along", "the", "line", "." ]
d078203640f66e4d2d3bd04b61c1e734a3aead90
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L324-L348
train
mapbox/cheap-ruler
index.js
function (bbox, buffer) { var v = buffer / this.ky; var h = buffer / this.kx; return [ bbox[0] - h, bbox[1] - v, bbox[2] + h, bbox[3] + v ]; }
javascript
function (bbox, buffer) { var v = buffer / this.ky; var h = buffer / this.kx; return [ bbox[0] - h, bbox[1] - v, bbox[2] + h, bbox[3] + v ]; }
[ "function", "(", "bbox", ",", "buffer", ")", "{", "var", "v", "=", "buffer", "/", "this", ".", "ky", ";", "var", "h", "=", "buffer", "/", "this", ".", "kx", ";", "return", "[", "bbox", "[", "0", "]", "-", "h", ",", "bbox", "[", "1", "]", "-...
Given a bounding box, returns the box buffered by a given distance. @param {Array<number>} box object ([w, s, e, n]) @param {number} buffer @returns {Array<number>} box object ([w, s, e, n]) @example var bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2); //=bbox
[ "Given", "a", "bounding", "box", "returns", "the", "box", "buffered", "by", "a", "given", "distance", "." ]
d078203640f66e4d2d3bd04b61c1e734a3aead90
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L381-L390
train
mapbox/cheap-ruler
index.js
function (p, bbox) { return p[0] >= bbox[0] && p[0] <= bbox[2] && p[1] >= bbox[1] && p[1] <= bbox[3]; }
javascript
function (p, bbox) { return p[0] >= bbox[0] && p[0] <= bbox[2] && p[1] >= bbox[1] && p[1] <= bbox[3]; }
[ "function", "(", "p", ",", "bbox", ")", "{", "return", "p", "[", "0", "]", ">=", "bbox", "[", "0", "]", "&&", "p", "[", "0", "]", "<=", "bbox", "[", "2", "]", "&&", "p", "[", "1", "]", ">=", "bbox", "[", "1", "]", "&&", "p", "[", "1", ...
Returns true if the given point is inside in the given bounding box, otherwise false. @param {Array<number>} p point [longitude, latitude] @param {Array<number>} box object ([w, s, e, n]) @returns {boolean} @example var inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]); //=inside
[ "Returns", "true", "if", "the", "given", "point", "is", "inside", "in", "the", "given", "bounding", "box", "otherwise", "false", "." ]
d078203640f66e4d2d3bd04b61c1e734a3aead90
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L402-L407
train
adrai/node-cqrs-domain
lib/definitions/context.js
function (aggregate) { if (!aggregate || !(aggregate instanceof Aggregate)) { throw new Error('Passed object should be an Aggregate'); } aggregate.defineContext(this); if (this.aggregates.indexOf(aggregate) < 0) { this.aggregates.push(aggregate); } }
javascript
function (aggregate) { if (!aggregate || !(aggregate instanceof Aggregate)) { throw new Error('Passed object should be an Aggregate'); } aggregate.defineContext(this); if (this.aggregates.indexOf(aggregate) < 0) { this.aggregates.push(aggregate); } }
[ "function", "(", "aggregate", ")", "{", "if", "(", "!", "aggregate", "||", "!", "(", "aggregate", "instanceof", "Aggregate", ")", ")", "{", "throw", "new", "Error", "(", "'Passed object should be an Aggregate'", ")", ";", "}", "aggregate", ".", "defineContext"...
Adds an aggregate to this context. @param {Aggregate} aggregate the aggregate that should be added
[ "Adds", "an", "aggregate", "to", "this", "context", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/context.js#L30-L40
train
adrai/node-cqrs-domain
lib/definitions/context.js
function (name) { if (!name || !_.isString(name)) { throw new Error('Please pass in an aggregate name!'); } return _.find(this.aggregates, function (agg) { return agg.name === name; }); }
javascript
function (name) { if (!name || !_.isString(name)) { throw new Error('Please pass in an aggregate name!'); } return _.find(this.aggregates, function (agg) { return agg.name === name; }); }
[ "function", "(", "name", ")", "{", "if", "(", "!", "name", "||", "!", "_", ".", "isString", "(", "name", ")", ")", "{", "throw", "new", "Error", "(", "'Please pass in an aggregate name!'", ")", ";", "}", "return", "_", ".", "find", "(", "this", ".", ...
Returns the aggregate with the requested name. @param {String} name command name @returns {Aggregate}
[ "Returns", "the", "aggregate", "with", "the", "requested", "name", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/context.js#L47-L55
train
adrai/node-cqrs-domain
lib/definitions/context.js
function (name, version) { if (!name || !_.isString(name)) { throw new Error('Please pass in a command name!'); } for (var a in this.aggregates) { var aggr = this.aggregates[a]; var cmd = aggr.getCommand(name, version); if (cmd) { return aggr; } } for (var a i...
javascript
function (name, version) { if (!name || !_.isString(name)) { throw new Error('Please pass in a command name!'); } for (var a in this.aggregates) { var aggr = this.aggregates[a]; var cmd = aggr.getCommand(name, version); if (cmd) { return aggr; } } for (var a i...
[ "function", "(", "name", ",", "version", ")", "{", "if", "(", "!", "name", "||", "!", "_", ".", "isString", "(", "name", ")", ")", "{", "throw", "new", "Error", "(", "'Please pass in a command name!'", ")", ";", "}", "for", "(", "var", "a", "in", "...
Return the aggregate that handles the requested command. @param {String} name command name @param {Number} version command version @returns {Aggregate}
[ "Return", "the", "aggregate", "that", "handles", "the", "requested", "command", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/context.js#L63-L87
train
adrai/node-cqrs-domain
lib/aggregateModel.js
function (streamInfo, rev) { this.set('_revision', rev); streamInfo.context = streamInfo.context || '_general'; this.get('_revisions')[streamInfo.context + '_' + streamInfo.aggregate + '_' + streamInfo.aggregateId] = rev; }
javascript
function (streamInfo, rev) { this.set('_revision', rev); streamInfo.context = streamInfo.context || '_general'; this.get('_revisions')[streamInfo.context + '_' + streamInfo.aggregate + '_' + streamInfo.aggregateId] = rev; }
[ "function", "(", "streamInfo", ",", "rev", ")", "{", "this", ".", "set", "(", "'_revision'", ",", "rev", ")", ";", "streamInfo", ".", "context", "=", "streamInfo", ".", "context", "||", "'_general'", ";", "this", ".", "get", "(", "'_revisions'", ")", "...
Sets the revision for this aggregate. @param {Object} streamInfo The stream info. @param {Number} rev The revision number.
[ "Sets", "the", "revision", "for", "this", "aggregate", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/aggregateModel.js#L57-L61
train
adrai/node-cqrs-domain
lib/aggregateModel.js
function (streamInfo) { if (!streamInfo) { return this.get('_revision'); } streamInfo.context = streamInfo.context || '_general'; return this.get('_revisions')[streamInfo.context + '_' + streamInfo.aggregate + '_' + streamInfo.aggregateId] || 0; }
javascript
function (streamInfo) { if (!streamInfo) { return this.get('_revision'); } streamInfo.context = streamInfo.context || '_general'; return this.get('_revisions')[streamInfo.context + '_' + streamInfo.aggregate + '_' + streamInfo.aggregateId] || 0; }
[ "function", "(", "streamInfo", ")", "{", "if", "(", "!", "streamInfo", ")", "{", "return", "this", ".", "get", "(", "'_revision'", ")", ";", "}", "streamInfo", ".", "context", "=", "streamInfo", ".", "context", "||", "'_general'", ";", "return", "this", ...
Returns the revision of this aggregate. @param {Object} streamInfo The stream info. @returns {Number}
[ "Returns", "the", "revision", "of", "this", "aggregate", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/aggregateModel.js#L68-L74
train
adrai/node-cqrs-domain
lib/aggregateModel.js
function (data) { if (arguments.length === 2) { dotty.put(this.attributes, arguments[0], arguments[1]); } else if (_.isObject(data)) { for (var m in data) { dotty.put(this.attributes, m, data[m]); } } }
javascript
function (data) { if (arguments.length === 2) { dotty.put(this.attributes, arguments[0], arguments[1]); } else if (_.isObject(data)) { for (var m in data) { dotty.put(this.attributes, m, data[m]); } } }
[ "function", "(", "data", ")", "{", "if", "(", "arguments", ".", "length", "===", "2", ")", "{", "dotty", ".", "put", "(", "this", ".", "attributes", ",", "arguments", "[", "0", "]", ",", "arguments", "[", "1", "]", ")", ";", "}", "else", "if", ...
Sets attributes for the aggregate. @example: aggregate.set('firstname', 'Jack'); // or aggregate.set({ firstname: 'Jack', lastname: 'X-Man' });
[ "Sets", "attributes", "for", "the", "aggregate", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/aggregateModel.js#L119-L127
train
adrai/node-cqrs-domain
lib/aggregateModel.js
function (data) { if (data instanceof AggregateModel) { this.attributes = data.toJSON(); } else { this.attributes = _.cloneDeep(data || {}); } this.attributes.id = this.id; this.attributes._destroyed = this.attributes._destroyed || false; this.attributes._revision = this.attributes....
javascript
function (data) { if (data instanceof AggregateModel) { this.attributes = data.toJSON(); } else { this.attributes = _.cloneDeep(data || {}); } this.attributes.id = this.id; this.attributes._destroyed = this.attributes._destroyed || false; this.attributes._revision = this.attributes....
[ "function", "(", "data", ")", "{", "if", "(", "data", "instanceof", "AggregateModel", ")", "{", "this", ".", "attributes", "=", "data", ".", "toJSON", "(", ")", ";", "}", "else", "{", "this", ".", "attributes", "=", "_", ".", "cloneDeep", "(", "data"...
Resets the attributes for the aggregate.
[ "Resets", "the", "attributes", "for", "the", "aggregate", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/aggregateModel.js#L157-L167
train
adrai/node-cqrs-domain
index.js
construct
function construct(klass, args) { function T() { klass.apply(this, arguments[0]); } T.prototype = klass.prototype; return new T(args); }
javascript
function construct(klass, args) { function T() { klass.apply(this, arguments[0]); } T.prototype = klass.prototype; return new T(args); }
[ "function", "construct", "(", "klass", ",", "args", ")", "{", "function", "T", "(", ")", "{", "klass", ".", "apply", "(", "this", ",", "arguments", "[", "0", "]", ")", ";", "}", "T", ".", "prototype", "=", "klass", ".", "prototype", ";", "return", ...
Calls the constructor. @param {Object} klass Constructor function. @param {Array} args Arguments for the constructor function. @return {Object} The new object.
[ "Calls", "the", "constructor", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/index.js#L22-L28
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
randomBetween
function randomBetween(min, max) { return Math.round(min + Math.random() * (max - min)); }
javascript
function randomBetween(min, max) { return Math.round(min + Math.random() * (max - min)); }
[ "function", "randomBetween", "(", "min", ",", "max", ")", "{", "return", "Math", ".", "round", "(", "min", "+", "Math", ".", "random", "(", ")", "*", "(", "max", "-", "min", ")", ")", ";", "}" ]
Returns a random number between passed values of min and max. @param {Number} min The minimum value of the resulting random number. @param {Number} max The maximum value of the resulting random number. @returns {Number}
[ "Returns", "a", "random", "number", "between", "passed", "values", "of", "min", "and", "max", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L19-L21
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregate) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } this.aggregate = aggregate; }
javascript
function (aggregate) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } this.aggregate = aggregate; }
[ "function", "(", "aggregate", ")", "{", "if", "(", "!", "aggregate", "||", "!", "_", ".", "isObject", "(", "aggregate", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregate!'", ")", ";", "debug", "(", "err", ")", ";", ...
Injects the needed aggregate. @param {Aggregate} aggregate The aggregate object to inject.
[ "Injects", "the", "needed", "aggregate", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L43-L50
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (eventStore) { if (!eventStore || !_.isObject(eventStore)) { var err = new Error('Please pass a valid eventStore!'); debug(err); throw err; } this.eventStore = eventStore; }
javascript
function (eventStore) { if (!eventStore || !_.isObject(eventStore)) { var err = new Error('Please pass a valid eventStore!'); debug(err); throw err; } this.eventStore = eventStore; }
[ "function", "(", "eventStore", ")", "{", "if", "(", "!", "eventStore", "||", "!", "_", ".", "isObject", "(", "eventStore", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid eventStore!'", ")", ";", "debug", "(", "err", ")", "...
Injects the needed eventStore. @param {Object} eventStore The eventStore object to inject.
[ "Injects", "the", "needed", "eventStore", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L56-L63
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregateLock) { if (!aggregateLock || !_.isObject(aggregateLock)) { var err = new Error('Please pass a valid aggregateLock!'); debug(err); throw err; } this.aggregateLock = aggregateLock; }
javascript
function (aggregateLock) { if (!aggregateLock || !_.isObject(aggregateLock)) { var err = new Error('Please pass a valid aggregateLock!'); debug(err); throw err; } this.aggregateLock = aggregateLock; }
[ "function", "(", "aggregateLock", ")", "{", "if", "(", "!", "aggregateLock", "||", "!", "_", ".", "isObject", "(", "aggregateLock", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregateLock!'", ")", ";", "debug", "(", "err"...
Injects the needed aggregateLock. @param {Object} aggregateLock The aggregateLock object to inject.
[ "Injects", "the", "needed", "aggregateLock", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L69-L76
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggId, cmd, clb) { if (!aggId || !_.isString(aggId)) { var err = new Error('Please pass a valid aggregate id!'); debug(err); throw err; } if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } if (!c...
javascript
function (aggId, cmd, clb) { if (!aggId || !_.isString(aggId)) { var err = new Error('Please pass a valid aggregate id!'); debug(err); throw err; } if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } if (!c...
[ "function", "(", "aggId", ",", "cmd", ",", "clb", ")", "{", "if", "(", "!", "aggId", "||", "!", "_", ".", "isString", "(", "aggId", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregate id!'", ")", ";", "debug", "(", ...
Queues the passed command and its callback. @param {String} aggId The passed aggregate id. @param {Object} cmd The command to be queued. @param {Function} clb The callback of this command.
[ "Queues", "the", "passed", "command", "and", "its", "callback", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L84-L103
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggId) { if (!aggId || !_.isString(aggId)) { var err = new Error('Please pass a valid aggregate id!'); debug(err); throw err; } if (this.queue[aggId] && this.queue[aggId].length > 0) { var nextCmd = this.queue[aggId][0]; return nextCmd; } return null; }
javascript
function (aggId) { if (!aggId || !_.isString(aggId)) { var err = new Error('Please pass a valid aggregate id!'); debug(err); throw err; } if (this.queue[aggId] && this.queue[aggId].length > 0) { var nextCmd = this.queue[aggId][0]; return nextCmd; } return null; }
[ "function", "(", "aggId", ")", "{", "if", "(", "!", "aggId", "||", "!", "_", ".", "isString", "(", "aggId", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregate id!'", ")", ";", "debug", "(", "err", ")", ";", "throw"...
Returns next command in the queue @param {String} aggId The passed aggregate id. @returns {Object}
[ "Returns", "next", "command", "in", "the", "queue" ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L110-L123
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggId, cmd) { if (!aggId || !_.isString(aggId)) { var err = new Error('Please pass a valid aggregate id!'); debug(err); throw err; } _.remove(this.queue[aggId], function (c) { return c.command === cmd; }); }
javascript
function (aggId, cmd) { if (!aggId || !_.isString(aggId)) { var err = new Error('Please pass a valid aggregate id!'); debug(err); throw err; } _.remove(this.queue[aggId], function (c) { return c.command === cmd; }); }
[ "function", "(", "aggId", ",", "cmd", ")", "{", "if", "(", "!", "aggId", "||", "!", "_", ".", "isString", "(", "aggId", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregate id!'", ")", ";", "debug", "(", "err", ")", ...
Removes the passed command from the queue. @param {String} aggId The passed aggregate id. @param {Object} cmd The command to be queued.
[ "Removes", "the", "passed", "command", "from", "the", "queue", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L130-L140
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregateId, callback) { if (!aggregateId || !_.isString(aggregateId)) { var err = new Error('Please pass a valid aggregateId!'); debug(err); throw err; } if (!callback || !_.isFunction(callback)) { var err = new Error('Please pass a valid callback!'); debug(err); ...
javascript
function (aggregateId, callback) { if (!aggregateId || !_.isString(aggregateId)) { var err = new Error('Please pass a valid aggregateId!'); debug(err); throw err; } if (!callback || !_.isFunction(callback)) { var err = new Error('Please pass a valid callback!'); debug(err); ...
[ "function", "(", "aggregateId", ",", "callback", ")", "{", "if", "(", "!", "aggregateId", "||", "!", "_", ".", "isString", "(", "aggregateId", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregateId!'", ")", ";", "debug", ...
Locks the aggregate. @param {String} aggregateId The passed aggregateId. @param {Function} callback The function, that will be called when this action is completed. `function(err){}`
[ "Locks", "the", "aggregate", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L148-L160
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregate, stream, callback) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } if (!stream || !_.isObject(stream)) { var err = new Error('Please pass a valid aggregate!'); debug(err); th...
javascript
function (aggregate, stream, callback) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } if (!stream || !_.isObject(stream)) { var err = new Error('Please pass a valid aggregate!'); debug(err); th...
[ "function", "(", "aggregate", ",", "stream", ",", "callback", ")", "{", "if", "(", "!", "aggregate", "||", "!", "_", ".", "isObject", "(", "aggregate", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregate!'", ")", ";", ...
Creates a new snapshot. @param {AggregateModel} aggregate The passed aggregate. @param {Object} stream The event stream. @param {Function} callback The function, that will be called when this action is completed. [optional] `function(err){}`
[ "Creates", "a", "new", "snapshot", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L500-L556
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregate, cmd) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } v...
javascript
function (aggregate, cmd) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } v...
[ "function", "(", "aggregate", ",", "cmd", ")", "{", "if", "(", "!", "aggregate", "||", "!", "_", ".", "isObject", "(", "aggregate", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregate!'", ")", ";", "debug", "(", "err"...
Returns an error if the aggregate is destroyed. @param {AggregateModel} aggregate The passed aggregate. @param {Object} cmd The command. @returns {AggregateDestroyedError}
[ "Returns", "an", "error", "if", "the", "aggregate", "is", "destroyed", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L564-L604
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregate, cmd) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } v...
javascript
function (aggregate, cmd) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } v...
[ "function", "(", "aggregate", ",", "cmd", ")", "{", "if", "(", "!", "aggregate", "||", "!", "_", ".", "isObject", "(", "aggregate", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregate!'", ")", ";", "debug", "(", "err"...
Returns an error if the revision does not match. @param {AggregateModel} aggregate The passed aggregate. @param {Object} cmd The command. @returns {AggregateConcurrencyError}
[ "Returns", "an", "error", "if", "the", "revision", "does", "not", "match", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L612-L664
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (cmd, callback) { if (!cmd || !_.isObject(cmd)) { debug(err); return callback(new Error('Please pass a valid command!'), null); } return this.aggregate.validateCommand(cmd, callback); }
javascript
function (cmd, callback) { if (!cmd || !_.isObject(cmd)) { debug(err); return callback(new Error('Please pass a valid command!'), null); } return this.aggregate.validateCommand(cmd, callback); }
[ "function", "(", "cmd", ",", "callback", ")", "{", "if", "(", "!", "cmd", "||", "!", "_", ".", "isObject", "(", "cmd", ")", ")", "{", "debug", "(", "err", ")", ";", "return", "callback", "(", "new", "Error", "(", "'Please pass a valid command!'", ")"...
Returns an error if the command is not valid. @param {Object} cmd The command. @returns {ValidationError}
[ "Returns", "an", "error", "if", "the", "command", "is", "not", "valid", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L671-L677
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregate, cmd) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } v...
javascript
function (aggregate, cmd) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } v...
[ "function", "(", "aggregate", ",", "cmd", ")", "{", "if", "(", "!", "aggregate", "||", "!", "_", ".", "isObject", "(", "aggregate", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregate!'", ")", ";", "debug", "(", "err"...
Returns an error if verification fails. @param {AggregateModel} aggregate The passed aggregate. @param {Object} cmd The command. @returns {Error}
[ "Returns", "an", "error", "if", "verification", "fails", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L689-L712
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregate, cmd, callback) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; ...
javascript
function (aggregate, cmd, callback) { if (!aggregate || !_.isObject(aggregate)) { var err = new Error('Please pass a valid aggregate!'); debug(err); throw err; } if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; ...
[ "function", "(", "aggregate", ",", "cmd", ",", "callback", ")", "{", "if", "(", "!", "aggregate", "||", "!", "_", ".", "isObject", "(", "aggregate", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregate!'", ")", ";", "d...
Handles the command by passing it to the handle function of the aggregate. @param {AggregateModel} aggregate The passed aggregate. @param {Object} cmd The command. @param {Function} callback The function, that will be called when this action is completed. `function(err){}`
[ "Handles", "the", "command", "by", "passing", "it", "to", "the", "handle", "function", "of", "the", "aggregate", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L721-L739
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregateId, callback) { if (!aggregateId || !_.isString(aggregateId)) { var err = new Error('Please pass a valid aggregateId!'); debug(err); throw err; } if (!callback || !_.isFunction(callback)) { var err = new Error('Please pass a valid callback!'); debug(err); ...
javascript
function (aggregateId, callback) { if (!aggregateId || !_.isString(aggregateId)) { var err = new Error('Please pass a valid aggregateId!'); debug(err); throw err; } if (!callback || !_.isFunction(callback)) { var err = new Error('Please pass a valid callback!'); debug(err); ...
[ "function", "(", "aggregateId", ",", "callback", ")", "{", "if", "(", "!", "aggregateId", "||", "!", "_", ".", "isString", "(", "aggregateId", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregateId!'", ")", ";", "debug", ...
Checks if the aggregate lock is ok. @param {String} aggregateId The passed aggregateId. @param {Function} callback The function, that will be called when this action is completed. `function(err){}`
[ "Checks", "if", "the", "aggregate", "lock", "is", "ok", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L747-L774
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregateId, callback) { if (!aggregateId || !_.isString(aggregateId)) { var err = new Error('Please pass a valid aggregateId!'); debug(err); throw err; } if (!callback || !_.isFunction(callback)) { var err = new Error('Please pass a valid callback!'); debug(err); ...
javascript
function (aggregateId, callback) { if (!aggregateId || !_.isString(aggregateId)) { var err = new Error('Please pass a valid aggregateId!'); debug(err); throw err; } if (!callback || !_.isFunction(callback)) { var err = new Error('Please pass a valid callback!'); debug(err); ...
[ "function", "(", "aggregateId", ",", "callback", ")", "{", "if", "(", "!", "aggregateId", "||", "!", "_", ".", "isString", "(", "aggregateId", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid aggregateId!'", ")", ";", "debug", ...
Resolves if the aggregate lock. @param {String} aggregateId The passed aggregateId. @param {Function} callback The function, that will be called when this action is completed. `function(err){}`
[ "Resolves", "if", "the", "aggregate", "lock", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L782-L795
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregate, streams, clb) { debug('handle command'); self.letHandleCommandByAggregate(aggregate, cmd, function (err) { // err is a business rule error if (err) { return clb(err); } clb(null, aggregate, streams); }); }
javascript
function (aggregate, streams, clb) { debug('handle command'); self.letHandleCommandByAggregate(aggregate, cmd, function (err) { // err is a business rule error if (err) { return clb(err); } clb(null, aggregate, streams); }); }
[ "function", "(", "aggregate", ",", "streams", ",", "clb", ")", "{", "debug", "(", "'handle command'", ")", ";", "self", ".", "letHandleCommandByAggregate", "(", "aggregate", ",", "cmd", ",", "function", "(", "err", ")", "{", "// err is a business rule error", ...
handle command and check business rules
[ "handle", "command", "and", "check", "business", "rules" ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L1015-L1023
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (aggregate, streams, clb) { if (hadNoAggregateId) return clb(null, aggregate, streams); debug('check aggregate lock'); self.checkAggregateLock(concatenatedId, function (err) { clb(err, aggregate, streams); }); }
javascript
function (aggregate, streams, clb) { if (hadNoAggregateId) return clb(null, aggregate, streams); debug('check aggregate lock'); self.checkAggregateLock(concatenatedId, function (err) { clb(err, aggregate, streams); }); }
[ "function", "(", "aggregate", ",", "streams", ",", "clb", ")", "{", "if", "(", "hadNoAggregateId", ")", "return", "clb", "(", "null", ",", "aggregate", ",", "streams", ")", ";", "debug", "(", "'check aggregate lock'", ")", ";", "self", ".", "checkAggregate...
check aggregate lock
[ "check", "aggregate", "lock" ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L1026-L1032
train
adrai/node-cqrs-domain
lib/defaultCommandHandler.js
function (cmd, callback) { var getNewIdFn = this.eventStore.getNewId.bind(this.eventStore); if (this.aggregate && this.aggregate.getNewAggregateId) { getNewIdFn = this.aggregate.getNewAggregateId.bind(this.aggregate); } else if (this.getNewAggregateIdFn) { getNewIdFn = this.getNewAggregateIdFn.b...
javascript
function (cmd, callback) { var getNewIdFn = this.eventStore.getNewId.bind(this.eventStore); if (this.aggregate && this.aggregate.getNewAggregateId) { getNewIdFn = this.aggregate.getNewAggregateId.bind(this.aggregate); } else if (this.getNewAggregateIdFn) { getNewIdFn = this.getNewAggregateIdFn.b...
[ "function", "(", "cmd", ",", "callback", ")", "{", "var", "getNewIdFn", "=", "this", ".", "eventStore", ".", "getNewId", ".", "bind", "(", "this", ".", "eventStore", ")", ";", "if", "(", "this", ".", "aggregate", "&&", "this", ".", "aggregate", ".", ...
IdGenerator function for aggregate id. @param {Function} callback The function, that will be called when this action is completed. `function(err, newId){}`
[ "IdGenerator", "function", "for", "aggregate", "id", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/defaultCommandHandler.js#L1200-L1213
train
adrai/node-cqrs-domain
lib/domain.js
function (fn) { if (!fn || !_.isFunction(fn)) { var err = new Error('Please pass a valid function!'); debug(err); throw err; } this.structureLoader = customLoader(fn); return this; }
javascript
function (fn) { if (!fn || !_.isFunction(fn)) { var err = new Error('Please pass a valid function!'); debug(err); throw err; } this.structureLoader = customLoader(fn); return this; }
[ "function", "(", "fn", ")", "{", "if", "(", "!", "fn", "||", "!", "_", ".", "isFunction", "(", "fn", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid function!'", ")", ";", "debug", "(", "err", ")", ";", "throw", "err", ...
Inject custom structure loader function @param {Function} fn The function to be injected. @returns {Domain} to be able to chain...
[ "Inject", "custom", "structure", "loader", "function" ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/domain.js#L285-L295
train
adrai/node-cqrs-domain
lib/domain.js
function (cmd, err) { if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } if (!err || !_.isObject(err)) { var err = new Error('Please pass a valid error!'); debug(err); throw err; } var evt = {}; if (...
javascript
function (cmd, err) { if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } if (!err || !_.isObject(err)) { var err = new Error('Please pass a valid error!'); debug(err); throw err; } var evt = {}; if (...
[ "function", "(", "cmd", ",", "err", ")", "{", "if", "(", "!", "cmd", "||", "!", "_", ".", "isObject", "(", "cmd", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid command!'", ")", ";", "debug", "(", "err", ")", ";", "t...
Converts an error to the commandRejected event @param {Object} cmd The command that was handled. @param {Error} err The error that occurs. @returns {Object} The resulting event.
[ "Converts", "an", "error", "to", "the", "commandRejected", "event" ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/domain.js#L328-L379
train
adrai/node-cqrs-domain
lib/domain.js
function (fn) { if (!fn || !_.isFunction(fn) || fn.length !== 1) { var err = new Error('Please pass a valid function!'); debug(err); throw err; } this.validatorExtension = fn; return this; }
javascript
function (fn) { if (!fn || !_.isFunction(fn) || fn.length !== 1) { var err = new Error('Please pass a valid function!'); debug(err); throw err; } this.validatorExtension = fn; return this; }
[ "function", "(", "fn", ")", "{", "if", "(", "!", "fn", "||", "!", "_", ".", "isFunction", "(", "fn", ")", "||", "fn", ".", "length", "!==", "1", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid function!'", ")", ";", "debug",...
Extends the validator instance. @param {Function} fn the function to be injected @returns {Domain} to be able to chain...
[ "Extends", "the", "validator", "instance", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/domain.js#L400-L410
train
adrai/node-cqrs-domain
lib/domain.js
function (callback) { debug('prepare eventStore...'); self.eventStore.on('connect', function () { self.emit('connect'); }); self.eventStore.on('disconnect', function () { self.emit('disconnect'); }); self.eventStore.i...
javascript
function (callback) { debug('prepare eventStore...'); self.eventStore.on('connect', function () { self.emit('connect'); }); self.eventStore.on('disconnect', function () { self.emit('disconnect'); }); self.eventStore.i...
[ "function", "(", "callback", ")", "{", "debug", "(", "'prepare eventStore...'", ")", ";", "self", ".", "eventStore", ".", "on", "(", "'connect'", ",", "function", "(", ")", "{", "self", ".", "emit", "(", "'connect'", ")", ";", "}", ")", ";", "self", ...
prepare eventStore...
[ "prepare", "eventStore", "..." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/domain.js#L447-L459
train
adrai/node-cqrs-domain
lib/domain.js
function (callback) { debug('prepare aggregateLock...'); self.aggregateLock.on('connect', function () { self.emit('connect'); }); self.aggregateLock.on('disconnect', function () { self.emit('disconnect'); }); self.agg...
javascript
function (callback) { debug('prepare aggregateLock...'); self.aggregateLock.on('connect', function () { self.emit('connect'); }); self.aggregateLock.on('disconnect', function () { self.emit('disconnect'); }); self.agg...
[ "function", "(", "callback", ")", "{", "debug", "(", "'prepare aggregateLock...'", ")", ";", "self", ".", "aggregateLock", ".", "on", "(", "'connect'", ",", "function", "(", ")", "{", "self", ".", "emit", "(", "'connect'", ")", ";", "}", ")", ";", "sel...
prepare aggregateLock...
[ "prepare", "aggregateLock", "..." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/domain.js#L462-L474
train
adrai/node-cqrs-domain
lib/domain.js
function (callback) { if (!self.commandBumper) { return callback(null); } debug('prepare commandBumper...'); self.commandBumper.on('connect', function () { self.emit('connect'); }); self.commandBumper.on('disconnect', ...
javascript
function (callback) { if (!self.commandBumper) { return callback(null); } debug('prepare commandBumper...'); self.commandBumper.on('connect', function () { self.emit('connect'); }); self.commandBumper.on('disconnect', ...
[ "function", "(", "callback", ")", "{", "if", "(", "!", "self", ".", "commandBumper", ")", "{", "return", "callback", "(", "null", ")", ";", "}", "debug", "(", "'prepare commandBumper...'", ")", ";", "self", ".", "commandBumper", ".", "on", "(", "'connect...
prepare commandBumper...
[ "prepare", "commandBumper", "..." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/domain.js#L477-L492
train
adrai/node-cqrs-domain
lib/domain.js
function (cmd, callback) { if (!cmd || !_.isObject(cmd) || !dotty.exists(cmd, this.definitions.command.name)) { var err = new Error('Please pass a valid command!'); debug(err); if (callback) callback(err); return; } var self = this; process.nextTick(function () { if (callb...
javascript
function (cmd, callback) { if (!cmd || !_.isObject(cmd) || !dotty.exists(cmd, this.definitions.command.name)) { var err = new Error('Please pass a valid command!'); debug(err); if (callback) callback(err); return; } var self = this; process.nextTick(function () { if (callb...
[ "function", "(", "cmd", ",", "callback", ")", "{", "if", "(", "!", "cmd", "||", "!", "_", ".", "isObject", "(", "cmd", ")", "||", "!", "dotty", ".", "exists", "(", "cmd", ",", "this", ".", "definitions", ".", "command", ".", "name", ")", ")", "...
Call this function to let the domain handle it. @param {Object} cmd the command object @param {Function} callback the function that will be called when this action has finished [optional] `function(err, evts, aggregateData, meta){}` evts is of type Array, aggregateData and meta are an object
[ "Call", "this", "function", "to", "let", "the", "domain", "handle", "it", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/domain.js#L654-L674
train
adrai/node-cqrs-domain
lib/definitions/event.js
function (evt, aggregateModel) { if (!this.evtFn) { return; } if (!this.payload || this.payload === '') { this.evtFn(evt, aggregateModel); return; } var payload = dotty.get(evt, this.payload); this.evtFn(payload, aggregateModel); }
javascript
function (evt, aggregateModel) { if (!this.evtFn) { return; } if (!this.payload || this.payload === '') { this.evtFn(evt, aggregateModel); return; } var payload = dotty.get(evt, this.payload); this.evtFn(payload, aggregateModel); }
[ "function", "(", "evt", ",", "aggregateModel", ")", "{", "if", "(", "!", "this", ".", "evtFn", ")", "{", "return", ";", "}", "if", "(", "!", "this", ".", "payload", "||", "this", ".", "payload", "===", "''", ")", "{", "this", ".", "evtFn", "(", ...
Apply an event. @param {Object} evt The event object. @param {AggregateModel} aggregateModel The aggregate object.
[ "Apply", "an", "event", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/event.js#L40-L52
train
adrai/node-cqrs-domain
lib/validator.js
getValidator
function getValidator (options, schema) { options = options || {}; options.schemas = options.schemas || {}; options.formats = options.formats || {}; if (!schema || !_.isObject(schema)) { var err = new Error('Please pass a valid schema!'); debug(err); throw err; } var tv4 = tv4Module.freshApi()...
javascript
function getValidator (options, schema) { options = options || {}; options.schemas = options.schemas || {}; options.formats = options.formats || {}; if (!schema || !_.isObject(schema)) { var err = new Error('Please pass a valid schema!'); debug(err); throw err; } var tv4 = tv4Module.freshApi()...
[ "function", "getValidator", "(", "options", ",", "schema", ")", "{", "options", "=", "options", "||", "{", "}", ";", "options", ".", "schemas", "=", "options", ".", "schemas", "||", "{", "}", ";", "options", ".", "formats", "=", "options", ".", "format...
Returns a validator function. @param {Object} options The options object. @param {Object} schema The schema object. @returns {Function}
[ "Returns", "a", "validator", "function", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/validator.js#L12-L58
train
adrai/node-cqrs-domain
lib/commandDispatcher.js
function (cmd) { if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } var aggregateId = null; if (dotty.exists(cmd, this.definition.aggregateId)) { aggregateId = dotty.get(cmd, this.definition.aggregateId); } else { ...
javascript
function (cmd) { if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } var aggregateId = null; if (dotty.exists(cmd, this.definition.aggregateId)) { aggregateId = dotty.get(cmd, this.definition.aggregateId); } else { ...
[ "function", "(", "cmd", ")", "{", "if", "(", "!", "cmd", "||", "!", "_", ".", "isObject", "(", "cmd", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid command!'", ")", ";", "debug", "(", "err", ")", ";", "throw", "err", ...
Returns the target information of this command. @param {Object} cmd The passed command. @returns {{name: 'commandName', aggregateId: 'aggregateId', version: 0, aggregate: 'aggregateName', context: 'contextName'}}
[ "Returns", "the", "target", "information", "of", "this", "command", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/commandDispatcher.js#L39-L83
train
adrai/node-cqrs-domain
lib/commandDispatcher.js
function (cmd, callback) { if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } if (!callback || !_.isFunction(callback)) { var err = new Error('Please pass a valid callback!'); debug(err); throw err; } va...
javascript
function (cmd, callback) { if (!cmd || !_.isObject(cmd)) { var err = new Error('Please pass a valid command!'); debug(err); throw err; } if (!callback || !_.isFunction(callback)) { var err = new Error('Please pass a valid callback!'); debug(err); throw err; } va...
[ "function", "(", "cmd", ",", "callback", ")", "{", "if", "(", "!", "cmd", "||", "!", "_", ".", "isObject", "(", "cmd", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid command!'", ")", ";", "debug", "(", "err", ")", ";",...
Dispatches a command. @param {Object} cmd The passed command. @param {Function} callback The function, that will be called when this action is completed. `function(err, evts){}`
[ "Dispatches", "a", "command", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/commandDispatcher.js#L91-L135
train
adrai/node-cqrs-domain
lib/definitions/committingEventTransformer.js
function (evt, callback) { var self = this; var callbacked = false; function handleError (err) { debug(err); callbacked = true; callback(err); } try { if (this.transformFn.length === 2) { this.transformFn(_.cloneDeep(evt), function (err, newEvt) { if (err)...
javascript
function (evt, callback) { var self = this; var callbacked = false; function handleError (err) { debug(err); callbacked = true; callback(err); } try { if (this.transformFn.length === 2) { this.transformFn(_.cloneDeep(evt), function (err, newEvt) { if (err)...
[ "function", "(", "evt", ",", "callback", ")", "{", "var", "self", "=", "this", ";", "var", "callbacked", "=", "false", ";", "function", "handleError", "(", "err", ")", "{", "debug", "(", "err", ")", ";", "callbacked", "=", "true", ";", "callback", "(...
transform an CommittingEventTransformer. @param {Object} evt The CommittingEventTransformer object. @param {Function} callback The function, that will be called when this action is completed. `function(err, evt){}`
[ "transform", "an", "CommittingEventTransformer", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/committingEventTransformer.js#L39-L66
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (context) { if (!context || !_.isObject(context)) { var err = new Error('Please inject a valid context object!'); debug(err); throw err; } this.context = context; for (var r in this.snapshotConversionRegistrations) { var reg = this.snapshotConversionRegistrations[r]; ...
javascript
function (context) { if (!context || !_.isObject(context)) { var err = new Error('Please inject a valid context object!'); debug(err); throw err; } this.context = context; for (var r in this.snapshotConversionRegistrations) { var reg = this.snapshotConversionRegistrations[r]; ...
[ "function", "(", "context", ")", "{", "if", "(", "!", "context", "||", "!", "_", ".", "isObject", "(", "context", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please inject a valid context object!'", ")", ";", "debug", "(", "err", ")", ";",...
Inject the context module. @param {Context} context The context module to be injected.
[ "Inject", "the", "context", "module", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L189-L230
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (command) { if (!command || !_.isObject(command)) { var err = new Error('Please inject a valid command object!'); debug(err); throw err; } if (!command.payload && command.payload !== '') { command.payload = this.defaultCommandPayload; } command.defineAggregate(this...
javascript
function (command) { if (!command || !_.isObject(command)) { var err = new Error('Please inject a valid command object!'); debug(err); throw err; } if (!command.payload && command.payload !== '') { command.payload = this.defaultCommandPayload; } command.defineAggregate(this...
[ "function", "(", "command", ")", "{", "if", "(", "!", "command", "||", "!", "_", ".", "isObject", "(", "command", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please inject a valid command object!'", ")", ";", "debug", "(", "err", ")", ";",...
Add command module. @param {Command} command The command module to be injected.
[ "Add", "command", "module", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L236-L252
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (event) { if (!event || !_.isObject(event)) { var err = new Error('Please inject a valid event object!'); debug(err); throw err; } if (!event.payload && event.payload !== '') { event.payload = this.defaultEventPayload; } if (this.events.indexOf(event) < 0) { ...
javascript
function (event) { if (!event || !_.isObject(event)) { var err = new Error('Please inject a valid event object!'); debug(err); throw err; } if (!event.payload && event.payload !== '') { event.payload = this.defaultEventPayload; } if (this.events.indexOf(event) < 0) { ...
[ "function", "(", "event", ")", "{", "if", "(", "!", "event", "||", "!", "_", ".", "isObject", "(", "event", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please inject a valid event object!'", ")", ";", "debug", "(", "err", ")", ";", "thro...
Add event module. @param {Event} event The event module to be injected.
[ "Add", "event", "module", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L258-L272
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (businessRule) { if (!businessRule || !_.isObject(businessRule)) { var err = new Error('Please inject a valid businessRule object!'); debug(err); throw err; } if (this.businessRules.indexOf(businessRule) < 0) { businessRule.defineAggregate(this); this.businessRules.pu...
javascript
function (businessRule) { if (!businessRule || !_.isObject(businessRule)) { var err = new Error('Please inject a valid businessRule object!'); debug(err); throw err; } if (this.businessRules.indexOf(businessRule) < 0) { businessRule.defineAggregate(this); this.businessRules.pu...
[ "function", "(", "businessRule", ")", "{", "if", "(", "!", "businessRule", "||", "!", "_", ".", "isObject", "(", "businessRule", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please inject a valid businessRule object!'", ")", ";", "debug", "(", ...
Add businessRule module. @param {BusinessRule} businessRule The businessRule module to be injected.
[ "Add", "businessRule", "module", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L278-L292
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (loadingEventTransformer) { if (!loadingEventTransformer || !_.isObject(loadingEventTransformer)) { var err = new Error('Please inject a valid loadingEventTransformer object!'); debug(err); throw err; } if (this.loadingEventTransformers.indexOf(loadingEventTransformer) < 0) { ...
javascript
function (loadingEventTransformer) { if (!loadingEventTransformer || !_.isObject(loadingEventTransformer)) { var err = new Error('Please inject a valid loadingEventTransformer object!'); debug(err); throw err; } if (this.loadingEventTransformers.indexOf(loadingEventTransformer) < 0) { ...
[ "function", "(", "loadingEventTransformer", ")", "{", "if", "(", "!", "loadingEventTransformer", "||", "!", "_", ".", "isObject", "(", "loadingEventTransformer", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please inject a valid loadingEventTransformer o...
Add loadingEventTransformer module. @param {LoadingEventTransformer} loadingEventTransformer The loadingEventTransformer module to be injected.
[ "Add", "loadingEventTransformer", "module", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L298-L308
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (committingEventTransformer) { if (!committingEventTransformer || !_.isObject(committingEventTransformer)) { var err = new Error('Please inject a valid committingEventTransformer object!'); debug(err); throw err; } if (this.committingEventTransformers.indexOf(committingEventTrans...
javascript
function (committingEventTransformer) { if (!committingEventTransformer || !_.isObject(committingEventTransformer)) { var err = new Error('Please inject a valid committingEventTransformer object!'); debug(err); throw err; } if (this.committingEventTransformers.indexOf(committingEventTrans...
[ "function", "(", "committingEventTransformer", ")", "{", "if", "(", "!", "committingEventTransformer", "||", "!", "_", ".", "isObject", "(", "committingEventTransformer", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please inject a valid committingEventT...
Add committingEventTransformer module. @param {CommittingEventTransformer} committingEventTransformer The committingEventTransformer module to be injected.
[ "Add", "committingEventTransformer", "module", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L314-L324
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (commandHandler) { if (!commandHandler || !_.isObject(commandHandler) || !_.isFunction(commandHandler.useAggregate)) { var err = new Error('Please inject a valid commandHandler object!'); debug(err); throw err; } commandHandler.useAggregate(this); if (this.commandHandlers.in...
javascript
function (commandHandler) { if (!commandHandler || !_.isObject(commandHandler) || !_.isFunction(commandHandler.useAggregate)) { var err = new Error('Please inject a valid commandHandler object!'); debug(err); throw err; } commandHandler.useAggregate(this); if (this.commandHandlers.in...
[ "function", "(", "commandHandler", ")", "{", "if", "(", "!", "commandHandler", "||", "!", "_", ".", "isObject", "(", "commandHandler", ")", "||", "!", "_", ".", "isFunction", "(", "commandHandler", ".", "useAggregate", ")", ")", "{", "var", "err", "=", ...
Add commandHandler module. @param {CommandHandler} commandHandler The commandHandler module to be injected.
[ "Add", "commandHandler", "module", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L330-L342
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (name) { if (!name || !_.isString(name)) { var err = new Error('Please pass a valid string as name!'); debug(err); throw err; } return _.filter(this.commands, function (cmd) { return cmd.name === name; }); }
javascript
function (name) { if (!name || !_.isString(name)) { var err = new Error('Please pass a valid string as name!'); debug(err); throw err; } return _.filter(this.commands, function (cmd) { return cmd.name === name; }); }
[ "function", "(", "name", ")", "{", "if", "(", "!", "name", "||", "!", "_", ".", "isString", "(", "name", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid string as name!'", ")", ";", "debug", "(", "err", ")", ";", "throw",...
Returns the command modules by command name. @param {String} name The command name. @returns {Array}
[ "Returns", "the", "command", "modules", "by", "command", "name", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L349-L359
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (name, version) { if (!name || !_.isString(name)) { var err = new Error('Please pass a valid string as name!'); debug(err); throw err; } version = version || 0; if (!_.isNumber(version)) { var err = new Error('Please pass a valid number as version!'); debug(err);...
javascript
function (name, version) { if (!name || !_.isString(name)) { var err = new Error('Please pass a valid string as name!'); debug(err); throw err; } version = version || 0; if (!_.isNumber(version)) { var err = new Error('Please pass a valid number as version!'); debug(err);...
[ "function", "(", "name", ",", "version", ")", "{", "if", "(", "!", "name", "||", "!", "_", ".", "isString", "(", "name", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid string as name!'", ")", ";", "debug", "(", "err", ")...
Returns the command module by command name and command version. @param {String} name The command name. @param {Number} version The command version. [optional; default 0] @returns {Command}
[ "Returns", "the", "command", "module", "by", "command", "name", "and", "command", "version", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L367-L385
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (name, version) { if (!name || !_.isString(name)) { var err = new Error('Please pass a valid string as name!'); debug(err); throw err; } version = version || 0; if (!_.isNumber(version)) { var err = new Error('Please pass a valid number as version!'); debug(err);...
javascript
function (name, version) { if (!name || !_.isString(name)) { var err = new Error('Please pass a valid string as name!'); debug(err); throw err; } version = version || 0; if (!_.isNumber(version)) { var err = new Error('Please pass a valid number as version!'); debug(err);...
[ "function", "(", "name", ",", "version", ")", "{", "if", "(", "!", "name", "||", "!", "_", ".", "isString", "(", "name", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid string as name!'", ")", ";", "debug", "(", "err", ")...
Returns the event module by event name and event version. @param {String} name The event name. @param {Number} version The event version. [optional; default 0] @returns {Event}
[ "Returns", "the", "event", "module", "by", "event", "name", "and", "event", "version", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L401-L419
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (name, version) { if (!name || !_.isString(name)) { var err = new Error('Please pass a valid string as name!'); debug(err); throw err; } version = version || 0; if (!_.isNumber(version)) { var err = new Error('Please pass a valid number as version!'); debug(err);...
javascript
function (name, version) { if (!name || !_.isString(name)) { var err = new Error('Please pass a valid string as name!'); debug(err); throw err; } version = version || 0; if (!_.isNumber(version)) { var err = new Error('Please pass a valid number as version!'); debug(err);...
[ "function", "(", "name", ",", "version", ")", "{", "if", "(", "!", "name", "||", "!", "_", ".", "isString", "(", "name", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid string as name!'", ")", ";", "debug", "(", "err", ")...
Returns the commandHandler module by command name and command version. @param {String} name The command name. @param {Number} version The command version. [optional; default 0] @returns {CommandHandler}
[ "Returns", "the", "commandHandler", "module", "by", "command", "name", "and", "command", "version", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L451-L479
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (name, version) { if (!name || !_.isString(name)) { var err = new Error('Please pass a valid string as name!'); debug(err); throw err; } version = version || 0; if (!_.isNumber(version)) { var err = new Error('Please pass a valid number as version!'); debug(err);...
javascript
function (name, version) { if (!name || !_.isString(name)) { var err = new Error('Please pass a valid string as name!'); debug(err); throw err; } version = version || 0; if (!_.isNumber(version)) { var err = new Error('Please pass a valid number as version!'); debug(err);...
[ "function", "(", "name", ",", "version", ")", "{", "if", "(", "!", "name", "||", "!", "_", ".", "isString", "(", "name", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid string as name!'", ")", ";", "debug", "(", "err", ")...
Returns the loadingEventTransformer module by event name and event version. @param {String} name The event name. @param {Number} version The event version. [optional; default 0] @returns {Event}
[ "Returns", "the", "loadingEventTransformer", "module", "by", "event", "name", "and", "event", "version", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L487-L511
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (id) { if (!id || !_.isString(id)) { var err = new Error('Please pass a valid string as id!'); debug(err); throw err; } return new AggregateModel(id, this.modelInitValues); }
javascript
function (id) { if (!id || !_.isString(id)) { var err = new Error('Please pass a valid string as id!'); debug(err); throw err; } return new AggregateModel(id, this.modelInitValues); }
[ "function", "(", "id", ")", "{", "if", "(", "!", "id", "||", "!", "_", ".", "isString", "(", "id", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid string as id!'", ")", ";", "debug", "(", "err", ")", ";", "throw", "err"...
Returns a new aggregate model, to be used in the command and event functions. @param {String} id The aggregate id. @returns {AggregateModel}
[ "Returns", "a", "new", "aggregate", "model", "to", "be", "used", "in", "the", "command", "and", "event", "functions", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L550-L558
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (cmd, callback) { var cmdName = dotty.get(cmd, this.definitions.command.name); var err; if (!cmdName) { err = new Error('command has no command name in ' + this.definitions.command.name); debug(err); return callback(err); } var version = 0; if (!!this.definitions.com...
javascript
function (cmd, callback) { var cmdName = dotty.get(cmd, this.definitions.command.name); var err; if (!cmdName) { err = new Error('command has no command name in ' + this.definitions.command.name); debug(err); return callback(err); } var version = 0; if (!!this.definitions.com...
[ "function", "(", "cmd", ",", "callback", ")", "{", "var", "cmdName", "=", "dotty", ".", "get", "(", "cmd", ",", "this", ".", "definitions", ".", "command", ".", "name", ")", ";", "var", "err", ";", "if", "(", "!", "cmdName", ")", "{", "err", "=",...
Validates the requested command. @param {Object} cmd The command object @returns {ValidationError}
[ "Validates", "the", "requested", "command", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L565-L596
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (cmd, callback) { var cmdName = dotty.get(cmd, this.definitions.command.name); if (!cmdName) { var err = new Error('command has no command name in ' + this.definitions.command.name); debug(err); throw err; } var version = 0; if (!!this.definitions.command.version) { ...
javascript
function (cmd, callback) { var cmdName = dotty.get(cmd, this.definitions.command.name); if (!cmdName) { var err = new Error('command has no command name in ' + this.definitions.command.name); debug(err); throw err; } var version = 0; if (!!this.definitions.command.version) { ...
[ "function", "(", "cmd", ",", "callback", ")", "{", "var", "cmdName", "=", "dotty", ".", "get", "(", "cmd", ",", "this", ".", "definitions", ".", "command", ".", "name", ")", ";", "if", "(", "!", "cmdName", ")", "{", "var", "err", "=", "new", "Err...
Checks for pre-load-conditions. This check will be done BEFORE the aggregate is locked and loaded. @param {Object} cmd The command that was handled. @param {Function} callback The function, that will be called when this action is completed. `function(err){}`
[ "Checks", "for", "pre", "-", "load", "-", "conditions", ".", "This", "check", "will", "be", "done", "BEFORE", "the", "aggregate", "is", "locked", "and", "loaded", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L603-L625
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (changed, previous, events, command, callback) { async.eachSeries(this.getBusinessRules(), function (rule, callback) { rule.check(changed, previous, events, command, callback); }, callback); }
javascript
function (changed, previous, events, command, callback) { async.eachSeries(this.getBusinessRules(), function (rule, callback) { rule.check(changed, previous, events, command, callback); }, callback); }
[ "function", "(", "changed", ",", "previous", ",", "events", ",", "command", ",", "callback", ")", "{", "async", ".", "eachSeries", "(", "this", ".", "getBusinessRules", "(", ")", ",", "function", "(", "rule", ",", "callback", ")", "{", "rule", ".", "ch...
Checks business rules. @param {Object} changed The new aggregate values. @param {Object} previous The previous aggregate values. @param {Array} events All new generated events. @param {Object} command The command that was handled. @param {Function} callback The function, that will be called when this actio...
[ "Checks", "business", "rules", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L667-L671
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (aggregateModel, cmd, callback) { var cmdName = dotty.get(cmd, this.definitions.command.name); if (!cmdName) { var err = new Error('command has no command name in ' + this.definitions.command.name); debug(err); return callback(err); } var version = 0; if (!!this.definitio...
javascript
function (aggregateModel, cmd, callback) { var cmdName = dotty.get(cmd, this.definitions.command.name); if (!cmdName) { var err = new Error('command has no command name in ' + this.definitions.command.name); debug(err); return callback(err); } var version = 0; if (!!this.definitio...
[ "function", "(", "aggregateModel", ",", "cmd", ",", "callback", ")", "{", "var", "cmdName", "=", "dotty", ".", "get", "(", "cmd", ",", "this", ".", "definitions", ".", "command", ".", "name", ")", ";", "if", "(", "!", "cmdName", ")", "{", "var", "e...
Handles the passed command and checks the business rules. @param {AggregateModel} aggregateModel The aggregateModel that should be used. @param {Object} cmd The command that was handled. @param {Function} callback The function, that will be called when this action is completed. `functi...
[ "Handles", "the", "passed", "command", "and", "checks", "the", "business", "rules", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L715-L795
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (events, aggregateModel, notSameOrigin) { if (!events) { return; } if (!_.isArray(events)) { events = [events]; } var self = this; events.forEach(function (evt) { var evtName = dotty.get(evt, self.definitions.event.name); if (!evtName) { var err = new ...
javascript
function (events, aggregateModel, notSameOrigin) { if (!events) { return; } if (!_.isArray(events)) { events = [events]; } var self = this; events.forEach(function (evt) { var evtName = dotty.get(evt, self.definitions.event.name); if (!evtName) { var err = new ...
[ "function", "(", "events", ",", "aggregateModel", ",", "notSameOrigin", ")", "{", "if", "(", "!", "events", ")", "{", "return", ";", "}", "if", "(", "!", "_", ".", "isArray", "(", "events", ")", ")", "{", "events", "=", "[", "events", "]", ";", "...
Applies the passed events to the passed aggregateModel. @param {Array || Object} events The events that should be applied. @param {AggregateModel} aggregateModel The aggregateModel that should be used. @param {boolean} notSameOrigin If true it's an indication to not throw if event handler not found.
[ "Applies", "the", "passed", "events", "to", "the", "passed", "aggregateModel", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L803-L841
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (aggregateModel, snapshot, events, loadingTime, stream, streams, notSameOrigin) { var self = this; var isSnapshotNeeded = false; if (snapshot) { // load snapshot debug('load snapshot ' + snapshot.id + ' from history', _.pick(snapshot, ['context', 'aggregate', 'version']), { co...
javascript
function (aggregateModel, snapshot, events, loadingTime, stream, streams, notSameOrigin) { var self = this; var isSnapshotNeeded = false; if (snapshot) { // load snapshot debug('load snapshot ' + snapshot.id + ' from history', _.pick(snapshot, ['context', 'aggregate', 'version']), { co...
[ "function", "(", "aggregateModel", ",", "snapshot", ",", "events", ",", "loadingTime", ",", "stream", ",", "streams", ",", "notSameOrigin", ")", "{", "var", "self", "=", "this", ";", "var", "isSnapshotNeeded", "=", "false", ";", "if", "(", "snapshot", ")",...
Loads the aggregateModel with the data of the snapshot and the events. And returns true if a new snapshot should be done. @param {AggregateModel} aggregateModel The aggregateModel that should be used. @param {Object} snapshot The snapshot object. @param {Array} events The events that s...
[ "Loads", "the", "aggregateModel", "with", "the", "data", "of", "the", "snapshot", "and", "the", "events", ".", "And", "returns", "true", "if", "a", "new", "snapshot", "should", "be", "done", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L855-L919
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (meta, fn) { if (!_.isObject(meta) || meta.version === undefined || meta.version === null || !_.isNumber(meta.version)) { throw new Error('Please pass in a version'); } if (!_.isFunction(fn)) { throw new Error('Please pass in a function'); } var wrappedFn; if (fn.length ===...
javascript
function (meta, fn) { if (!_.isObject(meta) || meta.version === undefined || meta.version === null || !_.isNumber(meta.version)) { throw new Error('Please pass in a version'); } if (!_.isFunction(fn)) { throw new Error('Please pass in a function'); } var wrappedFn; if (fn.length ===...
[ "function", "(", "meta", ",", "fn", ")", "{", "if", "(", "!", "_", ".", "isObject", "(", "meta", ")", "||", "meta", ".", "version", "===", "undefined", "||", "meta", ".", "version", "===", "null", "||", "!", "_", ".", "isNumber", "(", "meta", "."...
Defines a new loading transform function for snapshot. @param {Object} meta Meta infos like: { version: 10 } @param {Function} fn Function containing the transform function `function(snapshotData, callback){}` @returns {Aggregate}
[ "Defines", "a", "new", "loading", "transform", "function", "for", "snapshot", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L928-L951
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (loadingTime, events) { var snapshotThreshold = 100; if (this.options.snapshotThreshold) { snapshotThreshold = this.options.snapshotThreshold; } if (this.options.snapshotThresholdMs) { return loadingTime >= this.options.snapshotThresholdMs; } return events.length >= snapsh...
javascript
function (loadingTime, events) { var snapshotThreshold = 100; if (this.options.snapshotThreshold) { snapshotThreshold = this.options.snapshotThreshold; } if (this.options.snapshotThresholdMs) { return loadingTime >= this.options.snapshotThresholdMs; } return events.length >= snapsh...
[ "function", "(", "loadingTime", ",", "events", ")", "{", "var", "snapshotThreshold", "=", "100", ";", "if", "(", "this", ".", "options", ".", "snapshotThreshold", ")", "{", "snapshotThreshold", "=", "this", ".", "options", ".", "snapshotThreshold", ";", "}",...
Returns true if a new snapshot should be done. @param {Number} loadingTime The loading time in ms of the eventstore data. @param {Array} events The loaded events. @param {Object} aggregateModel The aggregate json object. [could be used for other algorithms] @param {Array} streams All loaded eventstr...
[ "Returns", "true", "if", "a", "new", "snapshot", "should", "be", "done", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L993-L1004
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (snapshot) { if (!this.snapshotIgnores[snapshot.version]) { return false; } return this.snapshotIgnores[snapshot.version](snapshot.data); }
javascript
function (snapshot) { if (!this.snapshotIgnores[snapshot.version]) { return false; } return this.snapshotIgnores[snapshot.version](snapshot.data); }
[ "function", "(", "snapshot", ")", "{", "if", "(", "!", "this", ".", "snapshotIgnores", "[", "snapshot", ".", "version", "]", ")", "{", "return", "false", ";", "}", "return", "this", ".", "snapshotIgnores", "[", "snapshot", ".", "version", "]", "(", "sn...
Checks if a snapshot should be ignored. @param {Object} snapshot The the snapshot. @returns {boolean}
[ "Checks", "if", "a", "snapshot", "should", "be", "ignored", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L1011-L1017
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (meta, fn) { if (!_.isObject(meta) || meta.version === undefined || meta.version === null || !_.isNumber(meta.version)) { throw new Error('Please pass in a version'); } if (!_.isFunction(fn)) { throw new Error('Please pass in a function'); } this.snapshotConversionRegistrations...
javascript
function (meta, fn) { if (!_.isObject(meta) || meta.version === undefined || meta.version === null || !_.isNumber(meta.version)) { throw new Error('Please pass in a version'); } if (!_.isFunction(fn)) { throw new Error('Please pass in a function'); } this.snapshotConversionRegistrations...
[ "function", "(", "meta", ",", "fn", ")", "{", "if", "(", "!", "_", ".", "isObject", "(", "meta", ")", "||", "meta", ".", "version", "===", "undefined", "||", "meta", ".", "version", "===", "null", "||", "!", "_", ".", "isNumber", "(", "meta", "."...
Defines a new conversion function for older snapshot versions. @param {Object} meta Meta infos like: { version: 10 } @param {Function} fn Function containing the conversion rule `function(snapshotData, aggregateModel){}` @returns {Aggregate}
[ "Defines", "a", "new", "conversion", "function", "for", "older", "snapshot", "versions", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L1040-L1050
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (meta, fn) { if (!_.isObject(meta) || meta.version === undefined || meta.version === null || !_.isNumber(meta.version)) { throw new Error('Please pass in a version'); } if (!fn) { this.snapshotIgnores[meta.version] = function () { return true; }; return this; } ...
javascript
function (meta, fn) { if (!_.isObject(meta) || meta.version === undefined || meta.version === null || !_.isNumber(meta.version)) { throw new Error('Please pass in a version'); } if (!fn) { this.snapshotIgnores[meta.version] = function () { return true; }; return this; } ...
[ "function", "(", "meta", ",", "fn", ")", "{", "if", "(", "!", "_", ".", "isObject", "(", "meta", ")", "||", "meta", ".", "version", "===", "undefined", "||", "meta", ".", "version", "===", "null", "||", "!", "_", ".", "isNumber", "(", "meta", "."...
Defines a if a snapshot should be ignored. -> if true it will loads all events @param {Object} meta Meta infos like: { version: 10 } @param {Function} fn Function containing the check function [optional], default return true `function(snapshotData){ return true; }` @returns {Aggregate}
[ "Defines", "a", "if", "a", "snapshot", "should", "be", "ignored", ".", "-", ">", "if", "true", "it", "will", "loads", "all", "events" ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L1059-L1080
train
adrai/node-cqrs-domain
lib/definitions/aggregate.js
function (fn) { if (fn.length === 0) throw new Error('Please define your function to accept the command!'); if (fn.length === 1) { var orgFn = fn; fn = function(cmd, callback) { callback(null, orgFn(cmd)); }; } this.getNewAggregateId = fn; return this; }
javascript
function (fn) { if (fn.length === 0) throw new Error('Please define your function to accept the command!'); if (fn.length === 1) { var orgFn = fn; fn = function(cmd, callback) { callback(null, orgFn(cmd)); }; } this.getNewAggregateId = fn; return this; }
[ "function", "(", "fn", ")", "{", "if", "(", "fn", ".", "length", "===", "0", ")", "throw", "new", "Error", "(", "'Please define your function to accept the command!'", ")", ";", "if", "(", "fn", ".", "length", "===", "1", ")", "{", "var", "orgFn", "=", ...
Inject idGenerator function for aggregate id that is command aware. @param {Function} fn The function to be injected. @returns {Aggregate} to be able to chain...
[ "Inject", "idGenerator", "function", "for", "aggregate", "id", "that", "is", "command", "aware", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/aggregate.js#L1105-L1117
train
adrai/node-cqrs-domain
lib/definitions/command.js
function (preCond) { if (!preCond || !_.isObject(preCond)) { var err = new Error('Please inject a valid preCondition object!'); debug(err); throw err; } if (!preCond.payload && preCond.payload !== '') { preCond.payload = this.aggregate.defaultPreConditionPayload; } if (this...
javascript
function (preCond) { if (!preCond || !_.isObject(preCond)) { var err = new Error('Please inject a valid preCondition object!'); debug(err); throw err; } if (!preCond.payload && preCond.payload !== '') { preCond.payload = this.aggregate.defaultPreConditionPayload; } if (this...
[ "function", "(", "preCond", ")", "{", "if", "(", "!", "preCond", "||", "!", "_", ".", "isObject", "(", "preCond", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please inject a valid preCondition object!'", ")", ";", "debug", "(", "err", ")", ...
Injects the pre-condition function. @param {Function} preCond The pre-condition function that should be injected
[ "Injects", "the", "pre", "-", "condition", "function", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/command.js#L67-L85
train
adrai/node-cqrs-domain
lib/definitions/command.js
function (preLoadCond) { if (!preLoadCond || !_.isObject(preLoadCond)) { var err = new Error('Please inject a valid preCondition object!'); debug(err); throw err; } if (!preLoadCond.payload) { preLoadCond.payload = this.aggregate.defaultPreLoadConditionPayload; } if (this.p...
javascript
function (preLoadCond) { if (!preLoadCond || !_.isObject(preLoadCond)) { var err = new Error('Please inject a valid preCondition object!'); debug(err); throw err; } if (!preLoadCond.payload) { preLoadCond.payload = this.aggregate.defaultPreLoadConditionPayload; } if (this.p...
[ "function", "(", "preLoadCond", ")", "{", "if", "(", "!", "preLoadCond", "||", "!", "_", ".", "isObject", "(", "preLoadCond", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please inject a valid preCondition object!'", ")", ";", "debug", "(", "er...
Injects the pre-load-condition function. @param {Function} preLoadCond The pre-load-condition function that should be injected
[ "Injects", "the", "pre", "-", "load", "-", "condition", "function", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/command.js#L91-L109
train
adrai/node-cqrs-domain
lib/definitions/command.js
function (validator) { if (!_.isFunction(validator)) { var err = new Error('Please pass in a function'); debug(err); throw err; } if (validator.length == 2) { return this.validator = validator; } this.validator = function (data, callback) { callback(validator(data)); ...
javascript
function (validator) { if (!_.isFunction(validator)) { var err = new Error('Please pass in a function'); debug(err); throw err; } if (validator.length == 2) { return this.validator = validator; } this.validator = function (data, callback) { callback(validator(data)); ...
[ "function", "(", "validator", ")", "{", "if", "(", "!", "_", ".", "isFunction", "(", "validator", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass in a function'", ")", ";", "debug", "(", "err", ")", ";", "throw", "err", ";", "}",...
Injects the validator function. @param {Function} validator The validator function that should be injected
[ "Injects", "the", "validator", "function", "." ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/command.js#L115-L130
train
adrai/node-cqrs-domain
lib/definitions/command.js
function (cmd, callback) { if (this.preLoadConditions.length === 0) { debug('no pre-load-condition for ' + this.name); return callback(null); } var self = this; async.eachSeries(this.preLoadConditions, function (preLoadCondition, callback) { if (preLoadCondition.version === undefined ...
javascript
function (cmd, callback) { if (this.preLoadConditions.length === 0) { debug('no pre-load-condition for ' + this.name); return callback(null); } var self = this; async.eachSeries(this.preLoadConditions, function (preLoadCondition, callback) { if (preLoadCondition.version === undefined ...
[ "function", "(", "cmd", ",", "callback", ")", "{", "if", "(", "this", ".", "preLoadConditions", ".", "length", "===", "0", ")", "{", "debug", "(", "'no pre-load-condition for '", "+", "this", ".", "name", ")", ";", "return", "callback", "(", "null", ")",...
Checks for pre-load conditions @param {Object} cmd The command object. @param {Function} callback The function, that will be called when this action is completed. `function(err){}`
[ "Checks", "for", "pre", "-", "load", "conditions" ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/command.js#L151-L164
train
adrai/node-cqrs-domain
lib/definitions/command.js
function (cmd, aggregateModel, callback) { if (this.existing === true && aggregateModel.get('_revision') === 0) { var err = new BusinessRuleError('This command only wants to be handled, if aggregate already existing!', { type: 'AggregateNotExisting', aggregateId: aggregateModel.id, agg...
javascript
function (cmd, aggregateModel, callback) { if (this.existing === true && aggregateModel.get('_revision') === 0) { var err = new BusinessRuleError('This command only wants to be handled, if aggregate already existing!', { type: 'AggregateNotExisting', aggregateId: aggregateModel.id, agg...
[ "function", "(", "cmd", ",", "aggregateModel", ",", "callback", ")", "{", "if", "(", "this", ".", "existing", "===", "true", "&&", "aggregateModel", ".", "get", "(", "'_revision'", ")", "===", "0", ")", "{", "var", "err", "=", "new", "BusinessRuleError",...
Checks for pre-conditions @param {Object} cmd The command object. @param {AggregateModel} aggregateModel The aggregate object. @param {Function} callback The function, that will be called when this action is completed. `function(err){}`
[ "Checks", "for", "pre", "-", "conditions" ]
4e70105b11a444b02c12f2850c61242b4998361c
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/command.js#L173-L206
train
jshttp/etag
index.js
entitytag
function entitytag (entity) { if (entity.length === 0) { // fast-path empty return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"' } // compute hash of entity var hash = crypto .createHash('sha1') .update(entity, 'utf8') .digest('base64') .substring(0, 27) // compute length of entity var len = t...
javascript
function entitytag (entity) { if (entity.length === 0) { // fast-path empty return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"' } // compute hash of entity var hash = crypto .createHash('sha1') .update(entity, 'utf8') .digest('base64') .substring(0, 27) // compute length of entity var len = t...
[ "function", "entitytag", "(", "entity", ")", "{", "if", "(", "entity", ".", "length", "===", "0", ")", "{", "// fast-path empty", "return", "'\"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk\"'", "}", "// compute hash of entity", "var", "hash", "=", "crypto", ".", "createHash", "(...
Generate an entity tag. @param {Buffer|string} entity @return {string} @private
[ "Generate", "an", "entity", "tag", "." ]
4664b6e53c85a56521076f9c5004dd9626ae10c8
https://github.com/jshttp/etag/blob/4664b6e53c85a56521076f9c5004dd9626ae10c8/index.js#L39-L58
train
jshttp/etag
index.js
etag
function etag (entity, options) { if (entity == null) { throw new TypeError('argument entity is required') } // support fs.Stats object var isStats = isstats(entity) var weak = options && typeof options.weak === 'boolean' ? options.weak : isStats // validate argument if (!isStats && typeof e...
javascript
function etag (entity, options) { if (entity == null) { throw new TypeError('argument entity is required') } // support fs.Stats object var isStats = isstats(entity) var weak = options && typeof options.weak === 'boolean' ? options.weak : isStats // validate argument if (!isStats && typeof e...
[ "function", "etag", "(", "entity", ",", "options", ")", "{", "if", "(", "entity", "==", "null", ")", "{", "throw", "new", "TypeError", "(", "'argument entity is required'", ")", "}", "// support fs.Stats object", "var", "isStats", "=", "isstats", "(", "entity"...
Create a simple ETag. @param {string|Buffer|Stats} entity @param {object} [options] @param {boolean} [options.weak] @return {String} @public
[ "Create", "a", "simple", "ETag", "." ]
4664b6e53c85a56521076f9c5004dd9626ae10c8
https://github.com/jshttp/etag/blob/4664b6e53c85a56521076f9c5004dd9626ae10c8/index.js#L70-L94
train
jshttp/etag
index.js
isstats
function isstats (obj) { // genuine fs.Stats if (typeof Stats === 'function' && obj instanceof Stats) { return true } // quack quack return obj && typeof obj === 'object' && 'ctime' in obj && toString.call(obj.ctime) === '[object Date]' && 'mtime' in obj && toString.call(obj.mtime) === '[object D...
javascript
function isstats (obj) { // genuine fs.Stats if (typeof Stats === 'function' && obj instanceof Stats) { return true } // quack quack return obj && typeof obj === 'object' && 'ctime' in obj && toString.call(obj.ctime) === '[object Date]' && 'mtime' in obj && toString.call(obj.mtime) === '[object D...
[ "function", "isstats", "(", "obj", ")", "{", "// genuine fs.Stats", "if", "(", "typeof", "Stats", "===", "'function'", "&&", "obj", "instanceof", "Stats", ")", "{", "return", "true", "}", "// quack quack", "return", "obj", "&&", "typeof", "obj", "===", "'obj...
Determine if object is a Stats object. @param {object} obj @return {boolean} @api private
[ "Determine", "if", "object", "is", "a", "Stats", "object", "." ]
4664b6e53c85a56521076f9c5004dd9626ae10c8
https://github.com/jshttp/etag/blob/4664b6e53c85a56521076f9c5004dd9626ae10c8/index.js#L104-L116
train
jshttp/etag
index.js
stattag
function stattag (stat) { var mtime = stat.mtime.getTime().toString(16) var size = stat.size.toString(16) return '"' + size + '-' + mtime + '"' }
javascript
function stattag (stat) { var mtime = stat.mtime.getTime().toString(16) var size = stat.size.toString(16) return '"' + size + '-' + mtime + '"' }
[ "function", "stattag", "(", "stat", ")", "{", "var", "mtime", "=", "stat", ".", "mtime", ".", "getTime", "(", ")", ".", "toString", "(", "16", ")", "var", "size", "=", "stat", ".", "size", ".", "toString", "(", "16", ")", "return", "'\"'", "+", "...
Generate a tag for a stat. @param {object} stat @return {string} @private
[ "Generate", "a", "tag", "for", "a", "stat", "." ]
4664b6e53c85a56521076f9c5004dd9626ae10c8
https://github.com/jshttp/etag/blob/4664b6e53c85a56521076f9c5004dd9626ae10c8/index.js#L126-L131
train
epoberezkin/ajv-keywords
index.js
defineKeywords
function defineKeywords(ajv, keyword) { if (Array.isArray(keyword)) { for (var i=0; i<keyword.length; i++) get(keyword[i])(ajv); return ajv; } if (keyword) { get(keyword)(ajv); return ajv; } for (keyword in KEYWORDS) get(keyword)(ajv); return ajv; }
javascript
function defineKeywords(ajv, keyword) { if (Array.isArray(keyword)) { for (var i=0; i<keyword.length; i++) get(keyword[i])(ajv); return ajv; } if (keyword) { get(keyword)(ajv); return ajv; } for (keyword in KEYWORDS) get(keyword)(ajv); return ajv; }
[ "function", "defineKeywords", "(", "ajv", ",", "keyword", ")", "{", "if", "(", "Array", ".", "isArray", "(", "keyword", ")", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "keyword", ".", "length", ";", "i", "++", ")", "get", "(", "...
Defines one or several keywords in ajv instance @param {Ajv} ajv validator instance @param {String|Array<String>|undefined} keyword keyword(s) to define @return {Ajv} ajv instance (for chaining)
[ "Defines", "one", "or", "several", "keywords", "in", "ajv", "instance" ]
9ebcae203fac7a78c391bfc7076497f591fe0be6
https://github.com/epoberezkin/ajv-keywords/blob/9ebcae203fac7a78c391bfc7076497f591fe0be6/index.js#L14-L26
train
efeiefei/node-file-manager
lib/public/js/angular-file.js
function(file) { var deferred = $q.defer(); var reader = angular.extend(new FileReader(), { onload: function(e) { deferred.resolve(e.target.result); if (!$rootScope.$$phase) $rootScope.$apply(); }, onerror: function(e) { deferred.reject(e); if...
javascript
function(file) { var deferred = $q.defer(); var reader = angular.extend(new FileReader(), { onload: function(e) { deferred.resolve(e.target.result); if (!$rootScope.$$phase) $rootScope.$apply(); }, onerror: function(e) { deferred.reject(e); if...
[ "function", "(", "file", ")", "{", "var", "deferred", "=", "$q", ".", "defer", "(", ")", ";", "var", "reader", "=", "angular", ".", "extend", "(", "new", "FileReader", "(", ")", ",", "{", "onload", ":", "function", "(", "e", ")", "{", "deferred", ...
Loads a file as a data URL and returns a promise representing the file's value.
[ "Loads", "a", "file", "as", "a", "data", "URL", "and", "returns", "a", "promise", "representing", "the", "file", "s", "value", "." ]
b28dd01f22796658d245d7a3a9c05f784c4b959e
https://github.com/efeiefei/node-file-manager/blob/b28dd01f22796658d245d7a3a9c05f784c4b959e/lib/public/js/angular-file.js#L128-L151
train
efeiefei/node-file-manager
lib/public/js/angular-file.js
function(file) { return { name: file.name, size: file.size, lastModifiedDate: file.lastModifiedDate }; }
javascript
function(file) { return { name: file.name, size: file.size, lastModifiedDate: file.lastModifiedDate }; }
[ "function", "(", "file", ")", "{", "return", "{", "name", ":", "file", ".", "name", ",", "size", ":", "file", ".", "size", ",", "lastModifiedDate", ":", "file", ".", "lastModifiedDate", "}", ";", "}" ]
Returns the metadata from a File object, including the name, size and last modified date.
[ "Returns", "the", "metadata", "from", "a", "File", "object", "including", "the", "name", "size", "and", "last", "modified", "date", "." ]
b28dd01f22796658d245d7a3a9c05f784c4b959e
https://github.com/efeiefei/node-file-manager/blob/b28dd01f22796658d245d7a3a9c05f784c4b959e/lib/public/js/angular-file.js#L156-L162
train
efeiefei/node-file-manager
lib/public/js/angular-file.js
function(data) { var extras = {}; if (data instanceof File) { extras = this.meta(data); data = data.toDataURL(); } var parts = data.split(","), headers = parts[0].split(":"), body; if (parts.length !== 2 || headers.length !== 2 || headers[0] !== "data") { throw ne...
javascript
function(data) { var extras = {}; if (data instanceof File) { extras = this.meta(data); data = data.toDataURL(); } var parts = data.split(","), headers = parts[0].split(":"), body; if (parts.length !== 2 || headers.length !== 2 || headers[0] !== "data") { throw ne...
[ "function", "(", "data", ")", "{", "var", "extras", "=", "{", "}", ";", "if", "(", "data", "instanceof", "File", ")", "{", "extras", "=", "this", ".", "meta", "(", "data", ")", ";", "data", "=", "data", ".", "toDataURL", "(", ")", ";", "}", "va...
Converts a File object or data URL to a Blob.
[ "Converts", "a", "File", "object", "or", "data", "URL", "to", "a", "Blob", "." ]
b28dd01f22796658d245d7a3a9c05f784c4b959e
https://github.com/efeiefei/node-file-manager/blob/b28dd01f22796658d245d7a3a9c05f784c4b959e/lib/public/js/angular-file.js#L167-L187
train
Zod-/jsVideoUrlParser
lib/util.js
getLetterTime
function getLetterTime(timeString) { var totalSeconds = 0; var timeValues = { 's': 1, 'm': 1 * 60, 'h': 1 * 60 * 60, 'd': 1 * 60 * 60 * 24, 'w': 1 * 60 * 60 * 24 * 7, }; var timePairs; //expand to "1 h 30 m 20 s" and split timeString = timeString.replace(/([smhdw])/g, ' $1 ').trim(); ...
javascript
function getLetterTime(timeString) { var totalSeconds = 0; var timeValues = { 's': 1, 'm': 1 * 60, 'h': 1 * 60 * 60, 'd': 1 * 60 * 60 * 24, 'w': 1 * 60 * 60 * 24 * 7, }; var timePairs; //expand to "1 h 30 m 20 s" and split timeString = timeString.replace(/([smhdw])/g, ' $1 ').trim(); ...
[ "function", "getLetterTime", "(", "timeString", ")", "{", "var", "totalSeconds", "=", "0", ";", "var", "timeValues", "=", "{", "'s'", ":", "1", ",", "'m'", ":", "1", "*", "60", ",", "'h'", ":", "1", "*", "60", "*", "60", ",", "'d'", ":", "1", "...
parses strings like 1h30m20s to seconds
[ "parses", "strings", "like", "1h30m20s", "to", "seconds" ]
4f819a536f57413f784f2a78ff826b605722e275
https://github.com/Zod-/jsVideoUrlParser/blob/4f819a536f57413f784f2a78ff826b605722e275/lib/util.js#L55-L75
train
esvit/ng-table
scripts/webpack/libParts.js
extractSass
function extractSass(files) { // note: The way we're setting up webpack here seems a bit of a hack: // // Although the setup creates two bundles seperating the js and css as desired, // it's also producing an extra styles.js file which we're throwing away/ignoring. // The alter...
javascript
function extractSass(files) { // note: The way we're setting up webpack here seems a bit of a hack: // // Although the setup creates two bundles seperating the js and css as desired, // it's also producing an extra styles.js file which we're throwing away/ignoring. // The alter...
[ "function", "extractSass", "(", "files", ")", "{", "// note: The way we're setting up webpack here seems a bit of a hack:", "//", "// Although the setup creates two bundles seperating the js and css as desired,", "// it's also producing an extra styles.js file which we're throwing away/ignoring."...
Extracts styles into a seperate bundle
[ "Extracts", "styles", "into", "a", "seperate", "bundle" ]
b6d5d0bfeef923c617081ffe80a0266d7fb4aa33
https://github.com/esvit/ng-table/blob/b6d5d0bfeef923c617081ffe80a0266d7fb4aa33/scripts/webpack/libParts.js#L65-L103
train
mapbox/tilelive
lib/stream-pyramid.js
nextShallow
function nextShallow(stream) { if (!stream.cursor) return false; var cursor = stream.cursor; cursor.x++; var bbox = stream.bboxes[cursor.z]; if (cursor.x > bbox.maxX) { cursor.x = bbox.minX; cursor.y++; } if (cursor.y > bbox.maxY) { stream.cursor = false; retu...
javascript
function nextShallow(stream) { if (!stream.cursor) return false; var cursor = stream.cursor; cursor.x++; var bbox = stream.bboxes[cursor.z]; if (cursor.x > bbox.maxX) { cursor.x = bbox.minX; cursor.y++; } if (cursor.y > bbox.maxY) { stream.cursor = false; retu...
[ "function", "nextShallow", "(", "stream", ")", "{", "if", "(", "!", "stream", ".", "cursor", ")", "return", "false", ";", "var", "cursor", "=", "stream", ".", "cursor", ";", "cursor", ".", "x", "++", ";", "var", "bbox", "=", "stream", ".", "bboxes", ...
Increment a tile cursor to the next position on the lowest zoom level.
[ "Increment", "a", "tile", "cursor", "to", "the", "next", "position", "on", "the", "lowest", "zoom", "level", "." ]
8a37d89dd6e9fb0f6938e1c6ccf62349556c9375
https://github.com/mapbox/tilelive/blob/8a37d89dd6e9fb0f6938e1c6ccf62349556c9375/lib/stream-pyramid.js#L172-L186
train
mapbox/tilelive
lib/stream-scanline.js
nextDeep
function nextDeep(stream) { if (!stream.cursor) return false; var cursor = stream.cursor; cursor.x++; var bbox = stream.bboxes[cursor.z]; if (cursor.x > bbox.maxX) { cursor.x = bbox.minX; cursor.y++; } if (cursor.y > bbox.maxY) { cursor.z++; if (cursor.z > str...
javascript
function nextDeep(stream) { if (!stream.cursor) return false; var cursor = stream.cursor; cursor.x++; var bbox = stream.bboxes[cursor.z]; if (cursor.x > bbox.maxX) { cursor.x = bbox.minX; cursor.y++; } if (cursor.y > bbox.maxY) { cursor.z++; if (cursor.z > str...
[ "function", "nextDeep", "(", "stream", ")", "{", "if", "(", "!", "stream", ".", "cursor", ")", "return", "false", ";", "var", "cursor", "=", "stream", ".", "cursor", ";", "cursor", ".", "x", "++", ";", "var", "bbox", "=", "stream", ".", "bboxes", "...
Increment a tile cursor to the next position, descending zoom levels until maxzoom is reached.
[ "Increment", "a", "tile", "cursor", "to", "the", "next", "position", "descending", "zoom", "levels", "until", "maxzoom", "is", "reached", "." ]
8a37d89dd6e9fb0f6938e1c6ccf62349556c9375
https://github.com/mapbox/tilelive/blob/8a37d89dd6e9fb0f6938e1c6ccf62349556c9375/lib/stream-scanline.js#L129-L149
train
mapbox/tilelive
lib/stream-util.js
multiread
function multiread(stream, get) { if (stream._multiread === undefined) { stream._multiread = stream._multiread || []; stream._multireading = stream._multireading || 0; stream._multireadmax = stream._multireadmax || concurrency; } if (stream._multiread.length) { push(); } ...
javascript
function multiread(stream, get) { if (stream._multiread === undefined) { stream._multiread = stream._multiread || []; stream._multireading = stream._multireading || 0; stream._multireadmax = stream._multireadmax || concurrency; } if (stream._multiread.length) { push(); } ...
[ "function", "multiread", "(", "stream", ",", "get", ")", "{", "if", "(", "stream", ".", "_multiread", "===", "undefined", ")", "{", "stream", ".", "_multiread", "=", "stream", ".", "_multiread", "||", "[", "]", ";", "stream", ".", "_multireading", "=", ...
Helper utility for _read functions. Pass your stream object and a getter that can be called concurrently and it will concurrently call your getter behind the scenes and manage the endstate of the stream.
[ "Helper", "utility", "for", "_read", "functions", ".", "Pass", "your", "stream", "object", "and", "a", "getter", "that", "can", "be", "called", "concurrently", "and", "it", "will", "concurrently", "call", "your", "getter", "behind", "the", "scenes", "and", "...
8a37d89dd6e9fb0f6938e1c6ccf62349556c9375
https://github.com/mapbox/tilelive/blob/8a37d89dd6e9fb0f6938e1c6ccf62349556c9375/lib/stream-util.js#L167-L200
train
sc-forks/solidity-coverage
lib/preprocessor.js
blockWrap
function blockWrap(contract, expression) { return contract.slice(0, expression.start) + '{' + contract.slice(expression.start, expression.end) + '}' + contract.slice(expression.end); }
javascript
function blockWrap(contract, expression) { return contract.slice(0, expression.start) + '{' + contract.slice(expression.start, expression.end) + '}' + contract.slice(expression.end); }
[ "function", "blockWrap", "(", "contract", ",", "expression", ")", "{", "return", "contract", ".", "slice", "(", "0", ",", "expression", ".", "start", ")", "+", "'{'", "+", "contract", ".", "slice", "(", "expression", ".", "start", ",", "expression", ".",...
Splices enclosing brackets into `contract` around `expression`; @param {String} contract solidity source @param {Object} node AST node to bracket @return {String} contract
[ "Splices", "enclosing", "brackets", "into", "contract", "around", "expression", ";" ]
7e18028812849ed4f2e0e7e78558a7b18dfda0e8
https://github.com/sc-forks/solidity-coverage/blob/7e18028812849ed4f2e0e7e78558a7b18dfda0e8/lib/preprocessor.js#L11-L13
train
sc-forks/solidity-coverage
lib/preprocessor.js
getModifierWhitespace
function getModifierWhitespace(contract, modifier){ const source = contract.slice(modifier.start, modifier.end); const whitespace = source.match(crRegex) || []; return whitespace.join(''); }
javascript
function getModifierWhitespace(contract, modifier){ const source = contract.slice(modifier.start, modifier.end); const whitespace = source.match(crRegex) || []; return whitespace.join(''); }
[ "function", "getModifierWhitespace", "(", "contract", ",", "modifier", ")", "{", "const", "source", "=", "contract", ".", "slice", "(", "modifier", ".", "start", ",", "modifier", ".", "end", ")", ";", "const", "whitespace", "=", "source", ".", "match", "("...
Captures carriage returns at modifiers we'll remove. These need to be re-injected into the source to keep line report alignments accurate. @param {String} contract solidity source @param {Object} modifier AST node @return {String} whitespace around the modifier
[ "Captures", "carriage", "returns", "at", "modifiers", "we", "ll", "remove", ".", "These", "need", "to", "be", "re", "-", "injected", "into", "the", "source", "to", "keep", "line", "report", "alignments", "accurate", "." ]
7e18028812849ed4f2e0e7e78558a7b18dfda0e8
https://github.com/sc-forks/solidity-coverage/blob/7e18028812849ed4f2e0e7e78558a7b18dfda0e8/lib/preprocessor.js#L23-L27
train
sc-forks/solidity-coverage
lib/instrumenter.js
createOrAppendInjectionPoint
function createOrAppendInjectionPoint(contract, key, value) { if (contract.injectionPoints[key]) { contract.injectionPoints[key].push(value); } else { contract.injectionPoints[key] = [value]; } }
javascript
function createOrAppendInjectionPoint(contract, key, value) { if (contract.injectionPoints[key]) { contract.injectionPoints[key].push(value); } else { contract.injectionPoints[key] = [value]; } }
[ "function", "createOrAppendInjectionPoint", "(", "contract", ",", "key", ",", "value", ")", "{", "if", "(", "contract", ".", "injectionPoints", "[", "key", "]", ")", "{", "contract", ".", "injectionPoints", "[", "key", "]", ".", "push", "(", "value", ")", ...
These functions work out where in an expression we can inject our instrumenation events.
[ "These", "functions", "work", "out", "where", "in", "an", "expression", "we", "can", "inject", "our", "instrumenation", "events", "." ]
7e18028812849ed4f2e0e7e78558a7b18dfda0e8
https://github.com/sc-forks/solidity-coverage/blob/7e18028812849ed4f2e0e7e78558a7b18dfda0e8/lib/instrumenter.js#L6-L12
train
sitespeedio/browsertime
lib/core/seleniumRunner.js
timeout
async function timeout(promise, ms, errorMessage) { let timer = null; return Promise.race([ new Promise((resolve, reject) => { timer = setTimeout(reject, ms, new BrowserError(errorMessage)); return timer; }), promise.then(value => { clearTimeout(timer); return value; }) ])...
javascript
async function timeout(promise, ms, errorMessage) { let timer = null; return Promise.race([ new Promise((resolve, reject) => { timer = setTimeout(reject, ms, new BrowserError(errorMessage)); return timer; }), promise.then(value => { clearTimeout(timer); return value; }) ])...
[ "async", "function", "timeout", "(", "promise", ",", "ms", ",", "errorMessage", ")", "{", "let", "timer", "=", "null", ";", "return", "Promise", ".", "race", "(", "[", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "timer", "="...
Timeout a promise after ms. Use promise.race to compete about the timeout and the promise. @param {promise} promise - The promise to wait for @param {int} ms - how long in ms to wait for the promise to fininsh @param {string} errorMessage - the error message in the Error if we timeouts
[ "Timeout", "a", "promise", "after", "ms", ".", "Use", "promise", ".", "race", "to", "compete", "about", "the", "timeout", "and", "the", "promise", "." ]
97cefe2a081e2a14d95a19e3a22ab68467988c68
https://github.com/sitespeedio/browsertime/blob/97cefe2a081e2a14d95a19e3a22ab68467988c68/lib/core/seleniumRunner.js#L35-L48
train
sitespeedio/browsertime
browserscripts/timings/rumSpeedIndex.js
function(el, url) { if (url) { var rect = GetElementViewportRect(el); if (rect) { rects.push({'url': url, 'area': rect.area, 'rect': rect}); } } }
javascript
function(el, url) { if (url) { var rect = GetElementViewportRect(el); if (rect) { rects.push({'url': url, 'area': rect.area, 'rect': rect}); } } }
[ "function", "(", "el", ",", "url", ")", "{", "if", "(", "url", ")", "{", "var", "rect", "=", "GetElementViewportRect", "(", "el", ")", ";", "if", "(", "rect", ")", "{", "rects", ".", "push", "(", "{", "'url'", ":", "url", ",", "'area'", ":", "r...
Check a given element to see if it is visible
[ "Check", "a", "given", "element", "to", "see", "if", "it", "is", "visible" ]
97cefe2a081e2a14d95a19e3a22ab68467988c68
https://github.com/sitespeedio/browsertime/blob/97cefe2a081e2a14d95a19e3a22ab68467988c68/browserscripts/timings/rumSpeedIndex.js#L78-L87
train
sitespeedio/browsertime
browserscripts/timings/rumSpeedIndex.js
function() { var timings = {}; var requests = win.performance.getEntriesByType("resource"); for (var i = 0; i < requests.length; i++) timings[requests[i].name] = requests[i].responseEnd; for (var j = 0; j < rects.length; j++) { if (!('tm' in rects[j])) rects[j].tm = tim...
javascript
function() { var timings = {}; var requests = win.performance.getEntriesByType("resource"); for (var i = 0; i < requests.length; i++) timings[requests[i].name] = requests[i].responseEnd; for (var j = 0; j < rects.length; j++) { if (!('tm' in rects[j])) rects[j].tm = tim...
[ "function", "(", ")", "{", "var", "timings", "=", "{", "}", ";", "var", "requests", "=", "win", ".", "performance", ".", "getEntriesByType", "(", "\"resource\"", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "requests", ".", "length", ...
Get the time at which each external resource loaded
[ "Get", "the", "time", "at", "which", "each", "external", "resource", "loaded" ]
97cefe2a081e2a14d95a19e3a22ab68467988c68
https://github.com/sitespeedio/browsertime/blob/97cefe2a081e2a14d95a19e3a22ab68467988c68/browserscripts/timings/rumSpeedIndex.js#L128-L137
train
sitespeedio/browsertime
browserscripts/timings/rumSpeedIndex.js
function() { var paints = {'0':0}; var total = 0; for (var i = 0; i < rects.length; i++) { var tm = firstPaint; if ('tm' in rects[i] && rects[i].tm > firstPaint) tm = rects[i].tm; if (paints[tm] === undefined) paints[tm] = 0; paints[tm] += rects[i].a...
javascript
function() { var paints = {'0':0}; var total = 0; for (var i = 0; i < rects.length; i++) { var tm = firstPaint; if ('tm' in rects[i] && rects[i].tm > firstPaint) tm = rects[i].tm; if (paints[tm] === undefined) paints[tm] = 0; paints[tm] += rects[i].a...
[ "function", "(", ")", "{", "var", "paints", "=", "{", "'0'", ":", "0", "}", ";", "var", "total", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "rects", ".", "length", ";", "i", "++", ")", "{", "var", "tm", "=", "firstPaint...
Sort and group all of the paint rects by time and use them to calculate the visual progress
[ "Sort", "and", "group", "all", "of", "the", "paint", "rects", "by", "time", "and", "use", "them", "to", "calculate", "the", "visual", "progress" ]
97cefe2a081e2a14d95a19e3a22ab68467988c68
https://github.com/sitespeedio/browsertime/blob/97cefe2a081e2a14d95a19e3a22ab68467988c68/browserscripts/timings/rumSpeedIndex.js#L188-L225
train
sitespeedio/browsertime
browserscripts/timings/rumSpeedIndex.js
function() { if (progress.length) { SpeedIndex = 0; var lastTime = 0; var lastProgress = 0; for (var i = 0; i < progress.length; i++) { var elapsed = progress[i].tm - lastTime; if (elapsed > 0 && lastProgress < 1) SpeedIndex += (1 - lastProgress) * e...
javascript
function() { if (progress.length) { SpeedIndex = 0; var lastTime = 0; var lastProgress = 0; for (var i = 0; i < progress.length; i++) { var elapsed = progress[i].tm - lastTime; if (elapsed > 0 && lastProgress < 1) SpeedIndex += (1 - lastProgress) * e...
[ "function", "(", ")", "{", "if", "(", "progress", ".", "length", ")", "{", "SpeedIndex", "=", "0", ";", "var", "lastTime", "=", "0", ";", "var", "lastProgress", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "progress", ".", "l...
Given the visual progress information, Calculate the speed index.
[ "Given", "the", "visual", "progress", "information", "Calculate", "the", "speed", "index", "." ]
97cefe2a081e2a14d95a19e3a22ab68467988c68
https://github.com/sitespeedio/browsertime/blob/97cefe2a081e2a14d95a19e3a22ab68467988c68/browserscripts/timings/rumSpeedIndex.js#L228-L243
train
sitespeedio/browsertime
browserscripts/pageinfo/visualElements.js
toArray
function toArray(arrayLike) { if (arrayLike === undefined || arrayLike === null) { return []; } if (Array.isArray(arrayLike)) { return arrayLike; } return [arrayLike]; }
javascript
function toArray(arrayLike) { if (arrayLike === undefined || arrayLike === null) { return []; } if (Array.isArray(arrayLike)) { return arrayLike; } return [arrayLike]; }
[ "function", "toArray", "(", "arrayLike", ")", "{", "if", "(", "arrayLike", "===", "undefined", "||", "arrayLike", "===", "null", ")", "{", "return", "[", "]", ";", "}", "if", "(", "Array", ".", "isArray", "(", "arrayLike", ")", ")", "{", "return", "a...
When we feed options from the CLI it can be a String or an Array with Strings. Make it easy to treat everything the same.
[ "When", "we", "feed", "options", "from", "the", "CLI", "it", "can", "be", "a", "String", "or", "an", "Array", "with", "Strings", ".", "Make", "it", "easy", "to", "treat", "everything", "the", "same", "." ]
97cefe2a081e2a14d95a19e3a22ab68467988c68
https://github.com/sitespeedio/browsertime/blob/97cefe2a081e2a14d95a19e3a22ab68467988c68/browserscripts/pageinfo/visualElements.js#L14-L22
train
sitespeedio/browsertime
lib/support/browserScript.js
scriptsFromDirectory
async function scriptsFromDirectory(dirpath) { const dir = (await readdir(dirpath)) .map(name => toFullPath(name, dirpath)) .filter(await filters.onlyFiles) .filter(filters.onlyWithExtension('.js')); const result = {}; for (const filepath of dir) { const name = path.basename(filepath, '.js'); ...
javascript
async function scriptsFromDirectory(dirpath) { const dir = (await readdir(dirpath)) .map(name => toFullPath(name, dirpath)) .filter(await filters.onlyFiles) .filter(filters.onlyWithExtension('.js')); const result = {}; for (const filepath of dir) { const name = path.basename(filepath, '.js'); ...
[ "async", "function", "scriptsFromDirectory", "(", "dirpath", ")", "{", "const", "dir", "=", "(", "await", "readdir", "(", "dirpath", ")", ")", ".", "map", "(", "name", "=>", "toFullPath", "(", "name", ",", "dirpath", ")", ")", ".", "filter", "(", "awai...
Read all JavaScript files in a specific dir. Will use the filename without .js as the name of the script. @param {*} dirpath
[ "Read", "all", "JavaScript", "files", "in", "a", "specific", "dir", ".", "Will", "use", "the", "filename", "without", ".", "js", "as", "the", "name", "of", "the", "script", "." ]
97cefe2a081e2a14d95a19e3a22ab68467988c68
https://github.com/sitespeedio/browsertime/blob/97cefe2a081e2a14d95a19e3a22ab68467988c68/lib/support/browserScript.js#L21-L33
train
sitespeedio/browsertime
lib/support/browserScript.js
findAndParseScripts
async function findAndParseScripts(root, category) { async function scriptsFromDirectory(dirpath) { const dir = (await readdir(dirpath)) .map(name => toFullPath(name, dirpath)) .filter(await filters.onlyFiles) .filter(filters.onlyWithExtension('.js')); const result = {}; for (const filep...
javascript
async function findAndParseScripts(root, category) { async function scriptsFromDirectory(dirpath) { const dir = (await readdir(dirpath)) .map(name => toFullPath(name, dirpath)) .filter(await filters.onlyFiles) .filter(filters.onlyWithExtension('.js')); const result = {}; for (const filep...
[ "async", "function", "findAndParseScripts", "(", "root", ",", "category", ")", "{", "async", "function", "scriptsFromDirectory", "(", "dirpath", ")", "{", "const", "dir", "=", "(", "await", "readdir", "(", "dirpath", ")", ")", ".", "map", "(", "name", "=>"...
Parse a file or directory, and return an object representing that groups scripts by category. Single js files will be put into the category 'custom', for directories the category name will be taken from the directory name. The resulting value looks like this: <pre> { 'category': { 'script': <contents of script.js> } }...
[ "Parse", "a", "file", "or", "directory", "and", "return", "an", "object", "representing", "that", "groups", "scripts", "by", "category", ".", "Single", "js", "files", "will", "be", "put", "into", "the", "category", "custom", "for", "directories", "the", "cat...
97cefe2a081e2a14d95a19e3a22ab68467988c68
https://github.com/sitespeedio/browsertime/blob/97cefe2a081e2a14d95a19e3a22ab68467988c68/lib/support/browserScript.js#L66-L108
train
nagix/chartjs-plugin-streaming
src/scales/scale.realtime.js
toTimestamp
function toTimestamp(scale, input) { var adapter = scale._adapter || defaultAdapter; var options = scale.options.time; var parser = options.parser; var format = parser || options.format; var value = input; if (typeof parser === 'function') { value = parser(value); } // Only parse if its not a timestamp alre...
javascript
function toTimestamp(scale, input) { var adapter = scale._adapter || defaultAdapter; var options = scale.options.time; var parser = options.parser; var format = parser || options.format; var value = input; if (typeof parser === 'function') { value = parser(value); } // Only parse if its not a timestamp alre...
[ "function", "toTimestamp", "(", "scale", ",", "input", ")", "{", "var", "adapter", "=", "scale", ".", "_adapter", "||", "defaultAdapter", ";", "var", "options", "=", "scale", ".", "options", ".", "time", ";", "var", "parser", "=", "options", ".", "parser...
Ported from Chart.js 2.8.0-rc.1 35273ee. Modified for Chart.js 2.7.x backward compatibility.
[ "Ported", "from", "Chart", ".", "js", "2", ".", "8", ".", "0", "-", "rc", ".", "1", "35273ee", ".", "Modified", "for", "Chart", ".", "js", "2", ".", "7", ".", "x", "backward", "compatibility", "." ]
b53ec168f2d0729014651d694cc041a6a7d4ff26
https://github.com/nagix/chartjs-plugin-streaming/blob/b53ec168f2d0729014651d694cc041a6a7d4ff26/src/scales/scale.realtime.js#L34-L68
train
nagix/chartjs-plugin-streaming
src/plugins/plugin.streaming.js
update
function update(config) { var me = this; var preservation = config && config.preservation; var tooltip, lastActive, tooltipLastActive, lastMouseEvent; if (preservation) { tooltip = me.tooltip; lastActive = me.lastActive; tooltipLastActive = tooltip._lastActive; me._bufferedRender = true; } Chart.prototy...
javascript
function update(config) { var me = this; var preservation = config && config.preservation; var tooltip, lastActive, tooltipLastActive, lastMouseEvent; if (preservation) { tooltip = me.tooltip; lastActive = me.lastActive; tooltipLastActive = tooltip._lastActive; me._bufferedRender = true; } Chart.prototy...
[ "function", "update", "(", "config", ")", "{", "var", "me", "=", "this", ";", "var", "preservation", "=", "config", "&&", "config", ".", "preservation", ";", "var", "tooltip", ",", "lastActive", ",", "tooltipLastActive", ",", "lastMouseEvent", ";", "if", "...
Update the chart keeping the current animation but suppressing a new one @param {object} config - animation options
[ "Update", "the", "chart", "keeping", "the", "current", "animation", "but", "suppressing", "a", "new", "one" ]
b53ec168f2d0729014651d694cc041a6a7d4ff26
https://github.com/nagix/chartjs-plugin-streaming/blob/b53ec168f2d0729014651d694cc041a6a7d4ff26/src/plugins/plugin.streaming.js#L24-L69
train