id
int32
0
58k
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
43,500
dsfields/radargun
lib/report.js
header
function header(dimensions) { return divider(dimensions, 'top') + BORDER_VERT + BOLD + padEnd(' NAME', dimensions.name) + RESET + BORDER_VERT + BOLD + padEnd(' AVG', dimensions.avg) + RESET + BORDER_VERT + BOLD + padEnd(' MIN', dimensions.min) + RESET + BORDER_VERT + BOLD + padEnd(' MAX', dimensions.max) + RESET + BORDER_VERT + '\n' + divider(dimensions, 'header'); }
javascript
function header(dimensions) { return divider(dimensions, 'top') + BORDER_VERT + BOLD + padEnd(' NAME', dimensions.name) + RESET + BORDER_VERT + BOLD + padEnd(' AVG', dimensions.avg) + RESET + BORDER_VERT + BOLD + padEnd(' MIN', dimensions.min) + RESET + BORDER_VERT + BOLD + padEnd(' MAX', dimensions.max) + RESET + BORDER_VERT + '\n' + divider(dimensions, 'header'); }
[ "function", "header", "(", "dimensions", ")", "{", "return", "divider", "(", "dimensions", ",", "'top'", ")", "+", "BORDER_VERT", "+", "BOLD", "+", "padEnd", "(", "' NAME'", ",", "dimensions", ".", "name", ")", "+", "RESET", "+", "BORDER_VERT", "+", "BOLD", "+", "padEnd", "(", "' AVG'", ",", "dimensions", ".", "avg", ")", "+", "RESET", "+", "BORDER_VERT", "+", "BOLD", "+", "padEnd", "(", "' MIN'", ",", "dimensions", ".", "min", ")", "+", "RESET", "+", "BORDER_VERT", "+", "BOLD", "+", "padEnd", "(", "' MAX'", ",", "dimensions", ".", "max", ")", "+", "RESET", "+", "BORDER_VERT", "+", "'\\n'", "+", "divider", "(", "dimensions", ",", "'header'", ")", ";", "}" ]
Generates the header for a report table. @param {Dimensions} dimensions @returns {string}
[ "Generates", "the", "header", "for", "a", "report", "table", "." ]
c0cf2730441e1e454355603c2fd7539b9d552f1a
https://github.com/dsfields/radargun/blob/c0cf2730441e1e454355603c2fd7539b9d552f1a/lib/report.js#L173-L186
43,501
dsfields/radargun
lib/report.js
row
function row(metric, dimensions, isTarget) { let left = ''; let right = ''; if (isTarget) { left = HIGHLIGHT; right = RESET; } return BORDER_VERT + left + padEnd(' ' + metric.label, dimensions.name) + right + BORDER_VERT + left + padEnd(' ' + metric.avg + UNIT, dimensions.avg) + right + BORDER_VERT + left + padEnd(' ' + metric.min + UNIT, dimensions.min) + right + BORDER_VERT + left + padEnd(' ' + metric.max + UNIT, dimensions.max) + right + BORDER_VERT + '\n'; }
javascript
function row(metric, dimensions, isTarget) { let left = ''; let right = ''; if (isTarget) { left = HIGHLIGHT; right = RESET; } return BORDER_VERT + left + padEnd(' ' + metric.label, dimensions.name) + right + BORDER_VERT + left + padEnd(' ' + metric.avg + UNIT, dimensions.avg) + right + BORDER_VERT + left + padEnd(' ' + metric.min + UNIT, dimensions.min) + right + BORDER_VERT + left + padEnd(' ' + metric.max + UNIT, dimensions.max) + right + BORDER_VERT + '\n'; }
[ "function", "row", "(", "metric", ",", "dimensions", ",", "isTarget", ")", "{", "let", "left", "=", "''", ";", "let", "right", "=", "''", ";", "if", "(", "isTarget", ")", "{", "left", "=", "HIGHLIGHT", ";", "right", "=", "RESET", ";", "}", "return", "BORDER_VERT", "+", "left", "+", "padEnd", "(", "' '", "+", "metric", ".", "label", ",", "dimensions", ".", "name", ")", "+", "right", "+", "BORDER_VERT", "+", "left", "+", "padEnd", "(", "' '", "+", "metric", ".", "avg", "+", "UNIT", ",", "dimensions", ".", "avg", ")", "+", "right", "+", "BORDER_VERT", "+", "left", "+", "padEnd", "(", "' '", "+", "metric", ".", "min", "+", "UNIT", ",", "dimensions", ".", "min", ")", "+", "right", "+", "BORDER_VERT", "+", "left", "+", "padEnd", "(", "' '", "+", "metric", ".", "max", "+", "UNIT", ",", "dimensions", ".", "max", ")", "+", "right", "+", "BORDER_VERT", "+", "'\\n'", ";", "}" ]
Generates a report table row. @param {@link FunctionMetrics} metric @param {Dimensions} dimensions @param {boolean} isTarget @returns {string}
[ "Generates", "a", "report", "table", "row", "." ]
c0cf2730441e1e454355603c2fd7539b9d552f1a
https://github.com/dsfields/radargun/blob/c0cf2730441e1e454355603c2fd7539b9d552f1a/lib/report.js#L198-L217
43,502
dsfields/radargun
lib/report.js
report
function report(stream, metrics, thresholds) { const target = (!elv(thresholds)) ? -1 : thresholds.target; const dimensions = tableDimensions(metrics); const border = divider(dimensions); let value = header(dimensions); for (let i = 0; i < metrics.length; i++) { if (i > 0) value += border; const metric = metrics[i]; value += row(metric, dimensions, i === target); } value += divider(dimensions, 'bottom'); value += '\n'; stream.write(value); }
javascript
function report(stream, metrics, thresholds) { const target = (!elv(thresholds)) ? -1 : thresholds.target; const dimensions = tableDimensions(metrics); const border = divider(dimensions); let value = header(dimensions); for (let i = 0; i < metrics.length; i++) { if (i > 0) value += border; const metric = metrics[i]; value += row(metric, dimensions, i === target); } value += divider(dimensions, 'bottom'); value += '\n'; stream.write(value); }
[ "function", "report", "(", "stream", ",", "metrics", ",", "thresholds", ")", "{", "const", "target", "=", "(", "!", "elv", "(", "thresholds", ")", ")", "?", "-", "1", ":", "thresholds", ".", "target", ";", "const", "dimensions", "=", "tableDimensions", "(", "metrics", ")", ";", "const", "border", "=", "divider", "(", "dimensions", ")", ";", "let", "value", "=", "header", "(", "dimensions", ")", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "metrics", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "value", "+=", "border", ";", "const", "metric", "=", "metrics", "[", "i", "]", ";", "value", "+=", "row", "(", "metric", ",", "dimensions", ",", "i", "===", "target", ")", ";", "}", "value", "+=", "divider", "(", "dimensions", ",", "'bottom'", ")", ";", "value", "+=", "'\\n'", ";", "stream", ".", "write", "(", "value", ")", ";", "}" ]
REPORTER Generates a report table. @param {@link Stream} stream @param {@link FunctionMetrics[]} metrics @param {@link Thresholds} thresholds
[ "REPORTER", "Generates", "a", "report", "table", "." ]
c0cf2730441e1e454355603c2fd7539b9d552f1a
https://github.com/dsfields/radargun/blob/c0cf2730441e1e454355603c2fd7539b9d552f1a/lib/report.js#L232-L248
43,503
partyka95/graph-type-orm
dist/find-many.js
findMany
function findMany(repository, options) { const entityColumns = repository.metadata.columns.map((columnMetadata) => columnMetadata.propertyName); const entityManyToOneRelationColumns = repository .metadata .relations .filter((relationMetadata) => relationMetadata.relationType === 'many-to-one' || relationMetadata.relationType === 'one-to-one') .map((relationMetadata) => relationMetadata.propertyName); return function (source, args, context, info) { return __awaiter(this, void 0, void 0, function* () { const selectedColumns = Object.keys(graphqlFields(info)); const selectQueryBuilder = repository.createQueryBuilder(repository.metadata.name.toLowerCase()); /** Select **/ const selectFactory = new select_factory_1.SelectFactory(selectQueryBuilder); selectFactory .select(selectedColumns.filter((select) => entityColumns.includes(select))); /** Where **/ const whereFactory = new where_factory_1.WhereFactory(selectQueryBuilder, entityManyToOneRelationColumns); whereFactory .where(lodash_1.get(args, 'filter', {})); /** Joins **/ const joinsFactory = new joins_factory_1.JoinsFactory(selectQueryBuilder); joinsFactory .join(selectedColumns .filter((select) => entityManyToOneRelationColumns.includes(select)) .reduce((selectedRelationColumns, selectedRelationColumn) => { selectedRelationColumns[selectQueryBuilder.alias] = selectedRelationColumn; return selectedRelationColumns; }, {})) .join(whereFactory.selectedManyToOneOrOneToOneRelationColumns); /** Pagination **/ const paginateFactory = new paginate_factory_1.PaginateFactory(selectQueryBuilder); paginateFactory .paginate(lodash_1.get(args, 'pagination', {})); /** Order by **/ const orderFactory = new order_factory_1.OrderFactory(selectQueryBuilder); orderFactory .order(lodash_1.get(args, 'orderBy', [])); /** Extend **/ if (lodash_1.get(options, 'extend')) { yield options.extend(selectQueryBuilder); } /** Execute get many method **/ return yield selectQueryBuilder.getMany(); }); }; }
javascript
function findMany(repository, options) { const entityColumns = repository.metadata.columns.map((columnMetadata) => columnMetadata.propertyName); const entityManyToOneRelationColumns = repository .metadata .relations .filter((relationMetadata) => relationMetadata.relationType === 'many-to-one' || relationMetadata.relationType === 'one-to-one') .map((relationMetadata) => relationMetadata.propertyName); return function (source, args, context, info) { return __awaiter(this, void 0, void 0, function* () { const selectedColumns = Object.keys(graphqlFields(info)); const selectQueryBuilder = repository.createQueryBuilder(repository.metadata.name.toLowerCase()); /** Select **/ const selectFactory = new select_factory_1.SelectFactory(selectQueryBuilder); selectFactory .select(selectedColumns.filter((select) => entityColumns.includes(select))); /** Where **/ const whereFactory = new where_factory_1.WhereFactory(selectQueryBuilder, entityManyToOneRelationColumns); whereFactory .where(lodash_1.get(args, 'filter', {})); /** Joins **/ const joinsFactory = new joins_factory_1.JoinsFactory(selectQueryBuilder); joinsFactory .join(selectedColumns .filter((select) => entityManyToOneRelationColumns.includes(select)) .reduce((selectedRelationColumns, selectedRelationColumn) => { selectedRelationColumns[selectQueryBuilder.alias] = selectedRelationColumn; return selectedRelationColumns; }, {})) .join(whereFactory.selectedManyToOneOrOneToOneRelationColumns); /** Pagination **/ const paginateFactory = new paginate_factory_1.PaginateFactory(selectQueryBuilder); paginateFactory .paginate(lodash_1.get(args, 'pagination', {})); /** Order by **/ const orderFactory = new order_factory_1.OrderFactory(selectQueryBuilder); orderFactory .order(lodash_1.get(args, 'orderBy', [])); /** Extend **/ if (lodash_1.get(options, 'extend')) { yield options.extend(selectQueryBuilder); } /** Execute get many method **/ return yield selectQueryBuilder.getMany(); }); }; }
[ "function", "findMany", "(", "repository", ",", "options", ")", "{", "const", "entityColumns", "=", "repository", ".", "metadata", ".", "columns", ".", "map", "(", "(", "columnMetadata", ")", "=>", "columnMetadata", ".", "propertyName", ")", ";", "const", "entityManyToOneRelationColumns", "=", "repository", ".", "metadata", ".", "relations", ".", "filter", "(", "(", "relationMetadata", ")", "=>", "relationMetadata", ".", "relationType", "===", "'many-to-one'", "||", "relationMetadata", ".", "relationType", "===", "'one-to-one'", ")", ".", "map", "(", "(", "relationMetadata", ")", "=>", "relationMetadata", ".", "propertyName", ")", ";", "return", "function", "(", "source", ",", "args", ",", "context", ",", "info", ")", "{", "return", "__awaiter", "(", "this", ",", "void", "0", ",", "void", "0", ",", "function", "*", "(", ")", "{", "const", "selectedColumns", "=", "Object", ".", "keys", "(", "graphqlFields", "(", "info", ")", ")", ";", "const", "selectQueryBuilder", "=", "repository", ".", "createQueryBuilder", "(", "repository", ".", "metadata", ".", "name", ".", "toLowerCase", "(", ")", ")", ";", "/** Select **/", "const", "selectFactory", "=", "new", "select_factory_1", ".", "SelectFactory", "(", "selectQueryBuilder", ")", ";", "selectFactory", ".", "select", "(", "selectedColumns", ".", "filter", "(", "(", "select", ")", "=>", "entityColumns", ".", "includes", "(", "select", ")", ")", ")", ";", "/** Where **/", "const", "whereFactory", "=", "new", "where_factory_1", ".", "WhereFactory", "(", "selectQueryBuilder", ",", "entityManyToOneRelationColumns", ")", ";", "whereFactory", ".", "where", "(", "lodash_1", ".", "get", "(", "args", ",", "'filter'", ",", "{", "}", ")", ")", ";", "/** Joins **/", "const", "joinsFactory", "=", "new", "joins_factory_1", ".", "JoinsFactory", "(", "selectQueryBuilder", ")", ";", "joinsFactory", ".", "join", "(", "selectedColumns", ".", "filter", "(", "(", "select", ")", "=>", "entityManyToOneRelationColumns", ".", "includes", "(", "select", ")", ")", ".", "reduce", "(", "(", "selectedRelationColumns", ",", "selectedRelationColumn", ")", "=>", "{", "selectedRelationColumns", "[", "selectQueryBuilder", ".", "alias", "]", "=", "selectedRelationColumn", ";", "return", "selectedRelationColumns", ";", "}", ",", "{", "}", ")", ")", ".", "join", "(", "whereFactory", ".", "selectedManyToOneOrOneToOneRelationColumns", ")", ";", "/** Pagination **/", "const", "paginateFactory", "=", "new", "paginate_factory_1", ".", "PaginateFactory", "(", "selectQueryBuilder", ")", ";", "paginateFactory", ".", "paginate", "(", "lodash_1", ".", "get", "(", "args", ",", "'pagination'", ",", "{", "}", ")", ")", ";", "/** Order by **/", "const", "orderFactory", "=", "new", "order_factory_1", ".", "OrderFactory", "(", "selectQueryBuilder", ")", ";", "orderFactory", ".", "order", "(", "lodash_1", ".", "get", "(", "args", ",", "'orderBy'", ",", "[", "]", ")", ")", ";", "/** Extend **/", "if", "(", "lodash_1", ".", "get", "(", "options", ",", "'extend'", ")", ")", "{", "yield", "options", ".", "extend", "(", "selectQueryBuilder", ")", ";", "}", "/** Execute get many method **/", "return", "yield", "selectQueryBuilder", ".", "getMany", "(", ")", ";", "}", ")", ";", "}", ";", "}" ]
Method to find many entity records. @param {Repository<Entity>} repository @param {FindManyOptions} options @returns {(source, args, context, info) => Promise<Entity[]>}
[ "Method", "to", "find", "many", "entity", "records", "." ]
c2c1d93c091ad8fb5d3015cabe6edb20dccfa225
https://github.com/partyka95/graph-type-orm/blob/c2c1d93c091ad8fb5d3015cabe6edb20dccfa225/dist/find-many.js#L27-L72
43,504
robinpowered/robin-js-sdk-public
lib/api/modules/events.js
function (data) { var path; if (data) { path = this.constructPath(constants.EVENTS); return this.Places.POST(path, data); } else { return this.rejectRequest('Bad Request: A data object is required.'); } }
javascript
function (data) { var path; if (data) { path = this.constructPath(constants.EVENTS); return this.Places.POST(path, data); } else { return this.rejectRequest('Bad Request: A data object is required.'); } }
[ "function", "(", "data", ")", "{", "var", "path", ";", "if", "(", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "EVENTS", ")", ";", "return", "this", ".", "Places", ".", "POST", "(", "path", ",", "data", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A data object is required.'", ")", ";", "}", "}" ]
Create an event @param {Object} data A data object @return {Function} A promise
[ "Create", "an", "event" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/events.js#L19-L27
43,505
jeffrose/emitter
dist/emitter.js
listenEmpty
function listenEmpty( handler, isFunction, emitter ){ const errors = []; if( isFunction ){ try { handler.call( emitter ); } catch( error ){ errors.push( error ); } } else { const length = handler.length, listeners = handler.slice(); let index = 0; for( ; index < length; index += 1 ){ try { listeners[ index ].call( emitter ); } catch( error ){ errors.push( error ); } } } if( errors.length ){ emitErrors( emitter, errors ); } }
javascript
function listenEmpty( handler, isFunction, emitter ){ const errors = []; if( isFunction ){ try { handler.call( emitter ); } catch( error ){ errors.push( error ); } } else { const length = handler.length, listeners = handler.slice(); let index = 0; for( ; index < length; index += 1 ){ try { listeners[ index ].call( emitter ); } catch( error ){ errors.push( error ); } } } if( errors.length ){ emitErrors( emitter, errors ); } }
[ "function", "listenEmpty", "(", "handler", ",", "isFunction", ",", "emitter", ")", "{", "const", "errors", "=", "[", "]", ";", "if", "(", "isFunction", ")", "{", "try", "{", "handler", ".", "call", "(", "emitter", ")", ";", "}", "catch", "(", "error", ")", "{", "errors", ".", "push", "(", "error", ")", ";", "}", "}", "else", "{", "const", "length", "=", "handler", ".", "length", ",", "listeners", "=", "handler", ".", "slice", "(", ")", ";", "let", "index", "=", "0", ";", "for", "(", ";", "index", "<", "length", ";", "index", "+=", "1", ")", "{", "try", "{", "listeners", "[", "index", "]", ".", "call", "(", "emitter", ")", ";", "}", "catch", "(", "error", ")", "{", "errors", ".", "push", "(", "error", ")", ";", "}", "}", "}", "if", "(", "errors", ".", "length", ")", "{", "emitErrors", "(", "emitter", ",", "errors", ")", ";", "}", "}" ]
Execute a listener with no arguments. @function Emitter~listenEmpty @param {EventListener|Array<EventListener>} handler One or more {@link EventListener|listeners} that will be executed on the `emitter`. @param {external:boolean} isFunction Whether or not the `handler` is a {@link external:Function|function}. @param {Emitter} emitter The emitter.
[ "Execute", "a", "listener", "with", "no", "arguments", "." ]
c6d8d1702ff60ca4f5100d13480914e4bd17183f
https://github.com/jeffrose/emitter/blob/c6d8d1702ff60ca4f5100d13480914e4bd17183f/dist/emitter.js#L450-L477
43,506
jeffrose/emitter
dist/emitter.js
toEmitter
function toEmitter( selection, target ){ // Apply the entire Emitter API if( selection === API ){ asEmitter.call( target ); // Apply only the selected API methods } else { let index, key, mapping, names, value; if( typeof selection === 'string' ){ names = selection.split( ' ' ); mapping = API; } else { names = Object.keys( selection ); mapping = selection; } index = names.length; while( index-- ){ key = names[ index ]; value = mapping[ key ]; target[ key ] = typeof value === 'function' ? value : API[ value ]; } } }
javascript
function toEmitter( selection, target ){ // Apply the entire Emitter API if( selection === API ){ asEmitter.call( target ); // Apply only the selected API methods } else { let index, key, mapping, names, value; if( typeof selection === 'string' ){ names = selection.split( ' ' ); mapping = API; } else { names = Object.keys( selection ); mapping = selection; } index = names.length; while( index-- ){ key = names[ index ]; value = mapping[ key ]; target[ key ] = typeof value === 'function' ? value : API[ value ]; } } }
[ "function", "toEmitter", "(", "selection", ",", "target", ")", "{", "// Apply the entire Emitter API", "if", "(", "selection", "===", "API", ")", "{", "asEmitter", ".", "call", "(", "target", ")", ";", "// Apply only the selected API methods", "}", "else", "{", "let", "index", ",", "key", ",", "mapping", ",", "names", ",", "value", ";", "if", "(", "typeof", "selection", "===", "'string'", ")", "{", "names", "=", "selection", ".", "split", "(", "' '", ")", ";", "mapping", "=", "API", ";", "}", "else", "{", "names", "=", "Object", ".", "keys", "(", "selection", ")", ";", "mapping", "=", "selection", ";", "}", "index", "=", "names", ".", "length", ";", "while", "(", "index", "--", ")", "{", "key", "=", "names", "[", "index", "]", ";", "value", "=", "mapping", "[", "key", "]", ";", "target", "[", "key", "]", "=", "typeof", "value", "===", "'function'", "?", "value", ":", "API", "[", "value", "]", ";", "}", "}", "}" ]
Applies a `selection` of the Emitter.js API to the `target`. @function Emitter~toEmitter @param {APIReference} [selection] A selection of the Emitter.js API. @param {external:Object} target The object on which the API will be applied.
[ "Applies", "a", "selection", "of", "the", "Emitter", ".", "js", "API", "to", "the", "target", "." ]
c6d8d1702ff60ca4f5100d13480914e4bd17183f
https://github.com/jeffrose/emitter/blob/c6d8d1702ff60ca4f5100d13480914e4bd17183f/dist/emitter.js#L731-L760
43,507
robinpowered/robin-js-sdk-public
lib/api/modules/devicemanifests.js
function (identifier, params) { var path = this.constructPath(constants.DEVICE_MANIFESTS, identifier); return this.Core.GET(path, params); }
javascript
function (identifier, params) { var path = this.constructPath(constants.DEVICE_MANIFESTS, identifier); return this.Core.GET(path, params); }
[ "function", "(", "identifier", ",", "params", ")", "{", "var", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICE_MANIFESTS", ",", "identifier", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}" ]
Get all the device manifests or a particular device manifest identified by the `identifier` parameter @param {String|Integer|undefined} identifier A Robin device manifest identifier @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "device", "manifests", "or", "a", "particular", "device", "manifest", "identified", "by", "the", "identifier", "parameter" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devicemanifests.js#L20-L23
43,508
robinpowered/robin-js-sdk-public
lib/api/modules/devicemanifests.js
function (data) { var path; if (data) { path = this.constructPath(constants.DEVICE_MANIFESTS); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: A data object is required'); } }
javascript
function (data) { var path; if (data) { path = this.constructPath(constants.DEVICE_MANIFESTS); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: A data object is required'); } }
[ "function", "(", "data", ")", "{", "var", "path", ";", "if", "(", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICE_MANIFESTS", ")", ";", "return", "this", ".", "Core", ".", "POST", "(", "path", ",", "data", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A data object is required'", ")", ";", "}", "}" ]
Create a device manifest @param {Object} data A data object @return {Function} A Promise
[ "Create", "a", "device", "manifest" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devicemanifests.js#L30-L38
43,509
robinpowered/robin-js-sdk-public
lib/api/modules/devicemanifests.js
function (identifier, data) { var path; if (identifier && data) { path = this.constructPath(constants.DEVICE_MANIFESTS, identifier); return this.Core.PATCH(path, data); } else { return this.rejectRequest('Bad Request: A device manifest identifier and a data object are required.'); } }
javascript
function (identifier, data) { var path; if (identifier && data) { path = this.constructPath(constants.DEVICE_MANIFESTS, identifier); return this.Core.PATCH(path, data); } else { return this.rejectRequest('Bad Request: A device manifest identifier and a data object are required.'); } }
[ "function", "(", "identifier", ",", "data", ")", "{", "var", "path", ";", "if", "(", "identifier", "&&", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICE_MANIFESTS", ",", "identifier", ")", ";", "return", "this", ".", "Core", ".", "PATCH", "(", "path", ",", "data", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device manifest identifier and a data object are required.'", ")", ";", "}", "}" ]
Update a device manifest @param {String|Integer|undefined} identifier A Robin device manifest identifier @param {Object} data A data object @return {Function} A Promise
[ "Update", "a", "device", "manifest" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devicemanifests.js#L46-L54
43,510
robinpowered/robin-js-sdk-public
lib/api/modules/devicemanifests.js
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, identifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A device manifest identifier is required.'); } }
javascript
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, identifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A device manifest identifier is required.'); } }
[ "function", "(", "identifier", ")", "{", "var", "path", ";", "if", "(", "identifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICE_MANIFESTS", ",", "identifier", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device manifest identifier is required.'", ")", ";", "}", "}" ]
Delete a device manifest @param {String|Integer|undefined} identifier A Robin device manifest identifier @return {Function} A Promise
[ "Delete", "a", "device", "manifest" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devicemanifests.js#L61-L69
43,511
robinpowered/robin-js-sdk-public
lib/api/modules/devicemanifests.js
function (deviceManifestIdentifier, feedIdentifier, params) { var path; if (deviceManifestIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS, feedIdentifier); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A device manifest identifier is required.'); } }
javascript
function (deviceManifestIdentifier, feedIdentifier, params) { var path; if (deviceManifestIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS, feedIdentifier); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A device manifest identifier is required.'); } }
[ "function", "(", "deviceManifestIdentifier", ",", "feedIdentifier", ",", "params", ")", "{", "var", "path", ";", "if", "(", "deviceManifestIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICE_MANIFESTS", ",", "deviceManifestIdentifier", ",", "constants", ".", "FEEDS", ",", "feedIdentifier", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device manifest identifier is required.'", ")", ";", "}", "}" ]
Get all the feeds for a device manifest or a particular feed identified by `feedIdentifier` @param {String|Integer} deviceManifestIdentifier A Robin device manifest identifier @param {String|Integer|undefined} feedIdentifier A Robin feed identifier @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "feeds", "for", "a", "device", "manifest", "or", "a", "particular", "feed", "identified", "by", "feedIdentifier" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devicemanifests.js#L83-L92
43,512
robinpowered/robin-js-sdk-public
lib/api/modules/devicemanifests.js
function (deviceManifestIdentifier, data) { var path; if (deviceManifestIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: A device manifest identifier and a data object are required.'); } }
javascript
function (deviceManifestIdentifier, data) { var path; if (deviceManifestIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: A device manifest identifier and a data object are required.'); } }
[ "function", "(", "deviceManifestIdentifier", ",", "data", ")", "{", "var", "path", ";", "if", "(", "deviceManifestIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICE_MANIFESTS", ",", "deviceManifestIdentifier", ",", "constants", ".", "FEEDS", ")", ";", "return", "this", ".", "Core", ".", "POST", "(", "path", ",", "data", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device manifest identifier and a data object are required.'", ")", ";", "}", "}" ]
Add a feed to a device manifest @param {String|Integer} deviceManifestIdentifier A Robin device manifest identifier @param {Object} data A querystring object @return {Function} A Promise
[ "Add", "a", "feed", "to", "a", "device", "manifest" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devicemanifests.js#L100-L108
43,513
robinpowered/robin-js-sdk-public
lib/api/modules/devicemanifests.js
function (deviceManifestIdentifier, feedIdentifier, data) { var path, rejectMsg; if (deviceManifestIdentifier && feedIdentifier && data) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS, feedIdentifier); return this.Core.PATCH(path, data); } else { rejectMsg = 'Bad Request: A device manifest identifier, a feed identifier and a data object are required.'; return this.rejectRequest(rejectMsg); } }
javascript
function (deviceManifestIdentifier, feedIdentifier, data) { var path, rejectMsg; if (deviceManifestIdentifier && feedIdentifier && data) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS, feedIdentifier); return this.Core.PATCH(path, data); } else { rejectMsg = 'Bad Request: A device manifest identifier, a feed identifier and a data object are required.'; return this.rejectRequest(rejectMsg); } }
[ "function", "(", "deviceManifestIdentifier", ",", "feedIdentifier", ",", "data", ")", "{", "var", "path", ",", "rejectMsg", ";", "if", "(", "deviceManifestIdentifier", "&&", "feedIdentifier", "&&", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICE_MANIFESTS", ",", "deviceManifestIdentifier", ",", "constants", ".", "FEEDS", ",", "feedIdentifier", ")", ";", "return", "this", ".", "Core", ".", "PATCH", "(", "path", ",", "data", ")", ";", "}", "else", "{", "rejectMsg", "=", "'Bad Request: A device manifest identifier, a feed identifier and a data object are required.'", ";", "return", "this", ".", "rejectRequest", "(", "rejectMsg", ")", ";", "}", "}" ]
Update a feed on a device manifest @param {String|Integer} deviceManifestIdentifier A Robin device manifest identifier @param {String|Integer} feedIdentifier A Robin feed identifier @param {Object} data A querystring object @return {Function} A Promise
[ "Update", "a", "feed", "on", "a", "device", "manifest" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devicemanifests.js#L117-L128
43,514
robinpowered/robin-js-sdk-public
lib/api/modules/devicemanifests.js
function (deviceManifestIdentifier, feedIdentifier) { var path; if (deviceManifestIdentifier && feedIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS, feedIdentifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A device manifest identifier and a feed identifier are required.'); } }
javascript
function (deviceManifestIdentifier, feedIdentifier) { var path; if (deviceManifestIdentifier && feedIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS, feedIdentifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A device manifest identifier and a feed identifier are required.'); } }
[ "function", "(", "deviceManifestIdentifier", ",", "feedIdentifier", ")", "{", "var", "path", ";", "if", "(", "deviceManifestIdentifier", "&&", "feedIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICE_MANIFESTS", ",", "deviceManifestIdentifier", ",", "constants", ".", "FEEDS", ",", "feedIdentifier", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device manifest identifier and a feed identifier are required.'", ")", ";", "}", "}" ]
Delete a feed from a device manifest @param {String|Integer} deviceManifestIdentifier A Robin device manifest identifier @param {String|Integer} feedIdentifier A Robin feed identifier @return {Function} A Promise
[ "Delete", "a", "feed", "from", "a", "device", "manifest" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devicemanifests.js#L136-L145
43,515
robinpowered/robin-js-sdk-public
lib/api/modules/devicemanifests.js
function (deviceManifestIdentifier, deviceIdentifier, params) { var path; if (deviceManifestIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.DEVICES, deviceIdentifier); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A device manifest identifier is required.'); } }
javascript
function (deviceManifestIdentifier, deviceIdentifier, params) { var path; if (deviceManifestIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.DEVICES, deviceIdentifier); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A device manifest identifier is required.'); } }
[ "function", "(", "deviceManifestIdentifier", ",", "deviceIdentifier", ",", "params", ")", "{", "var", "path", ";", "if", "(", "deviceManifestIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICE_MANIFESTS", ",", "deviceManifestIdentifier", ",", "constants", ".", "DEVICES", ",", "deviceIdentifier", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device manifest identifier is required.'", ")", ";", "}", "}" ]
Get all the devices for a device manifest or a particular device identified by `deviceIdentifier` @param {String|Integer} deviceManifestIdentifier A Robin device manifest identifier @param {String|Integer|undefined} deviceIdentifier A Robin device identifier @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "devices", "for", "a", "device", "manifest", "or", "a", "particular", "device", "identified", "by", "deviceIdentifier" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devicemanifests.js#L160-L169
43,516
robinpowered/robin-js-sdk-public
lib/api/modules/devices.js
function (identifier, params) { var path = this.constructPath(constants.DEVICES, identifier); return this.Core.GET(path, params); }
javascript
function (identifier, params) { var path = this.constructPath(constants.DEVICES, identifier); return this.Core.GET(path, params); }
[ "function", "(", "identifier", ",", "params", ")", "{", "var", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICES", ",", "identifier", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}" ]
Get all the devices or a particular device identified by the `identifier` parameter @param {String|Integer|undefined} identifier A Robin device identifier @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "devices", "or", "a", "particular", "device", "identified", "by", "the", "identifier", "parameter" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devices.js#L20-L23
43,517
robinpowered/robin-js-sdk-public
lib/api/modules/devices.js
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.DEVICES, identifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A device identifier is required.'); } }
javascript
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.DEVICES, identifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A device identifier is required.'); } }
[ "function", "(", "identifier", ")", "{", "var", "path", ";", "if", "(", "identifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICES", ",", "identifier", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device identifier is required.'", ")", ";", "}", "}" ]
Delete a device @param {String|Integer} identifier A Robin device identifier @return {Function} A Promise
[ "Delete", "a", "device" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devices.js#L61-L69
43,518
robinpowered/robin-js-sdk-public
lib/api/modules/devices.js
function (deviceIdentifier, identifierURN, params) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS, identifierURN); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A device identifier is required.'); } }
javascript
function (deviceIdentifier, identifierURN, params) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS, identifierURN); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A device identifier is required.'); } }
[ "function", "(", "deviceIdentifier", ",", "identifierURN", ",", "params", ")", "{", "var", "path", ";", "if", "(", "deviceIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICES", ",", "deviceIdentifier", ",", "constants", ".", "IDENTIFIERS", ",", "identifierURN", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device identifier is required.'", ")", ";", "}", "}" ]
Get all the identifiers for a device or a particular identifier identified by `identifierURN` @param {String|Integer} deviceIdentifier A Robin device identifier @param {String|Integer|undefined} identifierURN A Robin feed identifier @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "identifiers", "for", "a", "device", "or", "a", "particular", "identifier", "identified", "by", "identifierURN" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devices.js#L83-L91
43,519
robinpowered/robin-js-sdk-public
lib/api/modules/devices.js
function (deviceIdentifier, data) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: A device identifier and a data object are required.'); } }
javascript
function (deviceIdentifier, data) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: A device identifier and a data object are required.'); } }
[ "function", "(", "deviceIdentifier", ",", "data", ")", "{", "var", "path", ";", "if", "(", "deviceIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICES", ",", "deviceIdentifier", ",", "constants", ".", "IDENTIFIERS", ")", ";", "return", "this", ".", "Core", ".", "POST", "(", "path", ",", "data", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device identifier and a data object are required.'", ")", ";", "}", "}" ]
Create an identifier for a device @param {String|Integer} deviceIdentifier A Robin device identifier @param {Object} data A querystring object @return {Function} A Promise
[ "Create", "an", "identifier", "for", "a", "device" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devices.js#L99-L107
43,520
robinpowered/robin-js-sdk-public
lib/api/modules/devices.js
function (deviceIdentifier, identifierUrn, data) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS, identifierUrn); return this.Core.PATCH(path, data); } else { return this.rejectRequest('Bad Request: A device identifier, an identifier id and a data object are required.'); } }
javascript
function (deviceIdentifier, identifierUrn, data) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS, identifierUrn); return this.Core.PATCH(path, data); } else { return this.rejectRequest('Bad Request: A device identifier, an identifier id and a data object are required.'); } }
[ "function", "(", "deviceIdentifier", ",", "identifierUrn", ",", "data", ")", "{", "var", "path", ";", "if", "(", "deviceIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICES", ",", "deviceIdentifier", ",", "constants", ".", "IDENTIFIERS", ",", "identifierUrn", ")", ";", "return", "this", ".", "Core", ".", "PATCH", "(", "path", ",", "data", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device identifier, an identifier id and a data object are required.'", ")", ";", "}", "}" ]
Add an identifier for a device @param {String|Integer} deviceIdentifier A Robin device identifier @param {String|Integer} identifierUrn A Robin identifier URN @param {Object} data A querystring object @return {Function} A Promise
[ "Add", "an", "identifier", "for", "a", "device" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devices.js#L116-L124
43,521
robinpowered/robin-js-sdk-public
lib/api/modules/devices.js
function (deviceIdentifier, identifierUrn) { var path; if (deviceIdentifier && identifierUrn) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS, identifierUrn); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A device identifier and an identifier id are required.'); } }
javascript
function (deviceIdentifier, identifierUrn) { var path; if (deviceIdentifier && identifierUrn) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS, identifierUrn); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A device identifier and an identifier id are required.'); } }
[ "function", "(", "deviceIdentifier", ",", "identifierUrn", ")", "{", "var", "path", ";", "if", "(", "deviceIdentifier", "&&", "identifierUrn", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICES", ",", "deviceIdentifier", ",", "constants", ".", "IDENTIFIERS", ",", "identifierUrn", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device identifier and an identifier id are required.'", ")", ";", "}", "}" ]
Delete an identifier from a device @param {String|Integer} deviceIdentifier A Robin device identifier @param {String|Integer} identifierUrn A Robin identifier URN @return {Function} A Promise
[ "Delete", "an", "identifier", "from", "a", "device" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devices.js#L132-L140
43,522
robinpowered/robin-js-sdk-public
lib/api/modules/devices.js
function (deviceIdentifier, channelIdentifier, params) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.CHANNELS, channelIdentifier); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A device identifier is required.'); } }
javascript
function (deviceIdentifier, channelIdentifier, params) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.CHANNELS, channelIdentifier); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A device identifier is required.'); } }
[ "function", "(", "deviceIdentifier", ",", "channelIdentifier", ",", "params", ")", "{", "var", "path", ";", "if", "(", "deviceIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICES", ",", "deviceIdentifier", ",", "constants", ".", "CHANNELS", ",", "channelIdentifier", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device identifier is required.'", ")", ";", "}", "}" ]
Get all the channels for a device or a particular channel identified by `channelIdentifier` @param {String|Integer} deviceIdentifier A Robin device identifier @param {String|Integer|undefined} channelIdentifier A Robin channel identifier @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "channels", "for", "a", "device", "or", "a", "particular", "channel", "identified", "by", "channelIdentifier" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devices.js#L155-L163
43,523
robinpowered/robin-js-sdk-public
lib/api/modules/devices.js
function (deviceIdentifier, channelIdentifier, data) { var path, rejectMsg; if (deviceIdentifier && channelIdentifier && data) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.CHANNELS, channelIdentifier); return this.Core.PATCH(path, data); } else { rejectMsg = 'Bad Request: A device identifier, a feed identifier and a data object are required.'; return this.rejectRequest(rejectMsg); } }
javascript
function (deviceIdentifier, channelIdentifier, data) { var path, rejectMsg; if (deviceIdentifier && channelIdentifier && data) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.CHANNELS, channelIdentifier); return this.Core.PATCH(path, data); } else { rejectMsg = 'Bad Request: A device identifier, a feed identifier and a data object are required.'; return this.rejectRequest(rejectMsg); } }
[ "function", "(", "deviceIdentifier", ",", "channelIdentifier", ",", "data", ")", "{", "var", "path", ",", "rejectMsg", ";", "if", "(", "deviceIdentifier", "&&", "channelIdentifier", "&&", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICES", ",", "deviceIdentifier", ",", "constants", ".", "CHANNELS", ",", "channelIdentifier", ")", ";", "return", "this", ".", "Core", ".", "PATCH", "(", "path", ",", "data", ")", ";", "}", "else", "{", "rejectMsg", "=", "'Bad Request: A device identifier, a feed identifier and a data object are required.'", ";", "return", "this", ".", "rejectRequest", "(", "rejectMsg", ")", ";", "}", "}" ]
Update a feed on a channel @param {String|Integer} deviceIdentifier A Robin device identifier @param {String|Integer} channelIdentifier A Robin channel identifier @param {Object} data A querystring object @return {Function} A promise
[ "Update", "a", "feed", "on", "a", "channel" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devices.js#L188-L198
43,524
robinpowered/robin-js-sdk-public
lib/api/modules/devices.js
function (deviceIdentifier, channelIdentifier) { var path; if (deviceIdentifier && channelIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.CHANNELS, channelIdentifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A device identifier and a channel identifier are required.'); } }
javascript
function (deviceIdentifier, channelIdentifier) { var path; if (deviceIdentifier && channelIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.CHANNELS, channelIdentifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A device identifier and a channel identifier are required.'); } }
[ "function", "(", "deviceIdentifier", ",", "channelIdentifier", ")", "{", "var", "path", ";", "if", "(", "deviceIdentifier", "&&", "channelIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "DEVICES", ",", "deviceIdentifier", ",", "constants", ".", "CHANNELS", ",", "channelIdentifier", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A device identifier and a channel identifier are required.'", ")", ";", "}", "}" ]
Delete a channel from a device @param {String|Integer} deviceIdentifier A Robin device identifier @param {String|Integer} channelIdentifier A Robin channel identifier @return {Function} A Promise
[ "Delete", "a", "channel", "from", "a", "device" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/devices.js#L206-L214
43,525
robinpowered/robin-js-sdk-public
lib/api/modules/channels.js
function (identifier, params) { var path = this.constructPath(constants.CHANNELS, identifier); return this.Core.GET(path, params); }
javascript
function (identifier, params) { var path = this.constructPath(constants.CHANNELS, identifier); return this.Core.GET(path, params); }
[ "function", "(", "identifier", ",", "params", ")", "{", "var", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "CHANNELS", ",", "identifier", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}" ]
Get all the channels or a particular channel identified by the `identifier` parameter @param {String|Integer|undefined} identifier A Robin channel identifier @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "channels", "or", "a", "particular", "channel", "identified", "by", "the", "identifier", "parameter" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/channels.js#L20-L23
43,526
robinpowered/robin-js-sdk-public
lib/api/modules/channels.js
function (data) { var path; if (data) { path = this.constructPath(constants.CHANNELS); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: A data object is required.'); } }
javascript
function (data) { var path; if (data) { path = this.constructPath(constants.CHANNELS); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: A data object is required.'); } }
[ "function", "(", "data", ")", "{", "var", "path", ";", "if", "(", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "CHANNELS", ")", ";", "return", "this", ".", "Core", ".", "POST", "(", "path", ",", "data", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A data object is required.'", ")", ";", "}", "}" ]
Create a channel @param {Object} data A data object @return {Function} A Promise
[ "Create", "a", "channel" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/channels.js#L30-L38
43,527
robinpowered/robin-js-sdk-public
lib/api/modules/channels.js
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.CHANNELS, identifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A channel identifier is required.'); } }
javascript
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.CHANNELS, identifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A channel identifier is required.'); } }
[ "function", "(", "identifier", ")", "{", "var", "path", ";", "if", "(", "identifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "CHANNELS", ",", "identifier", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A channel identifier is required.'", ")", ";", "}", "}" ]
Delete a channel @param {String|Integer} identifier A Robin channel identifier @return {Function} A Promise
[ "Delete", "a", "channel" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/channels.js#L61-L69
43,528
robinpowered/robin-js-sdk-public
lib/api/modules/channels.js
function (channelIdentifier, dataIdentifier, params) { var path; if (channelIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.DATA, dataIdentifier); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A channel identifier is required.'); } }
javascript
function (channelIdentifier, dataIdentifier, params) { var path; if (channelIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.DATA, dataIdentifier); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A channel identifier is required.'); } }
[ "function", "(", "channelIdentifier", ",", "dataIdentifier", ",", "params", ")", "{", "var", "path", ";", "if", "(", "channelIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "CHANNELS", ",", "channelIdentifier", ",", "constants", ".", "DATA", ",", "dataIdentifier", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A channel identifier is required.'", ")", ";", "}", "}" ]
Get all the data from a channel or a particular channel data point identified by `dataIdentifier` @param {String|Integer} channelIdentifier A Robin channel identifier @param {String|Integer|undefined} dataIdentifier A Robin channel data point identifier @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "data", "from", "a", "channel", "or", "a", "particular", "channel", "data", "point", "identified", "by", "dataIdentifier" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/channels.js#L83-L91
43,529
robinpowered/robin-js-sdk-public
lib/api/modules/channels.js
function (channelIdentifier, dataIdentifier) { var path; if (channelIdentifier && dataIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.DATA, dataIdentifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A channel identifier and a data point identifier are required.'); } }
javascript
function (channelIdentifier, dataIdentifier) { var path; if (channelIdentifier && dataIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.DATA, dataIdentifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A channel identifier and a data point identifier are required.'); } }
[ "function", "(", "channelIdentifier", ",", "dataIdentifier", ")", "{", "var", "path", ";", "if", "(", "channelIdentifier", "&&", "dataIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "CHANNELS", ",", "channelIdentifier", ",", "constants", ".", "DATA", ",", "dataIdentifier", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A channel identifier and a data point identifier are required.'", ")", ";", "}", "}" ]
Delete a data point from a channel @param {String|Integer} channelIdentifier A Robin channel identifier @param {String|Integer} dataIdentifier A Robin channel data point identifier @return {Function} A Promise
[ "Delete", "a", "data", "point", "from", "a", "channel" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/channels.js#L115-L123
43,530
robinpowered/robin-js-sdk-public
lib/api/modules/channels.js
function (channelIdentifier, triggerIdentifier, params) { var path; if (channelIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS, triggerIdentifier); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A channel identifier is required.'); } }
javascript
function (channelIdentifier, triggerIdentifier, params) { var path; if (channelIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS, triggerIdentifier); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: A channel identifier is required.'); } }
[ "function", "(", "channelIdentifier", ",", "triggerIdentifier", ",", "params", ")", "{", "var", "path", ";", "if", "(", "channelIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "CHANNELS", ",", "channelIdentifier", ",", "constants", ".", "TRIGGERS", ",", "triggerIdentifier", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A channel identifier is required.'", ")", ";", "}", "}" ]
Get all the triggers on a channel or a particular channel trigger identified by `triggerIdentifier` @param {String|Integer} channelIdentifier A Robin channel identifier @param {String|Integer|undefined} triggerIdentifier A Robin channel trigger identifier @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "triggers", "on", "a", "channel", "or", "a", "particular", "channel", "trigger", "identified", "by", "triggerIdentifier" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/channels.js#L138-L146
43,531
robinpowered/robin-js-sdk-public
lib/api/modules/channels.js
function (channelIdentifier, data) { var path; if (channelIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: A channel identifier and a data object are required.'); } }
javascript
function (channelIdentifier, data) { var path; if (channelIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: A channel identifier and a data object are required.'); } }
[ "function", "(", "channelIdentifier", ",", "data", ")", "{", "var", "path", ";", "if", "(", "channelIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "CHANNELS", ",", "channelIdentifier", ",", "constants", ".", "TRIGGERS", ")", ";", "return", "this", ".", "Core", ".", "POST", "(", "path", ",", "data", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A channel identifier and a data object are required.'", ")", ";", "}", "}" ]
Add a trigger to a channel @param {String|Integer} channelIdentifier A Robin channel identifier @param {Object} data A querystring object @return {Function} A Promise
[ "Add", "a", "trigger", "to", "a", "channel" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/channels.js#L154-L162
43,532
robinpowered/robin-js-sdk-public
lib/api/modules/channels.js
function (channelIdentifier, triggerIdentifier, data) { var path, rejectMsg; if (channelIdentifier && triggerIdentifier && data) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS, triggerIdentifier); return this.Core.PATCH(path, data); } else { rejectMsg = 'Bad Request: A channel identifier, a feed identifier and a trigger object are required.'; return this.rejectRequest(rejectMsg); } }
javascript
function (channelIdentifier, triggerIdentifier, data) { var path, rejectMsg; if (channelIdentifier && triggerIdentifier && data) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS, triggerIdentifier); return this.Core.PATCH(path, data); } else { rejectMsg = 'Bad Request: A channel identifier, a feed identifier and a trigger object are required.'; return this.rejectRequest(rejectMsg); } }
[ "function", "(", "channelIdentifier", ",", "triggerIdentifier", ",", "data", ")", "{", "var", "path", ",", "rejectMsg", ";", "if", "(", "channelIdentifier", "&&", "triggerIdentifier", "&&", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "CHANNELS", ",", "channelIdentifier", ",", "constants", ".", "TRIGGERS", ",", "triggerIdentifier", ")", ";", "return", "this", ".", "Core", ".", "PATCH", "(", "path", ",", "data", ")", ";", "}", "else", "{", "rejectMsg", "=", "'Bad Request: A channel identifier, a feed identifier and a trigger object are required.'", ";", "return", "this", ".", "rejectRequest", "(", "rejectMsg", ")", ";", "}", "}" ]
Update a trigger on a channel @param {String|Integer} channelIdentifier A Robin channel identifier @param {String|Integer} triggerIdentifier A Robin channel trigger identifier @param {Object} data A querystring object @return {Function} A Promise
[ "Update", "a", "trigger", "on", "a", "channel" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/channels.js#L171-L181
43,533
robinpowered/robin-js-sdk-public
lib/api/modules/channels.js
function (channelIdentifier, triggerIdentifier) { var path; if (channelIdentifier && triggerIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS, triggerIdentifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A channel identifier and a trigger identifier are required.'); } }
javascript
function (channelIdentifier, triggerIdentifier) { var path; if (channelIdentifier && triggerIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS, triggerIdentifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A channel identifier and a trigger identifier are required.'); } }
[ "function", "(", "channelIdentifier", ",", "triggerIdentifier", ")", "{", "var", "path", ";", "if", "(", "channelIdentifier", "&&", "triggerIdentifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "CHANNELS", ",", "channelIdentifier", ",", "constants", ".", "TRIGGERS", ",", "triggerIdentifier", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A channel identifier and a trigger identifier are required.'", ")", ";", "}", "}" ]
Delete a trigger from a channel @param {String|Integer} channelIdentifier A Robin channel identifier @param {String|Integer} triggerIdentifier A Robin channel data point identifier @return {Function} A Promise
[ "Delete", "a", "trigger", "from", "a", "channel" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/channels.js#L189-L197
43,534
robinpowered/robin-js-sdk-public
lib/api/modules/organizations.js
function (orgIdOrSlug, params) { var path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug); return this.Core.GET(path, params); }
javascript
function (orgIdOrSlug, params) { var path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug); return this.Core.GET(path, params); }
[ "function", "(", "orgIdOrSlug", ",", "params", ")", "{", "var", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "ORGANIZATIONS", ",", "orgIdOrSlug", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}" ]
Get all the organizations or a particular organization identified by the `orgIdOrSlug` parameter @param {String|Integer|undefined} orgIdOrSlug A Robin organization id or slug @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "organizations", "or", "a", "particular", "organization", "identified", "by", "the", "orgIdOrSlug", "parameter" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/organizations.js#L20-L23
43,535
robinpowered/robin-js-sdk-public
lib/api/modules/organizations.js
function (orgIdOrSlug, data) { var path; if (orgIdOrSlug && data) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug); return this.Core.PATCH(path, data); } else { return this.rejectRequest('Bad Request: An organization id or slug and a data object are required.'); } }
javascript
function (orgIdOrSlug, data) { var path; if (orgIdOrSlug && data) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug); return this.Core.PATCH(path, data); } else { return this.rejectRequest('Bad Request: An organization id or slug and a data object are required.'); } }
[ "function", "(", "orgIdOrSlug", ",", "data", ")", "{", "var", "path", ";", "if", "(", "orgIdOrSlug", "&&", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "ORGANIZATIONS", ",", "orgIdOrSlug", ")", ";", "return", "this", ".", "Core", ".", "PATCH", "(", "path", ",", "data", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: An organization id or slug and a data object are required.'", ")", ";", "}", "}" ]
Update an organization @param {String|Integer|undefined} orgIdOrSlug A Robin organization id or slug @param {Object} data A data object @return {Function} A Promise
[ "Update", "an", "organization" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/organizations.js#L46-L54
43,536
robinpowered/robin-js-sdk-public
lib/api/modules/organizations.js
function (orgIdOrSlug) { var path; if (orgIdOrSlug) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: An organization id or slug is required.'); } }
javascript
function (orgIdOrSlug) { var path; if (orgIdOrSlug) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: An organization id or slug is required.'); } }
[ "function", "(", "orgIdOrSlug", ")", "{", "var", "path", ";", "if", "(", "orgIdOrSlug", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "ORGANIZATIONS", ",", "orgIdOrSlug", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: An organization id or slug is required.'", ")", ";", "}", "}" ]
Delete an organization @param {String|Integer} orgIdOrSlug A Robin organization id or slug @return {Function} A Promise
[ "Delete", "an", "organization" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/organizations.js#L61-L69
43,537
robinpowered/robin-js-sdk-public
lib/api/modules/organizations.js
function (orgIdOrSlug, userId, params) { var path; if (orgIdOrSlug) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug, constants.USERS, userId); return this.Core.GET(path); } else { return this.rejectRequest('Bad Request: An organization id or slug is required.'); } }
javascript
function (orgIdOrSlug, userId, params) { var path; if (orgIdOrSlug) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug, constants.USERS, userId); return this.Core.GET(path); } else { return this.rejectRequest('Bad Request: An organization id or slug is required.'); } }
[ "function", "(", "orgIdOrSlug", ",", "userId", ",", "params", ")", "{", "var", "path", ";", "if", "(", "orgIdOrSlug", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "ORGANIZATIONS", ",", "orgIdOrSlug", ",", "constants", ".", "USERS", ",", "userId", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: An organization id or slug is required.'", ")", ";", "}", "}" ]
Get an organizations users or a particular user identified by `userId` @param {String|Integer} orgIdOrSlug A Robin organization id or slug @param {String|Integer|undefined} userId A Robin user id @param {Object|undefined} params A querystring object @return {Function} A promise
[ "Get", "an", "organizations", "users", "or", "a", "particular", "user", "identified", "by", "userId" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/organizations.js#L83-L91
43,538
robinpowered/robin-js-sdk-public
lib/api/modules/organizations.js
function (orgIdOrSlug, userId, data) { var path, rejectMsg; if (orgIdOrSlug && userId && data) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug, constants.USERS, userId); return this.Core.PATCH(path, data); } else { rejectMsg = 'Bad Request: An organization id or slug and a user id and data is required.'; return this.rejectRequest(rejectMsg); } }
javascript
function (orgIdOrSlug, userId, data) { var path, rejectMsg; if (orgIdOrSlug && userId && data) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug, constants.USERS, userId); return this.Core.PATCH(path, data); } else { rejectMsg = 'Bad Request: An organization id or slug and a user id and data is required.'; return this.rejectRequest(rejectMsg); } }
[ "function", "(", "orgIdOrSlug", ",", "userId", ",", "data", ")", "{", "var", "path", ",", "rejectMsg", ";", "if", "(", "orgIdOrSlug", "&&", "userId", "&&", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "ORGANIZATIONS", ",", "orgIdOrSlug", ",", "constants", ".", "USERS", ",", "userId", ")", ";", "return", "this", ".", "Core", ".", "PATCH", "(", "path", ",", "data", ")", ";", "}", "else", "{", "rejectMsg", "=", "'Bad Request: An organization id or slug and a user id and data is required.'", ";", "return", "this", ".", "rejectRequest", "(", "rejectMsg", ")", ";", "}", "}" ]
Update a user in an organization @param {String|Integer} orgIdOrSlug A Robin organization id or slug @param {String|Integer} userId A Robin user id @param {Object} data A data object @return {Function} A promise
[ "Update", "a", "user", "in", "an", "organization" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/organizations.js#L116-L126
43,539
robinpowered/robin-js-sdk-public
lib/api/modules/organizations.js
function (orgIdOrSlug, data) { var path, rejectMsg; if (orgIdOrSlug && data) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug, constants.USERS); return this.Core.POST(path, data); } else { rejectMsg = 'Bad Request: An organization id or slug and data is required.'; return this.rejectRequest(rejectMsg); } }
javascript
function (orgIdOrSlug, data) { var path, rejectMsg; if (orgIdOrSlug && data) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug, constants.USERS); return this.Core.POST(path, data); } else { rejectMsg = 'Bad Request: An organization id or slug and data is required.'; return this.rejectRequest(rejectMsg); } }
[ "function", "(", "orgIdOrSlug", ",", "data", ")", "{", "var", "path", ",", "rejectMsg", ";", "if", "(", "orgIdOrSlug", "&&", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "ORGANIZATIONS", ",", "orgIdOrSlug", ",", "constants", ".", "USERS", ")", ";", "return", "this", ".", "Core", ".", "POST", "(", "path", ",", "data", ")", ";", "}", "else", "{", "rejectMsg", "=", "'Bad Request: An organization id or slug and data is required.'", ";", "return", "this", ".", "rejectRequest", "(", "rejectMsg", ")", ";", "}", "}" ]
Create a channel in an organization @param {String|Integer} orgIdOrSlug A Robin organization id or slug @param {Object} data A data object @return {Function} A promise
[ "Create", "a", "channel", "in", "an", "organization" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/organizations.js#L324-L334
43,540
TooTallNate/node-stream-parser
index.js
_bytes
function _bytes (n, fn) { assert(!this._parserCallback, 'there is already a "callback" set!'); assert(isFinite(n) && n > 0, 'can only buffer a finite number of bytes > 0, got "' + n + '"'); if (!this._parserInit) init(this); debug('buffering %o bytes', n); this._parserBytesLeft = n; this._parserCallback = fn; this._parserState = BUFFERING; }
javascript
function _bytes (n, fn) { assert(!this._parserCallback, 'there is already a "callback" set!'); assert(isFinite(n) && n > 0, 'can only buffer a finite number of bytes > 0, got "' + n + '"'); if (!this._parserInit) init(this); debug('buffering %o bytes', n); this._parserBytesLeft = n; this._parserCallback = fn; this._parserState = BUFFERING; }
[ "function", "_bytes", "(", "n", ",", "fn", ")", "{", "assert", "(", "!", "this", ".", "_parserCallback", ",", "'there is already a \"callback\" set!'", ")", ";", "assert", "(", "isFinite", "(", "n", ")", "&&", "n", ">", "0", ",", "'can only buffer a finite number of bytes > 0, got \"'", "+", "n", "+", "'\"'", ")", ";", "if", "(", "!", "this", ".", "_parserInit", ")", "init", "(", "this", ")", ";", "debug", "(", "'buffering %o bytes'", ",", "n", ")", ";", "this", ".", "_parserBytesLeft", "=", "n", ";", "this", ".", "_parserCallback", "=", "fn", ";", "this", ".", "_parserState", "=", "BUFFERING", ";", "}" ]
Buffers `n` bytes and then invokes `fn` once that amount has been collected. @param {Number} n the number of bytes to buffer @param {Function} fn callback function to invoke when `n` bytes are buffered @api public
[ "Buffers", "n", "bytes", "and", "then", "invokes", "fn", "once", "that", "amount", "has", "been", "collected", "." ]
b829e8a8d85f2504ed9092e7aa20e2e3855c2ee9
https://github.com/TooTallNate/node-stream-parser/blob/b829e8a8d85f2504ed9092e7aa20e2e3855c2ee9/index.js#L96-L104
43,541
TooTallNate/node-stream-parser
index.js
_skipBytes
function _skipBytes (n, fn) { assert(!this._parserCallback, 'there is already a "callback" set!'); assert(n > 0, 'can only skip > 0 bytes, got "' + n + '"'); if (!this._parserInit) init(this); debug('skipping %o bytes', n); this._parserBytesLeft = n; this._parserCallback = fn; this._parserState = SKIPPING; }
javascript
function _skipBytes (n, fn) { assert(!this._parserCallback, 'there is already a "callback" set!'); assert(n > 0, 'can only skip > 0 bytes, got "' + n + '"'); if (!this._parserInit) init(this); debug('skipping %o bytes', n); this._parserBytesLeft = n; this._parserCallback = fn; this._parserState = SKIPPING; }
[ "function", "_skipBytes", "(", "n", ",", "fn", ")", "{", "assert", "(", "!", "this", ".", "_parserCallback", ",", "'there is already a \"callback\" set!'", ")", ";", "assert", "(", "n", ">", "0", ",", "'can only skip > 0 bytes, got \"'", "+", "n", "+", "'\"'", ")", ";", "if", "(", "!", "this", ".", "_parserInit", ")", "init", "(", "this", ")", ";", "debug", "(", "'skipping %o bytes'", ",", "n", ")", ";", "this", ".", "_parserBytesLeft", "=", "n", ";", "this", ".", "_parserCallback", "=", "fn", ";", "this", ".", "_parserState", "=", "SKIPPING", ";", "}" ]
Skips over the next `n` bytes, then invokes `fn` once that amount has been discarded. @param {Number} n the number of bytes to discard @param {Function} fn callback function to invoke when `n` bytes have been skipped @api public
[ "Skips", "over", "the", "next", "n", "bytes", "then", "invokes", "fn", "once", "that", "amount", "has", "been", "discarded", "." ]
b829e8a8d85f2504ed9092e7aa20e2e3855c2ee9
https://github.com/TooTallNate/node-stream-parser/blob/b829e8a8d85f2504ed9092e7aa20e2e3855c2ee9/index.js#L115-L123
43,542
TooTallNate/node-stream-parser
index.js
_passthrough
function _passthrough (n, fn) { assert(!this._parserCallback, 'There is already a "callback" set!'); assert(n > 0, 'can only pass through > 0 bytes, got "' + n + '"'); if (!this._parserInit) init(this); debug('passing through %o bytes', n); this._parserBytesLeft = n; this._parserCallback = fn; this._parserState = PASSTHROUGH; }
javascript
function _passthrough (n, fn) { assert(!this._parserCallback, 'There is already a "callback" set!'); assert(n > 0, 'can only pass through > 0 bytes, got "' + n + '"'); if (!this._parserInit) init(this); debug('passing through %o bytes', n); this._parserBytesLeft = n; this._parserCallback = fn; this._parserState = PASSTHROUGH; }
[ "function", "_passthrough", "(", "n", ",", "fn", ")", "{", "assert", "(", "!", "this", ".", "_parserCallback", ",", "'There is already a \"callback\" set!'", ")", ";", "assert", "(", "n", ">", "0", ",", "'can only pass through > 0 bytes, got \"'", "+", "n", "+", "'\"'", ")", ";", "if", "(", "!", "this", ".", "_parserInit", ")", "init", "(", "this", ")", ";", "debug", "(", "'passing through %o bytes'", ",", "n", ")", ";", "this", ".", "_parserBytesLeft", "=", "n", ";", "this", ".", "_parserCallback", "=", "fn", ";", "this", ".", "_parserState", "=", "PASSTHROUGH", ";", "}" ]
Passes through `n` bytes to the readable side of this stream untouched, then invokes `fn` once that amount has been passed through. @param {Number} n the number of bytes to pass through @param {Function} fn callback function to invoke when `n` bytes have passed through @api public
[ "Passes", "through", "n", "bytes", "to", "the", "readable", "side", "of", "this", "stream", "untouched", "then", "invokes", "fn", "once", "that", "amount", "has", "been", "passed", "through", "." ]
b829e8a8d85f2504ed9092e7aa20e2e3855c2ee9
https://github.com/TooTallNate/node-stream-parser/blob/b829e8a8d85f2504ed9092e7aa20e2e3855c2ee9/index.js#L134-L142
43,543
TooTallNate/node-stream-parser
index.js
process
function process (stream, chunk, output, fn) { stream._parserBytesLeft -= chunk.length; debug('%o bytes left for stream piece', stream._parserBytesLeft); if (stream._parserState === BUFFERING) { // buffer stream._parserBuffers.push(chunk); stream._parserBuffered += chunk.length; } else if (stream._parserState === PASSTHROUGH) { // passthrough output(chunk); } // don't need to do anything for the SKIPPING case if (0 === stream._parserBytesLeft) { // done with stream "piece", invoke the callback var cb = stream._parserCallback; if (cb && stream._parserState === BUFFERING && stream._parserBuffers.length > 1) { chunk = Buffer.concat(stream._parserBuffers, stream._parserBuffered); } if (stream._parserState !== BUFFERING) { chunk = null; } stream._parserCallback = null; stream._parserBuffered = 0; stream._parserState = INIT; stream._parserBuffers.splice(0); // empty if (cb) { var args = []; if (chunk) { // buffered args.push(chunk); } else { // passthrough } if (output) { // on a Transform stream, has "output" function args.push(output); } var async = cb.length > args.length; if (async) { args.push(trampoline(fn)); } // invoke cb var rtn = cb.apply(stream, args); if (!async || fn === rtn) return fn; } } else { // need more bytes return fn; } }
javascript
function process (stream, chunk, output, fn) { stream._parserBytesLeft -= chunk.length; debug('%o bytes left for stream piece', stream._parserBytesLeft); if (stream._parserState === BUFFERING) { // buffer stream._parserBuffers.push(chunk); stream._parserBuffered += chunk.length; } else if (stream._parserState === PASSTHROUGH) { // passthrough output(chunk); } // don't need to do anything for the SKIPPING case if (0 === stream._parserBytesLeft) { // done with stream "piece", invoke the callback var cb = stream._parserCallback; if (cb && stream._parserState === BUFFERING && stream._parserBuffers.length > 1) { chunk = Buffer.concat(stream._parserBuffers, stream._parserBuffered); } if (stream._parserState !== BUFFERING) { chunk = null; } stream._parserCallback = null; stream._parserBuffered = 0; stream._parserState = INIT; stream._parserBuffers.splice(0); // empty if (cb) { var args = []; if (chunk) { // buffered args.push(chunk); } else { // passthrough } if (output) { // on a Transform stream, has "output" function args.push(output); } var async = cb.length > args.length; if (async) { args.push(trampoline(fn)); } // invoke cb var rtn = cb.apply(stream, args); if (!async || fn === rtn) return fn; } } else { // need more bytes return fn; } }
[ "function", "process", "(", "stream", ",", "chunk", ",", "output", ",", "fn", ")", "{", "stream", ".", "_parserBytesLeft", "-=", "chunk", ".", "length", ";", "debug", "(", "'%o bytes left for stream piece'", ",", "stream", ".", "_parserBytesLeft", ")", ";", "if", "(", "stream", ".", "_parserState", "===", "BUFFERING", ")", "{", "// buffer", "stream", ".", "_parserBuffers", ".", "push", "(", "chunk", ")", ";", "stream", ".", "_parserBuffered", "+=", "chunk", ".", "length", ";", "}", "else", "if", "(", "stream", ".", "_parserState", "===", "PASSTHROUGH", ")", "{", "// passthrough", "output", "(", "chunk", ")", ";", "}", "// don't need to do anything for the SKIPPING case", "if", "(", "0", "===", "stream", ".", "_parserBytesLeft", ")", "{", "// done with stream \"piece\", invoke the callback", "var", "cb", "=", "stream", ".", "_parserCallback", ";", "if", "(", "cb", "&&", "stream", ".", "_parserState", "===", "BUFFERING", "&&", "stream", ".", "_parserBuffers", ".", "length", ">", "1", ")", "{", "chunk", "=", "Buffer", ".", "concat", "(", "stream", ".", "_parserBuffers", ",", "stream", ".", "_parserBuffered", ")", ";", "}", "if", "(", "stream", ".", "_parserState", "!==", "BUFFERING", ")", "{", "chunk", "=", "null", ";", "}", "stream", ".", "_parserCallback", "=", "null", ";", "stream", ".", "_parserBuffered", "=", "0", ";", "stream", ".", "_parserState", "=", "INIT", ";", "stream", ".", "_parserBuffers", ".", "splice", "(", "0", ")", ";", "// empty", "if", "(", "cb", ")", "{", "var", "args", "=", "[", "]", ";", "if", "(", "chunk", ")", "{", "// buffered", "args", ".", "push", "(", "chunk", ")", ";", "}", "else", "{", "// passthrough", "}", "if", "(", "output", ")", "{", "// on a Transform stream, has \"output\" function", "args", ".", "push", "(", "output", ")", ";", "}", "var", "async", "=", "cb", ".", "length", ">", "args", ".", "length", ";", "if", "(", "async", ")", "{", "args", ".", "push", "(", "trampoline", "(", "fn", ")", ")", ";", "}", "// invoke cb", "var", "rtn", "=", "cb", ".", "apply", "(", "stream", ",", "args", ")", ";", "if", "(", "!", "async", "||", "fn", "===", "rtn", ")", "return", "fn", ";", "}", "}", "else", "{", "// need more bytes", "return", "fn", ";", "}", "}" ]
The internal `process` function gets called by the `data` function when something "interesting" happens. This function takes care of buffering the bytes when buffering, passing through the bytes when doing that, and invoking the user callback when the number of bytes has been reached. @api private
[ "The", "internal", "process", "function", "gets", "called", "by", "the", "data", "function", "when", "something", "interesting", "happens", ".", "This", "function", "takes", "care", "of", "buffering", "the", "bytes", "when", "buffering", "passing", "through", "the", "bytes", "when", "doing", "that", "and", "invoking", "the", "user", "callback", "when", "the", "number", "of", "bytes", "has", "been", "reached", "." ]
b829e8a8d85f2504ed9092e7aa20e2e3855c2ee9
https://github.com/TooTallNate/node-stream-parser/blob/b829e8a8d85f2504ed9092e7aa20e2e3855c2ee9/index.js#L225-L277
43,544
TooTallNate/node-stream-parser
index.js
trampoline
function trampoline (fn) { return function () { var result = fn.apply(this, arguments); while ('function' == typeof result) { result = result(); } return result; }; }
javascript
function trampoline (fn) { return function () { var result = fn.apply(this, arguments); while ('function' == typeof result) { result = result(); } return result; }; }
[ "function", "trampoline", "(", "fn", ")", "{", "return", "function", "(", ")", "{", "var", "result", "=", "fn", ".", "apply", "(", "this", ",", "arguments", ")", ";", "while", "(", "'function'", "==", "typeof", "result", ")", "{", "result", "=", "result", "(", ")", ";", "}", "return", "result", ";", "}", ";", "}" ]
Generic thunk-based "trampoline" helper function. @param {Function} input function @return {Function} "trampolined" function @api private
[ "Generic", "thunk", "-", "based", "trampoline", "helper", "function", "." ]
b829e8a8d85f2504ed9092e7aa20e2e3855c2ee9
https://github.com/TooTallNate/node-stream-parser/blob/b829e8a8d85f2504ed9092e7aa20e2e3855c2ee9/index.js#L289-L299
43,545
robinpowered/robin-js-sdk-public
lib/api/api.js
RobinApi
function RobinApi (accessToken, coreUrl, placesUrl) { if (accessToken) { RobinApi.super_.apply(this, arguments); this.setAccessToken(accessToken); this.setupCore(coreUrl); this.setupPlaces(placesUrl); this.loadApiModules(); } else { throw new TypeError('The access token is missing or malformed'); } }
javascript
function RobinApi (accessToken, coreUrl, placesUrl) { if (accessToken) { RobinApi.super_.apply(this, arguments); this.setAccessToken(accessToken); this.setupCore(coreUrl); this.setupPlaces(placesUrl); this.loadApiModules(); } else { throw new TypeError('The access token is missing or malformed'); } }
[ "function", "RobinApi", "(", "accessToken", ",", "coreUrl", ",", "placesUrl", ")", "{", "if", "(", "accessToken", ")", "{", "RobinApi", ".", "super_", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "setAccessToken", "(", "accessToken", ")", ";", "this", ".", "setupCore", "(", "coreUrl", ")", ";", "this", ".", "setupPlaces", "(", "placesUrl", ")", ";", "this", ".", "loadApiModules", "(", ")", ";", "}", "else", "{", "throw", "new", "TypeError", "(", "'The access token is missing or malformed'", ")", ";", "}", "}" ]
The Robin API constructor @param {String} accessToken A Robin Access Token @param {String} coreUrl The Base URL for the Core API. @param {String} placesUrl The Base URL for the Places API
[ "The", "Robin", "API", "constructor" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/api.js#L40-L50
43,546
robinpowered/robin-js-sdk-public
lib/api/modules/apps.js
function (appIdOrSlug, params) { var path = this.constructPath(constants.APPS, appIdOrSlug); return this.Core.GET(path, params); }
javascript
function (appIdOrSlug, params) { var path = this.constructPath(constants.APPS, appIdOrSlug); return this.Core.GET(path, params); }
[ "function", "(", "appIdOrSlug", ",", "params", ")", "{", "var", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "APPS", ",", "appIdOrSlug", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}" ]
Get an app @param {String|Integer|undefined} appIdOrSlug A Robin app identifier or slug @param {Object|undefnied} params A querystring object @return {Function} A Promise
[ "Get", "an", "app" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/apps.js#L20-L23
43,547
robinpowered/robin-js-sdk-public
lib/api/modules/apps.js
function (appIdOrSlug, data) { var path; if (appIdOrSlug && data) { path = this.constructPath(constants.APPS, appIdOrSlug); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: An app id or slug and a data object are required.'); } }
javascript
function (appIdOrSlug, data) { var path; if (appIdOrSlug && data) { path = this.constructPath(constants.APPS, appIdOrSlug); return this.Core.POST(path, data); } else { return this.rejectRequest('Bad Request: An app id or slug and a data object are required.'); } }
[ "function", "(", "appIdOrSlug", ",", "data", ")", "{", "var", "path", ";", "if", "(", "appIdOrSlug", "&&", "data", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "APPS", ",", "appIdOrSlug", ")", ";", "return", "this", ".", "Core", ".", "POST", "(", "path", ",", "data", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: An app id or slug and a data object are required.'", ")", ";", "}", "}" ]
Update an app @param {String|Integer} appIdOrSlug A Robin app identifier or slug @param {Object} data A data object @return {Function} A Promise
[ "Update", "an", "app" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/apps.js#L31-L39
43,548
robinpowered/robin-js-sdk-public
lib/api/modules/apps.js
function (appIdOrSlug) { var path; if (appIdOrSlug) { path = this.constructPath(constants.APPS, appIdOrSlug); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: An app id or slug is required.'); } }
javascript
function (appIdOrSlug) { var path; if (appIdOrSlug) { path = this.constructPath(constants.APPS, appIdOrSlug); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: An app id or slug is required.'); } }
[ "function", "(", "appIdOrSlug", ")", "{", "var", "path", ";", "if", "(", "appIdOrSlug", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "APPS", ",", "appIdOrSlug", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: An app id or slug is required.'", ")", ";", "}", "}" ]
Delete an app @param {String|Integer} appIdOrSlug A Robin app identifier or slug @return {Function} A Promise
[ "Delete", "an", "app" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/apps.js#L46-L54
43,549
jimf/jasmine-diff
index.js
getType
function getType (val) { if (val === null) { return 'null' } else if (val === void 0) { return 'undefined' } return Object.prototype.toString.call(val) .replace(/^\[.+\s(.+?)]$/, '$1') .toLowerCase() }
javascript
function getType (val) { if (val === null) { return 'null' } else if (val === void 0) { return 'undefined' } return Object.prototype.toString.call(val) .replace(/^\[.+\s(.+?)]$/, '$1') .toLowerCase() }
[ "function", "getType", "(", "val", ")", "{", "if", "(", "val", "===", "null", ")", "{", "return", "'null'", "}", "else", "if", "(", "val", "===", "void", "0", ")", "{", "return", "'undefined'", "}", "return", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "val", ")", ".", "replace", "(", "/", "^\\[.+\\s(.+?)]$", "/", ",", "'$1'", ")", ".", "toLowerCase", "(", ")", "}" ]
Return type of given value. @param {*} val Value to identify @return {string}
[ "Return", "type", "of", "given", "value", "." ]
3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82
https://github.com/jimf/jasmine-diff/blob/3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82/index.js#L9-L18
43,550
jimf/jasmine-diff
index.js
Value
function Value (val, parent, opts) { var obj = Object.create(Value.prototype) opts = opts || {} obj.value = val obj.parent = parent obj.type = getType(val) obj.key = opts.key obj.length = opts.length !== undefined ? opts.length : (val && val.length) return obj }
javascript
function Value (val, parent, opts) { var obj = Object.create(Value.prototype) opts = opts || {} obj.value = val obj.parent = parent obj.type = getType(val) obj.key = opts.key obj.length = opts.length !== undefined ? opts.length : (val && val.length) return obj }
[ "function", "Value", "(", "val", ",", "parent", ",", "opts", ")", "{", "var", "obj", "=", "Object", ".", "create", "(", "Value", ".", "prototype", ")", "opts", "=", "opts", "||", "{", "}", "obj", ".", "value", "=", "val", "obj", ".", "parent", "=", "parent", "obj", ".", "type", "=", "getType", "(", "val", ")", "obj", ".", "key", "=", "opts", ".", "key", "obj", ".", "length", "=", "opts", ".", "length", "!==", "undefined", "?", "opts", ".", "length", ":", "(", "val", "&&", "val", ".", "length", ")", "return", "obj", "}" ]
Value wrapper to contain state. @param {*} val Value to wrap @param {Value|null} parent Parent value @param {object} [opts] Options @param {string|number} [opts.key] Key/index if value is contained in an object/array @param {number} [opts.length] Length if value is an object/array @return {Value}
[ "Value", "wrapper", "to", "contain", "state", "." ]
3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82
https://github.com/jimf/jasmine-diff/blob/3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82/index.js#L30-L39
43,551
jimf/jasmine-diff
index.js
traverse
function traverse (value, v) { var state = {} var visitor = v.visitor var seen = [] /** * Recursively walk the value, dispatching visitor methods as values are encountered. * * @param {*} val Value * @param {Value|null} parent Parent value * @param {object} [opts] Additional options */ function traverseValue (val, parent, opts) { var wrapper = Value(val, parent, opts) var enterFn = wrapper.type + 'Enter' var exitFn = wrapper.type + 'Exit' var keys if (wrapper.type === 'object' || wrapper.type === 'array') { if (seen.indexOf(wrapper.value) >= 0) { wrapper.isCircularRef = true } seen.push(wrapper.value) } if (wrapper.type === 'object') { keys = Object.keys(wrapper.value).sort() wrapper.length = keys.length } if (visitor[enterFn]) { visitor[enterFn](wrapper, state) } else if (visitor.otherEnter) { visitor.otherEnter(wrapper, state) } switch (wrapper.type) { case 'array': if (!wrapper.isCircularRef) { wrapper.value.forEach(function (child, i) { traverseValue(child, wrapper, { key: i }) }) } break case 'object': if (!wrapper.isCircularRef) { keys.forEach(function (key) { traverseValue(wrapper.value[key], wrapper, { key: key }) }) } break default: /* do nothing */ break } if (visitor[exitFn]) { visitor[exitFn](wrapper, state) } if (wrapper.type === 'object' || wrapper.type === 'array') { seen.pop() } } if (v.pre) { v.pre.call(null, state) } traverseValue(value, null, null) if (v.post) { v.post.call(null, state) } }
javascript
function traverse (value, v) { var state = {} var visitor = v.visitor var seen = [] /** * Recursively walk the value, dispatching visitor methods as values are encountered. * * @param {*} val Value * @param {Value|null} parent Parent value * @param {object} [opts] Additional options */ function traverseValue (val, parent, opts) { var wrapper = Value(val, parent, opts) var enterFn = wrapper.type + 'Enter' var exitFn = wrapper.type + 'Exit' var keys if (wrapper.type === 'object' || wrapper.type === 'array') { if (seen.indexOf(wrapper.value) >= 0) { wrapper.isCircularRef = true } seen.push(wrapper.value) } if (wrapper.type === 'object') { keys = Object.keys(wrapper.value).sort() wrapper.length = keys.length } if (visitor[enterFn]) { visitor[enterFn](wrapper, state) } else if (visitor.otherEnter) { visitor.otherEnter(wrapper, state) } switch (wrapper.type) { case 'array': if (!wrapper.isCircularRef) { wrapper.value.forEach(function (child, i) { traverseValue(child, wrapper, { key: i }) }) } break case 'object': if (!wrapper.isCircularRef) { keys.forEach(function (key) { traverseValue(wrapper.value[key], wrapper, { key: key }) }) } break default: /* do nothing */ break } if (visitor[exitFn]) { visitor[exitFn](wrapper, state) } if (wrapper.type === 'object' || wrapper.type === 'array') { seen.pop() } } if (v.pre) { v.pre.call(null, state) } traverseValue(value, null, null) if (v.post) { v.post.call(null, state) } }
[ "function", "traverse", "(", "value", ",", "v", ")", "{", "var", "state", "=", "{", "}", "var", "visitor", "=", "v", ".", "visitor", "var", "seen", "=", "[", "]", "/**\n * Recursively walk the value, dispatching visitor methods as values are encountered.\n *\n * @param {*} val Value\n * @param {Value|null} parent Parent value\n * @param {object} [opts] Additional options\n */", "function", "traverseValue", "(", "val", ",", "parent", ",", "opts", ")", "{", "var", "wrapper", "=", "Value", "(", "val", ",", "parent", ",", "opts", ")", "var", "enterFn", "=", "wrapper", ".", "type", "+", "'Enter'", "var", "exitFn", "=", "wrapper", ".", "type", "+", "'Exit'", "var", "keys", "if", "(", "wrapper", ".", "type", "===", "'object'", "||", "wrapper", ".", "type", "===", "'array'", ")", "{", "if", "(", "seen", ".", "indexOf", "(", "wrapper", ".", "value", ")", ">=", "0", ")", "{", "wrapper", ".", "isCircularRef", "=", "true", "}", "seen", ".", "push", "(", "wrapper", ".", "value", ")", "}", "if", "(", "wrapper", ".", "type", "===", "'object'", ")", "{", "keys", "=", "Object", ".", "keys", "(", "wrapper", ".", "value", ")", ".", "sort", "(", ")", "wrapper", ".", "length", "=", "keys", ".", "length", "}", "if", "(", "visitor", "[", "enterFn", "]", ")", "{", "visitor", "[", "enterFn", "]", "(", "wrapper", ",", "state", ")", "}", "else", "if", "(", "visitor", ".", "otherEnter", ")", "{", "visitor", ".", "otherEnter", "(", "wrapper", ",", "state", ")", "}", "switch", "(", "wrapper", ".", "type", ")", "{", "case", "'array'", ":", "if", "(", "!", "wrapper", ".", "isCircularRef", ")", "{", "wrapper", ".", "value", ".", "forEach", "(", "function", "(", "child", ",", "i", ")", "{", "traverseValue", "(", "child", ",", "wrapper", ",", "{", "key", ":", "i", "}", ")", "}", ")", "}", "break", "case", "'object'", ":", "if", "(", "!", "wrapper", ".", "isCircularRef", ")", "{", "keys", ".", "forEach", "(", "function", "(", "key", ")", "{", "traverseValue", "(", "wrapper", ".", "value", "[", "key", "]", ",", "wrapper", ",", "{", "key", ":", "key", "}", ")", "}", ")", "}", "break", "default", ":", "/* do nothing */", "break", "}", "if", "(", "visitor", "[", "exitFn", "]", ")", "{", "visitor", "[", "exitFn", "]", "(", "wrapper", ",", "state", ")", "}", "if", "(", "wrapper", ".", "type", "===", "'object'", "||", "wrapper", ".", "type", "===", "'array'", ")", "{", "seen", ".", "pop", "(", ")", "}", "}", "if", "(", "v", ".", "pre", ")", "{", "v", ".", "pre", ".", "call", "(", "null", ",", "state", ")", "}", "traverseValue", "(", "value", ",", "null", ",", "null", ")", "if", "(", "v", ".", "post", ")", "{", "v", ".", "post", ".", "call", "(", "null", ",", "state", ")", "}", "}" ]
Traverse a value with a visitor object. @param {*} value Value to traverse @param {Visitor} visitor Visitor instance
[ "Traverse", "a", "value", "with", "a", "visitor", "object", "." ]
3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82
https://github.com/jimf/jasmine-diff/blob/3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82/index.js#L47-L117
43,552
jimf/jasmine-diff
index.js
prettyPrintVisitor
function prettyPrintVisitor (pp, spaces) { var visitor = {} visitor.pre = function (state) { state.result = '' state.depth = 0 } visitor.visitor = { arrayEnter: function (val, state) { if (val.key !== undefined) { state.result += repeat(state.depth * spaces, ' ') if (val.parent.type === 'object') { state.result += "'" + val.key + "': " } } if (val.isCircularRef) { state.result += '[Circular]\n' return } else if (val.length === 0) { state.result += '[]\n' return } state.result += '[\n' state.depth += 1 }, arrayExit: function (val, state) { if (val.length === 0 || val.isCircularRef) { return } state.depth -= 1 state.result += repeat(state.depth * spaces, ' ') + ']\n' }, objectEnter: function (val, state) { if (val.key !== undefined) { state.result += repeat(state.depth * spaces, ' ') if (val.parent.type === 'object') { state.result += "'" + val.key + "': " } } if (val.isCircularRef) { state.result += '[Circular]\n' return } else if (val.length === 0) { state.result += '{}\n' return } state.result += '{\n' state.depth += 1 }, objectExit: function (val, state) { if (val.length === 0 || val.isCircularRef) { return } state.depth -= 1 state.result += repeat(state.depth * spaces, ' ') + '}\n' }, stringEnter: function (val, state) { if (val.parent === null) { state.result += pp(val.value).slice(1, -1) return } state.result += repeat(state.depth * spaces, ' ') if (val.parent.type === 'object') { state.result += "'" + val.key + "': " } state.result += pp(val.value) + '\n' }, otherEnter: function (val, state) { state.result += repeat(state.depth * spaces, ' ') if (val.key !== undefined && val.parent.type === 'object') { state.result += "'" + val.key + "': " } state.result += pp(val.value) + '\n' } } visitor.post = function (state) { visitor.result = state.result.trim() } return visitor }
javascript
function prettyPrintVisitor (pp, spaces) { var visitor = {} visitor.pre = function (state) { state.result = '' state.depth = 0 } visitor.visitor = { arrayEnter: function (val, state) { if (val.key !== undefined) { state.result += repeat(state.depth * spaces, ' ') if (val.parent.type === 'object') { state.result += "'" + val.key + "': " } } if (val.isCircularRef) { state.result += '[Circular]\n' return } else if (val.length === 0) { state.result += '[]\n' return } state.result += '[\n' state.depth += 1 }, arrayExit: function (val, state) { if (val.length === 0 || val.isCircularRef) { return } state.depth -= 1 state.result += repeat(state.depth * spaces, ' ') + ']\n' }, objectEnter: function (val, state) { if (val.key !== undefined) { state.result += repeat(state.depth * spaces, ' ') if (val.parent.type === 'object') { state.result += "'" + val.key + "': " } } if (val.isCircularRef) { state.result += '[Circular]\n' return } else if (val.length === 0) { state.result += '{}\n' return } state.result += '{\n' state.depth += 1 }, objectExit: function (val, state) { if (val.length === 0 || val.isCircularRef) { return } state.depth -= 1 state.result += repeat(state.depth * spaces, ' ') + '}\n' }, stringEnter: function (val, state) { if (val.parent === null) { state.result += pp(val.value).slice(1, -1) return } state.result += repeat(state.depth * spaces, ' ') if (val.parent.type === 'object') { state.result += "'" + val.key + "': " } state.result += pp(val.value) + '\n' }, otherEnter: function (val, state) { state.result += repeat(state.depth * spaces, ' ') if (val.key !== undefined && val.parent.type === 'object') { state.result += "'" + val.key + "': " } state.result += pp(val.value) + '\n' } } visitor.post = function (state) { visitor.result = state.result.trim() } return visitor }
[ "function", "prettyPrintVisitor", "(", "pp", ",", "spaces", ")", "{", "var", "visitor", "=", "{", "}", "visitor", ".", "pre", "=", "function", "(", "state", ")", "{", "state", ".", "result", "=", "''", "state", ".", "depth", "=", "0", "}", "visitor", ".", "visitor", "=", "{", "arrayEnter", ":", "function", "(", "val", ",", "state", ")", "{", "if", "(", "val", ".", "key", "!==", "undefined", ")", "{", "state", ".", "result", "+=", "repeat", "(", "state", ".", "depth", "*", "spaces", ",", "' '", ")", "if", "(", "val", ".", "parent", ".", "type", "===", "'object'", ")", "{", "state", ".", "result", "+=", "\"'\"", "+", "val", ".", "key", "+", "\"': \"", "}", "}", "if", "(", "val", ".", "isCircularRef", ")", "{", "state", ".", "result", "+=", "'[Circular]\\n'", "return", "}", "else", "if", "(", "val", ".", "length", "===", "0", ")", "{", "state", ".", "result", "+=", "'[]\\n'", "return", "}", "state", ".", "result", "+=", "'[\\n'", "state", ".", "depth", "+=", "1", "}", ",", "arrayExit", ":", "function", "(", "val", ",", "state", ")", "{", "if", "(", "val", ".", "length", "===", "0", "||", "val", ".", "isCircularRef", ")", "{", "return", "}", "state", ".", "depth", "-=", "1", "state", ".", "result", "+=", "repeat", "(", "state", ".", "depth", "*", "spaces", ",", "' '", ")", "+", "']\\n'", "}", ",", "objectEnter", ":", "function", "(", "val", ",", "state", ")", "{", "if", "(", "val", ".", "key", "!==", "undefined", ")", "{", "state", ".", "result", "+=", "repeat", "(", "state", ".", "depth", "*", "spaces", ",", "' '", ")", "if", "(", "val", ".", "parent", ".", "type", "===", "'object'", ")", "{", "state", ".", "result", "+=", "\"'\"", "+", "val", ".", "key", "+", "\"': \"", "}", "}", "if", "(", "val", ".", "isCircularRef", ")", "{", "state", ".", "result", "+=", "'[Circular]\\n'", "return", "}", "else", "if", "(", "val", ".", "length", "===", "0", ")", "{", "state", ".", "result", "+=", "'{}\\n'", "return", "}", "state", ".", "result", "+=", "'{\\n'", "state", ".", "depth", "+=", "1", "}", ",", "objectExit", ":", "function", "(", "val", ",", "state", ")", "{", "if", "(", "val", ".", "length", "===", "0", "||", "val", ".", "isCircularRef", ")", "{", "return", "}", "state", ".", "depth", "-=", "1", "state", ".", "result", "+=", "repeat", "(", "state", ".", "depth", "*", "spaces", ",", "' '", ")", "+", "'}\\n'", "}", ",", "stringEnter", ":", "function", "(", "val", ",", "state", ")", "{", "if", "(", "val", ".", "parent", "===", "null", ")", "{", "state", ".", "result", "+=", "pp", "(", "val", ".", "value", ")", ".", "slice", "(", "1", ",", "-", "1", ")", "return", "}", "state", ".", "result", "+=", "repeat", "(", "state", ".", "depth", "*", "spaces", ",", "' '", ")", "if", "(", "val", ".", "parent", ".", "type", "===", "'object'", ")", "{", "state", ".", "result", "+=", "\"'\"", "+", "val", ".", "key", "+", "\"': \"", "}", "state", ".", "result", "+=", "pp", "(", "val", ".", "value", ")", "+", "'\\n'", "}", ",", "otherEnter", ":", "function", "(", "val", ",", "state", ")", "{", "state", ".", "result", "+=", "repeat", "(", "state", ".", "depth", "*", "spaces", ",", "' '", ")", "if", "(", "val", ".", "key", "!==", "undefined", "&&", "val", ".", "parent", ".", "type", "===", "'object'", ")", "{", "state", ".", "result", "+=", "\"'\"", "+", "val", ".", "key", "+", "\"': \"", "}", "state", ".", "result", "+=", "pp", "(", "val", ".", "value", ")", "+", "'\\n'", "}", "}", "visitor", ".", "post", "=", "function", "(", "state", ")", "{", "visitor", ".", "result", "=", "state", ".", "result", ".", "trim", "(", ")", "}", "return", "visitor", "}" ]
Visitor factory for pretty printing a JavaScript value. @param {function} pp Fallback pretty printer @param {number} spaces Number of spaces for indentation @return {object} Visitor instance
[ "Visitor", "factory", "for", "pretty", "printing", "a", "JavaScript", "value", "." ]
3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82
https://github.com/jimf/jasmine-diff/blob/3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82/index.js#L142-L216
43,553
jimf/jasmine-diff
index.js
createStringifier
function createStringifier (pp, spaces) { return function stringify (value) { var visitor = prettyPrintVisitor(pp, spaces) traverse(value, visitor) return visitor.result } }
javascript
function createStringifier (pp, spaces) { return function stringify (value) { var visitor = prettyPrintVisitor(pp, spaces) traverse(value, visitor) return visitor.result } }
[ "function", "createStringifier", "(", "pp", ",", "spaces", ")", "{", "return", "function", "stringify", "(", "value", ")", "{", "var", "visitor", "=", "prettyPrintVisitor", "(", "pp", ",", "spaces", ")", "traverse", "(", "value", ",", "visitor", ")", "return", "visitor", ".", "result", "}", "}" ]
Stringifier factory. @param {function} pp Fallback pretty printer @param {number} spaces Number of spaces for indentation @return {function}
[ "Stringifier", "factory", "." ]
3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82
https://github.com/jimf/jasmine-diff/blob/3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82/index.js#L225-L231
43,554
jimf/jasmine-diff
index.js
isDiffable
function isDiffable (val) { switch (getType(val)) { case 'array': case 'object': return true case 'string': return val.length >= 40 || (val.trim().match(/\n/g) || []).length >= 1 default: return false } }
javascript
function isDiffable (val) { switch (getType(val)) { case 'array': case 'object': return true case 'string': return val.length >= 40 || (val.trim().match(/\n/g) || []).length >= 1 default: return false } }
[ "function", "isDiffable", "(", "val", ")", "{", "switch", "(", "getType", "(", "val", ")", ")", "{", "case", "'array'", ":", "case", "'object'", ":", "return", "true", "case", "'string'", ":", "return", "val", ".", "length", ">=", "40", "||", "(", "val", ".", "trim", "(", ")", ".", "match", "(", "/", "\\n", "/", "g", ")", "||", "[", "]", ")", ".", "length", ">=", "1", "default", ":", "return", "false", "}", "}" ]
Return whether value should be diffed. @param {*} val Value to test @return {boolean}
[ "Return", "whether", "value", "should", "be", "diffed", "." ]
3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82
https://github.com/jimf/jasmine-diff/blob/3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82/index.js#L239-L251
43,555
jimf/jasmine-diff
index.js
lpad
function lpad (str, width) { while (String(str).length < width) { str = ' ' + str } return str }
javascript
function lpad (str, width) { while (String(str).length < width) { str = ' ' + str } return str }
[ "function", "lpad", "(", "str", ",", "width", ")", "{", "while", "(", "String", "(", "str", ")", ".", "length", "<", "width", ")", "{", "str", "=", "' '", "+", "str", "}", "return", "str", "}" ]
Left-pad utility. @param {string} str String to pad @param {number} width Total desired width of string @return {string}
[ "Left", "-", "pad", "utility", "." ]
3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82
https://github.com/jimf/jasmine-diff/blob/3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82/index.js#L260-L265
43,556
jimf/jasmine-diff
index.js
unifiedDiff
function unifiedDiff (actual, expected, formatAdd, formatRem) { return [ formatAdd('+ expected'), formatRem('- actual'), '' ] .concat( diff.createPatch('string', actual, expected) .split('\n') .slice(4) .filter(function (line) { return line[0] === '+' || line[0] === '-' }) .map(function (line) { return line[0] === '+' ? formatAdd(line) : formatRem(line) }) ) .join('\n') }
javascript
function unifiedDiff (actual, expected, formatAdd, formatRem) { return [ formatAdd('+ expected'), formatRem('- actual'), '' ] .concat( diff.createPatch('string', actual, expected) .split('\n') .slice(4) .filter(function (line) { return line[0] === '+' || line[0] === '-' }) .map(function (line) { return line[0] === '+' ? formatAdd(line) : formatRem(line) }) ) .join('\n') }
[ "function", "unifiedDiff", "(", "actual", ",", "expected", ",", "formatAdd", ",", "formatRem", ")", "{", "return", "[", "formatAdd", "(", "'+ expected'", ")", ",", "formatRem", "(", "'- actual'", ")", ",", "''", "]", ".", "concat", "(", "diff", ".", "createPatch", "(", "'string'", ",", "actual", ",", "expected", ")", ".", "split", "(", "'\\n'", ")", ".", "slice", "(", "4", ")", ".", "filter", "(", "function", "(", "line", ")", "{", "return", "line", "[", "0", "]", "===", "'+'", "||", "line", "[", "0", "]", "===", "'-'", "}", ")", ".", "map", "(", "function", "(", "line", ")", "{", "return", "line", "[", "0", "]", "===", "'+'", "?", "formatAdd", "(", "line", ")", ":", "formatRem", "(", "line", ")", "}", ")", ")", ".", "join", "(", "'\\n'", ")", "}" ]
Return unified diff of actual vs expected. @param {*} actual Actual value @param {*} expected Expected value @param {function} formatAdd Addition formatter @param {function} formatRem Removal formatter @return {string}
[ "Return", "unified", "diff", "of", "actual", "vs", "expected", "." ]
3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82
https://github.com/jimf/jasmine-diff/blob/3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82/index.js#L318-L336
43,557
jimf/jasmine-diff
index.js
formatLinesWith
function formatLinesWith (formatter, str) { return str .split('\n') .map(function (line) { return line.length ? formatter(line) : '' }) .join('\n') }
javascript
function formatLinesWith (formatter, str) { return str .split('\n') .map(function (line) { return line.length ? formatter(line) : '' }) .join('\n') }
[ "function", "formatLinesWith", "(", "formatter", ",", "str", ")", "{", "return", "str", ".", "split", "(", "'\\n'", ")", ".", "map", "(", "function", "(", "line", ")", "{", "return", "line", ".", "length", "?", "formatter", "(", "line", ")", ":", "''", "}", ")", ".", "join", "(", "'\\n'", ")", "}" ]
Run a transformation function over the lines within a string and return the result. @param {function} formatter Formatter function @param {string} str String to format @return {string}
[ "Run", "a", "transformation", "function", "over", "the", "lines", "within", "a", "string", "and", "return", "the", "result", "." ]
3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82
https://github.com/jimf/jasmine-diff/blob/3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82/index.js#L346-L353
43,558
jimf/jasmine-diff
index.js
inlineDiff
function inlineDiff (actual, expected, formatAdd, formatRem) { var result = diff.diffWordsWithSpace(actual, expected) .map(function (line, idx) { if (line.added) { return formatLinesWith(formatAdd, line.value) } return line.removed ? formatLinesWith(formatRem, line.value) : line.value }) .join('') var lines = result.split('\n') if (lines.length > 4) { result = lines .map(function (line, idx) { return lpad(idx + 1, String(lines.length).length) + ' | ' + line }) .join('\n') } return formatRem('actual') + ' ' + formatAdd('expected') + '\n\n' + result }
javascript
function inlineDiff (actual, expected, formatAdd, formatRem) { var result = diff.diffWordsWithSpace(actual, expected) .map(function (line, idx) { if (line.added) { return formatLinesWith(formatAdd, line.value) } return line.removed ? formatLinesWith(formatRem, line.value) : line.value }) .join('') var lines = result.split('\n') if (lines.length > 4) { result = lines .map(function (line, idx) { return lpad(idx + 1, String(lines.length).length) + ' | ' + line }) .join('\n') } return formatRem('actual') + ' ' + formatAdd('expected') + '\n\n' + result }
[ "function", "inlineDiff", "(", "actual", ",", "expected", ",", "formatAdd", ",", "formatRem", ")", "{", "var", "result", "=", "diff", ".", "diffWordsWithSpace", "(", "actual", ",", "expected", ")", ".", "map", "(", "function", "(", "line", ",", "idx", ")", "{", "if", "(", "line", ".", "added", ")", "{", "return", "formatLinesWith", "(", "formatAdd", ",", "line", ".", "value", ")", "}", "return", "line", ".", "removed", "?", "formatLinesWith", "(", "formatRem", ",", "line", ".", "value", ")", ":", "line", ".", "value", "}", ")", ".", "join", "(", "''", ")", "var", "lines", "=", "result", ".", "split", "(", "'\\n'", ")", "if", "(", "lines", ".", "length", ">", "4", ")", "{", "result", "=", "lines", ".", "map", "(", "function", "(", "line", ",", "idx", ")", "{", "return", "lpad", "(", "idx", "+", "1", ",", "String", "(", "lines", ".", "length", ")", ".", "length", ")", "+", "' | '", "+", "line", "}", ")", ".", "join", "(", "'\\n'", ")", "}", "return", "formatRem", "(", "'actual'", ")", "+", "' '", "+", "formatAdd", "(", "'expected'", ")", "+", "'\\n\\n'", "+", "result", "}" ]
Return inline diff of actual vs expected. @param {*} actual Actual value @param {*} expected Expected value @param {function} formatAdd Addition formatter @param {function} formatRem Removal formatter @return {string}
[ "Return", "inline", "diff", "of", "actual", "vs", "expected", "." ]
3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82
https://github.com/jimf/jasmine-diff/blob/3e9095d00bd6a87fcd6f52eab6b9afcc9c993d82/index.js#L364-L384
43,559
iceddev/matchmedia
index.js
Mql
function Mql(query, values){ var self = this; if(dynamicMatch){ var mql = dynamicMatch.call(window, query); this.matches = mql.matches; this.media = mql.media; // TODO: is there a time it makes sense to remove this listener? mql.addListener(update); } else { this.matches = staticMatch(query, values); this.media = query; } this.addListener = addListener; this.removeListener = removeListener; this.dispose = dispose; function addListener(listener){ if(mql){ mql.addListener(listener); } } function removeListener(listener){ if(mql){ mql.removeListener(listener); } } // update ourselves! function update(evt){ self.matches = evt.matches; self.media = evt.media; } function dispose(){ mql.removeListener(update); } }
javascript
function Mql(query, values){ var self = this; if(dynamicMatch){ var mql = dynamicMatch.call(window, query); this.matches = mql.matches; this.media = mql.media; // TODO: is there a time it makes sense to remove this listener? mql.addListener(update); } else { this.matches = staticMatch(query, values); this.media = query; } this.addListener = addListener; this.removeListener = removeListener; this.dispose = dispose; function addListener(listener){ if(mql){ mql.addListener(listener); } } function removeListener(listener){ if(mql){ mql.removeListener(listener); } } // update ourselves! function update(evt){ self.matches = evt.matches; self.media = evt.media; } function dispose(){ mql.removeListener(update); } }
[ "function", "Mql", "(", "query", ",", "values", ")", "{", "var", "self", "=", "this", ";", "if", "(", "dynamicMatch", ")", "{", "var", "mql", "=", "dynamicMatch", ".", "call", "(", "window", ",", "query", ")", ";", "this", ".", "matches", "=", "mql", ".", "matches", ";", "this", ".", "media", "=", "mql", ".", "media", ";", "// TODO: is there a time it makes sense to remove this listener?", "mql", ".", "addListener", "(", "update", ")", ";", "}", "else", "{", "this", ".", "matches", "=", "staticMatch", "(", "query", ",", "values", ")", ";", "this", ".", "media", "=", "query", ";", "}", "this", ".", "addListener", "=", "addListener", ";", "this", ".", "removeListener", "=", "removeListener", ";", "this", ".", "dispose", "=", "dispose", ";", "function", "addListener", "(", "listener", ")", "{", "if", "(", "mql", ")", "{", "mql", ".", "addListener", "(", "listener", ")", ";", "}", "}", "function", "removeListener", "(", "listener", ")", "{", "if", "(", "mql", ")", "{", "mql", ".", "removeListener", "(", "listener", ")", ";", "}", "}", "// update ourselves!", "function", "update", "(", "evt", ")", "{", "self", ".", "matches", "=", "evt", ".", "matches", ";", "self", ".", "media", "=", "evt", ".", "media", ";", "}", "function", "dispose", "(", ")", "{", "mql", ".", "removeListener", "(", "update", ")", ";", "}", "}" ]
our fake MediaQueryList
[ "our", "fake", "MediaQueryList" ]
96eee43707a7414dca326c6527a75a78b1c71010
https://github.com/iceddev/matchmedia/blob/96eee43707a7414dca326c6527a75a78b1c71010/index.js#L7-L45
43,560
dsfields/radargun
lib/bench.js
assertThresholds
function assertThresholds(thresholds) { if (!elv(thresholds)) return null; if (typeof thresholds !== 'object') { throw new TypeError(msg.argThresholds); } const avg = elv.coalesce(thresholds.avg, false); const max = elv.coalesce(thresholds.max, false); const min = elv.coalesce(thresholds.min, false); const { target } = thresholds; if (avg !== false && typeof avg !== 'number') { throw new TypeError(msg.argAvg); } if (max !== false && typeof max !== 'number') { throw new TypeError(msg.argMax); } if (min !== false && typeof min !== 'number') { throw new TypeError(msg.argMin); } if (!Number.isInteger(target) || target < 0) { throw new TypeError(msg.argTarget); } return { avg, max, min, target, }; }
javascript
function assertThresholds(thresholds) { if (!elv(thresholds)) return null; if (typeof thresholds !== 'object') { throw new TypeError(msg.argThresholds); } const avg = elv.coalesce(thresholds.avg, false); const max = elv.coalesce(thresholds.max, false); const min = elv.coalesce(thresholds.min, false); const { target } = thresholds; if (avg !== false && typeof avg !== 'number') { throw new TypeError(msg.argAvg); } if (max !== false && typeof max !== 'number') { throw new TypeError(msg.argMax); } if (min !== false && typeof min !== 'number') { throw new TypeError(msg.argMin); } if (!Number.isInteger(target) || target < 0) { throw new TypeError(msg.argTarget); } return { avg, max, min, target, }; }
[ "function", "assertThresholds", "(", "thresholds", ")", "{", "if", "(", "!", "elv", "(", "thresholds", ")", ")", "return", "null", ";", "if", "(", "typeof", "thresholds", "!==", "'object'", ")", "{", "throw", "new", "TypeError", "(", "msg", ".", "argThresholds", ")", ";", "}", "const", "avg", "=", "elv", ".", "coalesce", "(", "thresholds", ".", "avg", ",", "false", ")", ";", "const", "max", "=", "elv", ".", "coalesce", "(", "thresholds", ".", "max", ",", "false", ")", ";", "const", "min", "=", "elv", ".", "coalesce", "(", "thresholds", ".", "min", ",", "false", ")", ";", "const", "{", "target", "}", "=", "thresholds", ";", "if", "(", "avg", "!==", "false", "&&", "typeof", "avg", "!==", "'number'", ")", "{", "throw", "new", "TypeError", "(", "msg", ".", "argAvg", ")", ";", "}", "if", "(", "max", "!==", "false", "&&", "typeof", "max", "!==", "'number'", ")", "{", "throw", "new", "TypeError", "(", "msg", ".", "argMax", ")", ";", "}", "if", "(", "min", "!==", "false", "&&", "typeof", "min", "!==", "'number'", ")", "{", "throw", "new", "TypeError", "(", "msg", ".", "argMin", ")", ";", "}", "if", "(", "!", "Number", ".", "isInteger", "(", "target", ")", "||", "target", "<", "0", ")", "{", "throw", "new", "TypeError", "(", "msg", ".", "argTarget", ")", ";", "}", "return", "{", "avg", ",", "max", ",", "min", ",", "target", ",", "}", ";", "}" ]
Validates threshold options. If it is invalid a TypeError is thrown. Otherwise, a normalized thresholds object or null is returned. @param {object} thresholds @returns {object}
[ "Validates", "threshold", "options", ".", "If", "it", "is", "invalid", "a", "TypeError", "is", "thrown", ".", "Otherwise", "a", "normalized", "thresholds", "object", "or", "null", "is", "returned", "." ]
c0cf2730441e1e454355603c2fd7539b9d552f1a
https://github.com/dsfields/radargun/blob/c0cf2730441e1e454355603c2fd7539b9d552f1a/lib/bench.js#L172-L206
43,561
dsfields/radargun
lib/bench.js
assertThreshold
function assertThreshold(value, other, threshold) { if (!threshold && value > other) throw new ThresholdError(); const ratio = 1 - (value / other); if (ratio < threshold) throw new ThresholdError(); }
javascript
function assertThreshold(value, other, threshold) { if (!threshold && value > other) throw new ThresholdError(); const ratio = 1 - (value / other); if (ratio < threshold) throw new ThresholdError(); }
[ "function", "assertThreshold", "(", "value", ",", "other", ",", "threshold", ")", "{", "if", "(", "!", "threshold", "&&", "value", ">", "other", ")", "throw", "new", "ThresholdError", "(", ")", ";", "const", "ratio", "=", "1", "-", "(", "value", "/", "other", ")", ";", "if", "(", "ratio", "<", "threshold", ")", "throw", "new", "ThresholdError", "(", ")", ";", "}" ]
CHECK THRESHOLDS Throws if a given threshold ratio is not met. @param {number} value @param {number} other @param {?number} threshold
[ "CHECK", "THRESHOLDS", "Throws", "if", "a", "given", "threshold", "ratio", "is", "not", "met", "." ]
c0cf2730441e1e454355603c2fd7539b9d552f1a
https://github.com/dsfields/radargun/blob/c0cf2730441e1e454355603c2fd7539b9d552f1a/lib/bench.js#L271-L275
43,562
dsfields/radargun
lib/bench.js
checkThresholds
function checkThresholds(metrics, thresholds) { if (!elv(thresholds)) return; const target = metrics[thresholds.target]; for (let i = 0; i < metrics.length; i++) { if (i === thresholds.target) continue; const other = metrics[i]; assertThreshold(target.avg, other.avg, thresholds.avg); assertThreshold(target.max, other.max, thresholds.max); assertThreshold(target.min, other.min, thresholds.min); } }
javascript
function checkThresholds(metrics, thresholds) { if (!elv(thresholds)) return; const target = metrics[thresholds.target]; for (let i = 0; i < metrics.length; i++) { if (i === thresholds.target) continue; const other = metrics[i]; assertThreshold(target.avg, other.avg, thresholds.avg); assertThreshold(target.max, other.max, thresholds.max); assertThreshold(target.min, other.min, thresholds.min); } }
[ "function", "checkThresholds", "(", "metrics", ",", "thresholds", ")", "{", "if", "(", "!", "elv", "(", "thresholds", ")", ")", "return", ";", "const", "target", "=", "metrics", "[", "thresholds", ".", "target", "]", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "metrics", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", "===", "thresholds", ".", "target", ")", "continue", ";", "const", "other", "=", "metrics", "[", "i", "]", ";", "assertThreshold", "(", "target", ".", "avg", ",", "other", ".", "avg", ",", "thresholds", ".", "avg", ")", ";", "assertThreshold", "(", "target", ".", "max", ",", "other", ".", "max", ",", "thresholds", ".", "max", ")", ";", "assertThreshold", "(", "target", ".", "min", ",", "other", ".", "min", ",", "thresholds", ".", "min", ")", ";", "}", "}" ]
Validates results of a benchmarking run against a given set of thresholds. If the target function's metrics are outside of the given thresholds, an error is thrown. @param {FunctionMetrics[]} metrics @param {Thresholds} thresholds
[ "Validates", "results", "of", "a", "benchmarking", "run", "against", "a", "given", "set", "of", "thresholds", ".", "If", "the", "target", "function", "s", "metrics", "are", "outside", "of", "the", "given", "thresholds", "an", "error", "is", "thrown", "." ]
c0cf2730441e1e454355603c2fd7539b9d552f1a
https://github.com/dsfields/radargun/blob/c0cf2730441e1e454355603c2fd7539b9d552f1a/lib/bench.js#L286-L299
43,563
dsfields/radargun
lib/bench.js
bench
function bench(functions, options) { const funcs = assertFunctions(functions); const opts = assertOptions(options); const metrics = []; const totalRuns = funcs.length * opts.runs; let runCount = 0; for (let i = 0; i < funcs.length; i++) { const func = funcs[i]; const totals = [0, 0]; let max = 0; let min = Number.MAX_SAFE_INTEGER; for (let j = 0; j < opts.runs; j++) { const start = process.hrtime(); func.fn.call(func.bind, func.params); const end = process.hrtime(start); totals[0] += end[0]; totals[1] += end[1]; const ns = (end[0] * NS_PER_SEC) + end[1]; if (ns > max) max = ns; if (ns < min) min = ns; updateStatus(++runCount, totalRuns, opts.stream); } const whole = (totals[0] / opts.runs) * NS_PER_SEC; const partial = totals[1] / opts.runs; const avg = Math.ceil(whole + partial); metrics.push({ avg, label: func.label, max, min, }); } opts.report(opts.stream, metrics, opts.thresholds); checkThresholds(metrics, opts.thresholds); return metrics; }
javascript
function bench(functions, options) { const funcs = assertFunctions(functions); const opts = assertOptions(options); const metrics = []; const totalRuns = funcs.length * opts.runs; let runCount = 0; for (let i = 0; i < funcs.length; i++) { const func = funcs[i]; const totals = [0, 0]; let max = 0; let min = Number.MAX_SAFE_INTEGER; for (let j = 0; j < opts.runs; j++) { const start = process.hrtime(); func.fn.call(func.bind, func.params); const end = process.hrtime(start); totals[0] += end[0]; totals[1] += end[1]; const ns = (end[0] * NS_PER_SEC) + end[1]; if (ns > max) max = ns; if (ns < min) min = ns; updateStatus(++runCount, totalRuns, opts.stream); } const whole = (totals[0] / opts.runs) * NS_PER_SEC; const partial = totals[1] / opts.runs; const avg = Math.ceil(whole + partial); metrics.push({ avg, label: func.label, max, min, }); } opts.report(opts.stream, metrics, opts.thresholds); checkThresholds(metrics, opts.thresholds); return metrics; }
[ "function", "bench", "(", "functions", ",", "options", ")", "{", "const", "funcs", "=", "assertFunctions", "(", "functions", ")", ";", "const", "opts", "=", "assertOptions", "(", "options", ")", ";", "const", "metrics", "=", "[", "]", ";", "const", "totalRuns", "=", "funcs", ".", "length", "*", "opts", ".", "runs", ";", "let", "runCount", "=", "0", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "funcs", ".", "length", ";", "i", "++", ")", "{", "const", "func", "=", "funcs", "[", "i", "]", ";", "const", "totals", "=", "[", "0", ",", "0", "]", ";", "let", "max", "=", "0", ";", "let", "min", "=", "Number", ".", "MAX_SAFE_INTEGER", ";", "for", "(", "let", "j", "=", "0", ";", "j", "<", "opts", ".", "runs", ";", "j", "++", ")", "{", "const", "start", "=", "process", ".", "hrtime", "(", ")", ";", "func", ".", "fn", ".", "call", "(", "func", ".", "bind", ",", "func", ".", "params", ")", ";", "const", "end", "=", "process", ".", "hrtime", "(", "start", ")", ";", "totals", "[", "0", "]", "+=", "end", "[", "0", "]", ";", "totals", "[", "1", "]", "+=", "end", "[", "1", "]", ";", "const", "ns", "=", "(", "end", "[", "0", "]", "*", "NS_PER_SEC", ")", "+", "end", "[", "1", "]", ";", "if", "(", "ns", ">", "max", ")", "max", "=", "ns", ";", "if", "(", "ns", "<", "min", ")", "min", "=", "ns", ";", "updateStatus", "(", "++", "runCount", ",", "totalRuns", ",", "opts", ".", "stream", ")", ";", "}", "const", "whole", "=", "(", "totals", "[", "0", "]", "/", "opts", ".", "runs", ")", "*", "NS_PER_SEC", ";", "const", "partial", "=", "totals", "[", "1", "]", "/", "opts", ".", "runs", ";", "const", "avg", "=", "Math", ".", "ceil", "(", "whole", "+", "partial", ")", ";", "metrics", ".", "push", "(", "{", "avg", ",", "label", ":", "func", ".", "label", ",", "max", ",", "min", ",", "}", ")", ";", "}", "opts", ".", "report", "(", "opts", ".", "stream", ",", "metrics", ",", "opts", ".", "thresholds", ")", ";", "checkThresholds", "(", "metrics", ",", "opts", ".", "thresholds", ")", ";", "return", "metrics", ";", "}" ]
BENCHMARKING Runs a benchmark analysis for a given array of functions, and generates a report. @param {(function|FunctionConfiguration)[]} functions @param {BenchOptions} options @returns {FunctionMetrics[]}
[ "BENCHMARKING", "Runs", "a", "benchmark", "analysis", "for", "a", "given", "array", "of", "functions", "and", "generates", "a", "report", "." ]
c0cf2730441e1e454355603c2fd7539b9d552f1a
https://github.com/dsfields/radargun/blob/c0cf2730441e1e454355603c2fd7539b9d552f1a/lib/bench.js#L316-L360
43,564
robinpowered/robin-js-sdk-public
lib/api/modules/accounts.js
function (accountIdOrSlug, params) { var path; if (accountIdOrSlug) { path = this.constructPath(constants.ACCOUNTS, accountIdOrSlug); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: An account id or slug must be supplied for this operation'); } }
javascript
function (accountIdOrSlug, params) { var path; if (accountIdOrSlug) { path = this.constructPath(constants.ACCOUNTS, accountIdOrSlug); return this.Core.GET(path, params); } else { return this.rejectRequest('Bad Request: An account id or slug must be supplied for this operation'); } }
[ "function", "(", "accountIdOrSlug", ",", "params", ")", "{", "var", "path", ";", "if", "(", "accountIdOrSlug", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "ACCOUNTS", ",", "accountIdOrSlug", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: An account id or slug must be supplied for this operation'", ")", ";", "}", "}" ]
Get an account @param {String|Integer} accountIdOrSlug A Robin account identifier or slug @param {Object} params A querystring object @return {Function} A Promise
[ "Get", "an", "account" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/accounts.js#L20-L28
43,565
Beh01der/node-docker-monitor
lib/index.js
updateContainers
function updateContainers(next) { monitor.docker.listContainers(function(err, list) { if (err) { console.log('Error listing running containers: %s', err.message, err); return next(err); } if (!monitor.started) { if (handler.onMonitorStarted) { handler.onMonitorStarted(monitor, monitor.docker); } monitor.started = true; } list.forEach(function(it) { var info = clone(it); info.Name = getContainerName(it.Names); updateContainer(info); }); next(); }); }
javascript
function updateContainers(next) { monitor.docker.listContainers(function(err, list) { if (err) { console.log('Error listing running containers: %s', err.message, err); return next(err); } if (!monitor.started) { if (handler.onMonitorStarted) { handler.onMonitorStarted(monitor, monitor.docker); } monitor.started = true; } list.forEach(function(it) { var info = clone(it); info.Name = getContainerName(it.Names); updateContainer(info); }); next(); }); }
[ "function", "updateContainers", "(", "next", ")", "{", "monitor", ".", "docker", ".", "listContainers", "(", "function", "(", "err", ",", "list", ")", "{", "if", "(", "err", ")", "{", "console", ".", "log", "(", "'Error listing running containers: %s'", ",", "err", ".", "message", ",", "err", ")", ";", "return", "next", "(", "err", ")", ";", "}", "if", "(", "!", "monitor", ".", "started", ")", "{", "if", "(", "handler", ".", "onMonitorStarted", ")", "{", "handler", ".", "onMonitorStarted", "(", "monitor", ",", "monitor", ".", "docker", ")", ";", "}", "monitor", ".", "started", "=", "true", ";", "}", "list", ".", "forEach", "(", "function", "(", "it", ")", "{", "var", "info", "=", "clone", "(", "it", ")", ";", "info", ".", "Name", "=", "getContainerName", "(", "it", ".", "Names", ")", ";", "updateContainer", "(", "info", ")", ";", "}", ")", ";", "next", "(", ")", ";", "}", ")", ";", "}" ]
initially populate container map
[ "initially", "populate", "container", "map" ]
4e81eb12081c1fb91b5b91e0683e4cc1c0b05a43
https://github.com/Beh01der/node-docker-monitor/blob/4e81eb12081c1fb91b5b91e0683e4cc1c0b05a43/lib/index.js#L136-L159
43,566
Beh01der/node-docker-monitor
lib/index.js
processDockerEvent
function processDockerEvent(event, stop) { if (trackedEvents.indexOf(event.status) !== -1) { var container = containerById.get(event.id); if (container) { if (positiveEvents.indexOf(event.status) !== -1) { updateContainer(container); } else { removeContainer(container); } } else { // new container if (!stop && positiveEvents.indexOf(event.status) !== -1) { updateContainers(function(err) { if (!err) { processDockerEvent(event, true); } }); } } } }
javascript
function processDockerEvent(event, stop) { if (trackedEvents.indexOf(event.status) !== -1) { var container = containerById.get(event.id); if (container) { if (positiveEvents.indexOf(event.status) !== -1) { updateContainer(container); } else { removeContainer(container); } } else { // new container if (!stop && positiveEvents.indexOf(event.status) !== -1) { updateContainers(function(err) { if (!err) { processDockerEvent(event, true); } }); } } } }
[ "function", "processDockerEvent", "(", "event", ",", "stop", ")", "{", "if", "(", "trackedEvents", ".", "indexOf", "(", "event", ".", "status", ")", "!==", "-", "1", ")", "{", "var", "container", "=", "containerById", ".", "get", "(", "event", ".", "id", ")", ";", "if", "(", "container", ")", "{", "if", "(", "positiveEvents", ".", "indexOf", "(", "event", ".", "status", ")", "!==", "-", "1", ")", "{", "updateContainer", "(", "container", ")", ";", "}", "else", "{", "removeContainer", "(", "container", ")", ";", "}", "}", "else", "{", "// new container", "if", "(", "!", "stop", "&&", "positiveEvents", ".", "indexOf", "(", "event", ".", "status", ")", "!==", "-", "1", ")", "{", "updateContainers", "(", "function", "(", "err", ")", "{", "if", "(", "!", "err", ")", "{", "processDockerEvent", "(", "event", ",", "true", ")", ";", "}", "}", ")", ";", "}", "}", "}", "}" ]
start monitoring docker events
[ "start", "monitoring", "docker", "events" ]
4e81eb12081c1fb91b5b91e0683e4cc1c0b05a43
https://github.com/Beh01der/node-docker-monitor/blob/4e81eb12081c1fb91b5b91e0683e4cc1c0b05a43/lib/index.js#L162-L182
43,567
mwild1/xmppjs
lib/xmpp.js
function (attr) { this.debug("STREAM: opened."); this._setStatus(xmpp.Status.AUTHENTICATING); var handshake = sha1.hex(attr.id + this.password); this.debug("Calculated authentication token " + handshake + " from stream id '" + attr.id + "' and password '" + this.password + "'"); this.debug("Sending authentication token..."); this.send("<handshake>"+handshake+"</handshake>"); }
javascript
function (attr) { this.debug("STREAM: opened."); this._setStatus(xmpp.Status.AUTHENTICATING); var handshake = sha1.hex(attr.id + this.password); this.debug("Calculated authentication token " + handshake + " from stream id '" + attr.id + "' and password '" + this.password + "'"); this.debug("Sending authentication token..."); this.send("<handshake>"+handshake+"</handshake>"); }
[ "function", "(", "attr", ")", "{", "this", ".", "debug", "(", "\"STREAM: opened.\"", ")", ";", "this", ".", "_setStatus", "(", "xmpp", ".", "Status", ".", "AUTHENTICATING", ")", ";", "var", "handshake", "=", "sha1", ".", "hex", "(", "attr", ".", "id", "+", "this", ".", "password", ")", ";", "this", ".", "debug", "(", "\"Calculated authentication token \"", "+", "handshake", "+", "\" from stream id '\"", "+", "attr", ".", "id", "+", "\"' and password '\"", "+", "this", ".", "password", "+", "\"'\"", ")", ";", "this", ".", "debug", "(", "\"Sending authentication token...\"", ")", ";", "this", ".", "send", "(", "\"<handshake>\"", "+", "handshake", "+", "\"</handshake>\"", ")", ";", "}" ]
Stream listeners, called on XMPP-level events
[ "Stream", "listeners", "called", "on", "XMPP", "-", "level", "events" ]
35cfa5b004058942d9c91d3df0afd81a4c987a02
https://github.com/mwild1/xmppjs/blob/35cfa5b004058942d9c91d3df0afd81a4c987a02/lib/xmpp.js#L206-L215
43,568
jeffrose/emitter
dist/emitter-umd.js
addConditionalEventListener
function addConditionalEventListener(emitter, type, listener) { function conditionalListener() { var done = listener.apply(emitter, arguments); if (done === true) { removeEventListener(emitter, type, conditionalListener); } } // TODO Check beyond just one level of listener references conditionalListener.listener = listener.listener || listener; addEventListener(emitter, type, conditionalListener, NaN); }
javascript
function addConditionalEventListener(emitter, type, listener) { function conditionalListener() { var done = listener.apply(emitter, arguments); if (done === true) { removeEventListener(emitter, type, conditionalListener); } } // TODO Check beyond just one level of listener references conditionalListener.listener = listener.listener || listener; addEventListener(emitter, type, conditionalListener, NaN); }
[ "function", "addConditionalEventListener", "(", "emitter", ",", "type", ",", "listener", ")", "{", "function", "conditionalListener", "(", ")", "{", "var", "done", "=", "listener", ".", "apply", "(", "emitter", ",", "arguments", ")", ";", "if", "(", "done", "===", "true", ")", "{", "removeEventListener", "(", "emitter", ",", "type", ",", "conditionalListener", ")", ";", "}", "}", "// TODO Check beyond just one level of listener references", "conditionalListener", ".", "listener", "=", "listener", ".", "listener", "||", "listener", ";", "addEventListener", "(", "emitter", ",", "type", ",", "conditionalListener", ",", "NaN", ")", ";", "}" ]
Many of these functions are broken out from the prototype for the sake of optimization. The functions on the protoytype take a variable number of arguments and can be deoptimized as a result. These functions have a fixed number of arguments and therefore do not get deoptimized. @function Emitter~addConditionalEventListener @param {Emitter} emitter The emitter on which the event would be emitted. @param {EventType} type The event type. @param {EventListener} listener The event callback.
[ "Many", "of", "these", "functions", "are", "broken", "out", "from", "the", "prototype", "for", "the", "sake", "of", "optimization", ".", "The", "functions", "on", "the", "protoytype", "take", "a", "variable", "number", "of", "arguments", "and", "can", "be", "deoptimized", "as", "a", "result", ".", "These", "functions", "have", "a", "fixed", "number", "of", "arguments", "and", "therefore", "do", "not", "get", "deoptimized", "." ]
c6d8d1702ff60ca4f5100d13480914e4bd17183f
https://github.com/jeffrose/emitter/blob/c6d8d1702ff60ca4f5100d13480914e4bd17183f/dist/emitter-umd.js#L172-L185
43,569
jeffrose/emitter
dist/emitter-umd.js
listenMany
function listenMany(handler, isFunction, emitter, args) { var errors = []; if (isFunction) { try { handler.apply(emitter, args); } catch (error) { errors.push(error); } } else { var length = handler.length, listeners = handler.slice(); var index = 0; for (; index < length; index += 1) { try { listeners[index].apply(emitter, args); } catch (error) { errors.push(error); } } } if (errors.length) { emitErrors(emitter, errors); } }
javascript
function listenMany(handler, isFunction, emitter, args) { var errors = []; if (isFunction) { try { handler.apply(emitter, args); } catch (error) { errors.push(error); } } else { var length = handler.length, listeners = handler.slice(); var index = 0; for (; index < length; index += 1) { try { listeners[index].apply(emitter, args); } catch (error) { errors.push(error); } } } if (errors.length) { emitErrors(emitter, errors); } }
[ "function", "listenMany", "(", "handler", ",", "isFunction", ",", "emitter", ",", "args", ")", "{", "var", "errors", "=", "[", "]", ";", "if", "(", "isFunction", ")", "{", "try", "{", "handler", ".", "apply", "(", "emitter", ",", "args", ")", ";", "}", "catch", "(", "error", ")", "{", "errors", ".", "push", "(", "error", ")", ";", "}", "}", "else", "{", "var", "length", "=", "handler", ".", "length", ",", "listeners", "=", "handler", ".", "slice", "(", ")", ";", "var", "index", "=", "0", ";", "for", "(", ";", "index", "<", "length", ";", "index", "+=", "1", ")", "{", "try", "{", "listeners", "[", "index", "]", ".", "apply", "(", "emitter", ",", "args", ")", ";", "}", "catch", "(", "error", ")", "{", "errors", ".", "push", "(", "error", ")", ";", "}", "}", "}", "if", "(", "errors", ".", "length", ")", "{", "emitErrors", "(", "emitter", ",", "errors", ")", ";", "}", "}" ]
Execute a listener with four or more arguments. @function Emitter~listenMany @param {EventListener|Array<EventListener>} handler One or more {@link EventListener|listeners} that will be executed on the `emitter`. @param {external:boolean} isFunction Whether or not the `handler` is a {@link external:Function|function}. @param {Emitter} emitter The emitter. @param {external:Array} args Four or more arguments.
[ "Execute", "a", "listener", "with", "four", "or", "more", "arguments", "." ]
c6d8d1702ff60ca4f5100d13480914e4bd17183f
https://github.com/jeffrose/emitter/blob/c6d8d1702ff60ca4f5100d13480914e4bd17183f/dist/emitter-umd.js#L621-L648
43,570
jeffrose/emitter
dist/emitter-umd.js
spliceList
function spliceList(list, index) { for (var i = index, j = i + 1, length = list.length; j < length; i += 1, j += 1) { list[i] = list[j]; } list.pop(); }
javascript
function spliceList(list, index) { for (var i = index, j = i + 1, length = list.length; j < length; i += 1, j += 1) { list[i] = list[j]; } list.pop(); }
[ "function", "spliceList", "(", "list", ",", "index", ")", "{", "for", "(", "var", "i", "=", "index", ",", "j", "=", "i", "+", "1", ",", "length", "=", "list", ".", "length", ";", "j", "<", "length", ";", "i", "+=", "1", ",", "j", "+=", "1", ")", "{", "list", "[", "i", "]", "=", "list", "[", "j", "]", ";", "}", "list", ".", "pop", "(", ")", ";", "}" ]
Faster than `Array.prototype.splice` @function Emitter~spliceList @param {external:Array} list @param {external:number} index
[ "Faster", "than", "Array", ".", "prototype", ".", "splice" ]
c6d8d1702ff60ca4f5100d13480914e4bd17183f
https://github.com/jeffrose/emitter/blob/c6d8d1702ff60ca4f5100d13480914e4bd17183f/dist/emitter-umd.js#L713-L719
43,571
brochington/Akkad
lib/Oimo.js
function(){ this.randX=65535; while(this.joints!==null){ this.removeJoint(this.joints); } while(this.contacts!==null){ this.removeContact(this.contacts); } while(this.rigidBodies!==null){ this.removeRigidBody(this.rigidBodies); } OIMO.nextID=0; }
javascript
function(){ this.randX=65535; while(this.joints!==null){ this.removeJoint(this.joints); } while(this.contacts!==null){ this.removeContact(this.contacts); } while(this.rigidBodies!==null){ this.removeRigidBody(this.rigidBodies); } OIMO.nextID=0; }
[ "function", "(", ")", "{", "this", ".", "randX", "=", "65535", ";", "while", "(", "this", ".", "joints", "!==", "null", ")", "{", "this", ".", "removeJoint", "(", "this", ".", "joints", ")", ";", "}", "while", "(", "this", ".", "contacts", "!==", "null", ")", "{", "this", ".", "removeContact", "(", "this", ".", "contacts", ")", ";", "}", "while", "(", "this", ".", "rigidBodies", "!==", "null", ")", "{", "this", ".", "removeRigidBody", "(", "this", ".", "rigidBodies", ")", ";", "}", "OIMO", ".", "nextID", "=", "0", ";", "}" ]
Reset the randomizer and remove all rigid bodies, shapes, joints and any object from the world.
[ "Reset", "the", "randomizer", "and", "remove", "all", "rigid", "bodies", "shapes", "joints", "and", "any", "object", "from", "the", "world", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L110-L122
43,572
brochington/Akkad
lib/Oimo.js
function(rigidBody){ if(rigidBody.parent){ throw new Error("It is not possible to be added to more than one world one of the rigid body"); } rigidBody.parent=this; rigidBody.awake(); for(var shape=rigidBody.shapes; shape!==null; shape=shape.next){ this.addShape(shape); } if(this.rigidBodies!==null)(this.rigidBodies.prev=rigidBody).next=this.rigidBodies; this.rigidBodies = rigidBody; this.numRigidBodies++; }
javascript
function(rigidBody){ if(rigidBody.parent){ throw new Error("It is not possible to be added to more than one world one of the rigid body"); } rigidBody.parent=this; rigidBody.awake(); for(var shape=rigidBody.shapes; shape!==null; shape=shape.next){ this.addShape(shape); } if(this.rigidBodies!==null)(this.rigidBodies.prev=rigidBody).next=this.rigidBodies; this.rigidBodies = rigidBody; this.numRigidBodies++; }
[ "function", "(", "rigidBody", ")", "{", "if", "(", "rigidBody", ".", "parent", ")", "{", "throw", "new", "Error", "(", "\"It is not possible to be added to more than one world one of the rigid body\"", ")", ";", "}", "rigidBody", ".", "parent", "=", "this", ";", "rigidBody", ".", "awake", "(", ")", ";", "for", "(", "var", "shape", "=", "rigidBody", ".", "shapes", ";", "shape", "!==", "null", ";", "shape", "=", "shape", ".", "next", ")", "{", "this", ".", "addShape", "(", "shape", ")", ";", "}", "if", "(", "this", ".", "rigidBodies", "!==", "null", ")", "(", "this", ".", "rigidBodies", ".", "prev", "=", "rigidBody", ")", ".", "next", "=", "this", ".", "rigidBodies", ";", "this", ".", "rigidBodies", "=", "rigidBody", ";", "this", ".", "numRigidBodies", "++", ";", "}" ]
I'll add a rigid body to the world. Rigid body that has been added will be the operands of each step. @param rigidBody Rigid body that you want to add
[ "I", "ll", "add", "a", "rigid", "body", "to", "the", "world", ".", "Rigid", "body", "that", "has", "been", "added", "will", "be", "the", "operands", "of", "each", "step", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L128-L140
43,573
brochington/Akkad
lib/Oimo.js
function(rigidBody){ var remove=rigidBody; if(remove.parent!==this)return; remove.awake(); var js=remove.jointLink; while(js!=null){ var joint=js.joint; js=js.next; this.removeJoint(joint); } for(var shape=rigidBody.shapes; shape!==null; shape=shape.next){ this.removeShape(shape); } var prev=remove.prev; var next=remove.next; if(prev!==null) prev.next=next; if(next!==null) next.prev=prev; if(this.rigidBodies==remove) this.rigidBodies=next; remove.prev=null; remove.next=null; remove.parent=null; this.numRigidBodies--; }
javascript
function(rigidBody){ var remove=rigidBody; if(remove.parent!==this)return; remove.awake(); var js=remove.jointLink; while(js!=null){ var joint=js.joint; js=js.next; this.removeJoint(joint); } for(var shape=rigidBody.shapes; shape!==null; shape=shape.next){ this.removeShape(shape); } var prev=remove.prev; var next=remove.next; if(prev!==null) prev.next=next; if(next!==null) next.prev=prev; if(this.rigidBodies==remove) this.rigidBodies=next; remove.prev=null; remove.next=null; remove.parent=null; this.numRigidBodies--; }
[ "function", "(", "rigidBody", ")", "{", "var", "remove", "=", "rigidBody", ";", "if", "(", "remove", ".", "parent", "!==", "this", ")", "return", ";", "remove", ".", "awake", "(", ")", ";", "var", "js", "=", "remove", ".", "jointLink", ";", "while", "(", "js", "!=", "null", ")", "{", "var", "joint", "=", "js", ".", "joint", ";", "js", "=", "js", ".", "next", ";", "this", ".", "removeJoint", "(", "joint", ")", ";", "}", "for", "(", "var", "shape", "=", "rigidBody", ".", "shapes", ";", "shape", "!==", "null", ";", "shape", "=", "shape", ".", "next", ")", "{", "this", ".", "removeShape", "(", "shape", ")", ";", "}", "var", "prev", "=", "remove", ".", "prev", ";", "var", "next", "=", "remove", ".", "next", ";", "if", "(", "prev", "!==", "null", ")", "prev", ".", "next", "=", "next", ";", "if", "(", "next", "!==", "null", ")", "next", ".", "prev", "=", "prev", ";", "if", "(", "this", ".", "rigidBodies", "==", "remove", ")", "this", ".", "rigidBodies", "=", "next", ";", "remove", ".", "prev", "=", "null", ";", "remove", ".", "next", "=", "null", ";", "remove", ".", "parent", "=", "null", ";", "this", ".", "numRigidBodies", "--", ";", "}" ]
I will remove the rigid body from the world. Rigid body that has been deleted is excluded from the calculation on a step-by-step basis. @param rigidBody Rigid body to be removed
[ "I", "will", "remove", "the", "rigid", "body", "from", "the", "world", ".", "Rigid", "body", "that", "has", "been", "deleted", "is", "excluded", "from", "the", "calculation", "on", "a", "step", "-", "by", "-", "step", "basis", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L146-L168
43,574
brochington/Akkad
lib/Oimo.js
function(shape){ if(!shape.parent || !shape.parent.parent){ throw new Error("It is not possible to be added alone to shape world"); } shape.proxy = this.broadPhase.createProxy(shape); shape.updateProxy(); this.broadPhase.addProxy(shape.proxy); }
javascript
function(shape){ if(!shape.parent || !shape.parent.parent){ throw new Error("It is not possible to be added alone to shape world"); } shape.proxy = this.broadPhase.createProxy(shape); shape.updateProxy(); this.broadPhase.addProxy(shape.proxy); }
[ "function", "(", "shape", ")", "{", "if", "(", "!", "shape", ".", "parent", "||", "!", "shape", ".", "parent", ".", "parent", ")", "{", "throw", "new", "Error", "(", "\"It is not possible to be added alone to shape world\"", ")", ";", "}", "shape", ".", "proxy", "=", "this", ".", "broadPhase", ".", "createProxy", "(", "shape", ")", ";", "shape", ".", "updateProxy", "(", ")", ";", "this", ".", "broadPhase", ".", "addProxy", "(", "shape", ".", "proxy", ")", ";", "}" ]
I'll add a shape to the world.. Add to the rigid world, and if you add a shape to a rigid body that has been added to the world, Shape will be added to the world automatically, please do not call from outside this method. @param shape Shape you want to add
[ "I", "ll", "add", "a", "shape", "to", "the", "world", "..", "Add", "to", "the", "rigid", "world", "and", "if", "you", "add", "a", "shape", "to", "a", "rigid", "body", "that", "has", "been", "added", "to", "the", "world", "Shape", "will", "be", "added", "to", "the", "world", "automatically", "please", "do", "not", "call", "from", "outside", "this", "method", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L190-L197
43,575
brochington/Akkad
lib/Oimo.js
function(joint){ if(joint.parent){ throw new Error("It is not possible to be added to more than one world one of the joint"); } if(this.joints!=null)(this.joints.prev=joint).next=this.joints; this.joints=joint; joint.parent=this; this.numJoints++; joint.awake(); joint.attach(); }
javascript
function(joint){ if(joint.parent){ throw new Error("It is not possible to be added to more than one world one of the joint"); } if(this.joints!=null)(this.joints.prev=joint).next=this.joints; this.joints=joint; joint.parent=this; this.numJoints++; joint.awake(); joint.attach(); }
[ "function", "(", "joint", ")", "{", "if", "(", "joint", ".", "parent", ")", "{", "throw", "new", "Error", "(", "\"It is not possible to be added to more than one world one of the joint\"", ")", ";", "}", "if", "(", "this", ".", "joints", "!=", "null", ")", "(", "this", ".", "joints", ".", "prev", "=", "joint", ")", ".", "next", "=", "this", ".", "joints", ";", "this", ".", "joints", "=", "joint", ";", "joint", ".", "parent", "=", "this", ";", "this", ".", "numJoints", "++", ";", "joint", ".", "awake", "(", ")", ";", "joint", ".", "attach", "(", ")", ";", "}" ]
I'll add a joint to the world. Joint that has been added will be the operands of each step. @param shape Joint to be added
[ "I", "ll", "add", "a", "joint", "to", "the", "world", ".", "Joint", "that", "has", "been", "added", "will", "be", "the", "operands", "of", "each", "step", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L215-L225
43,576
brochington/Akkad
lib/Oimo.js
function(joint){ var remove=joint; var prev=remove.prev; var next=remove.next; if(prev!==null)prev.next=next; if(next!==null)next.prev=prev; if(this.joints==remove)this.joints=next; remove.prev=null; remove.next=null; this.numJoints--; remove.awake(); remove.detach(); remove.parent=null; }
javascript
function(joint){ var remove=joint; var prev=remove.prev; var next=remove.next; if(prev!==null)prev.next=next; if(next!==null)next.prev=prev; if(this.joints==remove)this.joints=next; remove.prev=null; remove.next=null; this.numJoints--; remove.awake(); remove.detach(); remove.parent=null; }
[ "function", "(", "joint", ")", "{", "var", "remove", "=", "joint", ";", "var", "prev", "=", "remove", ".", "prev", ";", "var", "next", "=", "remove", ".", "next", ";", "if", "(", "prev", "!==", "null", ")", "prev", ".", "next", "=", "next", ";", "if", "(", "next", "!==", "null", ")", "next", ".", "prev", "=", "prev", ";", "if", "(", "this", ".", "joints", "==", "remove", ")", "this", ".", "joints", "=", "next", ";", "remove", ".", "prev", "=", "null", ";", "remove", ".", "next", "=", "null", ";", "this", ".", "numJoints", "--", ";", "remove", ".", "awake", "(", ")", ";", "remove", ".", "detach", "(", ")", ";", "remove", ".", "parent", "=", "null", ";", "}" ]
I will remove the joint from the world. Joint that has been added will be the operands of each step. @param shape Joint to be deleted
[ "I", "will", "remove", "the", "joint", "from", "the", "world", ".", "Joint", "that", "has", "been", "added", "will", "be", "the", "operands", "of", "each", "step", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L232-L245
43,577
brochington/Akkad
lib/Oimo.js
function(shape){ if(shape.parent){ throw new Error("It is not possible that you add to the multi-rigid body the shape of one"); } if(this.shapes!=null)(this.shapes.prev=shape).next=this.shapes; this.shapes=shape; shape.parent=this; if(this.parent)this.parent.addShape(shape); this.numShapes++; }
javascript
function(shape){ if(shape.parent){ throw new Error("It is not possible that you add to the multi-rigid body the shape of one"); } if(this.shapes!=null)(this.shapes.prev=shape).next=this.shapes; this.shapes=shape; shape.parent=this; if(this.parent)this.parent.addShape(shape); this.numShapes++; }
[ "function", "(", "shape", ")", "{", "if", "(", "shape", ".", "parent", ")", "{", "throw", "new", "Error", "(", "\"It is not possible that you add to the multi-rigid body the shape of one\"", ")", ";", "}", "if", "(", "this", ".", "shapes", "!=", "null", ")", "(", "this", ".", "shapes", ".", "prev", "=", "shape", ")", ".", "next", "=", "this", ".", "shapes", ";", "this", ".", "shapes", "=", "shape", ";", "shape", ".", "parent", "=", "this", ";", "if", "(", "this", ".", "parent", ")", "this", ".", "parent", ".", "addShape", "(", "shape", ")", ";", "this", ".", "numShapes", "++", ";", "}" ]
I'll add a shape to rigid body. If you add a shape, please call the setupMass method to step up to the start of the next. @param shape shape to Add
[ "I", "ll", "add", "a", "shape", "to", "rigid", "body", ".", "If", "you", "add", "a", "shape", "please", "call", "the", "setupMass", "method", "to", "step", "up", "to", "the", "start", "of", "the", "next", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L759-L768
43,578
brochington/Akkad
lib/Oimo.js
function(shape){ var remove=shape; if(remove.parent!=this)return; var prev=remove.prev; var next=remove.next; if(prev!=null)prev.next=next; if(next!=null)next.prev=prev; if(this.shapes==remove)this.shapes=next; remove.prev=null; remove.next=null; remove.parent=null; if(this.parent)this.parent.removeShape(remove); this.numShapes--; }
javascript
function(shape){ var remove=shape; if(remove.parent!=this)return; var prev=remove.prev; var next=remove.next; if(prev!=null)prev.next=next; if(next!=null)next.prev=prev; if(this.shapes==remove)this.shapes=next; remove.prev=null; remove.next=null; remove.parent=null; if(this.parent)this.parent.removeShape(remove); this.numShapes--; }
[ "function", "(", "shape", ")", "{", "var", "remove", "=", "shape", ";", "if", "(", "remove", ".", "parent", "!=", "this", ")", "return", ";", "var", "prev", "=", "remove", ".", "prev", ";", "var", "next", "=", "remove", ".", "next", ";", "if", "(", "prev", "!=", "null", ")", "prev", ".", "next", "=", "next", ";", "if", "(", "next", "!=", "null", ")", "next", ".", "prev", "=", "prev", ";", "if", "(", "this", ".", "shapes", "==", "remove", ")", "this", ".", "shapes", "=", "next", ";", "remove", ".", "prev", "=", "null", ";", "remove", ".", "next", "=", "null", ";", "remove", ".", "parent", "=", "null", ";", "if", "(", "this", ".", "parent", ")", "this", ".", "parent", ".", "removeShape", "(", "remove", ")", ";", "this", ".", "numShapes", "--", ";", "}" ]
I will delete the shape from the rigid body. If you delete a shape, please call the setupMass method to step up to the start of the next. @param shape shape to Delete
[ "I", "will", "delete", "the", "shape", "from", "the", "rigid", "body", ".", "If", "you", "delete", "a", "shape", "please", "call", "the", "setupMass", "method", "to", "step", "up", "to", "the", "start", "of", "the", "next", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L774-L787
43,579
brochington/Akkad
lib/Oimo.js
function(){ if(!this.allowSleep||!this.sleeping)return; this.sleeping=false; this.sleepTime=0; // awake connected constraints var cs=this.contactLink; while(cs!=null){ cs.body.sleepTime=0; cs.body.sleeping=false; cs=cs.next; } var js=this.jointLink; while(js!=null){ js.body.sleepTime=0; js.body.sleeping=false; js=js.next; } for(var shape=this.shapes;shape!=null;shape=shape.next){ shape.updateProxy(); } }
javascript
function(){ if(!this.allowSleep||!this.sleeping)return; this.sleeping=false; this.sleepTime=0; // awake connected constraints var cs=this.contactLink; while(cs!=null){ cs.body.sleepTime=0; cs.body.sleeping=false; cs=cs.next; } var js=this.jointLink; while(js!=null){ js.body.sleepTime=0; js.body.sleeping=false; js=js.next; } for(var shape=this.shapes;shape!=null;shape=shape.next){ shape.updateProxy(); } }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "allowSleep", "||", "!", "this", ".", "sleeping", ")", "return", ";", "this", ".", "sleeping", "=", "false", ";", "this", ".", "sleepTime", "=", "0", ";", "// awake connected constraints", "var", "cs", "=", "this", ".", "contactLink", ";", "while", "(", "cs", "!=", "null", ")", "{", "cs", ".", "body", ".", "sleepTime", "=", "0", ";", "cs", ".", "body", ".", "sleeping", "=", "false", ";", "cs", "=", "cs", ".", "next", ";", "}", "var", "js", "=", "this", ".", "jointLink", ";", "while", "(", "js", "!=", "null", ")", "{", "js", ".", "body", ".", "sleepTime", "=", "0", ";", "js", ".", "body", ".", "sleeping", "=", "false", ";", "js", "=", "js", ".", "next", ";", "}", "for", "(", "var", "shape", "=", "this", ".", "shapes", ";", "shape", "!=", "null", ";", "shape", "=", "shape", ".", "next", ")", "{", "shape", ".", "updateProxy", "(", ")", ";", "}", "}" ]
Awake the rigid body.
[ "Awake", "the", "rigid", "body", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L873-L893
43,580
brochington/Akkad
lib/Oimo.js
function(){ if(!this.allowSleep||this.sleeping)return; this.linearVelocity.init(); this.angularVelocity.init(); this.sleepPosition.copy(this.position); this.sleepOrientation.copy(this.orientation); /*this.linearVelocity.x=0; this.linearVelocity.y=0; this.linearVelocity.z=0; this.angularVelocity.x=0; this.angularVelocity.y=0; this.angularVelocity.z=0; this.sleepPosition.x=this.position.x; this.sleepPosition.y=this.position.y; this.sleepPosition.z=this.position.z;*/ /*this.sleepOrientation.s=this.orientation.s; this.sleepOrientation.x=this.orientation.x; this.sleepOrientation.y=this.orientation.y; this.sleepOrientation.z=this.orientation.z;*/ this.sleepTime=0; this.sleeping=true; for(var shape=this.shapes;shape!=null;shape=shape.next){ shape.updateProxy(); } }
javascript
function(){ if(!this.allowSleep||this.sleeping)return; this.linearVelocity.init(); this.angularVelocity.init(); this.sleepPosition.copy(this.position); this.sleepOrientation.copy(this.orientation); /*this.linearVelocity.x=0; this.linearVelocity.y=0; this.linearVelocity.z=0; this.angularVelocity.x=0; this.angularVelocity.y=0; this.angularVelocity.z=0; this.sleepPosition.x=this.position.x; this.sleepPosition.y=this.position.y; this.sleepPosition.z=this.position.z;*/ /*this.sleepOrientation.s=this.orientation.s; this.sleepOrientation.x=this.orientation.x; this.sleepOrientation.y=this.orientation.y; this.sleepOrientation.z=this.orientation.z;*/ this.sleepTime=0; this.sleeping=true; for(var shape=this.shapes;shape!=null;shape=shape.next){ shape.updateProxy(); } }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "allowSleep", "||", "this", ".", "sleeping", ")", "return", ";", "this", ".", "linearVelocity", ".", "init", "(", ")", ";", "this", ".", "angularVelocity", ".", "init", "(", ")", ";", "this", ".", "sleepPosition", ".", "copy", "(", "this", ".", "position", ")", ";", "this", ".", "sleepOrientation", ".", "copy", "(", "this", ".", "orientation", ")", ";", "/*this.linearVelocity.x=0;\n this.linearVelocity.y=0;\n this.linearVelocity.z=0;\n this.angularVelocity.x=0;\n this.angularVelocity.y=0;\n this.angularVelocity.z=0;\n this.sleepPosition.x=this.position.x;\n this.sleepPosition.y=this.position.y;\n this.sleepPosition.z=this.position.z;*/", "/*this.sleepOrientation.s=this.orientation.s;\n this.sleepOrientation.x=this.orientation.x;\n this.sleepOrientation.y=this.orientation.y;\n this.sleepOrientation.z=this.orientation.z;*/", "this", ".", "sleepTime", "=", "0", ";", "this", ".", "sleeping", "=", "true", ";", "for", "(", "var", "shape", "=", "this", ".", "shapes", ";", "shape", "!=", "null", ";", "shape", "=", "shape", ".", "next", ")", "{", "shape", ".", "updateProxy", "(", ")", ";", "}", "}" ]
Sleep the rigid body.
[ "Sleep", "the", "rigid", "body", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L897-L922
43,581
brochington/Akkad
lib/Oimo.js
function(timeStep){ switch(this.type){ case this.BODY_STATIC: this.linearVelocity.init(); this.angularVelocity.init(); // ONLY FOR TEST if(this.controlPos){ this.position.copy(this.newPosition); this.controlPos = false; } if(this.controlRot){ this.orientation.copy(this.newOrientation); this.controlRot = false; } /*this.linearVelocity.x=0; this.linearVelocity.y=0; this.linearVelocity.z=0; this.angularVelocity.x=0; this.angularVelocity.y=0; this.angularVelocity.z=0;*/ break; case this.BODY_DYNAMIC: if(this.controlPos){ this.angularVelocity.init(); this.linearVelocity.init(); this.linearVelocity.x = (this.newPosition.x - this.position.x)/timeStep; this.linearVelocity.y = (this.newPosition.y - this.position.y)/timeStep; this.linearVelocity.z = (this.newPosition.z - this.position.z)/timeStep; this.controlPos = false; } if(this.controlRot){ this.angularVelocity.init(); this.orientation.copy(this.newOrientation); //var t=timeStep//*0.5; //var q = new OIMO.Quat(); //q.sub(this.newOrientation, this.orientation); //q.normalize(q); /*q.s = (this.newOrientation.s - this.orientation.s)/t; q.x = (this.newOrientation.x - this.orientation.x)/t; q.y = (this.newOrientation.y - this.orientation.y)/t; q.z = (this.newOrientation.z - this.orientation.z)/t;*/ //this.angularVelocity.applyQuaternion(q); //this.angularVelocity.x = this.angularVelocity.x/t; //this.angularVelocity.y = this.angularVelocity.y/t; //this.angularVelocity.z = this.angularVelocity.z/t; this.controlRot = false; } this.position.addTime(this.linearVelocity, timeStep); this.orientation.addTime(this.angularVelocity, timeStep); break; default: throw new Error("Invalid type."); } this.syncShapes(); }
javascript
function(timeStep){ switch(this.type){ case this.BODY_STATIC: this.linearVelocity.init(); this.angularVelocity.init(); // ONLY FOR TEST if(this.controlPos){ this.position.copy(this.newPosition); this.controlPos = false; } if(this.controlRot){ this.orientation.copy(this.newOrientation); this.controlRot = false; } /*this.linearVelocity.x=0; this.linearVelocity.y=0; this.linearVelocity.z=0; this.angularVelocity.x=0; this.angularVelocity.y=0; this.angularVelocity.z=0;*/ break; case this.BODY_DYNAMIC: if(this.controlPos){ this.angularVelocity.init(); this.linearVelocity.init(); this.linearVelocity.x = (this.newPosition.x - this.position.x)/timeStep; this.linearVelocity.y = (this.newPosition.y - this.position.y)/timeStep; this.linearVelocity.z = (this.newPosition.z - this.position.z)/timeStep; this.controlPos = false; } if(this.controlRot){ this.angularVelocity.init(); this.orientation.copy(this.newOrientation); //var t=timeStep//*0.5; //var q = new OIMO.Quat(); //q.sub(this.newOrientation, this.orientation); //q.normalize(q); /*q.s = (this.newOrientation.s - this.orientation.s)/t; q.x = (this.newOrientation.x - this.orientation.x)/t; q.y = (this.newOrientation.y - this.orientation.y)/t; q.z = (this.newOrientation.z - this.orientation.z)/t;*/ //this.angularVelocity.applyQuaternion(q); //this.angularVelocity.x = this.angularVelocity.x/t; //this.angularVelocity.y = this.angularVelocity.y/t; //this.angularVelocity.z = this.angularVelocity.z/t; this.controlRot = false; } this.position.addTime(this.linearVelocity, timeStep); this.orientation.addTime(this.angularVelocity, timeStep); break; default: throw new Error("Invalid type."); } this.syncShapes(); }
[ "function", "(", "timeStep", ")", "{", "switch", "(", "this", ".", "type", ")", "{", "case", "this", ".", "BODY_STATIC", ":", "this", ".", "linearVelocity", ".", "init", "(", ")", ";", "this", ".", "angularVelocity", ".", "init", "(", ")", ";", "// ONLY FOR TEST", "if", "(", "this", ".", "controlPos", ")", "{", "this", ".", "position", ".", "copy", "(", "this", ".", "newPosition", ")", ";", "this", ".", "controlPos", "=", "false", ";", "}", "if", "(", "this", ".", "controlRot", ")", "{", "this", ".", "orientation", ".", "copy", "(", "this", ".", "newOrientation", ")", ";", "this", ".", "controlRot", "=", "false", ";", "}", "/*this.linearVelocity.x=0;\n this.linearVelocity.y=0;\n this.linearVelocity.z=0;\n this.angularVelocity.x=0;\n this.angularVelocity.y=0;\n this.angularVelocity.z=0;*/", "break", ";", "case", "this", ".", "BODY_DYNAMIC", ":", "if", "(", "this", ".", "controlPos", ")", "{", "this", ".", "angularVelocity", ".", "init", "(", ")", ";", "this", ".", "linearVelocity", ".", "init", "(", ")", ";", "this", ".", "linearVelocity", ".", "x", "=", "(", "this", ".", "newPosition", ".", "x", "-", "this", ".", "position", ".", "x", ")", "/", "timeStep", ";", "this", ".", "linearVelocity", ".", "y", "=", "(", "this", ".", "newPosition", ".", "y", "-", "this", ".", "position", ".", "y", ")", "/", "timeStep", ";", "this", ".", "linearVelocity", ".", "z", "=", "(", "this", ".", "newPosition", ".", "z", "-", "this", ".", "position", ".", "z", ")", "/", "timeStep", ";", "this", ".", "controlPos", "=", "false", ";", "}", "if", "(", "this", ".", "controlRot", ")", "{", "this", ".", "angularVelocity", ".", "init", "(", ")", ";", "this", ".", "orientation", ".", "copy", "(", "this", ".", "newOrientation", ")", ";", "//var t=timeStep//*0.5;", "//var q = new OIMO.Quat();", "//q.sub(this.newOrientation, this.orientation);", "//q.normalize(q);", "/*q.s = (this.newOrientation.s - this.orientation.s)/t;\n q.x = (this.newOrientation.x - this.orientation.x)/t;\n q.y = (this.newOrientation.y - this.orientation.y)/t;\n q.z = (this.newOrientation.z - this.orientation.z)/t;*/", "//this.angularVelocity.applyQuaternion(q);", "//this.angularVelocity.x = this.angularVelocity.x/t;", "//this.angularVelocity.y = this.angularVelocity.y/t;", "//this.angularVelocity.z = this.angularVelocity.z/t;", "this", ".", "controlRot", "=", "false", ";", "}", "this", ".", "position", ".", "addTime", "(", "this", ".", "linearVelocity", ",", "timeStep", ")", ";", "this", ".", "orientation", ".", "addTime", "(", "this", ".", "angularVelocity", ",", "timeStep", ")", ";", "break", ";", "default", ":", "throw", "new", "Error", "(", "\"Invalid type.\"", ")", ";", "}", "this", ".", "syncShapes", "(", ")", ";", "}" ]
The time integration of the motion of a rigid body, you can update the information such as the shape. This method is invoked automatically when calling the step of the World, There is no need to call from outside usually. @param timeStep time
[ "The", "time", "integration", "of", "the", "motion", "of", "a", "rigid", "body", "you", "can", "update", "the", "information", "such", "as", "the", "shape", ".", "This", "method", "is", "invoked", "automatically", "when", "calling", "the", "step", "of", "the", "World", "There", "is", "no", "need", "to", "call", "from", "outside", "usually", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L938-L998
43,582
brochington/Akkad
lib/Oimo.js
function(){ var prev=this.s1Link.prev; var next=this.s1Link.next; if(prev!==null)prev.next=next; if(next!==null)next.prev=prev; if(this.shape1.contactLink==this.s1Link)this.shape1.contactLink=next; this.s1Link.prev=null; this.s1Link.next=null; this.s1Link.shape=null; this.s1Link.body=null; this.shape1.numContacts--; prev=this.s2Link.prev; next=this.s2Link.next; if(prev!==null)prev.next=next; if(next!==null)next.prev=prev; if(this.shape2.contactLink==this.s2Link)this.shape2.contactLink=next; this.s2Link.prev=null; this.s2Link.next=null; this.s2Link.shape=null; this.s2Link.body=null; this.shape2.numContacts--; prev=this.b1Link.prev; next=this.b1Link.next; if(prev!==null)prev.next=next; if(next!==null)next.prev=prev; if(this.body1.contactLink==this.b1Link)this.body1.contactLink=next; this.b1Link.prev=null; this.b1Link.next=null; this.b1Link.shape=null; this.b1Link.body=null; this.body1.numContacts--; prev=this.b2Link.prev; next=this.b2Link.next; if(prev!==null)prev.next=next; if(next!==null)next.prev=prev; if(this.body2.contactLink==this.b2Link)this.body2.contactLink=next; this.b2Link.prev=null; this.b2Link.next=null; this.b2Link.shape=null; this.b2Link.body=null; this.body2.numContacts--; this.manifold.body1=null; this.manifold.body2=null; this.constraint.body1=null; this.constraint.body2=null; this.constraint.detach(); this.shape1=null; this.shape2=null; this.body1=null; this.body2=null; }
javascript
function(){ var prev=this.s1Link.prev; var next=this.s1Link.next; if(prev!==null)prev.next=next; if(next!==null)next.prev=prev; if(this.shape1.contactLink==this.s1Link)this.shape1.contactLink=next; this.s1Link.prev=null; this.s1Link.next=null; this.s1Link.shape=null; this.s1Link.body=null; this.shape1.numContacts--; prev=this.s2Link.prev; next=this.s2Link.next; if(prev!==null)prev.next=next; if(next!==null)next.prev=prev; if(this.shape2.contactLink==this.s2Link)this.shape2.contactLink=next; this.s2Link.prev=null; this.s2Link.next=null; this.s2Link.shape=null; this.s2Link.body=null; this.shape2.numContacts--; prev=this.b1Link.prev; next=this.b1Link.next; if(prev!==null)prev.next=next; if(next!==null)next.prev=prev; if(this.body1.contactLink==this.b1Link)this.body1.contactLink=next; this.b1Link.prev=null; this.b1Link.next=null; this.b1Link.shape=null; this.b1Link.body=null; this.body1.numContacts--; prev=this.b2Link.prev; next=this.b2Link.next; if(prev!==null)prev.next=next; if(next!==null)next.prev=prev; if(this.body2.contactLink==this.b2Link)this.body2.contactLink=next; this.b2Link.prev=null; this.b2Link.next=null; this.b2Link.shape=null; this.b2Link.body=null; this.body2.numContacts--; this.manifold.body1=null; this.manifold.body2=null; this.constraint.body1=null; this.constraint.body2=null; this.constraint.detach(); this.shape1=null; this.shape2=null; this.body1=null; this.body2=null; }
[ "function", "(", ")", "{", "var", "prev", "=", "this", ".", "s1Link", ".", "prev", ";", "var", "next", "=", "this", ".", "s1Link", ".", "next", ";", "if", "(", "prev", "!==", "null", ")", "prev", ".", "next", "=", "next", ";", "if", "(", "next", "!==", "null", ")", "next", ".", "prev", "=", "prev", ";", "if", "(", "this", ".", "shape1", ".", "contactLink", "==", "this", ".", "s1Link", ")", "this", ".", "shape1", ".", "contactLink", "=", "next", ";", "this", ".", "s1Link", ".", "prev", "=", "null", ";", "this", ".", "s1Link", ".", "next", "=", "null", ";", "this", ".", "s1Link", ".", "shape", "=", "null", ";", "this", ".", "s1Link", ".", "body", "=", "null", ";", "this", ".", "shape1", ".", "numContacts", "--", ";", "prev", "=", "this", ".", "s2Link", ".", "prev", ";", "next", "=", "this", ".", "s2Link", ".", "next", ";", "if", "(", "prev", "!==", "null", ")", "prev", ".", "next", "=", "next", ";", "if", "(", "next", "!==", "null", ")", "next", ".", "prev", "=", "prev", ";", "if", "(", "this", ".", "shape2", ".", "contactLink", "==", "this", ".", "s2Link", ")", "this", ".", "shape2", ".", "contactLink", "=", "next", ";", "this", ".", "s2Link", ".", "prev", "=", "null", ";", "this", ".", "s2Link", ".", "next", "=", "null", ";", "this", ".", "s2Link", ".", "shape", "=", "null", ";", "this", ".", "s2Link", ".", "body", "=", "null", ";", "this", ".", "shape2", ".", "numContacts", "--", ";", "prev", "=", "this", ".", "b1Link", ".", "prev", ";", "next", "=", "this", ".", "b1Link", ".", "next", ";", "if", "(", "prev", "!==", "null", ")", "prev", ".", "next", "=", "next", ";", "if", "(", "next", "!==", "null", ")", "next", ".", "prev", "=", "prev", ";", "if", "(", "this", ".", "body1", ".", "contactLink", "==", "this", ".", "b1Link", ")", "this", ".", "body1", ".", "contactLink", "=", "next", ";", "this", ".", "b1Link", ".", "prev", "=", "null", ";", "this", ".", "b1Link", ".", "next", "=", "null", ";", "this", ".", "b1Link", ".", "shape", "=", "null", ";", "this", ".", "b1Link", ".", "body", "=", "null", ";", "this", ".", "body1", ".", "numContacts", "--", ";", "prev", "=", "this", ".", "b2Link", ".", "prev", ";", "next", "=", "this", ".", "b2Link", ".", "next", ";", "if", "(", "prev", "!==", "null", ")", "prev", ".", "next", "=", "next", ";", "if", "(", "next", "!==", "null", ")", "next", ".", "prev", "=", "prev", ";", "if", "(", "this", ".", "body2", ".", "contactLink", "==", "this", ".", "b2Link", ")", "this", ".", "body2", ".", "contactLink", "=", "next", ";", "this", ".", "b2Link", ".", "prev", "=", "null", ";", "this", ".", "b2Link", ".", "next", "=", "null", ";", "this", ".", "b2Link", ".", "shape", "=", "null", ";", "this", ".", "b2Link", ".", "body", "=", "null", ";", "this", ".", "body2", ".", "numContacts", "--", ";", "this", ".", "manifold", ".", "body1", "=", "null", ";", "this", ".", "manifold", ".", "body2", "=", "null", ";", "this", ".", "constraint", ".", "body1", "=", "null", ";", "this", ".", "constraint", ".", "body2", "=", "null", ";", "this", ".", "constraint", ".", "detach", "(", ")", ";", "this", ".", "shape1", "=", "null", ";", "this", ".", "shape2", "=", "null", ";", "this", ".", "body1", "=", "null", ";", "this", ".", "body2", "=", "null", ";", "}" ]
Detach the contact from the shapes.
[ "Detach", "the", "contact", "from", "the", "shapes", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L5804-L5859
43,583
brochington/Akkad
lib/Oimo.js
function(x,y,z,normalX,normalY,normalZ,penetration,flip){ var p=this.points[this.numPoints++]; p.position.x=x; p.position.y=y; p.position.z=z; var r=this.body1.rotation; var rx=x-this.body1.position.x; var ry=y-this.body1.position.y; var rz=z-this.body1.position.z; var tr = r.elements; p.localPoint1.x=rx*tr[0]+ry*tr[3]+rz*tr[6]; p.localPoint1.y=rx*tr[1]+ry*tr[4]+rz*tr[7]; p.localPoint1.z=rx*tr[2]+ry*tr[5]+rz*tr[8]; r=this.body2.rotation; rx=x-this.body2.position.x; ry=y-this.body2.position.y; rz=z-this.body2.position.z; p.localPoint2.x=rx*tr[0]+ry*tr[3]+rz*tr[6]; p.localPoint2.y=rx*tr[1]+ry*tr[4]+rz*tr[7]; p.localPoint2.z=rx*tr[2]+ry*tr[5]+rz*tr[8]; p.normalImpulse=0; if(flip){ p.normal.x=-normalX; p.normal.y=-normalY; p.normal.z=-normalZ; }else{ p.normal.x=normalX; p.normal.y=normalY; p.normal.z=normalZ; } p.penetration=penetration; p.warmStarted=false; }
javascript
function(x,y,z,normalX,normalY,normalZ,penetration,flip){ var p=this.points[this.numPoints++]; p.position.x=x; p.position.y=y; p.position.z=z; var r=this.body1.rotation; var rx=x-this.body1.position.x; var ry=y-this.body1.position.y; var rz=z-this.body1.position.z; var tr = r.elements; p.localPoint1.x=rx*tr[0]+ry*tr[3]+rz*tr[6]; p.localPoint1.y=rx*tr[1]+ry*tr[4]+rz*tr[7]; p.localPoint1.z=rx*tr[2]+ry*tr[5]+rz*tr[8]; r=this.body2.rotation; rx=x-this.body2.position.x; ry=y-this.body2.position.y; rz=z-this.body2.position.z; p.localPoint2.x=rx*tr[0]+ry*tr[3]+rz*tr[6]; p.localPoint2.y=rx*tr[1]+ry*tr[4]+rz*tr[7]; p.localPoint2.z=rx*tr[2]+ry*tr[5]+rz*tr[8]; p.normalImpulse=0; if(flip){ p.normal.x=-normalX; p.normal.y=-normalY; p.normal.z=-normalZ; }else{ p.normal.x=normalX; p.normal.y=normalY; p.normal.z=normalZ; } p.penetration=penetration; p.warmStarted=false; }
[ "function", "(", "x", ",", "y", ",", "z", ",", "normalX", ",", "normalY", ",", "normalZ", ",", "penetration", ",", "flip", ")", "{", "var", "p", "=", "this", ".", "points", "[", "this", ".", "numPoints", "++", "]", ";", "p", ".", "position", ".", "x", "=", "x", ";", "p", ".", "position", ".", "y", "=", "y", ";", "p", ".", "position", ".", "z", "=", "z", ";", "var", "r", "=", "this", ".", "body1", ".", "rotation", ";", "var", "rx", "=", "x", "-", "this", ".", "body1", ".", "position", ".", "x", ";", "var", "ry", "=", "y", "-", "this", ".", "body1", ".", "position", ".", "y", ";", "var", "rz", "=", "z", "-", "this", ".", "body1", ".", "position", ".", "z", ";", "var", "tr", "=", "r", ".", "elements", ";", "p", ".", "localPoint1", ".", "x", "=", "rx", "*", "tr", "[", "0", "]", "+", "ry", "*", "tr", "[", "3", "]", "+", "rz", "*", "tr", "[", "6", "]", ";", "p", ".", "localPoint1", ".", "y", "=", "rx", "*", "tr", "[", "1", "]", "+", "ry", "*", "tr", "[", "4", "]", "+", "rz", "*", "tr", "[", "7", "]", ";", "p", ".", "localPoint1", ".", "z", "=", "rx", "*", "tr", "[", "2", "]", "+", "ry", "*", "tr", "[", "5", "]", "+", "rz", "*", "tr", "[", "8", "]", ";", "r", "=", "this", ".", "body2", ".", "rotation", ";", "rx", "=", "x", "-", "this", ".", "body2", ".", "position", ".", "x", ";", "ry", "=", "y", "-", "this", ".", "body2", ".", "position", ".", "y", ";", "rz", "=", "z", "-", "this", ".", "body2", ".", "position", ".", "z", ";", "p", ".", "localPoint2", ".", "x", "=", "rx", "*", "tr", "[", "0", "]", "+", "ry", "*", "tr", "[", "3", "]", "+", "rz", "*", "tr", "[", "6", "]", ";", "p", ".", "localPoint2", ".", "y", "=", "rx", "*", "tr", "[", "1", "]", "+", "ry", "*", "tr", "[", "4", "]", "+", "rz", "*", "tr", "[", "7", "]", ";", "p", ".", "localPoint2", ".", "z", "=", "rx", "*", "tr", "[", "2", "]", "+", "ry", "*", "tr", "[", "5", "]", "+", "rz", "*", "tr", "[", "8", "]", ";", "p", ".", "normalImpulse", "=", "0", ";", "if", "(", "flip", ")", "{", "p", ".", "normal", ".", "x", "=", "-", "normalX", ";", "p", ".", "normal", ".", "y", "=", "-", "normalY", ";", "p", ".", "normal", ".", "z", "=", "-", "normalZ", ";", "}", "else", "{", "p", ".", "normal", ".", "x", "=", "normalX", ";", "p", ".", "normal", ".", "y", "=", "normalY", ";", "p", ".", "normal", ".", "z", "=", "normalZ", ";", "}", "p", ".", "penetration", "=", "penetration", ";", "p", ".", "warmStarted", "=", "false", ";", "}" ]
Add a point into this manifold. @param x @param y @param z @param normalX @param normalY @param normalZ @param penetration @param flip
[ "Add", "a", "point", "into", "this", "manifold", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L6390-L6424
43,584
brochington/Akkad
lib/Oimo.js
function(aabb1,aabb2){ this.minX = (aabb1.minX<aabb2.minX) ? aabb1.minX : aabb2.minX; this.maxX = (aabb1.maxX>aabb2.maxX) ? aabb1.maxX : aabb2.maxX; this.minY = (aabb1.minY<aabb2.minY) ? aabb1.minY : aabb2.minY; this.maxY = (aabb1.maxY>aabb2.maxY) ? aabb1.maxY : aabb2.maxY; this.minZ = (aabb1.minZ<aabb2.minZ) ? aabb1.minZ : aabb2.minZ; this.maxZ = (aabb1.maxZ>aabb2.maxZ) ? aabb1.maxZ : aabb2.maxZ; /* var margin=0; this.minX-=margin; this.minY-=margin; this.minZ-=margin; this.maxX+=margin; this.maxY+=margin; this.maxZ+=margin; */ }
javascript
function(aabb1,aabb2){ this.minX = (aabb1.minX<aabb2.minX) ? aabb1.minX : aabb2.minX; this.maxX = (aabb1.maxX>aabb2.maxX) ? aabb1.maxX : aabb2.maxX; this.minY = (aabb1.minY<aabb2.minY) ? aabb1.minY : aabb2.minY; this.maxY = (aabb1.maxY>aabb2.maxY) ? aabb1.maxY : aabb2.maxY; this.minZ = (aabb1.minZ<aabb2.minZ) ? aabb1.minZ : aabb2.minZ; this.maxZ = (aabb1.maxZ>aabb2.maxZ) ? aabb1.maxZ : aabb2.maxZ; /* var margin=0; this.minX-=margin; this.minY-=margin; this.minZ-=margin; this.maxX+=margin; this.maxY+=margin; this.maxZ+=margin; */ }
[ "function", "(", "aabb1", ",", "aabb2", ")", "{", "this", ".", "minX", "=", "(", "aabb1", ".", "minX", "<", "aabb2", ".", "minX", ")", "?", "aabb1", ".", "minX", ":", "aabb2", ".", "minX", ";", "this", ".", "maxX", "=", "(", "aabb1", ".", "maxX", ">", "aabb2", ".", "maxX", ")", "?", "aabb1", ".", "maxX", ":", "aabb2", ".", "maxX", ";", "this", ".", "minY", "=", "(", "aabb1", ".", "minY", "<", "aabb2", ".", "minY", ")", "?", "aabb1", ".", "minY", ":", "aabb2", ".", "minY", ";", "this", ".", "maxY", "=", "(", "aabb1", ".", "maxY", ">", "aabb2", ".", "maxY", ")", "?", "aabb1", ".", "maxY", ":", "aabb2", ".", "maxY", ";", "this", ".", "minZ", "=", "(", "aabb1", ".", "minZ", "<", "aabb2", ".", "minZ", ")", "?", "aabb1", ".", "minZ", ":", "aabb2", ".", "minZ", ";", "this", ".", "maxZ", "=", "(", "aabb1", ".", "maxZ", ">", "aabb2", ".", "maxZ", ")", "?", "aabb1", ".", "maxZ", ":", "aabb2", ".", "maxZ", ";", "/*\n var margin=0;\n this.minX-=margin;\n this.minY-=margin;\n this.minZ-=margin;\n this.maxX+=margin;\n this.maxY+=margin;\n this.maxZ+=margin;\n */", "}" ]
Set this AABB to the combined AABB of aabb1 and aabb2. @param aabb1 @param aabb2
[ "Set", "this", "AABB", "to", "the", "combined", "AABB", "of", "aabb1", "and", "aabb2", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L8435-L8451
43,585
brochington/Akkad
lib/Oimo.js
function(){ var h=this.maxY-this.minY; var d=this.maxZ-this.minZ; return 2*((this.maxX-this.minX)*(h+d)+h*d); }
javascript
function(){ var h=this.maxY-this.minY; var d=this.maxZ-this.minZ; return 2*((this.maxX-this.minX)*(h+d)+h*d); }
[ "function", "(", ")", "{", "var", "h", "=", "this", ".", "maxY", "-", "this", ".", "minY", ";", "var", "d", "=", "this", ".", "maxZ", "-", "this", ".", "minZ", ";", "return", "2", "*", "(", "(", "this", ".", "maxX", "-", "this", ".", "minX", ")", "*", "(", "h", "+", "d", ")", "+", "h", "*", "d", ")", ";", "}" ]
Get the surface area. @return
[ "Get", "the", "surface", "area", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L8456-L8460
43,586
brochington/Akkad
lib/Oimo.js
function(x,y,z){ return x>=this.minX&&x<=this.maxX&&y>=this.minY&&y<=this.maxY&&z>=this.minZ&&z<=this.maxZ; }
javascript
function(x,y,z){ return x>=this.minX&&x<=this.maxX&&y>=this.minY&&y<=this.maxY&&z>=this.minZ&&z<=this.maxZ; }
[ "function", "(", "x", ",", "y", ",", "z", ")", "{", "return", "x", ">=", "this", ".", "minX", "&&", "x", "<=", "this", ".", "maxX", "&&", "y", ">=", "this", ".", "minY", "&&", "y", "<=", "this", ".", "maxY", "&&", "z", ">=", "this", ".", "minZ", "&&", "z", "<=", "this", ".", "maxZ", ";", "}" ]
Get whether the AABB intersects with the point or not. @param x @param y @param z @return
[ "Get", "whether", "the", "AABB", "intersects", "with", "the", "point", "or", "not", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L8468-L8470
43,587
brochington/Akkad
lib/Oimo.js
function(s1,s2){ var b1=s1.parent; var b2=s2.parent; if( b1==b2 || // same parents (!b1.isDynamic&&!b2.isDynamic) || // static or kinematic object (s1.belongsTo&s2.collidesWith)==0 || (s2.belongsTo&s1.collidesWith)==0 // collision filtering ){ return false; } var js; if(b1.numJoints<b2.numJoints) js=b1.jointLink; else js=b2.jointLink; while(js!=null){ var joint=js.joint; if( !joint.allowCollision && (joint.body1==b1&&joint.body2==b2 || joint.body1==b2&&joint.body2==b1) ){ return false; } js=js.next; } return true; }
javascript
function(s1,s2){ var b1=s1.parent; var b2=s2.parent; if( b1==b2 || // same parents (!b1.isDynamic&&!b2.isDynamic) || // static or kinematic object (s1.belongsTo&s2.collidesWith)==0 || (s2.belongsTo&s1.collidesWith)==0 // collision filtering ){ return false; } var js; if(b1.numJoints<b2.numJoints) js=b1.jointLink; else js=b2.jointLink; while(js!=null){ var joint=js.joint; if( !joint.allowCollision && (joint.body1==b1&&joint.body2==b2 || joint.body1==b2&&joint.body2==b1) ){ return false; } js=js.next; } return true; }
[ "function", "(", "s1", ",", "s2", ")", "{", "var", "b1", "=", "s1", ".", "parent", ";", "var", "b2", "=", "s2", ".", "parent", ";", "if", "(", "b1", "==", "b2", "||", "// same parents", "(", "!", "b1", ".", "isDynamic", "&&", "!", "b2", ".", "isDynamic", ")", "||", "// static or kinematic object", "(", "s1", ".", "belongsTo", "&", "s2", ".", "collidesWith", ")", "==", "0", "||", "(", "s2", ".", "belongsTo", "&", "s1", ".", "collidesWith", ")", "==", "0", "// collision filtering", ")", "{", "return", "false", ";", "}", "var", "js", ";", "if", "(", "b1", ".", "numJoints", "<", "b2", ".", "numJoints", ")", "js", "=", "b1", ".", "jointLink", ";", "else", "js", "=", "b2", ".", "jointLink", ";", "while", "(", "js", "!=", "null", ")", "{", "var", "joint", "=", "js", ".", "joint", ";", "if", "(", "!", "joint", ".", "allowCollision", "&&", "(", "joint", ".", "body1", "==", "b1", "&&", "joint", ".", "body2", "==", "b2", "||", "joint", ".", "body1", "==", "b2", "&&", "joint", ".", "body2", "==", "b1", ")", ")", "{", "return", "false", ";", "}", "js", "=", "js", ".", "next", ";", "}", "return", "true", ";", "}" ]
Returns whether the pair is available or not. @param s1 @param s2 @return
[ "Returns", "whether", "the", "pair", "is", "available", "or", "not", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L8552-L8569
43,588
brochington/Akkad
lib/Oimo.js
function(){ while(this.numPairs>0){ var pair=this.pairs[--this.numPairs]; pair.shape1=null; pair.shape2=null; } this.numPairChecks=0; this.collectPairs(); }
javascript
function(){ while(this.numPairs>0){ var pair=this.pairs[--this.numPairs]; pair.shape1=null; pair.shape2=null; } this.numPairChecks=0; this.collectPairs(); }
[ "function", "(", ")", "{", "while", "(", "this", ".", "numPairs", ">", "0", ")", "{", "var", "pair", "=", "this", ".", "pairs", "[", "--", "this", ".", "numPairs", "]", ";", "pair", ".", "shape1", "=", "null", ";", "pair", ".", "shape2", "=", "null", ";", "}", "this", ".", "numPairChecks", "=", "0", ";", "this", ".", "collectPairs", "(", ")", ";", "}" ]
Detect overlapping pairs.
[ "Detect", "overlapping", "pairs", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L8571-L8579
43,589
brochington/Akkad
lib/Oimo.js
function(leaf){ if(this.root==null){ this.root=leaf; return; } var lb=leaf.aabb; var sibling=this.root; var oldArea; var newArea; while(sibling.proxy==null){ // descend the node to search the best pair var c1=sibling.child1; var c2=sibling.child2; var b=sibling.aabb; var c1b=c1.aabb; var c2b=c2.aabb; oldArea=b.surfaceArea(); this.aabb.combine(lb,b); newArea=this.aabb.surfaceArea(); var creatingCost=newArea*2; var incrementalCost=(newArea-oldArea)*2; // cost of creating a new pair with the node var discendingCost1=incrementalCost; this.aabb.combine(lb,c1b); if(c1.proxy!=null){ // leaf cost = area(combined aabb) discendingCost1+=this.aabb.surfaceArea(); }else{ // node cost = area(combined aabb) - area(old aabb) discendingCost1+=this.aabb.surfaceArea()-c1b.surfaceArea(); } var discendingCost2=incrementalCost; this.aabb.combine(lb,c2b); if(c2.proxy!=null){ // leaf cost = area(combined aabb) discendingCost2+=this.aabb.surfaceArea(); }else{ // node cost = area(combined aabb) - area(old aabb) discendingCost2+=this.aabb.surfaceArea()-c2b.surfaceArea(); } if(discendingCost1<discendingCost2){ if(creatingCost<discendingCost1){ break;// stop descending }else{ sibling=c1;// descend into first child } }else{ if(creatingCost<discendingCost2){ break;// stop descending }else{ sibling=c2;// descend into second child } } } var oldParent=sibling.parent; var newParent; if(this.numFreeNodes>0){ newParent=this.freeNodes[--this.numFreeNodes]; }else{ newParent=new OIMO.DBVTNode(); } newParent.parent=oldParent; newParent.child1=leaf; newParent.child2=sibling; newParent.aabb.combine(leaf.aabb,sibling.aabb); newParent.height=sibling.height+1; sibling.parent=newParent; leaf.parent=newParent; if(sibling==this.root){ // replace root this.root=newParent; }else{ // replace child if(oldParent.child1==sibling){ oldParent.child1=newParent; }else{ oldParent.child2=newParent; } } // update whole tree do{ newParent=this.balance(newParent); this.fix(newParent); newParent=newParent.parent; }while(newParent!=null); }
javascript
function(leaf){ if(this.root==null){ this.root=leaf; return; } var lb=leaf.aabb; var sibling=this.root; var oldArea; var newArea; while(sibling.proxy==null){ // descend the node to search the best pair var c1=sibling.child1; var c2=sibling.child2; var b=sibling.aabb; var c1b=c1.aabb; var c2b=c2.aabb; oldArea=b.surfaceArea(); this.aabb.combine(lb,b); newArea=this.aabb.surfaceArea(); var creatingCost=newArea*2; var incrementalCost=(newArea-oldArea)*2; // cost of creating a new pair with the node var discendingCost1=incrementalCost; this.aabb.combine(lb,c1b); if(c1.proxy!=null){ // leaf cost = area(combined aabb) discendingCost1+=this.aabb.surfaceArea(); }else{ // node cost = area(combined aabb) - area(old aabb) discendingCost1+=this.aabb.surfaceArea()-c1b.surfaceArea(); } var discendingCost2=incrementalCost; this.aabb.combine(lb,c2b); if(c2.proxy!=null){ // leaf cost = area(combined aabb) discendingCost2+=this.aabb.surfaceArea(); }else{ // node cost = area(combined aabb) - area(old aabb) discendingCost2+=this.aabb.surfaceArea()-c2b.surfaceArea(); } if(discendingCost1<discendingCost2){ if(creatingCost<discendingCost1){ break;// stop descending }else{ sibling=c1;// descend into first child } }else{ if(creatingCost<discendingCost2){ break;// stop descending }else{ sibling=c2;// descend into second child } } } var oldParent=sibling.parent; var newParent; if(this.numFreeNodes>0){ newParent=this.freeNodes[--this.numFreeNodes]; }else{ newParent=new OIMO.DBVTNode(); } newParent.parent=oldParent; newParent.child1=leaf; newParent.child2=sibling; newParent.aabb.combine(leaf.aabb,sibling.aabb); newParent.height=sibling.height+1; sibling.parent=newParent; leaf.parent=newParent; if(sibling==this.root){ // replace root this.root=newParent; }else{ // replace child if(oldParent.child1==sibling){ oldParent.child1=newParent; }else{ oldParent.child2=newParent; } } // update whole tree do{ newParent=this.balance(newParent); this.fix(newParent); newParent=newParent.parent; }while(newParent!=null); }
[ "function", "(", "leaf", ")", "{", "if", "(", "this", ".", "root", "==", "null", ")", "{", "this", ".", "root", "=", "leaf", ";", "return", ";", "}", "var", "lb", "=", "leaf", ".", "aabb", ";", "var", "sibling", "=", "this", ".", "root", ";", "var", "oldArea", ";", "var", "newArea", ";", "while", "(", "sibling", ".", "proxy", "==", "null", ")", "{", "// descend the node to search the best pair", "var", "c1", "=", "sibling", ".", "child1", ";", "var", "c2", "=", "sibling", ".", "child2", ";", "var", "b", "=", "sibling", ".", "aabb", ";", "var", "c1b", "=", "c1", ".", "aabb", ";", "var", "c2b", "=", "c2", ".", "aabb", ";", "oldArea", "=", "b", ".", "surfaceArea", "(", ")", ";", "this", ".", "aabb", ".", "combine", "(", "lb", ",", "b", ")", ";", "newArea", "=", "this", ".", "aabb", ".", "surfaceArea", "(", ")", ";", "var", "creatingCost", "=", "newArea", "*", "2", ";", "var", "incrementalCost", "=", "(", "newArea", "-", "oldArea", ")", "*", "2", ";", "// cost of creating a new pair with the node", "var", "discendingCost1", "=", "incrementalCost", ";", "this", ".", "aabb", ".", "combine", "(", "lb", ",", "c1b", ")", ";", "if", "(", "c1", ".", "proxy", "!=", "null", ")", "{", "// leaf cost = area(combined aabb)", "discendingCost1", "+=", "this", ".", "aabb", ".", "surfaceArea", "(", ")", ";", "}", "else", "{", "// node cost = area(combined aabb) - area(old aabb)", "discendingCost1", "+=", "this", ".", "aabb", ".", "surfaceArea", "(", ")", "-", "c1b", ".", "surfaceArea", "(", ")", ";", "}", "var", "discendingCost2", "=", "incrementalCost", ";", "this", ".", "aabb", ".", "combine", "(", "lb", ",", "c2b", ")", ";", "if", "(", "c2", ".", "proxy", "!=", "null", ")", "{", "// leaf cost = area(combined aabb)", "discendingCost2", "+=", "this", ".", "aabb", ".", "surfaceArea", "(", ")", ";", "}", "else", "{", "// node cost = area(combined aabb) - area(old aabb)", "discendingCost2", "+=", "this", ".", "aabb", ".", "surfaceArea", "(", ")", "-", "c2b", ".", "surfaceArea", "(", ")", ";", "}", "if", "(", "discendingCost1", "<", "discendingCost2", ")", "{", "if", "(", "creatingCost", "<", "discendingCost1", ")", "{", "break", ";", "// stop descending", "}", "else", "{", "sibling", "=", "c1", ";", "// descend into first child", "}", "}", "else", "{", "if", "(", "creatingCost", "<", "discendingCost2", ")", "{", "break", ";", "// stop descending", "}", "else", "{", "sibling", "=", "c2", ";", "// descend into second child", "}", "}", "}", "var", "oldParent", "=", "sibling", ".", "parent", ";", "var", "newParent", ";", "if", "(", "this", ".", "numFreeNodes", ">", "0", ")", "{", "newParent", "=", "this", ".", "freeNodes", "[", "--", "this", ".", "numFreeNodes", "]", ";", "}", "else", "{", "newParent", "=", "new", "OIMO", ".", "DBVTNode", "(", ")", ";", "}", "newParent", ".", "parent", "=", "oldParent", ";", "newParent", ".", "child1", "=", "leaf", ";", "newParent", ".", "child2", "=", "sibling", ";", "newParent", ".", "aabb", ".", "combine", "(", "leaf", ".", "aabb", ",", "sibling", ".", "aabb", ")", ";", "newParent", ".", "height", "=", "sibling", ".", "height", "+", "1", ";", "sibling", ".", "parent", "=", "newParent", ";", "leaf", ".", "parent", "=", "newParent", ";", "if", "(", "sibling", "==", "this", ".", "root", ")", "{", "// replace root", "this", ".", "root", "=", "newParent", ";", "}", "else", "{", "// replace child", "if", "(", "oldParent", ".", "child1", "==", "sibling", ")", "{", "oldParent", ".", "child1", "=", "newParent", ";", "}", "else", "{", "oldParent", ".", "child2", "=", "newParent", ";", "}", "}", "// update whole tree", "do", "{", "newParent", "=", "this", ".", "balance", "(", "newParent", ")", ";", "this", ".", "fix", "(", "newParent", ")", ";", "newParent", "=", "newParent", ".", "parent", ";", "}", "while", "(", "newParent", "!=", "null", ")", ";", "}" ]
Insert a leaf to the tree. @param node
[ "Insert", "a", "leaf", "to", "the", "tree", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L9112-L9195
43,590
brochington/Akkad
lib/Oimo.js
function(leaf){ if(leaf==this.root){ this.root=null; return; } var parent=leaf.parent; var sibling; if(parent.child1==leaf){ sibling=parent.child2; }else{ sibling=parent.child1; } if(parent==this.root){ this.root=sibling; sibling.parent=null; return; } var grandParent=parent.parent; sibling.parent=grandParent; if(grandParent.child1==parent){ grandParent.child1=sibling; }else{ grandParent.child2=sibling; } if(this.numFreeNodes<16384){ this.freeNodes[this.numFreeNodes++]=parent; } do{ grandParent=this.balance(grandParent); this.fix(grandParent); grandParent=grandParent.parent; }while(grandParent!=null); }
javascript
function(leaf){ if(leaf==this.root){ this.root=null; return; } var parent=leaf.parent; var sibling; if(parent.child1==leaf){ sibling=parent.child2; }else{ sibling=parent.child1; } if(parent==this.root){ this.root=sibling; sibling.parent=null; return; } var grandParent=parent.parent; sibling.parent=grandParent; if(grandParent.child1==parent){ grandParent.child1=sibling; }else{ grandParent.child2=sibling; } if(this.numFreeNodes<16384){ this.freeNodes[this.numFreeNodes++]=parent; } do{ grandParent=this.balance(grandParent); this.fix(grandParent); grandParent=grandParent.parent; }while(grandParent!=null); }
[ "function", "(", "leaf", ")", "{", "if", "(", "leaf", "==", "this", ".", "root", ")", "{", "this", ".", "root", "=", "null", ";", "return", ";", "}", "var", "parent", "=", "leaf", ".", "parent", ";", "var", "sibling", ";", "if", "(", "parent", ".", "child1", "==", "leaf", ")", "{", "sibling", "=", "parent", ".", "child2", ";", "}", "else", "{", "sibling", "=", "parent", ".", "child1", ";", "}", "if", "(", "parent", "==", "this", ".", "root", ")", "{", "this", ".", "root", "=", "sibling", ";", "sibling", ".", "parent", "=", "null", ";", "return", ";", "}", "var", "grandParent", "=", "parent", ".", "parent", ";", "sibling", ".", "parent", "=", "grandParent", ";", "if", "(", "grandParent", ".", "child1", "==", "parent", ")", "{", "grandParent", ".", "child1", "=", "sibling", ";", "}", "else", "{", "grandParent", ".", "child2", "=", "sibling", ";", "}", "if", "(", "this", ".", "numFreeNodes", "<", "16384", ")", "{", "this", ".", "freeNodes", "[", "this", ".", "numFreeNodes", "++", "]", "=", "parent", ";", "}", "do", "{", "grandParent", "=", "this", ".", "balance", "(", "grandParent", ")", ";", "this", ".", "fix", "(", "grandParent", ")", ";", "grandParent", "=", "grandParent", ".", "parent", ";", "}", "while", "(", "grandParent", "!=", "null", ")", ";", "}" ]
Delete a leaf from the tree. @param node
[ "Delete", "a", "leaf", "from", "the", "tree", "." ]
ccc3bb33f27e4c922a559320461fe3d21bc53f4a
https://github.com/brochington/Akkad/blob/ccc3bb33f27e4c922a559320461fe3d21bc53f4a/lib/Oimo.js#L9214-L9246
43,591
evansiroky/gtfs-sequelize
lib/gtfsLoader.js
function (timeString) { if (!timeString) { return null } var timeArr = timeString.split(':') return parseInt(timeArr[0], 10) * 3600 + parseInt(timeArr[1], 10) * 60 + parseInt(timeArr[2]) }
javascript
function (timeString) { if (!timeString) { return null } var timeArr = timeString.split(':') return parseInt(timeArr[0], 10) * 3600 + parseInt(timeArr[1], 10) * 60 + parseInt(timeArr[2]) }
[ "function", "(", "timeString", ")", "{", "if", "(", "!", "timeString", ")", "{", "return", "null", "}", "var", "timeArr", "=", "timeString", ".", "split", "(", "':'", ")", "return", "parseInt", "(", "timeArr", "[", "0", "]", ",", "10", ")", "*", "3600", "+", "parseInt", "(", "timeArr", "[", "1", "]", ",", "10", ")", "*", "60", "+", "parseInt", "(", "timeArr", "[", "2", "]", ")", "}" ]
convert timeString to int of seconds past midnight
[ "convert", "timeString", "to", "int", "of", "seconds", "past", "midnight" ]
ba101fa82e730694c536c43e615ff38fd264a65b
https://github.com/evansiroky/gtfs-sequelize/blob/ba101fa82e730694c536c43e615ff38fd264a65b/lib/gtfsLoader.js#L25-L33
43,592
evansiroky/gtfs-sequelize
lib/gtfsLoader.js
function () { insertCfg.model.sync({force: true}).then(function () { var streamInserterCfg = util.makeStreamerConfig(insertCfg.model) var inserter = dbStreamer.getInserter(streamInserterCfg) inserter.connect(function (err) { if (err) return callback(err) csv() .fromFile(insertCfg.filename) .on('json', line => { inserter.push(transformer2(line)) }) .on('done', err => { if (err) return callback(err) inserter.setEndHandler(callback) inserter.end() }) }) }) }
javascript
function () { insertCfg.model.sync({force: true}).then(function () { var streamInserterCfg = util.makeStreamerConfig(insertCfg.model) var inserter = dbStreamer.getInserter(streamInserterCfg) inserter.connect(function (err) { if (err) return callback(err) csv() .fromFile(insertCfg.filename) .on('json', line => { inserter.push(transformer2(line)) }) .on('done', err => { if (err) return callback(err) inserter.setEndHandler(callback) inserter.end() }) }) }) }
[ "function", "(", ")", "{", "insertCfg", ".", "model", ".", "sync", "(", "{", "force", ":", "true", "}", ")", ".", "then", "(", "function", "(", ")", "{", "var", "streamInserterCfg", "=", "util", ".", "makeStreamerConfig", "(", "insertCfg", ".", "model", ")", "var", "inserter", "=", "dbStreamer", ".", "getInserter", "(", "streamInserterCfg", ")", "inserter", ".", "connect", "(", "function", "(", "err", ")", "{", "if", "(", "err", ")", "return", "callback", "(", "err", ")", "csv", "(", ")", ".", "fromFile", "(", "insertCfg", ".", "filename", ")", ".", "on", "(", "'json'", ",", "line", "=>", "{", "inserter", ".", "push", "(", "transformer2", "(", "line", ")", ")", "}", ")", ".", "on", "(", "'done'", ",", "err", "=>", "{", "if", "(", "err", ")", "return", "callback", "(", "err", ")", "inserter", ".", "setEndHandler", "(", "callback", ")", "inserter", ".", "end", "(", ")", "}", ")", "}", ")", "}", ")", "}" ]
prepare processing function, but don't run it until file existance is confirmed
[ "prepare", "processing", "function", "but", "don", "t", "run", "it", "until", "file", "existance", "is", "confirmed" ]
ba101fa82e730694c536c43e615ff38fd264a65b
https://github.com/evansiroky/gtfs-sequelize/blob/ba101fa82e730694c536c43e615ff38fd264a65b/lib/gtfsLoader.js#L329-L348
43,593
kgryte/github-create-issue
lib/create.js
done
function done( error, data, info ) { error = error || null; data = data || null; info = info || null; clbk( error, data, info ); }
javascript
function done( error, data, info ) { error = error || null; data = data || null; info = info || null; clbk( error, data, info ); }
[ "function", "done", "(", "error", ",", "data", ",", "info", ")", "{", "error", "=", "error", "||", "null", ";", "data", "=", "data", "||", "null", ";", "info", "=", "info", "||", "null", ";", "clbk", "(", "error", ",", "data", ",", "info", ")", ";", "}" ]
Callback invoked after receiving an API response. @private @param {(Error|null)} error - error object @param {Object} data - query data @param {Object} info - response info
[ "Callback", "invoked", "after", "receiving", "an", "API", "response", "." ]
40612361f618ac0d0b52b23f641d78ca6342b19a
https://github.com/kgryte/github-create-issue/blob/40612361f618ac0d0b52b23f641d78ca6342b19a/lib/create.js#L68-L73
43,594
robinpowered/robin-js-sdk-public
lib/api/modules/identifiers.js
function (identifierUrn, params) { var path = this.constructPath(constants.IDENTIFIERS, identifierUrn); return this.Core.GET(path, params); }
javascript
function (identifierUrn, params) { var path = this.constructPath(constants.IDENTIFIERS, identifierUrn); return this.Core.GET(path, params); }
[ "function", "(", "identifierUrn", ",", "params", ")", "{", "var", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "IDENTIFIERS", ",", "identifierUrn", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}" ]
Get all the identifiers or a particular identifier identified by the `identifierUrn` parameter @param {String|Integer|undefined} identifierUrn A Robin identifier URN @param {Object|undefined} params A querystring object @return {Function} A Promise
[ "Get", "all", "the", "identifiers", "or", "a", "particular", "identifier", "identified", "by", "the", "identifierUrn", "parameter" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/identifiers.js#L20-L23
43,595
robinpowered/robin-js-sdk-public
lib/api/modules/identifiers.js
function (identifierUrn) { if (identifierUrn) { var path = this.constructPath(constants.IDENTIFIERS, identifierUrn); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad request: An identifier URN is required.'); } }
javascript
function (identifierUrn) { if (identifierUrn) { var path = this.constructPath(constants.IDENTIFIERS, identifierUrn); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad request: An identifier URN is required.'); } }
[ "function", "(", "identifierUrn", ")", "{", "if", "(", "identifierUrn", ")", "{", "var", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "IDENTIFIERS", ",", "identifierUrn", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad request: An identifier URN is required.'", ")", ";", "}", "}" ]
Delete an identifier @param {String|Integer} identifierUrn A Robin identifier URN @return {Function} A Promise
[ "Delete", "an", "identifier" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/identifiers.js#L30-L37
43,596
partyka95/graph-type-orm
dist/find-one.js
findOne
function findOne(repository, options) { const entityPrimaryKeyColumn = lodash_1.find(repository.metadata.columns, (columnMetadata) => columnMetadata.isPrimary).propertyName; const entityColumns = repository.metadata.columns.map((columnMetadata) => columnMetadata.propertyName); const entityManyToOneOrOneToOneRelationColumns = repository .metadata .relations .filter((relationMetadata) => relationMetadata.relationType === 'many-to-one' || relationMetadata.relationType === 'one-to-one') .map((relationMetadata) => relationMetadata.propertyName); const entityUniqueColumns = repository .metadata .columns .filter((columnMetadata) => columnMetadata.isUnique) .map((columnMetadata) => columnMetadata.propertyName); return function (source, args, context, info) { return __awaiter(this, void 0, void 0, function* () { const selectedColumns = Object.keys(graphqlFields(info)); const selectQueryBuilder = repository.createQueryBuilder(repository.metadata.name.toLowerCase()); /** Select **/ const selectFactory = new select_factory_1.SelectFactory(selectQueryBuilder); selectFactory .select(selectedColumns.filter((select) => entityColumns.includes(select))); /** Where **/ const filter = Object .keys(args) .filter((argName) => entityUniqueColumns.includes(argName) || argName === entityPrimaryKeyColumn) .reduce((filteredArgs, argName) => { filteredArgs[argName] = args[argName]; return filteredArgs; }, {}); const whereFactory = new where_factory_1.WhereFactory(selectQueryBuilder, entityManyToOneOrOneToOneRelationColumns); whereFactory .where(filter); /** Joins **/ const joinsFactory = new joins_factory_1.JoinsFactory(selectQueryBuilder); joinsFactory .join(selectedColumns .filter((select) => entityManyToOneOrOneToOneRelationColumns.includes(select)) .reduce((selectedRelationColumns, selectedRelationColumn) => { selectedRelationColumns[selectQueryBuilder.alias] = selectedRelationColumn; return selectedRelationColumns; }, {})) .join(whereFactory.selectedManyToOneOrOneToOneRelationColumns); /** Extend **/ if (lodash_1.get(options, 'extend')) { yield options.extend(selectQueryBuilder); } /** Execute get many method **/ return yield selectQueryBuilder.getOne(); }); }; }
javascript
function findOne(repository, options) { const entityPrimaryKeyColumn = lodash_1.find(repository.metadata.columns, (columnMetadata) => columnMetadata.isPrimary).propertyName; const entityColumns = repository.metadata.columns.map((columnMetadata) => columnMetadata.propertyName); const entityManyToOneOrOneToOneRelationColumns = repository .metadata .relations .filter((relationMetadata) => relationMetadata.relationType === 'many-to-one' || relationMetadata.relationType === 'one-to-one') .map((relationMetadata) => relationMetadata.propertyName); const entityUniqueColumns = repository .metadata .columns .filter((columnMetadata) => columnMetadata.isUnique) .map((columnMetadata) => columnMetadata.propertyName); return function (source, args, context, info) { return __awaiter(this, void 0, void 0, function* () { const selectedColumns = Object.keys(graphqlFields(info)); const selectQueryBuilder = repository.createQueryBuilder(repository.metadata.name.toLowerCase()); /** Select **/ const selectFactory = new select_factory_1.SelectFactory(selectQueryBuilder); selectFactory .select(selectedColumns.filter((select) => entityColumns.includes(select))); /** Where **/ const filter = Object .keys(args) .filter((argName) => entityUniqueColumns.includes(argName) || argName === entityPrimaryKeyColumn) .reduce((filteredArgs, argName) => { filteredArgs[argName] = args[argName]; return filteredArgs; }, {}); const whereFactory = new where_factory_1.WhereFactory(selectQueryBuilder, entityManyToOneOrOneToOneRelationColumns); whereFactory .where(filter); /** Joins **/ const joinsFactory = new joins_factory_1.JoinsFactory(selectQueryBuilder); joinsFactory .join(selectedColumns .filter((select) => entityManyToOneOrOneToOneRelationColumns.includes(select)) .reduce((selectedRelationColumns, selectedRelationColumn) => { selectedRelationColumns[selectQueryBuilder.alias] = selectedRelationColumn; return selectedRelationColumns; }, {})) .join(whereFactory.selectedManyToOneOrOneToOneRelationColumns); /** Extend **/ if (lodash_1.get(options, 'extend')) { yield options.extend(selectQueryBuilder); } /** Execute get many method **/ return yield selectQueryBuilder.getOne(); }); }; }
[ "function", "findOne", "(", "repository", ",", "options", ")", "{", "const", "entityPrimaryKeyColumn", "=", "lodash_1", ".", "find", "(", "repository", ".", "metadata", ".", "columns", ",", "(", "columnMetadata", ")", "=>", "columnMetadata", ".", "isPrimary", ")", ".", "propertyName", ";", "const", "entityColumns", "=", "repository", ".", "metadata", ".", "columns", ".", "map", "(", "(", "columnMetadata", ")", "=>", "columnMetadata", ".", "propertyName", ")", ";", "const", "entityManyToOneOrOneToOneRelationColumns", "=", "repository", ".", "metadata", ".", "relations", ".", "filter", "(", "(", "relationMetadata", ")", "=>", "relationMetadata", ".", "relationType", "===", "'many-to-one'", "||", "relationMetadata", ".", "relationType", "===", "'one-to-one'", ")", ".", "map", "(", "(", "relationMetadata", ")", "=>", "relationMetadata", ".", "propertyName", ")", ";", "const", "entityUniqueColumns", "=", "repository", ".", "metadata", ".", "columns", ".", "filter", "(", "(", "columnMetadata", ")", "=>", "columnMetadata", ".", "isUnique", ")", ".", "map", "(", "(", "columnMetadata", ")", "=>", "columnMetadata", ".", "propertyName", ")", ";", "return", "function", "(", "source", ",", "args", ",", "context", ",", "info", ")", "{", "return", "__awaiter", "(", "this", ",", "void", "0", ",", "void", "0", ",", "function", "*", "(", ")", "{", "const", "selectedColumns", "=", "Object", ".", "keys", "(", "graphqlFields", "(", "info", ")", ")", ";", "const", "selectQueryBuilder", "=", "repository", ".", "createQueryBuilder", "(", "repository", ".", "metadata", ".", "name", ".", "toLowerCase", "(", ")", ")", ";", "/** Select **/", "const", "selectFactory", "=", "new", "select_factory_1", ".", "SelectFactory", "(", "selectQueryBuilder", ")", ";", "selectFactory", ".", "select", "(", "selectedColumns", ".", "filter", "(", "(", "select", ")", "=>", "entityColumns", ".", "includes", "(", "select", ")", ")", ")", ";", "/** Where **/", "const", "filter", "=", "Object", ".", "keys", "(", "args", ")", ".", "filter", "(", "(", "argName", ")", "=>", "entityUniqueColumns", ".", "includes", "(", "argName", ")", "||", "argName", "===", "entityPrimaryKeyColumn", ")", ".", "reduce", "(", "(", "filteredArgs", ",", "argName", ")", "=>", "{", "filteredArgs", "[", "argName", "]", "=", "args", "[", "argName", "]", ";", "return", "filteredArgs", ";", "}", ",", "{", "}", ")", ";", "const", "whereFactory", "=", "new", "where_factory_1", ".", "WhereFactory", "(", "selectQueryBuilder", ",", "entityManyToOneOrOneToOneRelationColumns", ")", ";", "whereFactory", ".", "where", "(", "filter", ")", ";", "/** Joins **/", "const", "joinsFactory", "=", "new", "joins_factory_1", ".", "JoinsFactory", "(", "selectQueryBuilder", ")", ";", "joinsFactory", ".", "join", "(", "selectedColumns", ".", "filter", "(", "(", "select", ")", "=>", "entityManyToOneOrOneToOneRelationColumns", ".", "includes", "(", "select", ")", ")", ".", "reduce", "(", "(", "selectedRelationColumns", ",", "selectedRelationColumn", ")", "=>", "{", "selectedRelationColumns", "[", "selectQueryBuilder", ".", "alias", "]", "=", "selectedRelationColumn", ";", "return", "selectedRelationColumns", ";", "}", ",", "{", "}", ")", ")", ".", "join", "(", "whereFactory", ".", "selectedManyToOneOrOneToOneRelationColumns", ")", ";", "/** Extend **/", "if", "(", "lodash_1", ".", "get", "(", "options", ",", "'extend'", ")", ")", "{", "yield", "options", ".", "extend", "(", "selectQueryBuilder", ")", ";", "}", "/** Execute get many method **/", "return", "yield", "selectQueryBuilder", ".", "getOne", "(", ")", ";", "}", ")", ";", "}", ";", "}" ]
Method to find the entity record. @param {Repository<Entity>} repository @param {FindOneOptions<Entity>} options @returns {(source, args, context, info) => Promise<Entity>}
[ "Method", "to", "find", "the", "entity", "record", "." ]
c2c1d93c091ad8fb5d3015cabe6edb20dccfa225
https://github.com/partyka95/graph-type-orm/blob/c2c1d93c091ad8fb5d3015cabe6edb20dccfa225/dist/find-one.js#L25-L75
43,597
dsfields/radargun
lib/update-status.js
updateStatus
function updateStatus(runCount, totalRuns, stream) { if (runCount % 10 !== 0) return; const percent = Math.floor((runCount / totalRuns) * 100); const blocks = Math.floor(percent / 2); const empty = 50 - blocks; const value = '|' + '\u2588'.repeat(blocks) + '\u2591'.repeat(empty) + '| ' + percent.toString() + '% || ' + runCount.toString() + ' / ' + totalRuns.toString(); readline.cursorTo(stream, 0, null); stream.write(value); if (percent === 100) stream.write('\n\n'); }
javascript
function updateStatus(runCount, totalRuns, stream) { if (runCount % 10 !== 0) return; const percent = Math.floor((runCount / totalRuns) * 100); const blocks = Math.floor(percent / 2); const empty = 50 - blocks; const value = '|' + '\u2588'.repeat(blocks) + '\u2591'.repeat(empty) + '| ' + percent.toString() + '% || ' + runCount.toString() + ' / ' + totalRuns.toString(); readline.cursorTo(stream, 0, null); stream.write(value); if (percent === 100) stream.write('\n\n'); }
[ "function", "updateStatus", "(", "runCount", ",", "totalRuns", ",", "stream", ")", "{", "if", "(", "runCount", "%", "10", "!==", "0", ")", "return", ";", "const", "percent", "=", "Math", ".", "floor", "(", "(", "runCount", "/", "totalRuns", ")", "*", "100", ")", ";", "const", "blocks", "=", "Math", ".", "floor", "(", "percent", "/", "2", ")", ";", "const", "empty", "=", "50", "-", "blocks", ";", "const", "value", "=", "'|'", "+", "'\\u2588'", ".", "repeat", "(", "blocks", ")", "+", "'\\u2591'", ".", "repeat", "(", "empty", ")", "+", "'| '", "+", "percent", ".", "toString", "(", ")", "+", "'% || '", "+", "runCount", ".", "toString", "(", ")", "+", "' / '", "+", "totalRuns", ".", "toString", "(", ")", ";", "readline", ".", "cursorTo", "(", "stream", ",", "0", ",", "null", ")", ";", "stream", ".", "write", "(", "value", ")", ";", "if", "(", "percent", "===", "100", ")", "stream", ".", "write", "(", "'\\n\\n'", ")", ";", "}" ]
Renders the progress bar. @param {number} runCount @param {number} totalRuns
[ "Renders", "the", "progress", "bar", "." ]
c0cf2730441e1e454355603c2fd7539b9d552f1a
https://github.com/dsfields/radargun/blob/c0cf2730441e1e454355603c2fd7539b9d552f1a/lib/update-status.js#L12-L33
43,598
robinpowered/robin-js-sdk-public
lib/api/modules/locations.js
function (identifier, params) { var path = this.constructPath(constants.LOCATIONS, identifier); return this.Core.GET(path, params); }
javascript
function (identifier, params) { var path = this.constructPath(constants.LOCATIONS, identifier); return this.Core.GET(path, params); }
[ "function", "(", "identifier", ",", "params", ")", "{", "var", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "LOCATIONS", ",", "identifier", ")", ";", "return", "this", ".", "Core", ".", "GET", "(", "path", ",", "params", ")", ";", "}" ]
Get all the locations or a particular location identified by `identifier` @param {String|Integer|undefined} identifier A location identifier @param {Object} params A querystring object @return {Function} A promise
[ "Get", "all", "the", "locations", "or", "a", "particular", "location", "identified", "by", "identifier" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/locations.js#L20-L23
43,599
robinpowered/robin-js-sdk-public
lib/api/modules/locations.js
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.LOCATIONS, identifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A location identifier is required.'); } }
javascript
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.LOCATIONS, identifier); return this.Core.DELETE(path); } else { return this.rejectRequest('Bad Request: A location identifier is required.'); } }
[ "function", "(", "identifier", ")", "{", "var", "path", ";", "if", "(", "identifier", ")", "{", "path", "=", "this", ".", "constructPath", "(", "constants", ".", "LOCATIONS", ",", "identifier", ")", ";", "return", "this", ".", "Core", ".", "DELETE", "(", "path", ")", ";", "}", "else", "{", "return", "this", ".", "rejectRequest", "(", "'Bad Request: A location identifier is required.'", ")", ";", "}", "}" ]
Delete a location @param {String|Integer} identifier A Robin location identifier @return {Function} A Promise
[ "Delete", "a", "location" ]
c3119f8340a728a2fba607c353893559376dd490
https://github.com/robinpowered/robin-js-sdk-public/blob/c3119f8340a728a2fba607c353893559376dd490/lib/api/modules/locations.js#L46-L54