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
49,300
tolokoban/ToloFrameWork
ker/mod/tfw.web-service.js
callWebService
function callWebService( name, args, url ) { return new Promise( function( resolve, reject ) { svc( name, args, url ).then( resolve, function( err ) { if ( typeof err === 'object' && err.id === exports.BAD_ROLE ) { // Echec de connexion, on retente de se connecter avant d'abandonner. login().then( function() { svc( name, args, url ).then( resolve, reject ); }, reject ); } else { reject( err ); } } ); } ); }
javascript
function callWebService( name, args, url ) { return new Promise( function( resolve, reject ) { svc( name, args, url ).then( resolve, function( err ) { if ( typeof err === 'object' && err.id === exports.BAD_ROLE ) { // Echec de connexion, on retente de se connecter avant d'abandonner. login().then( function() { svc( name, args, url ).then( resolve, reject ); }, reject ); } else { reject( err ); } } ); } ); }
[ "function", "callWebService", "(", "name", ",", "args", ",", "url", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "svc", "(", "name", ",", "args", ",", "url", ")", ".", "then", "(", "resolve", ",", "function", "(", "err", ")", "{", "if", "(", "typeof", "err", "===", "'object'", "&&", "err", ".", "id", "===", "exports", ".", "BAD_ROLE", ")", "{", "// Echec de connexion, on retente de se connecter avant d'abandonner.", "login", "(", ")", ".", "then", "(", "function", "(", ")", "{", "svc", "(", "name", ",", "args", ",", "url", ")", ".", "then", "(", "resolve", ",", "reject", ")", ";", "}", ",", "reject", ")", ";", "}", "else", "{", "reject", "(", "err", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}" ]
Call a webservice.
[ "Call", "a", "webservice", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.web-service.js#L361-L382
49,301
vkiding/jud-vue-render
src/render/vue/components/slider/indicator.js
_reLayout
function _reLayout (context, virtualRect, ltbr) { const el = context.$el const rect = _getIndicatorRect(el) const rectWithPx = Object.keys(rect).reduce((pre, key) => { pre[key] = rect[key] + 'px' return pre }, {}) extend(el.style, rectWithPx) const axisMap = [ { dir: ltbr.left ? 'left' : ltbr.right ? 'right' : 'left', scale: 'width' }, { dir: ltbr.top ? 'top' : ltbr.bottom ? 'bottom' : 'top', scale: 'height' } ] Object.keys(axisMap).forEach(key => { const { dir, scale } = axisMap[key] el.style[dir] = ltbr[dir] + virtualRect[scale] / 2 - rect[scale] / 2 + 'px' }) }
javascript
function _reLayout (context, virtualRect, ltbr) { const el = context.$el const rect = _getIndicatorRect(el) const rectWithPx = Object.keys(rect).reduce((pre, key) => { pre[key] = rect[key] + 'px' return pre }, {}) extend(el.style, rectWithPx) const axisMap = [ { dir: ltbr.left ? 'left' : ltbr.right ? 'right' : 'left', scale: 'width' }, { dir: ltbr.top ? 'top' : ltbr.bottom ? 'bottom' : 'top', scale: 'height' } ] Object.keys(axisMap).forEach(key => { const { dir, scale } = axisMap[key] el.style[dir] = ltbr[dir] + virtualRect[scale] / 2 - rect[scale] / 2 + 'px' }) }
[ "function", "_reLayout", "(", "context", ",", "virtualRect", ",", "ltbr", ")", "{", "const", "el", "=", "context", ".", "$el", "const", "rect", "=", "_getIndicatorRect", "(", "el", ")", "const", "rectWithPx", "=", "Object", ".", "keys", "(", "rect", ")", ".", "reduce", "(", "(", "pre", ",", "key", ")", "=>", "{", "pre", "[", "key", "]", "=", "rect", "[", "key", "]", "+", "'px'", "return", "pre", "}", ",", "{", "}", ")", "extend", "(", "el", ".", "style", ",", "rectWithPx", ")", "const", "axisMap", "=", "[", "{", "dir", ":", "ltbr", ".", "left", "?", "'left'", ":", "ltbr", ".", "right", "?", "'right'", ":", "'left'", ",", "scale", ":", "'width'", "}", ",", "{", "dir", ":", "ltbr", ".", "top", "?", "'top'", ":", "ltbr", ".", "bottom", "?", "'bottom'", ":", "'top'", ",", "scale", ":", "'height'", "}", "]", "Object", ".", "keys", "(", "axisMap", ")", ".", "forEach", "(", "key", "=>", "{", "const", "{", "dir", ",", "scale", "}", "=", "axisMap", "[", "key", "]", "el", ".", "style", "[", "dir", "]", "=", "ltbr", "[", "dir", "]", "+", "virtualRect", "[", "scale", "]", "/", "2", "-", "rect", "[", "scale", "]", "/", "2", "+", "'px'", "}", ")", "}" ]
calculate and reset indicator's width, height, and ltbr. @param {object} virtualRect. width and height of indicator's virtual rect box. @param {object} ltbr. the user specified left, top, bottom, right pixels (without units).
[ "calculate", "and", "reset", "indicator", "s", "width", "height", "and", "ltbr", "." ]
07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47
https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/vue/components/slider/indicator.js#L120-L136
49,302
jmjuanes/objectsort
dist/objectsort.js
ObjectSort
function ObjectSort(array, columns, order) { //Check the columns if(typeof columns === 'undefined') { //Create the columns array var columns = []; //Add the keys for(var key in array[0]){ columns.push(key); } } //Check if columns is not an array else if(Array.isArray(columns) === false) { //Convert it to array columns = [columns]; } //Check the order if(typeof order === 'undefined') { //Create the order array var order = []; //Add ASC order for(var i = 0; i < columns.length; i++){ order.push('ASC'); } } //Check if order is not an array else if(Array.isArray(order) === false) { //Convert it to array order = [order]; } //Else, check for lowercase else { //Add the order to uppercase for(var i = 0; i < order.length; i++){ order[i] = order[i].toUpperCase(); } } //Check the order array length if(order.length < columns.length) { //Complete the order array for(var i = order.length; i < columns.length; i++){ order.push('ASC'); } } //Sort the array array.sort(function(left, right){ return Compare(left, right, columns, order); }); //Return the array return array; }
javascript
function ObjectSort(array, columns, order) { //Check the columns if(typeof columns === 'undefined') { //Create the columns array var columns = []; //Add the keys for(var key in array[0]){ columns.push(key); } } //Check if columns is not an array else if(Array.isArray(columns) === false) { //Convert it to array columns = [columns]; } //Check the order if(typeof order === 'undefined') { //Create the order array var order = []; //Add ASC order for(var i = 0; i < columns.length; i++){ order.push('ASC'); } } //Check if order is not an array else if(Array.isArray(order) === false) { //Convert it to array order = [order]; } //Else, check for lowercase else { //Add the order to uppercase for(var i = 0; i < order.length; i++){ order[i] = order[i].toUpperCase(); } } //Check the order array length if(order.length < columns.length) { //Complete the order array for(var i = order.length; i < columns.length; i++){ order.push('ASC'); } } //Sort the array array.sort(function(left, right){ return Compare(left, right, columns, order); }); //Return the array return array; }
[ "function", "ObjectSort", "(", "array", ",", "columns", ",", "order", ")", "{", "//Check the columns\r", "if", "(", "typeof", "columns", "===", "'undefined'", ")", "{", "//Create the columns array\r", "var", "columns", "=", "[", "]", ";", "//Add the keys\r", "for", "(", "var", "key", "in", "array", "[", "0", "]", ")", "{", "columns", ".", "push", "(", "key", ")", ";", "}", "}", "//Check if columns is not an array\r", "else", "if", "(", "Array", ".", "isArray", "(", "columns", ")", "===", "false", ")", "{", "//Convert it to array\r", "columns", "=", "[", "columns", "]", ";", "}", "//Check the order\r", "if", "(", "typeof", "order", "===", "'undefined'", ")", "{", "//Create the order array\r", "var", "order", "=", "[", "]", ";", "//Add ASC order\r", "for", "(", "var", "i", "=", "0", ";", "i", "<", "columns", ".", "length", ";", "i", "++", ")", "{", "order", ".", "push", "(", "'ASC'", ")", ";", "}", "}", "//Check if order is not an array\r", "else", "if", "(", "Array", ".", "isArray", "(", "order", ")", "===", "false", ")", "{", "//Convert it to array\r", "order", "=", "[", "order", "]", ";", "}", "//Else, check for lowercase\r", "else", "{", "//Add the order to uppercase\r", "for", "(", "var", "i", "=", "0", ";", "i", "<", "order", ".", "length", ";", "i", "++", ")", "{", "order", "[", "i", "]", "=", "order", "[", "i", "]", ".", "toUpperCase", "(", ")", ";", "}", "}", "//Check the order array length\r", "if", "(", "order", ".", "length", "<", "columns", ".", "length", ")", "{", "//Complete the order array\r", "for", "(", "var", "i", "=", "order", ".", "length", ";", "i", "<", "columns", ".", "length", ";", "i", "++", ")", "{", "order", ".", "push", "(", "'ASC'", ")", ";", "}", "}", "//Sort the array\r", "array", ".", "sort", "(", "function", "(", "left", ",", "right", ")", "{", "return", "Compare", "(", "left", ",", "right", ",", "columns", ",", "order", ")", ";", "}", ")", ";", "//Return the array\r", "return", "array", ";", "}" ]
Sort main function
[ "Sort", "main", "function" ]
a3d29a83423e56ff8aed5ebc06446fff0596ba46
https://github.com/jmjuanes/objectsort/blob/a3d29a83423e56ff8aed5ebc06446fff0596ba46/dist/objectsort.js#L2-L57
49,303
jmjuanes/objectsort
dist/objectsort.js
Compare
function Compare(left, right, columns, order) { //Compare all for(var i = 0; i < columns.length; i++) { //Check if que difference is numeric var numeric = !isNaN(+left[columns[i]] - +right[columns[i]]); //Get the values var a = (numeric === true) ? +left[columns[i]] : left[columns[i]].toLowerCase(); var b = (numeric === true) ? +right[columns[i]] : right[columns[i]].toLowerCase(); //Check the values if(a < b) { //Check the order return (order[i] === 'ASC') ? -1 : 1; } else if(a > b) { //Check the order return (order[i] === 'ASC') ? 1 : -1; } } //Default, return 0 return 0; }
javascript
function Compare(left, right, columns, order) { //Compare all for(var i = 0; i < columns.length; i++) { //Check if que difference is numeric var numeric = !isNaN(+left[columns[i]] - +right[columns[i]]); //Get the values var a = (numeric === true) ? +left[columns[i]] : left[columns[i]].toLowerCase(); var b = (numeric === true) ? +right[columns[i]] : right[columns[i]].toLowerCase(); //Check the values if(a < b) { //Check the order return (order[i] === 'ASC') ? -1 : 1; } else if(a > b) { //Check the order return (order[i] === 'ASC') ? 1 : -1; } } //Default, return 0 return 0; }
[ "function", "Compare", "(", "left", ",", "right", ",", "columns", ",", "order", ")", "{", "//Compare all\r", "for", "(", "var", "i", "=", "0", ";", "i", "<", "columns", ".", "length", ";", "i", "++", ")", "{", "//Check if que difference is numeric\r", "var", "numeric", "=", "!", "isNaN", "(", "+", "left", "[", "columns", "[", "i", "]", "]", "-", "+", "right", "[", "columns", "[", "i", "]", "]", ")", ";", "//Get the values\r", "var", "a", "=", "(", "numeric", "===", "true", ")", "?", "+", "left", "[", "columns", "[", "i", "]", "]", ":", "left", "[", "columns", "[", "i", "]", "]", ".", "toLowerCase", "(", ")", ";", "var", "b", "=", "(", "numeric", "===", "true", ")", "?", "+", "right", "[", "columns", "[", "i", "]", "]", ":", "right", "[", "columns", "[", "i", "]", "]", ".", "toLowerCase", "(", ")", ";", "//Check the values\r", "if", "(", "a", "<", "b", ")", "{", "//Check the order\r", "return", "(", "order", "[", "i", "]", "===", "'ASC'", ")", "?", "-", "1", ":", "1", ";", "}", "else", "if", "(", "a", ">", "b", ")", "{", "//Check the order\r", "return", "(", "order", "[", "i", "]", "===", "'ASC'", ")", "?", "1", ":", "-", "1", ";", "}", "}", "//Default, return 0\r", "return", "0", ";", "}" ]
Function for compare two elements
[ "Function", "for", "compare", "two", "elements" ]
a3d29a83423e56ff8aed5ebc06446fff0596ba46
https://github.com/jmjuanes/objectsort/blob/a3d29a83423e56ff8aed5ebc06446fff0596ba46/dist/objectsort.js#L60-L87
49,304
jeremyruppel/hoagie
lib/middleware/completion/index.js
commands
function commands(req, res /*, next */) { req.app.commands.forEach(function(command) { res.writeln(command); }); res.end(); }
javascript
function commands(req, res /*, next */) { req.app.commands.forEach(function(command) { res.writeln(command); }); res.end(); }
[ "function", "commands", "(", "req", ",", "res", "/*, next */", ")", "{", "req", ".", "app", ".", "commands", ".", "forEach", "(", "function", "(", "command", ")", "{", "res", ".", "writeln", "(", "command", ")", ";", "}", ")", ";", "res", ".", "end", "(", ")", ";", "}" ]
Prints all registered commands.
[ "Prints", "all", "registered", "commands", "." ]
9e05b4c9f0537d681dcb240eab41822f15bef613
https://github.com/jeremyruppel/hoagie/blob/9e05b4c9f0537d681dcb240eab41822f15bef613/lib/middleware/completion/index.js#L50-L55
49,305
jeremyruppel/hoagie
lib/middleware/completion/index.js
install
function install(req, res /*, next */) { res.writeln('Add the following to your profile:'); res.writeln('eval "$(%s --completion)"', req.program); res.end(); }
javascript
function install(req, res /*, next */) { res.writeln('Add the following to your profile:'); res.writeln('eval "$(%s --completion)"', req.program); res.end(); }
[ "function", "install", "(", "req", ",", "res", "/*, next */", ")", "{", "res", ".", "writeln", "(", "'Add the following to your profile:'", ")", ";", "res", ".", "writeln", "(", "'eval \"$(%s --completion)\"'", ",", "req", ".", "program", ")", ";", "res", ".", "end", "(", ")", ";", "}" ]
Prints install instructions for the completion script.
[ "Prints", "install", "instructions", "for", "the", "completion", "script", "." ]
9e05b4c9f0537d681dcb240eab41822f15bef613
https://github.com/jeremyruppel/hoagie/blob/9e05b4c9f0537d681dcb240eab41822f15bef613/lib/middleware/completion/index.js#L61-L65
49,306
jeremyruppel/hoagie
lib/middleware/completion/index.js
script
function script(req, res, next) { switch (req.get('SHELL')) { case '/bin/sh': case '/bin/bash': res.render(__dirname + '/init.bash'); break; default: next(new Error('Unsupported shell: ' + req.get('SHELL'))); } }
javascript
function script(req, res, next) { switch (req.get('SHELL')) { case '/bin/sh': case '/bin/bash': res.render(__dirname + '/init.bash'); break; default: next(new Error('Unsupported shell: ' + req.get('SHELL'))); } }
[ "function", "script", "(", "req", ",", "res", ",", "next", ")", "{", "switch", "(", "req", ".", "get", "(", "'SHELL'", ")", ")", "{", "case", "'/bin/sh'", ":", "case", "'/bin/bash'", ":", "res", ".", "render", "(", "__dirname", "+", "'/init.bash'", ")", ";", "break", ";", "default", ":", "next", "(", "new", "Error", "(", "'Unsupported shell: '", "+", "req", ".", "get", "(", "'SHELL'", ")", ")", ")", ";", "}", "}" ]
Prints the completion init script for the user's shell.
[ "Prints", "the", "completion", "init", "script", "for", "the", "user", "s", "shell", "." ]
9e05b4c9f0537d681dcb240eab41822f15bef613
https://github.com/jeremyruppel/hoagie/blob/9e05b4c9f0537d681dcb240eab41822f15bef613/lib/middleware/completion/index.js#L71-L80
49,307
leeola/tork
lib/middleware/history.js
function () { var middlewares = Array.prototype.slice.apply(arguments) , req = middlewares.splice(0, 1) , next = middlewares.pop() // Check other middlewares for client objects. If we find one, merge // it and ours together. for (var i = 0; i < middlewares.length; i++) { var middleware_obj = middlewares[i] if (middleware_obj.type == 'client') { utils.merge(middlewares[i], hist_obj) return undefined } } // If we get this far, no other middlewares match client type. So pass // our middleware object. next({'history': hist_obj}) return undefined }
javascript
function () { var middlewares = Array.prototype.slice.apply(arguments) , req = middlewares.splice(0, 1) , next = middlewares.pop() // Check other middlewares for client objects. If we find one, merge // it and ours together. for (var i = 0; i < middlewares.length; i++) { var middleware_obj = middlewares[i] if (middleware_obj.type == 'client') { utils.merge(middlewares[i], hist_obj) return undefined } } // If we get this far, no other middlewares match client type. So pass // our middleware object. next({'history': hist_obj}) return undefined }
[ "function", "(", ")", "{", "var", "middlewares", "=", "Array", ".", "prototype", ".", "slice", ".", "apply", "(", "arguments", ")", ",", "req", "=", "middlewares", ".", "splice", "(", "0", ",", "1", ")", ",", "next", "=", "middlewares", ".", "pop", "(", ")", "// Check other middlewares for client objects. If we find one, merge\r", "// it and ours together.\r", "for", "(", "var", "i", "=", "0", ";", "i", "<", "middlewares", ".", "length", ";", "i", "++", ")", "{", "var", "middleware_obj", "=", "middlewares", "[", "i", "]", "if", "(", "middleware_obj", ".", "type", "==", "'client'", ")", "{", "utils", ".", "merge", "(", "middlewares", "[", "i", "]", ",", "hist_obj", ")", "return", "undefined", "}", "}", "// If we get this far, no other middlewares match client type. So pass\r", "// our middleware object.\r", "next", "(", "{", "'history'", ":", "hist_obj", "}", ")", "return", "undefined", "}" ]
Our middleware function
[ "Our", "middleware", "function" ]
d29edabb97ac49ac4cdbcce091647d4faa75989c
https://github.com/leeola/tork/blob/d29edabb97ac49ac4cdbcce091647d4faa75989c/lib/middleware/history.js#L41-L60
49,308
dalekjs/dalek-driver-sauce
lib/commands/frame.js
function (selector, hash) { if (selector !== null) { this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector)); } this.actionQueue.push(this.webdriverClient.frame.bind(this.webdriverClient)); this.actionQueue.push(this._frameCb.bind(this, selector, hash)); return this; }
javascript
function (selector, hash) { if (selector !== null) { this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector)); } this.actionQueue.push(this.webdriverClient.frame.bind(this.webdriverClient)); this.actionQueue.push(this._frameCb.bind(this, selector, hash)); return this; }
[ "function", "(", "selector", ",", "hash", ")", "{", "if", "(", "selector", "!==", "null", ")", "{", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "webdriverClient", ".", "element", ".", "bind", "(", "this", ".", "webdriverClient", ",", "selector", ")", ")", ";", "}", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "webdriverClient", ".", "frame", ".", "bind", "(", "this", ".", "webdriverClient", ")", ")", ";", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "_frameCb", ".", "bind", "(", "this", ",", "selector", ",", "hash", ")", ")", ";", "return", "this", ";", "}" ]
Switches to frame context @method toFrame @param {string} selector Selector expression to find the element @param {string} hash Unique hash of that fn call @chainable
[ "Switches", "to", "frame", "context" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/frame.js#L49-L56
49,309
Nazariglez/perenquen
lib/pixi/src/filters/sepia/SepiaFilter.js
SepiaFilter
function SepiaFilter() { core.AbstractFilter.call(this, // vertex shader null, // fragment shader fs.readFileSync(__dirname + '/sepia.frag', 'utf8'), // custom uniforms { sepia: { type: '1f', value: 1 } } ); }
javascript
function SepiaFilter() { core.AbstractFilter.call(this, // vertex shader null, // fragment shader fs.readFileSync(__dirname + '/sepia.frag', 'utf8'), // custom uniforms { sepia: { type: '1f', value: 1 } } ); }
[ "function", "SepiaFilter", "(", ")", "{", "core", ".", "AbstractFilter", ".", "call", "(", "this", ",", "// vertex shader", "null", ",", "// fragment shader", "fs", ".", "readFileSync", "(", "__dirname", "+", "'/sepia.frag'", ",", "'utf8'", ")", ",", "// custom uniforms", "{", "sepia", ":", "{", "type", ":", "'1f'", ",", "value", ":", "1", "}", "}", ")", ";", "}" ]
This applies a sepia effect to your Display Objects. @class @extends AbstractFilter @memberof PIXI.filters
[ "This", "applies", "a", "sepia", "effect", "to", "your", "Display", "Objects", "." ]
e023964d05afeefebdcac4e2044819fdfa3899ae
https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/sepia/SepiaFilter.js#L12-L24
49,310
b-heilman/bmoor
src/array.js
remove
function remove( arr, searchElement, fromIndex ){ var pos = arr.indexOf( searchElement, fromIndex ); if ( pos > -1 ){ return arr.splice( pos, 1 )[0]; } }
javascript
function remove( arr, searchElement, fromIndex ){ var pos = arr.indexOf( searchElement, fromIndex ); if ( pos > -1 ){ return arr.splice( pos, 1 )[0]; } }
[ "function", "remove", "(", "arr", ",", "searchElement", ",", "fromIndex", ")", "{", "var", "pos", "=", "arr", ".", "indexOf", "(", "searchElement", ",", "fromIndex", ")", ";", "if", "(", "pos", ">", "-", "1", ")", "{", "return", "arr", ".", "splice", "(", "pos", ",", "1", ")", "[", "0", "]", ";", "}", "}" ]
Search an array for an element and remove it, starting at the begining or a specified location @function remove @param {array} arr An array to be searched @param {*} searchElement Content for which to be searched @param {integer} fromIndex The begining index from which to begin the search, defaults to 0 @return {array} array containing removed element
[ "Search", "an", "array", "for", "an", "element", "and", "remove", "it", "starting", "at", "the", "begining", "or", "a", "specified", "location" ]
b21a315b477093c14e5f32d857b4644a5a0a36fd
https://github.com/b-heilman/bmoor/blob/b21a315b477093c14e5f32d857b4644a5a0a36fd/src/array.js#L17-L23
49,311
b-heilman/bmoor
src/array.js
removeAll
function removeAll( arr, searchElement, fromIndex ){ var r, pos = arr.indexOf( searchElement, fromIndex ); if ( pos > -1 ){ r = removeAll( arr, searchElement, pos+1 ); r.unshift( arr.splice(pos,1)[0] ); return r; } else { return []; } }
javascript
function removeAll( arr, searchElement, fromIndex ){ var r, pos = arr.indexOf( searchElement, fromIndex ); if ( pos > -1 ){ r = removeAll( arr, searchElement, pos+1 ); r.unshift( arr.splice(pos,1)[0] ); return r; } else { return []; } }
[ "function", "removeAll", "(", "arr", ",", "searchElement", ",", "fromIndex", ")", "{", "var", "r", ",", "pos", "=", "arr", ".", "indexOf", "(", "searchElement", ",", "fromIndex", ")", ";", "if", "(", "pos", ">", "-", "1", ")", "{", "r", "=", "removeAll", "(", "arr", ",", "searchElement", ",", "pos", "+", "1", ")", ";", "r", ".", "unshift", "(", "arr", ".", "splice", "(", "pos", ",", "1", ")", "[", "0", "]", ")", ";", "return", "r", ";", "}", "else", "{", "return", "[", "]", ";", "}", "}" ]
Search an array for an element and remove all instances of it, starting at the begining or a specified location @function remove @param {array} arr An array to be searched @param {*} searchElement Content for which to be searched @param {integer} fromIndex The begining index from which to begin the search, defaults to 0 @return {integer} number of elements removed
[ "Search", "an", "array", "for", "an", "element", "and", "remove", "all", "instances", "of", "it", "starting", "at", "the", "begining", "or", "a", "specified", "location" ]
b21a315b477093c14e5f32d857b4644a5a0a36fd
https://github.com/b-heilman/bmoor/blob/b21a315b477093c14e5f32d857b4644a5a0a36fd/src/array.js#L34-L46
49,312
b-heilman/bmoor
src/array.js
compare
function compare( arr1, arr2, func ){ var cmp, left = [], right = [], leftI = [], rightI = []; arr1 = arr1.slice(0); arr2 = arr2.slice(0); arr1.sort( func ); arr2.sort( func ); while( arr1.length > 0 && arr2.length > 0 ){ cmp = func( arr1[0], arr2[0] ); if ( cmp < 0 ){ left.push( arr1.shift() ); }else if ( cmp > 0 ){ right.push( arr2.shift() ); }else{ leftI.push( arr1.shift() ); rightI.push( arr2.shift() ); } } while( arr1.length ){ left.push( arr1.shift() ); } while( arr2.length ){ right.push( arr2.shift() ); } return { left : left, intersection : { left : leftI, right : rightI }, right : right }; }
javascript
function compare( arr1, arr2, func ){ var cmp, left = [], right = [], leftI = [], rightI = []; arr1 = arr1.slice(0); arr2 = arr2.slice(0); arr1.sort( func ); arr2.sort( func ); while( arr1.length > 0 && arr2.length > 0 ){ cmp = func( arr1[0], arr2[0] ); if ( cmp < 0 ){ left.push( arr1.shift() ); }else if ( cmp > 0 ){ right.push( arr2.shift() ); }else{ leftI.push( arr1.shift() ); rightI.push( arr2.shift() ); } } while( arr1.length ){ left.push( arr1.shift() ); } while( arr2.length ){ right.push( arr2.shift() ); } return { left : left, intersection : { left : leftI, right : rightI }, right : right }; }
[ "function", "compare", "(", "arr1", ",", "arr2", ",", "func", ")", "{", "var", "cmp", ",", "left", "=", "[", "]", ",", "right", "=", "[", "]", ",", "leftI", "=", "[", "]", ",", "rightI", "=", "[", "]", ";", "arr1", "=", "arr1", ".", "slice", "(", "0", ")", ";", "arr2", "=", "arr2", ".", "slice", "(", "0", ")", ";", "arr1", ".", "sort", "(", "func", ")", ";", "arr2", ".", "sort", "(", "func", ")", ";", "while", "(", "arr1", ".", "length", ">", "0", "&&", "arr2", ".", "length", ">", "0", ")", "{", "cmp", "=", "func", "(", "arr1", "[", "0", "]", ",", "arr2", "[", "0", "]", ")", ";", "if", "(", "cmp", "<", "0", ")", "{", "left", ".", "push", "(", "arr1", ".", "shift", "(", ")", ")", ";", "}", "else", "if", "(", "cmp", ">", "0", ")", "{", "right", ".", "push", "(", "arr2", ".", "shift", "(", ")", ")", ";", "}", "else", "{", "leftI", ".", "push", "(", "arr1", ".", "shift", "(", ")", ")", ";", "rightI", ".", "push", "(", "arr2", ".", "shift", "(", ")", ")", ";", "}", "}", "while", "(", "arr1", ".", "length", ")", "{", "left", ".", "push", "(", "arr1", ".", "shift", "(", ")", ")", ";", "}", "while", "(", "arr2", ".", "length", ")", "{", "right", ".", "push", "(", "arr2", ".", "shift", "(", ")", ")", ";", "}", "return", "{", "left", ":", "left", ",", "intersection", ":", "{", "left", ":", "leftI", ",", "right", ":", "rightI", "}", ",", "right", ":", "right", "}", ";", "}" ]
Compare two arrays. @function remove @param {array} arr1 An array to be compared @param {array} arr2 An array to be compared @param {function} func The comparison function @return {object} an object containing the elements unique to the left, matched, and unqiue to the right
[ "Compare", "two", "arrays", "." ]
b21a315b477093c14e5f32d857b4644a5a0a36fd
https://github.com/b-heilman/bmoor/blob/b21a315b477093c14e5f32d857b4644a5a0a36fd/src/array.js#L118-L160
49,313
b-heilman/bmoor
src/array.js
unique
function unique( arr, sort, uniqueFn ){ var rtn = []; if ( arr.length ){ if ( sort ){ // more efficient because I can presort if ( bmoor.isFunction(sort) ){ arr = arr.slice(0).sort(sort); } let last; for( let i = 0, c = arr.length; i < c; i++ ){ let d = arr[i], v = uniqueFn ? uniqueFn(d) : d; if ( v !== last ){ last = v; rtn.push( d ); } } }else if ( uniqueFn ){ let hash = {}; for( let i = 0, c = arr.length; i < c; i++ ){ let d = arr[i], v = uniqueFn(d); if ( !hash[v] ){ hash[v] = true; rtn.push( d ); } } }else{ // greedy and inefficient for( let i = 0, c = arr.length; i < c; i++ ){ let d = arr[i]; if ( rtn.indexOf(d) === -1 ){ rtn.push( d ); } } } } return rtn; }
javascript
function unique( arr, sort, uniqueFn ){ var rtn = []; if ( arr.length ){ if ( sort ){ // more efficient because I can presort if ( bmoor.isFunction(sort) ){ arr = arr.slice(0).sort(sort); } let last; for( let i = 0, c = arr.length; i < c; i++ ){ let d = arr[i], v = uniqueFn ? uniqueFn(d) : d; if ( v !== last ){ last = v; rtn.push( d ); } } }else if ( uniqueFn ){ let hash = {}; for( let i = 0, c = arr.length; i < c; i++ ){ let d = arr[i], v = uniqueFn(d); if ( !hash[v] ){ hash[v] = true; rtn.push( d ); } } }else{ // greedy and inefficient for( let i = 0, c = arr.length; i < c; i++ ){ let d = arr[i]; if ( rtn.indexOf(d) === -1 ){ rtn.push( d ); } } } } return rtn; }
[ "function", "unique", "(", "arr", ",", "sort", ",", "uniqueFn", ")", "{", "var", "rtn", "=", "[", "]", ";", "if", "(", "arr", ".", "length", ")", "{", "if", "(", "sort", ")", "{", "// more efficient because I can presort", "if", "(", "bmoor", ".", "isFunction", "(", "sort", ")", ")", "{", "arr", "=", "arr", ".", "slice", "(", "0", ")", ".", "sort", "(", "sort", ")", ";", "}", "let", "last", ";", "for", "(", "let", "i", "=", "0", ",", "c", "=", "arr", ".", "length", ";", "i", "<", "c", ";", "i", "++", ")", "{", "let", "d", "=", "arr", "[", "i", "]", ",", "v", "=", "uniqueFn", "?", "uniqueFn", "(", "d", ")", ":", "d", ";", "if", "(", "v", "!==", "last", ")", "{", "last", "=", "v", ";", "rtn", ".", "push", "(", "d", ")", ";", "}", "}", "}", "else", "if", "(", "uniqueFn", ")", "{", "let", "hash", "=", "{", "}", ";", "for", "(", "let", "i", "=", "0", ",", "c", "=", "arr", ".", "length", ";", "i", "<", "c", ";", "i", "++", ")", "{", "let", "d", "=", "arr", "[", "i", "]", ",", "v", "=", "uniqueFn", "(", "d", ")", ";", "if", "(", "!", "hash", "[", "v", "]", ")", "{", "hash", "[", "v", "]", "=", "true", ";", "rtn", ".", "push", "(", "d", ")", ";", "}", "}", "}", "else", "{", "// greedy and inefficient", "for", "(", "let", "i", "=", "0", ",", "c", "=", "arr", ".", "length", ";", "i", "<", "c", ";", "i", "++", ")", "{", "let", "d", "=", "arr", "[", "i", "]", ";", "if", "(", "rtn", ".", "indexOf", "(", "d", ")", "===", "-", "1", ")", "{", "rtn", ".", "push", "(", "d", ")", ";", "}", "}", "}", "}", "return", "rtn", ";", "}" ]
Create a new array that is completely unique @function unique @param {array} arr The array to be made unique @param {function|boolean} sort If boolean === true, array is presorted. If function, use to sort
[ "Create", "a", "new", "array", "that", "is", "completely", "unique" ]
b21a315b477093c14e5f32d857b4644a5a0a36fd
https://github.com/b-heilman/bmoor/blob/b21a315b477093c14e5f32d857b4644a5a0a36fd/src/array.js#L169-L215
49,314
b-heilman/bmoor
src/array.js
intersection
function intersection( arr1, arr2 ){ var rtn = []; if ( arr1.length > arr2.length ){ let t = arr1; arr1 = arr2; arr2 = t; } for( let i = 0, c = arr1.length; i < c; i++ ){ let d = arr1[i]; if ( arr2.indexOf(d) !== -1 ){ rtn.push( d ); } } return rtn; }
javascript
function intersection( arr1, arr2 ){ var rtn = []; if ( arr1.length > arr2.length ){ let t = arr1; arr1 = arr2; arr2 = t; } for( let i = 0, c = arr1.length; i < c; i++ ){ let d = arr1[i]; if ( arr2.indexOf(d) !== -1 ){ rtn.push( d ); } } return rtn; }
[ "function", "intersection", "(", "arr1", ",", "arr2", ")", "{", "var", "rtn", "=", "[", "]", ";", "if", "(", "arr1", ".", "length", ">", "arr2", ".", "length", ")", "{", "let", "t", "=", "arr1", ";", "arr1", "=", "arr2", ";", "arr2", "=", "t", ";", "}", "for", "(", "let", "i", "=", "0", ",", "c", "=", "arr1", ".", "length", ";", "i", "<", "c", ";", "i", "++", ")", "{", "let", "d", "=", "arr1", "[", "i", "]", ";", "if", "(", "arr2", ".", "indexOf", "(", "d", ")", "!==", "-", "1", ")", "{", "rtn", ".", "push", "(", "d", ")", ";", "}", "}", "return", "rtn", ";", "}" ]
I could probably make this sexier, like allow uniqueness algorithm, but I'm keeping it simple for now
[ "I", "could", "probably", "make", "this", "sexier", "like", "allow", "uniqueness", "algorithm", "but", "I", "m", "keeping", "it", "simple", "for", "now" ]
b21a315b477093c14e5f32d857b4644a5a0a36fd
https://github.com/b-heilman/bmoor/blob/b21a315b477093c14e5f32d857b4644a5a0a36fd/src/array.js#L218-L237
49,315
vibe-project/vibe-protocol
lib/socket.js
open
function open() { // If there is no remaining URI, fires `error` and `close` event as // it means that all connection failed. if (uris.length === 0) { self.emit("error", new Error()); self.emit("close"); return; } // Removes the first element and returns it. For example, // `[1,2].shift()` returns `1` and make the array `[2]`. var uri = uris.shift(); // Because transport can handle only the specific URI, URI // determines transport. It finds which transport can handle this // `uri` among transports specified by `transports` option. for (var i = 0; i < options.transports.length; i++) { // Each transport factory checks if the given URI can be handled // and creates and returns transport object if so and returns // nothing if not. trans = options.transports[i](uri, options); // If factory creates a transport, if (trans) { // it establishes a connection. trans.open(); // If it fails, it tries with next URI or other transport. trans.on("close", open); // If it succeeds, a process to find working transport is // terminated. At the socket level, the first message is // used to handshake the protocol. `once` registers one-time // event handler. trans.once("text", function(text) { // The handshake output is in the form of URI and uses // query part to get/set header. var result = url.parse(text, true).query; // To maintain alive connection, heartbeat is used. options.heartbeat = +result.heartbeat; // `_heartbeat` is usually for testing so it may be not // passed from the server. The default value is `5000`. options._heartbeat = +result._heartbeat || 5000; // Now that the working transport is found and // handshaking is completed, removes `close` // event's `open` handler which is used to find working // transport, trans.removeListener("close", open); // initializes the transport init(trans); // and fires `open` event which is the first event user // can handle socket. self.emit("open"); }); break; } } }
javascript
function open() { // If there is no remaining URI, fires `error` and `close` event as // it means that all connection failed. if (uris.length === 0) { self.emit("error", new Error()); self.emit("close"); return; } // Removes the first element and returns it. For example, // `[1,2].shift()` returns `1` and make the array `[2]`. var uri = uris.shift(); // Because transport can handle only the specific URI, URI // determines transport. It finds which transport can handle this // `uri` among transports specified by `transports` option. for (var i = 0; i < options.transports.length; i++) { // Each transport factory checks if the given URI can be handled // and creates and returns transport object if so and returns // nothing if not. trans = options.transports[i](uri, options); // If factory creates a transport, if (trans) { // it establishes a connection. trans.open(); // If it fails, it tries with next URI or other transport. trans.on("close", open); // If it succeeds, a process to find working transport is // terminated. At the socket level, the first message is // used to handshake the protocol. `once` registers one-time // event handler. trans.once("text", function(text) { // The handshake output is in the form of URI and uses // query part to get/set header. var result = url.parse(text, true).query; // To maintain alive connection, heartbeat is used. options.heartbeat = +result.heartbeat; // `_heartbeat` is usually for testing so it may be not // passed from the server. The default value is `5000`. options._heartbeat = +result._heartbeat || 5000; // Now that the working transport is found and // handshaking is completed, removes `close` // event's `open` handler which is used to find working // transport, trans.removeListener("close", open); // initializes the transport init(trans); // and fires `open` event which is the first event user // can handle socket. self.emit("open"); }); break; } } }
[ "function", "open", "(", ")", "{", "// If there is no remaining URI, fires `error` and `close` event as", "// it means that all connection failed.", "if", "(", "uris", ".", "length", "===", "0", ")", "{", "self", ".", "emit", "(", "\"error\"", ",", "new", "Error", "(", ")", ")", ";", "self", ".", "emit", "(", "\"close\"", ")", ";", "return", ";", "}", "// Removes the first element and returns it. For example,", "// `[1,2].shift()` returns `1` and make the array `[2]`.", "var", "uri", "=", "uris", ".", "shift", "(", ")", ";", "// Because transport can handle only the specific URI, URI", "// determines transport. It finds which transport can handle this", "// `uri` among transports specified by `transports` option.", "for", "(", "var", "i", "=", "0", ";", "i", "<", "options", ".", "transports", ".", "length", ";", "i", "++", ")", "{", "// Each transport factory checks if the given URI can be handled", "// and creates and returns transport object if so and returns", "// nothing if not.", "trans", "=", "options", ".", "transports", "[", "i", "]", "(", "uri", ",", "options", ")", ";", "// If factory creates a transport,", "if", "(", "trans", ")", "{", "// it establishes a connection.", "trans", ".", "open", "(", ")", ";", "// If it fails, it tries with next URI or other transport.", "trans", ".", "on", "(", "\"close\"", ",", "open", ")", ";", "// If it succeeds, a process to find working transport is", "// terminated. At the socket level, the first message is", "// used to handshake the protocol. `once` registers one-time", "// event handler.", "trans", ".", "once", "(", "\"text\"", ",", "function", "(", "text", ")", "{", "// The handshake output is in the form of URI and uses", "// query part to get/set header.", "var", "result", "=", "url", ".", "parse", "(", "text", ",", "true", ")", ".", "query", ";", "// To maintain alive connection, heartbeat is used.", "options", ".", "heartbeat", "=", "+", "result", ".", "heartbeat", ";", "// `_heartbeat` is usually for testing so it may be not", "// passed from the server. The default value is `5000`.", "options", ".", "_heartbeat", "=", "+", "result", ".", "_heartbeat", "||", "5000", ";", "// Now that the working transport is found and", "// handshaking is completed, removes `close`", "// event's `open` handler which is used to find working", "// transport,", "trans", ".", "removeListener", "(", "\"close\"", ",", "open", ")", ";", "// initializes the transport", "init", "(", "trans", ")", ";", "// and fires `open` event which is the first event user", "// can handle socket.", "self", ".", "emit", "(", "\"open\"", ")", ";", "}", ")", ";", "break", ";", "}", "}", "}" ]
Tries connection with next URI.
[ "Tries", "connection", "with", "next", "URI", "." ]
4a350acade3760ea13e75d7b9ce0815cf8b1d688
https://github.com/vibe-project/vibe-protocol/blob/4a350acade3760ea13e75d7b9ce0815cf8b1d688/lib/socket.js#L65-L117
49,316
vibe-project/vibe-protocol
lib/socket.js
init
function init(trans) { // Assign `trans` to `transport` which is associated with the // socket. transport = trans; // When the transport has received a message from the server. transport.on("text", function(text) { // Converts JSON text to an event object. // // It should have the following properties: // * `id: string`: an event identifier. // * `type: string`: an event type. // * `data: any`: an event data. // * `reply: boolean`: true if this event requires the reply. var event = JSON.parse(text); // If the server sends a plain event, dispatch it. if (!event.reply) { self.emit(event.type, event.data); } else { var latch; // A function to create a function. function reply(success) { // A controller function. return function(value) { // The latch prevents double reply. if (!latch) { latch = true; self.send("reply", {id: event.id, data: value, exception: !success}); } }; } // Here, the controller is passed to the handler as 2nd // argument and calls the server's `resolved` or `rejected` // callback by sending `reply` event. self.emit(event.type, event.data, {resolve: reply(true), reject: reply(false)}); } }); // When any error has occurred. transport.on("error", function(error) { self.emit("error", error); }); // When the transport has been closed for any reason. transport.on("close", function() { self.emit("close"); }); }
javascript
function init(trans) { // Assign `trans` to `transport` which is associated with the // socket. transport = trans; // When the transport has received a message from the server. transport.on("text", function(text) { // Converts JSON text to an event object. // // It should have the following properties: // * `id: string`: an event identifier. // * `type: string`: an event type. // * `data: any`: an event data. // * `reply: boolean`: true if this event requires the reply. var event = JSON.parse(text); // If the server sends a plain event, dispatch it. if (!event.reply) { self.emit(event.type, event.data); } else { var latch; // A function to create a function. function reply(success) { // A controller function. return function(value) { // The latch prevents double reply. if (!latch) { latch = true; self.send("reply", {id: event.id, data: value, exception: !success}); } }; } // Here, the controller is passed to the handler as 2nd // argument and calls the server's `resolved` or `rejected` // callback by sending `reply` event. self.emit(event.type, event.data, {resolve: reply(true), reject: reply(false)}); } }); // When any error has occurred. transport.on("error", function(error) { self.emit("error", error); }); // When the transport has been closed for any reason. transport.on("close", function() { self.emit("close"); }); }
[ "function", "init", "(", "trans", ")", "{", "// Assign `trans` to `transport` which is associated with the", "// socket.", "transport", "=", "trans", ";", "// When the transport has received a message from the server.", "transport", ".", "on", "(", "\"text\"", ",", "function", "(", "text", ")", "{", "// Converts JSON text to an event object.", "// ", "// It should have the following properties:", "// * `id: string`: an event identifier.", "// * `type: string`: an event type.", "// * `data: any`: an event data.", "// * `reply: boolean`: true if this event requires the reply.", "var", "event", "=", "JSON", ".", "parse", "(", "text", ")", ";", "// If the server sends a plain event, dispatch it.", "if", "(", "!", "event", ".", "reply", ")", "{", "self", ".", "emit", "(", "event", ".", "type", ",", "event", ".", "data", ")", ";", "}", "else", "{", "var", "latch", ";", "// A function to create a function.", "function", "reply", "(", "success", ")", "{", "// A controller function.", "return", "function", "(", "value", ")", "{", "// The latch prevents double reply.", "if", "(", "!", "latch", ")", "{", "latch", "=", "true", ";", "self", ".", "send", "(", "\"reply\"", ",", "{", "id", ":", "event", ".", "id", ",", "data", ":", "value", ",", "exception", ":", "!", "success", "}", ")", ";", "}", "}", ";", "}", "// Here, the controller is passed to the handler as 2nd", "// argument and calls the server's `resolved` or `rejected`", "// callback by sending `reply` event.", "self", ".", "emit", "(", "event", ".", "type", ",", "event", ".", "data", ",", "{", "resolve", ":", "reply", "(", "true", ")", ",", "reject", ":", "reply", "(", "false", ")", "}", ")", ";", "}", "}", ")", ";", "// When any error has occurred.", "transport", ".", "on", "(", "\"error\"", ",", "function", "(", "error", ")", "{", "self", ".", "emit", "(", "\"error\"", ",", "error", ")", ";", "}", ")", ";", "// When the transport has been closed for any reason.", "transport", ".", "on", "(", "\"close\"", ",", "function", "(", ")", "{", "self", ".", "emit", "(", "\"close\"", ")", ";", "}", ")", ";", "}" ]
Now that working transport is determined, associates it with the socket.
[ "Now", "that", "working", "transport", "is", "determined", "associates", "it", "with", "the", "socket", "." ]
4a350acade3760ea13e75d7b9ce0815cf8b1d688
https://github.com/vibe-project/vibe-protocol/blob/4a350acade3760ea13e75d7b9ce0815cf8b1d688/lib/socket.js#L132-L176
49,317
antoniobrandao/mongoose3-bsonfix-bson
lib/bson/db_ref.js
DBRef
function DBRef(namespace, oid, db) { if(!(this instanceof DBRef)) return new DBRef(namespace, oid, db); this._bsontype = 'DBRef'; this.namespace = namespace; this.oid = oid; this.db = db; }
javascript
function DBRef(namespace, oid, db) { if(!(this instanceof DBRef)) return new DBRef(namespace, oid, db); this._bsontype = 'DBRef'; this.namespace = namespace; this.oid = oid; this.db = db; }
[ "function", "DBRef", "(", "namespace", ",", "oid", ",", "db", ")", "{", "if", "(", "!", "(", "this", "instanceof", "DBRef", ")", ")", "return", "new", "DBRef", "(", "namespace", ",", "oid", ",", "db", ")", ";", "this", ".", "_bsontype", "=", "'DBRef'", ";", "this", ".", "namespace", "=", "namespace", ";", "this", ".", "oid", "=", "oid", ";", "this", ".", "db", "=", "db", ";", "}" ]
A class representation of the BSON DBRef type. @class @param {string} namespace the collection name. @param {ObjectID} oid the reference ObjectID. @param {string} [db] optional db name, if omitted the reference is local to the current db. @return {DBRef}
[ "A", "class", "representation", "of", "the", "BSON", "DBRef", "type", "." ]
b0eae261710704de70f6f282669cf020dbd6a490
https://github.com/antoniobrandao/mongoose3-bsonfix-bson/blob/b0eae261710704de70f6f282669cf020dbd6a490/lib/bson/db_ref.js#L10-L17
49,318
dalekjs/dalek-driver-sauce
lib/browser.js
function (configuration, events, config) { var deferred = Q.defer(); // override desired capabilities, status & browser longname this.desiredCapabilities = this._generateDesiredCaps(configuration.name, config); this.driverDefaults.status = this._generateStatusInfo(this.desiredCapabilities); this.longName = this._generateLongName(configuration.name,config); // store injected configuration/log event handlers this.reporterEvents = events; this.configuration = configuration; this.config = config; // immediatly resolve the deferred deferred.resolve(); return deferred.promise; }
javascript
function (configuration, events, config) { var deferred = Q.defer(); // override desired capabilities, status & browser longname this.desiredCapabilities = this._generateDesiredCaps(configuration.name, config); this.driverDefaults.status = this._generateStatusInfo(this.desiredCapabilities); this.longName = this._generateLongName(configuration.name,config); // store injected configuration/log event handlers this.reporterEvents = events; this.configuration = configuration; this.config = config; // immediatly resolve the deferred deferred.resolve(); return deferred.promise; }
[ "function", "(", "configuration", ",", "events", ",", "config", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "// override desired capabilities, status & browser longname", "this", ".", "desiredCapabilities", "=", "this", ".", "_generateDesiredCaps", "(", "configuration", ".", "name", ",", "config", ")", ";", "this", ".", "driverDefaults", ".", "status", "=", "this", ".", "_generateStatusInfo", "(", "this", ".", "desiredCapabilities", ")", ";", "this", ".", "longName", "=", "this", ".", "_generateLongName", "(", "configuration", ".", "name", ",", "config", ")", ";", "// store injected configuration/log event handlers", "this", ".", "reporterEvents", "=", "events", ";", "this", ".", "configuration", "=", "configuration", ";", "this", ".", "config", "=", "config", ";", "// immediatly resolve the deferred", "deferred", ".", "resolve", "(", ")", ";", "return", "deferred", ".", "promise", ";", "}" ]
Stores & validates the incoming browser config @method launch @param {object} configuration Browser configuration @param {EventEmitter2} events EventEmitter (Reporter Emitter instance) @param {Dalek.Internal.Config} config Dalek configuration class @return {object} Browser promise
[ "Stores", "&", "validates", "the", "incoming", "browser", "config" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/browser.js#L182-L198
49,319
dalekjs/dalek-driver-sauce
lib/browser.js
function (browserName, config) { var browsers = config.get('browsers'); // check if we couldnt find a configured alias, // set to defaults otherwise if (!browsers) { return {actAs: this.desiredCapabilities.browserName, version: this.desiredCapabilities['browser-version']}; } var browser = config.get('browsers')[0][browserName] || null; // check if we couldnt find a configured alias, // check and apply if there is a default config if (!browser && this.browsers[browserName]) { browser = this.browsers[browserName]; } // check if the actas property has been set, if not // use the given browser name if (!browser.actAs) { browser.actAs = browserName; } return browser; }
javascript
function (browserName, config) { var browsers = config.get('browsers'); // check if we couldnt find a configured alias, // set to defaults otherwise if (!browsers) { return {actAs: this.desiredCapabilities.browserName, version: this.desiredCapabilities['browser-version']}; } var browser = config.get('browsers')[0][browserName] || null; // check if we couldnt find a configured alias, // check and apply if there is a default config if (!browser && this.browsers[browserName]) { browser = this.browsers[browserName]; } // check if the actas property has been set, if not // use the given browser name if (!browser.actAs) { browser.actAs = browserName; } return browser; }
[ "function", "(", "browserName", ",", "config", ")", "{", "var", "browsers", "=", "config", ".", "get", "(", "'browsers'", ")", ";", "// check if we couldnt find a configured alias,", "// set to defaults otherwise", "if", "(", "!", "browsers", ")", "{", "return", "{", "actAs", ":", "this", ".", "desiredCapabilities", ".", "browserName", ",", "version", ":", "this", ".", "desiredCapabilities", "[", "'browser-version'", "]", "}", ";", "}", "var", "browser", "=", "config", ".", "get", "(", "'browsers'", ")", "[", "0", "]", "[", "browserName", "]", "||", "null", ";", "// check if we couldnt find a configured alias,", "// check and apply if there is a default config", "if", "(", "!", "browser", "&&", "this", ".", "browsers", "[", "browserName", "]", ")", "{", "browser", "=", "this", ".", "browsers", "[", "browserName", "]", ";", "}", "// check if the actas property has been set, if not", "// use the given browser name", "if", "(", "!", "browser", ".", "actAs", ")", "{", "browser", ".", "actAs", "=", "browserName", ";", "}", "return", "browser", ";", "}" ]
Verifies the browser config @method _verfiyBrowserConfig @param {string} browserName Name of the browser to verify @param {object} config Daleks internal config helper @return {object} Browser config @private
[ "Verifies", "the", "browser", "config" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/browser.js#L263-L285
49,320
dalekjs/dalek-driver-sauce
lib/browser.js
function (browser) { var isValid = this.platforms.reduce(function (previousValue, platform) { if (previousValue === browser.platform || platform === browser.platform) { return browser.platform; } }); return isValid || this.desiredCapabilities.platform; }
javascript
function (browser) { var isValid = this.platforms.reduce(function (previousValue, platform) { if (previousValue === browser.platform || platform === browser.platform) { return browser.platform; } }); return isValid || this.desiredCapabilities.platform; }
[ "function", "(", "browser", ")", "{", "var", "isValid", "=", "this", ".", "platforms", ".", "reduce", "(", "function", "(", "previousValue", ",", "platform", ")", "{", "if", "(", "previousValue", "===", "browser", ".", "platform", "||", "platform", "===", "browser", ".", "platform", ")", "{", "return", "browser", ".", "platform", ";", "}", "}", ")", ";", "return", "isValid", "||", "this", ".", "desiredCapabilities", ".", "platform", ";", "}" ]
Verfies the OS platform config @method _verfiyPlatformConfig @param {object} browser Browser information @return {string} Platform @private
[ "Verfies", "the", "OS", "platform", "config" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/browser.js#L296-L304
49,321
dalekjs/dalek-driver-sauce
lib/browser.js
function (browserName, config) { var browser = this._verfiyBrowserConfig(browserName, config); var platform = this._verfiyPlatformConfig(browser); var driverConfig = config.get('driver.sauce'); var desiredCaps = { browserName: browser.actAs, platform: platform, 'screen-resolution': (browser['screen-resolution'] || null), version: (browser.version || this.desiredCapabilities['browser-version']), name: driverConfig.name || this.desiredCapabilities.name }; // check if the user added tags if (driverConfig.tags) { desiredCaps.tags = driverConfig.tags; } // check if the user added a build id if (driverConfig.build) { desiredCaps.build = driverConfig.build; } return desiredCaps; }
javascript
function (browserName, config) { var browser = this._verfiyBrowserConfig(browserName, config); var platform = this._verfiyPlatformConfig(browser); var driverConfig = config.get('driver.sauce'); var desiredCaps = { browserName: browser.actAs, platform: platform, 'screen-resolution': (browser['screen-resolution'] || null), version: (browser.version || this.desiredCapabilities['browser-version']), name: driverConfig.name || this.desiredCapabilities.name }; // check if the user added tags if (driverConfig.tags) { desiredCaps.tags = driverConfig.tags; } // check if the user added a build id if (driverConfig.build) { desiredCaps.build = driverConfig.build; } return desiredCaps; }
[ "function", "(", "browserName", ",", "config", ")", "{", "var", "browser", "=", "this", ".", "_verfiyBrowserConfig", "(", "browserName", ",", "config", ")", ";", "var", "platform", "=", "this", ".", "_verfiyPlatformConfig", "(", "browser", ")", ";", "var", "driverConfig", "=", "config", ".", "get", "(", "'driver.sauce'", ")", ";", "var", "desiredCaps", "=", "{", "browserName", ":", "browser", ".", "actAs", ",", "platform", ":", "platform", ",", "'screen-resolution'", ":", "(", "browser", "[", "'screen-resolution'", "]", "||", "null", ")", ",", "version", ":", "(", "browser", ".", "version", "||", "this", ".", "desiredCapabilities", "[", "'browser-version'", "]", ")", ",", "name", ":", "driverConfig", ".", "name", "||", "this", ".", "desiredCapabilities", ".", "name", "}", ";", "// check if the user added tags", "if", "(", "driverConfig", ".", "tags", ")", "{", "desiredCaps", ".", "tags", "=", "driverConfig", ".", "tags", ";", "}", "// check if the user added a build id", "if", "(", "driverConfig", ".", "build", ")", "{", "desiredCaps", ".", "build", "=", "driverConfig", ".", "build", ";", "}", "return", "desiredCaps", ";", "}" ]
Generates the desired capabilities for this session @method _generateDesiredCaps @param {string} browserName The browser name @param {object} config Daleks internal config helper @return {object} The sessions desired capabilities @private
[ "Generates", "the", "desired", "capabilities", "for", "this", "session" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/browser.js#L316-L339
49,322
dalekjs/dalek-driver-sauce
lib/browser.js
function (browserName, config) { var longName = null; if(this.browsers.hasOwnProperty(browserName)){ longName = this.browsers[browserName].longName; } if(config.get('browsers')[0].hasOwnProperty(browserName)){ longName = config.get('browsers')[0][browserName].longName; } return longName; }
javascript
function (browserName, config) { var longName = null; if(this.browsers.hasOwnProperty(browserName)){ longName = this.browsers[browserName].longName; } if(config.get('browsers')[0].hasOwnProperty(browserName)){ longName = config.get('browsers')[0][browserName].longName; } return longName; }
[ "function", "(", "browserName", ",", "config", ")", "{", "var", "longName", "=", "null", ";", "if", "(", "this", ".", "browsers", ".", "hasOwnProperty", "(", "browserName", ")", ")", "{", "longName", "=", "this", ".", "browsers", "[", "browserName", "]", ".", "longName", ";", "}", "if", "(", "config", ".", "get", "(", "'browsers'", ")", "[", "0", "]", ".", "hasOwnProperty", "(", "browserName", ")", ")", "{", "longName", "=", "config", ".", "get", "(", "'browsers'", ")", "[", "0", "]", "[", "browserName", "]", ".", "longName", ";", "}", "return", "longName", ";", "}" ]
Generates the verbose name of the current remote browser in use @method _generateLongName @param {object} desiredCaps The sessions desired capabilities @return {string} Verbose browser name @private
[ "Generates", "the", "verbose", "name", "of", "the", "current", "remote", "browser", "in", "use" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/browser.js#L363-L372
49,323
tolokoban/ToloFrameWork
ker/mod/wdg.wysiwyg.js
onMenu
function onMenu( item ) { var squire = this.squire; var id = item.id; switch ( id ) { case 'undo': squire.undo(); break; case 'redo': squire.redo(); break; case 'eraser': squire.removeAllFormatting(); break; case 'link': makeLink.call( squire ); break; case 'image': this.insertImage(); break; case 'format-bold': if ( squire.hasFormat( 'b' ) ) { squire.removeBold(); } else { squire.bold(); } break; case 'format-italic': if ( squire.hasFormat( 'i' ) || squire.hasFormat( 'em' ) ) { squire.removeItalic(); } else { squire.italic(); } break; case 'format-underline': if ( squire.hasFormat( 'u' ) ) { squire.removeUnderline(); } else { squire.underline(); } break; case 'format-align-left': squire.setTextAlignment( 'left' ); break; case 'format-align-center': squire.setTextAlignment( 'center' ); break; case 'format-align-right': squire.setTextAlignment( 'right' ); break; case 'format-align-justify': squire.setTextAlignment( 'justify' ); break; case 'font': setFontFaceSizeColor.call( squire ); break; case 'format-float-left': setFloat.call( squire, 'left' ); break; case 'format-float-center': setFloat.call( squire, 'center' ); break; case 'format-float-right': setFloat.call( squire, 'right' ); break; case 'format-float-none': setFloat.call( squire, 'none' ); break; case 'format-header': setHeader.call( squire ); break; default: this.processButton( id ); } this.focus = true; }
javascript
function onMenu( item ) { var squire = this.squire; var id = item.id; switch ( id ) { case 'undo': squire.undo(); break; case 'redo': squire.redo(); break; case 'eraser': squire.removeAllFormatting(); break; case 'link': makeLink.call( squire ); break; case 'image': this.insertImage(); break; case 'format-bold': if ( squire.hasFormat( 'b' ) ) { squire.removeBold(); } else { squire.bold(); } break; case 'format-italic': if ( squire.hasFormat( 'i' ) || squire.hasFormat( 'em' ) ) { squire.removeItalic(); } else { squire.italic(); } break; case 'format-underline': if ( squire.hasFormat( 'u' ) ) { squire.removeUnderline(); } else { squire.underline(); } break; case 'format-align-left': squire.setTextAlignment( 'left' ); break; case 'format-align-center': squire.setTextAlignment( 'center' ); break; case 'format-align-right': squire.setTextAlignment( 'right' ); break; case 'format-align-justify': squire.setTextAlignment( 'justify' ); break; case 'font': setFontFaceSizeColor.call( squire ); break; case 'format-float-left': setFloat.call( squire, 'left' ); break; case 'format-float-center': setFloat.call( squire, 'center' ); break; case 'format-float-right': setFloat.call( squire, 'right' ); break; case 'format-float-none': setFloat.call( squire, 'none' ); break; case 'format-header': setHeader.call( squire ); break; default: this.processButton( id ); } this.focus = true; }
[ "function", "onMenu", "(", "item", ")", "{", "var", "squire", "=", "this", ".", "squire", ";", "var", "id", "=", "item", ".", "id", ";", "switch", "(", "id", ")", "{", "case", "'undo'", ":", "squire", ".", "undo", "(", ")", ";", "break", ";", "case", "'redo'", ":", "squire", ".", "redo", "(", ")", ";", "break", ";", "case", "'eraser'", ":", "squire", ".", "removeAllFormatting", "(", ")", ";", "break", ";", "case", "'link'", ":", "makeLink", ".", "call", "(", "squire", ")", ";", "break", ";", "case", "'image'", ":", "this", ".", "insertImage", "(", ")", ";", "break", ";", "case", "'format-bold'", ":", "if", "(", "squire", ".", "hasFormat", "(", "'b'", ")", ")", "{", "squire", ".", "removeBold", "(", ")", ";", "}", "else", "{", "squire", ".", "bold", "(", ")", ";", "}", "break", ";", "case", "'format-italic'", ":", "if", "(", "squire", ".", "hasFormat", "(", "'i'", ")", "||", "squire", ".", "hasFormat", "(", "'em'", ")", ")", "{", "squire", ".", "removeItalic", "(", ")", ";", "}", "else", "{", "squire", ".", "italic", "(", ")", ";", "}", "break", ";", "case", "'format-underline'", ":", "if", "(", "squire", ".", "hasFormat", "(", "'u'", ")", ")", "{", "squire", ".", "removeUnderline", "(", ")", ";", "}", "else", "{", "squire", ".", "underline", "(", ")", ";", "}", "break", ";", "case", "'format-align-left'", ":", "squire", ".", "setTextAlignment", "(", "'left'", ")", ";", "break", ";", "case", "'format-align-center'", ":", "squire", ".", "setTextAlignment", "(", "'center'", ")", ";", "break", ";", "case", "'format-align-right'", ":", "squire", ".", "setTextAlignment", "(", "'right'", ")", ";", "break", ";", "case", "'format-align-justify'", ":", "squire", ".", "setTextAlignment", "(", "'justify'", ")", ";", "break", ";", "case", "'font'", ":", "setFontFaceSizeColor", ".", "call", "(", "squire", ")", ";", "break", ";", "case", "'format-float-left'", ":", "setFloat", ".", "call", "(", "squire", ",", "'left'", ")", ";", "break", ";", "case", "'format-float-center'", ":", "setFloat", ".", "call", "(", "squire", ",", "'center'", ")", ";", "break", ";", "case", "'format-float-right'", ":", "setFloat", ".", "call", "(", "squire", ",", "'right'", ")", ";", "break", ";", "case", "'format-float-none'", ":", "setFloat", ".", "call", "(", "squire", ",", "'none'", ")", ";", "break", ";", "case", "'format-header'", ":", "setHeader", ".", "call", "(", "squire", ")", ";", "break", ";", "default", ":", "this", ".", "processButton", "(", "id", ")", ";", "}", "this", ".", "focus", "=", "true", ";", "}" ]
`this` is the squire object.
[ "this", "is", "the", "squire", "object", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.wysiwyg.js#L373-L448
49,324
weekeight/gulp-joycss
joycss/lib/csslib/cssReader.js
ruleEnd
function ruleEnd(e){ var selectors ; if (e.old === 'ruleStart'){ selectors = this.get('selectors'); //delete the last selector selectors.pop(); var lines = this.get('lines'); lines.pop(); this.attributes.nest.pop(); return; } else if (e.old === 'valueStart') { this._addValue(e); } ruleEnd.recode = ruleEnd.recode || 0; ruleEnd.recode++; this.attributes.nest.pop(); if (!this.attributes.nest.length){ var num = this.getLen() - ruleEnd.recode; ruleEnd.recode = 0; var idList = this.get('idList'); idList.push(num); this.fire(this.get('RULE_END_EVT'), this.getRule(num)); } }
javascript
function ruleEnd(e){ var selectors ; if (e.old === 'ruleStart'){ selectors = this.get('selectors'); //delete the last selector selectors.pop(); var lines = this.get('lines'); lines.pop(); this.attributes.nest.pop(); return; } else if (e.old === 'valueStart') { this._addValue(e); } ruleEnd.recode = ruleEnd.recode || 0; ruleEnd.recode++; this.attributes.nest.pop(); if (!this.attributes.nest.length){ var num = this.getLen() - ruleEnd.recode; ruleEnd.recode = 0; var idList = this.get('idList'); idList.push(num); this.fire(this.get('RULE_END_EVT'), this.getRule(num)); } }
[ "function", "ruleEnd", "(", "e", ")", "{", "var", "selectors", ";", "if", "(", "e", ".", "old", "===", "'ruleStart'", ")", "{", "selectors", "=", "this", ".", "get", "(", "'selectors'", ")", ";", "//delete the last selector", "selectors", ".", "pop", "(", ")", ";", "var", "lines", "=", "this", ".", "get", "(", "'lines'", ")", ";", "lines", ".", "pop", "(", ")", ";", "this", ".", "attributes", ".", "nest", ".", "pop", "(", ")", ";", "return", ";", "}", "else", "if", "(", "e", ".", "old", "===", "'valueStart'", ")", "{", "this", ".", "_addValue", "(", "e", ")", ";", "}", "ruleEnd", ".", "recode", "=", "ruleEnd", ".", "recode", "||", "0", ";", "ruleEnd", ".", "recode", "++", ";", "this", ".", "attributes", ".", "nest", ".", "pop", "(", ")", ";", "if", "(", "!", "this", ".", "attributes", ".", "nest", ".", "length", ")", "{", "var", "num", "=", "this", ".", "getLen", "(", ")", "-", "ruleEnd", ".", "recode", ";", "ruleEnd", ".", "recode", "=", "0", ";", "var", "idList", "=", "this", ".", "get", "(", "'idList'", ")", ";", "idList", ".", "push", "(", "num", ")", ";", "this", ".", "fire", "(", "this", ".", "get", "(", "'RULE_END_EVT'", ")", ",", "this", ".", "getRule", "(", "num", ")", ")", ";", "}", "}" ]
1. fix the problem when have some empty rule such as @example .foo {} remove the selector in the collections of selector 2. fix when the last value don't end with the semicolon @example .foo { color: red }
[ "1", ".", "fix", "the", "problem", "when", "have", "some", "empty", "rule", "such", "as" ]
5dc7a1276bcca878c2ac513efe6442fc47a36e29
https://github.com/weekeight/gulp-joycss/blob/5dc7a1276bcca878c2ac513efe6442fc47a36e29/joycss/lib/csslib/cssReader.js#L170-L199
49,325
weekeight/gulp-joycss
joycss/lib/csslib/cssReader.js
addValue
function addValue(e){ var len; if (e.old === 'valueStart') { var history = this.get('history'); len = history.length; var preStatus = history[len - 3]; isNew = preStatus == 'ruleStart'; value = this._getLast(isNew, 'values'); value && value.push(e.data); } else { var metas = this.get('metas'); var selectors = this.get('selectors'); len = selectors.length; metas[len] = metas[len] || []; var data = ''; /*when @import url("booya.css") print, screen;*/ if (e.old === 'selectorBreak'){ data = selectors.pop().join(', ') + ', '; var lines = this.get('lines'); lines.pop(); } data += e.data; metas[len].push(data); } }
javascript
function addValue(e){ var len; if (e.old === 'valueStart') { var history = this.get('history'); len = history.length; var preStatus = history[len - 3]; isNew = preStatus == 'ruleStart'; value = this._getLast(isNew, 'values'); value && value.push(e.data); } else { var metas = this.get('metas'); var selectors = this.get('selectors'); len = selectors.length; metas[len] = metas[len] || []; var data = ''; /*when @import url("booya.css") print, screen;*/ if (e.old === 'selectorBreak'){ data = selectors.pop().join(', ') + ', '; var lines = this.get('lines'); lines.pop(); } data += e.data; metas[len].push(data); } }
[ "function", "addValue", "(", "e", ")", "{", "var", "len", ";", "if", "(", "e", ".", "old", "===", "'valueStart'", ")", "{", "var", "history", "=", "this", ".", "get", "(", "'history'", ")", ";", "len", "=", "history", ".", "length", ";", "var", "preStatus", "=", "history", "[", "len", "-", "3", "]", ";", "isNew", "=", "preStatus", "==", "'ruleStart'", ";", "value", "=", "this", ".", "_getLast", "(", "isNew", ",", "'values'", ")", ";", "value", "&&", "value", ".", "push", "(", "e", ".", "data", ")", ";", "}", "else", "{", "var", "metas", "=", "this", ".", "get", "(", "'metas'", ")", ";", "var", "selectors", "=", "this", ".", "get", "(", "'selectors'", ")", ";", "len", "=", "selectors", ".", "length", ";", "metas", "[", "len", "]", "=", "metas", "[", "len", "]", "||", "[", "]", ";", "var", "data", "=", "''", ";", "/*when @import url(\"booya.css\") print, screen;*/", "if", "(", "e", ".", "old", "===", "'selectorBreak'", ")", "{", "data", "=", "selectors", ".", "pop", "(", ")", ".", "join", "(", "', '", ")", "+", "', '", ";", "var", "lines", "=", "this", ".", "get", "(", "'lines'", ")", ";", "lines", ".", "pop", "(", ")", ";", "}", "data", "+=", "e", ".", "data", ";", "metas", "[", "len", "]", ".", "push", "(", "data", ")", ";", "}", "}" ]
add value and when meet with single rule, such as '@charset "UTF-8";', push the is to the object of metas
[ "add", "value", "and", "when", "meet", "with", "single", "rule", "such", "as" ]
5dc7a1276bcca878c2ac513efe6442fc47a36e29
https://github.com/weekeight/gulp-joycss/blob/5dc7a1276bcca878c2ac513efe6442fc47a36e29/joycss/lib/csslib/cssReader.js#L234-L263
49,326
weekeight/gulp-joycss
joycss/lib/csslib/cssReader.js
getLast
function getLast(isNew, opt_key){ opt_key = opt_key || 'selectors'; var items = this.get(opt_key); var len = items.length; if (isNew){ len++; items.push([]); var nest = this.get('nest'); var nLen = nest.length; if (nLen > 1){ //console.log([nest, nest[nLen - 2], len - 1]); //push the new rule to is father items[nest[nLen - 2]].push(items[len - 1]); } } return items[len - 1]; }
javascript
function getLast(isNew, opt_key){ opt_key = opt_key || 'selectors'; var items = this.get(opt_key); var len = items.length; if (isNew){ len++; items.push([]); var nest = this.get('nest'); var nLen = nest.length; if (nLen > 1){ //console.log([nest, nest[nLen - 2], len - 1]); //push the new rule to is father items[nest[nLen - 2]].push(items[len - 1]); } } return items[len - 1]; }
[ "function", "getLast", "(", "isNew", ",", "opt_key", ")", "{", "opt_key", "=", "opt_key", "||", "'selectors'", ";", "var", "items", "=", "this", ".", "get", "(", "opt_key", ")", ";", "var", "len", "=", "items", ".", "length", ";", "if", "(", "isNew", ")", "{", "len", "++", ";", "items", ".", "push", "(", "[", "]", ")", ";", "var", "nest", "=", "this", ".", "get", "(", "'nest'", ")", ";", "var", "nLen", "=", "nest", ".", "length", ";", "if", "(", "nLen", ">", "1", ")", "{", "//console.log([nest, nest[nLen - 2], len - 1]);", "//push the new rule to is father", "items", "[", "nest", "[", "nLen", "-", "2", "]", "]", ".", "push", "(", "items", "[", "len", "-", "1", "]", ")", ";", "}", "}", "return", "items", "[", "len", "-", "1", "]", ";", "}" ]
get last item of selectors or properties or values @param isNew {bool} if isNew, push it an new empty array, if isNew is null, isNew equal to false @param opt_key {string} selectors | properties | values by default opt_key is selectors
[ "get", "last", "item", "of", "selectors", "or", "properties", "or", "values" ]
5dc7a1276bcca878c2ac513efe6442fc47a36e29
https://github.com/weekeight/gulp-joycss/blob/5dc7a1276bcca878c2ac513efe6442fc47a36e29/joycss/lib/csslib/cssReader.js#L296-L315
49,327
weekeight/gulp-joycss
joycss/lib/csslib/cssReader.js
read
function read(data){ var dismember = this.get('DISMEMBER'); var i = 0, j = 0; var comment = false; var len = data.length; var code = data[0]; var line = 1; var val; var slice = data.asciiSlice ? 'asciiSlice' : 'slice'; //console.log("one\n"); while(code){ if (typeof code == 'string') code = code.charCodeAt(); if (code === 10 || code === 13){ var isoneLine = code === 10 && data[i - 1] === 13; //isoneLine = isoneLine || (code === 10 && data[i - 1] === 13); if (!isoneLine) line = line + 1; } else if (code === 42 && (data[i + 1] === 47 || data[i + 1] == '/')){ //comment end comment = false; i++; j = i + 1; } else if (code === 47 && (data[i + 1] === 42 || data[i + 1] == '*')){ //comment start comment = true; i++; } else if (!comment && code in dismember){ var status = this.get('status'); //filter the condiction of semicolon(,) in css rule such as //_filter: xxx(src=url, sizingMethod='crop') var isFalseSelecterBreak = code === 44 && status == 'valueStart'; //filter the condiction of pseudo selector(:) var isPseudo = code == 58 && status != 'ruleStart' && status != 'valueEnd'; // var isInExpression = (code === 123 || code === 125) && status === 'valueStart' && data[slice](j, i).indexOf('expression') > -1; if (isPseudo || isFalseSelecterBreak || isInExpression){ code = data[++i]; continue; } val = data[slice](j, i).replace(this.get('TRIM_REG'), ''); this._addEvent(dismember[code], val, line); j = i + 1; } code = data[++i]; } }
javascript
function read(data){ var dismember = this.get('DISMEMBER'); var i = 0, j = 0; var comment = false; var len = data.length; var code = data[0]; var line = 1; var val; var slice = data.asciiSlice ? 'asciiSlice' : 'slice'; //console.log("one\n"); while(code){ if (typeof code == 'string') code = code.charCodeAt(); if (code === 10 || code === 13){ var isoneLine = code === 10 && data[i - 1] === 13; //isoneLine = isoneLine || (code === 10 && data[i - 1] === 13); if (!isoneLine) line = line + 1; } else if (code === 42 && (data[i + 1] === 47 || data[i + 1] == '/')){ //comment end comment = false; i++; j = i + 1; } else if (code === 47 && (data[i + 1] === 42 || data[i + 1] == '*')){ //comment start comment = true; i++; } else if (!comment && code in dismember){ var status = this.get('status'); //filter the condiction of semicolon(,) in css rule such as //_filter: xxx(src=url, sizingMethod='crop') var isFalseSelecterBreak = code === 44 && status == 'valueStart'; //filter the condiction of pseudo selector(:) var isPseudo = code == 58 && status != 'ruleStart' && status != 'valueEnd'; // var isInExpression = (code === 123 || code === 125) && status === 'valueStart' && data[slice](j, i).indexOf('expression') > -1; if (isPseudo || isFalseSelecterBreak || isInExpression){ code = data[++i]; continue; } val = data[slice](j, i).replace(this.get('TRIM_REG'), ''); this._addEvent(dismember[code], val, line); j = i + 1; } code = data[++i]; } }
[ "function", "read", "(", "data", ")", "{", "var", "dismember", "=", "this", ".", "get", "(", "'DISMEMBER'", ")", ";", "var", "i", "=", "0", ",", "j", "=", "0", ";", "var", "comment", "=", "false", ";", "var", "len", "=", "data", ".", "length", ";", "var", "code", "=", "data", "[", "0", "]", ";", "var", "line", "=", "1", ";", "var", "val", ";", "var", "slice", "=", "data", ".", "asciiSlice", "?", "'asciiSlice'", ":", "'slice'", ";", "//console.log(\"one\\n\");", "while", "(", "code", ")", "{", "if", "(", "typeof", "code", "==", "'string'", ")", "code", "=", "code", ".", "charCodeAt", "(", ")", ";", "if", "(", "code", "===", "10", "||", "code", "===", "13", ")", "{", "var", "isoneLine", "=", "code", "===", "10", "&&", "data", "[", "i", "-", "1", "]", "===", "13", ";", "//isoneLine = isoneLine || (code === 10 && data[i - 1] === 13);", "if", "(", "!", "isoneLine", ")", "line", "=", "line", "+", "1", ";", "}", "else", "if", "(", "code", "===", "42", "&&", "(", "data", "[", "i", "+", "1", "]", "===", "47", "||", "data", "[", "i", "+", "1", "]", "==", "'/'", ")", ")", "{", "//comment end ", "comment", "=", "false", ";", "i", "++", ";", "j", "=", "i", "+", "1", ";", "}", "else", "if", "(", "code", "===", "47", "&&", "(", "data", "[", "i", "+", "1", "]", "===", "42", "||", "data", "[", "i", "+", "1", "]", "==", "'*'", ")", ")", "{", "//comment start", "comment", "=", "true", ";", "i", "++", ";", "}", "else", "if", "(", "!", "comment", "&&", "code", "in", "dismember", ")", "{", "var", "status", "=", "this", ".", "get", "(", "'status'", ")", ";", "//filter the condiction of semicolon(,) in css rule such as", "//_filter: xxx(src=url, sizingMethod='crop')", "var", "isFalseSelecterBreak", "=", "code", "===", "44", "&&", "status", "==", "'valueStart'", ";", "//filter the condiction of pseudo selector(:)", "var", "isPseudo", "=", "code", "==", "58", "&&", "status", "!=", "'ruleStart'", "&&", "status", "!=", "'valueEnd'", ";", "//", "var", "isInExpression", "=", "(", "code", "===", "123", "||", "code", "===", "125", ")", "&&", "status", "===", "'valueStart'", "&&", "data", "[", "slice", "]", "(", "j", ",", "i", ")", ".", "indexOf", "(", "'expression'", ")", ">", "-", "1", ";", "if", "(", "isPseudo", "||", "isFalseSelecterBreak", "||", "isInExpression", ")", "{", "code", "=", "data", "[", "++", "i", "]", ";", "continue", ";", "}", "val", "=", "data", "[", "slice", "]", "(", "j", ",", "i", ")", ".", "replace", "(", "this", ".", "get", "(", "'TRIM_REG'", ")", ",", "''", ")", ";", "this", ".", "_addEvent", "(", "dismember", "[", "code", "]", ",", "val", ",", "line", ")", ";", "j", "=", "i", "+", "1", ";", "}", "code", "=", "data", "[", "++", "i", "]", ";", "}", "}" ]
read data steam, loop exam the assic code one by one. filter the comment and when meet with code in dismember, fire some event, then change the property of status, push event into the array of history, and deliver a string of selector or property or value.
[ "read", "data", "steam", "loop", "exam", "the", "assic", "code", "one", "by", "one", ".", "filter", "the", "comment", "and", "when", "meet", "with", "code", "in", "dismember", "fire", "some", "event", "then", "change", "the", "property", "of", "status", "push", "event", "into", "the", "array", "of", "history", "and", "deliver", "a", "string", "of", "selector", "or", "property", "or", "value", "." ]
5dc7a1276bcca878c2ac513efe6442fc47a36e29
https://github.com/weekeight/gulp-joycss/blob/5dc7a1276bcca878c2ac513efe6442fc47a36e29/joycss/lib/csslib/cssReader.js#L339-L395
49,328
arufian/better-say
app.js
function(sentences, options) { var voice = options.voice, callback = options.callback, iswrite = options.writetext; for (var i=0; i<sentences.length; i++) { speechList.push(sentences[i]); }; try{ tts(voice, iswrite, callback); return true; } catch(e) { throw new Error('error while speaking'); } }
javascript
function(sentences, options) { var voice = options.voice, callback = options.callback, iswrite = options.writetext; for (var i=0; i<sentences.length; i++) { speechList.push(sentences[i]); }; try{ tts(voice, iswrite, callback); return true; } catch(e) { throw new Error('error while speaking'); } }
[ "function", "(", "sentences", ",", "options", ")", "{", "var", "voice", "=", "options", ".", "voice", ",", "callback", "=", "options", ".", "callback", ",", "iswrite", "=", "options", ".", "writetext", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "sentences", ".", "length", ";", "i", "++", ")", "{", "speechList", ".", "push", "(", "sentences", "[", "i", "]", ")", ";", "}", ";", "try", "{", "tts", "(", "voice", ",", "iswrite", ",", "callback", ")", ";", "return", "true", ";", "}", "catch", "(", "e", ")", "{", "throw", "new", "Error", "(", "'error while speaking'", ")", ";", "}", "}" ]
Make your computer speak better with multiple sentences @param {Array} | {String} Array list of sentences or filepath @param {Object<voice, writetext, callback>} options
[ "Make", "your", "computer", "speak", "better", "with", "multiple", "sentences" ]
52a53c0e96329109286bc64683ef65fdc06e1fda
https://github.com/arufian/better-say/blob/52a53c0e96329109286bc64683ef65fdc06e1fda/app.js#L69-L81
49,329
assertjs/assert.js
dist/assert.esm.js
AssertionException
function AssertionException(type, message, id) { var _this = _super.call(this, message) || this; _this.type = type; _this.id = id; if (Error.captureStackTrace) { Error.captureStackTrace(_this, _this.constructor); } return _this; }
javascript
function AssertionException(type, message, id) { var _this = _super.call(this, message) || this; _this.type = type; _this.id = id; if (Error.captureStackTrace) { Error.captureStackTrace(_this, _this.constructor); } return _this; }
[ "function", "AssertionException", "(", "type", ",", "message", ",", "id", ")", "{", "var", "_this", "=", "_super", ".", "call", "(", "this", ",", "message", ")", "||", "this", ";", "_this", ".", "type", "=", "type", ";", "_this", ".", "id", "=", "id", ";", "if", "(", "Error", ".", "captureStackTrace", ")", "{", "Error", ".", "captureStackTrace", "(", "_this", ",", "_this", ".", "constructor", ")", ";", "}", "return", "_this", ";", "}" ]
Create AssertionException based on type, message and id @param {assertionTypes} type - Assertion type @param {string} message - Custom error message @param {string} id - Exception id
[ "Create", "AssertionException", "based", "on", "type", "message", "and", "id" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L115-L123
49,330
assertjs/assert.js
dist/assert.esm.js
fail
function fail(message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled) { throw new AssertionException(assertionTypes.FAIL, message, id); } }
javascript
function fail(message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled) { throw new AssertionException(assertionTypes.FAIL, message, id); } }
[ "function", "fail", "(", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", ")", "{", "throw", "new", "AssertionException", "(", "assertionTypes", ".", "FAIL", ",", "message", ",", "id", ")", ";", "}", "}" ]
Always throw AssertError @param message @param id @returns {void}
[ "Always", "throw", "AssertError" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L147-L153
49,331
assertjs/assert.js
dist/assert.esm.js
isTruthy
function isTruthy(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !value) { throw LogicException.throw(assertionTypes.IS_TRUTHY, value, message, id); } }
javascript
function isTruthy(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !value) { throw LogicException.throw(assertionTypes.IS_TRUTHY, value, message, id); } }
[ "function", "isTruthy", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "!", "value", ")", "{", "throw", "LogicException", ".", "throw", "(", "assertionTypes", ".", "IS_TRUTHY", ",", "value", ",", "message", ",", "id", ")", ";", "}", "}" ]
Assert if given value is truthy @param value @param {string} message @param {string} id @returns {void}
[ "Assert", "if", "given", "value", "is", "truthy" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L259-L265
49,332
assertjs/assert.js
dist/assert.esm.js
isFalsy
function isFalsy(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value) { throw LogicException.throw(assertionTypes.IS_FALSY, value, message, id); } }
javascript
function isFalsy(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value) { throw LogicException.throw(assertionTypes.IS_FALSY, value, message, id); } }
[ "function", "isFalsy", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "value", ")", "{", "throw", "LogicException", ".", "throw", "(", "assertionTypes", ".", "IS_FALSY", ",", "value", ",", "message", ",", "id", ")", ";", "}", "}" ]
Assert if given value is falsy @param value @param {string} message @param {string} id @returns {void}
[ "Assert", "if", "given", "value", "is", "falsy" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L274-L280
49,333
assertjs/assert.js
dist/assert.esm.js
isEmpty
function isEmpty(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && ((typeof value === 'string' && value.length === 0) || (typeof value === 'number' && value === 0))) { throw LogicException.throw(assertionTypes.IS_EMPTY, value, message, id); } }
javascript
function isEmpty(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && ((typeof value === 'string' && value.length === 0) || (typeof value === 'number' && value === 0))) { throw LogicException.throw(assertionTypes.IS_EMPTY, value, message, id); } }
[ "function", "isEmpty", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "(", "(", "typeof", "value", "===", "'string'", "&&", "value", ".", "length", "===", "0", ")", "||", "(", "typeof", "value", "===", "'number'", "&&", "value", "===", "0", ")", ")", ")", "{", "throw", "LogicException", ".", "throw", "(", "assertionTypes", ".", "IS_EMPTY", ",", "value", ",", "message", ",", "id", ")", ";", "}", "}" ]
Assert if given value is empty @param value @param {string} message @param {string} id @returns {void}
[ "Assert", "if", "given", "value", "is", "empty" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L289-L297
49,334
assertjs/assert.js
dist/assert.esm.js
isNotEmpty
function isNotEmpty(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && ((typeof value === 'string' && value.length !== 0) || (typeof value === 'number' && value !== 0))) { throw LogicException.throw(assertionTypes.IS_NOT_EMPTY, value, message, id); } }
javascript
function isNotEmpty(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && ((typeof value === 'string' && value.length !== 0) || (typeof value === 'number' && value !== 0))) { throw LogicException.throw(assertionTypes.IS_NOT_EMPTY, value, message, id); } }
[ "function", "isNotEmpty", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "(", "(", "typeof", "value", "===", "'string'", "&&", "value", ".", "length", "!==", "0", ")", "||", "(", "typeof", "value", "===", "'number'", "&&", "value", "!==", "0", ")", ")", ")", "{", "throw", "LogicException", ".", "throw", "(", "assertionTypes", ".", "IS_NOT_EMPTY", ",", "value", ",", "message", ",", "id", ")", ";", "}", "}" ]
Assert if given value is not empty @param value @param {string} message @param {string} id @returns {void}
[ "Assert", "if", "given", "value", "is", "not", "empty" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L306-L314
49,335
assertjs/assert.js
dist/assert.esm.js
isUndefined
function isUndefined(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value !== undefined) { throw TypeException.unexpectedType(assertionTypes.IS_UNDEFINED, value, '<undefined>', message, id); } }
javascript
function isUndefined(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value !== undefined) { throw TypeException.unexpectedType(assertionTypes.IS_UNDEFINED, value, '<undefined>', message, id); } }
[ "function", "isUndefined", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "value", "!==", "undefined", ")", "{", "throw", "TypeException", ".", "unexpectedType", "(", "assertionTypes", ".", "IS_UNDEFINED", ",", "value", ",", "'<undefined>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is undefined @param value @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "undefined" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L384-L390
49,336
assertjs/assert.js
dist/assert.esm.js
isBool
function isBool(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value !== 'boolean') { throw TypeException.unexpectedType(assertionTypes.IS_BOOL, value, '<boolean>', message, id); } }
javascript
function isBool(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value !== 'boolean') { throw TypeException.unexpectedType(assertionTypes.IS_BOOL, value, '<boolean>', message, id); } }
[ "function", "isBool", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "typeof", "value", "!==", "'boolean'", ")", "{", "throw", "TypeException", ".", "unexpectedType", "(", "assertionTypes", ".", "IS_BOOL", ",", "value", ",", "'<boolean>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is boolean @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "boolean" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L399-L405
49,337
assertjs/assert.js
dist/assert.esm.js
isNotBool
function isNotBool(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value === 'boolean') { throw TypeException.expectedType(assertionTypes.IS_NOT_BOOL, value, '<boolean>', message, id); } }
javascript
function isNotBool(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value === 'boolean') { throw TypeException.expectedType(assertionTypes.IS_NOT_BOOL, value, '<boolean>', message, id); } }
[ "function", "isNotBool", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "typeof", "value", "===", "'boolean'", ")", "{", "throw", "TypeException", ".", "expectedType", "(", "assertionTypes", ".", "IS_NOT_BOOL", ",", "value", ",", "'<boolean>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is not boolean @param value @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "not", "boolean" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L414-L420
49,338
assertjs/assert.js
dist/assert.esm.js
isNumber
function isNumber(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !(typeof value === 'number' || value instanceof Number)) { throw TypeException.unexpectedType(assertionTypes.IS_NUMBER, value, '<number>', message, id); } }
javascript
function isNumber(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !(typeof value === 'number' || value instanceof Number)) { throw TypeException.unexpectedType(assertionTypes.IS_NUMBER, value, '<number>', message, id); } }
[ "function", "isNumber", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "!", "(", "typeof", "value", "===", "'number'", "||", "value", "instanceof", "Number", ")", ")", "{", "throw", "TypeException", ".", "unexpectedType", "(", "assertionTypes", ".", "IS_NUMBER", ",", "value", ",", "'<number>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is number @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "number" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L429-L435
49,339
assertjs/assert.js
dist/assert.esm.js
isNotNumber
function isNotNumber(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && (typeof value === 'number' || value instanceof Number)) { throw TypeException.expectedType(assertionTypes.IS_NOT_NUMBER, value, '<number>', message, id); } }
javascript
function isNotNumber(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && (typeof value === 'number' || value instanceof Number)) { throw TypeException.expectedType(assertionTypes.IS_NOT_NUMBER, value, '<number>', message, id); } }
[ "function", "isNotNumber", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "(", "typeof", "value", "===", "'number'", "||", "value", "instanceof", "Number", ")", ")", "{", "throw", "TypeException", ".", "expectedType", "(", "assertionTypes", ".", "IS_NOT_NUMBER", ",", "value", ",", "'<number>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is not number @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "not", "number" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L444-L450
49,340
assertjs/assert.js
dist/assert.esm.js
isNaN
function isNaN(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !Number.isNaN(value)) { throw TypeException.unexpectedType(assertionTypes.IS_NAN, value, '<NaN>', message, id); } }
javascript
function isNaN(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !Number.isNaN(value)) { throw TypeException.unexpectedType(assertionTypes.IS_NAN, value, '<NaN>', message, id); } }
[ "function", "isNaN", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "!", "Number", ".", "isNaN", "(", "value", ")", ")", "{", "throw", "TypeException", ".", "unexpectedType", "(", "assertionTypes", ".", "IS_NAN", ",", "value", ",", "'<NaN>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is Not a Number @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "Not", "a", "Number" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L489-L495
49,341
assertjs/assert.js
dist/assert.esm.js
isNotNaN
function isNotNaN(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && Number.isNaN(value)) { throw TypeException.expectedType(assertionTypes.IS_NOT_NAN, value, '<NaN>', message, id); } }
javascript
function isNotNaN(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && Number.isNaN(value)) { throw TypeException.expectedType(assertionTypes.IS_NOT_NAN, value, '<NaN>', message, id); } }
[ "function", "isNotNaN", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "Number", ".", "isNaN", "(", "value", ")", ")", "{", "throw", "TypeException", ".", "expectedType", "(", "assertionTypes", ".", "IS_NOT_NAN", ",", "value", ",", "'<NaN>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is other than Not a Number @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "other", "than", "Not", "a", "Number" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L504-L510
49,342
assertjs/assert.js
dist/assert.esm.js
isString
function isString(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !(typeof value === 'string' || value instanceof String)) { throw TypeException.unexpectedType(assertionTypes.IS_STRING, value, '<string>', message, id); } }
javascript
function isString(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !(typeof value === 'string' || value instanceof String)) { throw TypeException.unexpectedType(assertionTypes.IS_STRING, value, '<string>', message, id); } }
[ "function", "isString", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "!", "(", "typeof", "value", "===", "'string'", "||", "value", "instanceof", "String", ")", ")", "{", "throw", "TypeException", ".", "unexpectedType", "(", "assertionTypes", ".", "IS_STRING", ",", "value", ",", "'<string>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is string @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "string" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L519-L525
49,343
assertjs/assert.js
dist/assert.esm.js
isNotString
function isNotString(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && (typeof value === 'string' || value instanceof String)) { throw TypeException.expectedType(assertionTypes.IS_NOT_STRING, value, '<string>', message, id); } }
javascript
function isNotString(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && (typeof value === 'string' || value instanceof String)) { throw TypeException.expectedType(assertionTypes.IS_NOT_STRING, value, '<string>', message, id); } }
[ "function", "isNotString", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "(", "typeof", "value", "===", "'string'", "||", "value", "instanceof", "String", ")", ")", "{", "throw", "TypeException", ".", "expectedType", "(", "assertionTypes", ".", "IS_NOT_STRING", ",", "value", ",", "'<string>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is not string @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "not", "string" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L534-L540
49,344
assertjs/assert.js
dist/assert.esm.js
isArray
function isArray(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !Array.isArray(value)) { throw TypeException.unexpectedType(assertionTypes.IS_ARRAY, value, '<array>', message, id); } }
javascript
function isArray(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !Array.isArray(value)) { throw TypeException.unexpectedType(assertionTypes.IS_ARRAY, value, '<array>', message, id); } }
[ "function", "isArray", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "!", "Array", ".", "isArray", "(", "value", ")", ")", "{", "throw", "TypeException", ".", "unexpectedType", "(", "assertionTypes", ".", "IS_ARRAY", ",", "value", ",", "'<array>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is an array @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "an", "array" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L549-L555
49,345
assertjs/assert.js
dist/assert.esm.js
isNotArray
function isNotArray(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && Array.isArray(value)) { throw TypeException.expectedType(assertionTypes.IS_NOT_ARRAY, value, '<array>', message, id); } }
javascript
function isNotArray(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && Array.isArray(value)) { throw TypeException.expectedType(assertionTypes.IS_NOT_ARRAY, value, '<array>', message, id); } }
[ "function", "isNotArray", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "Array", ".", "isArray", "(", "value", ")", ")", "{", "throw", "TypeException", ".", "expectedType", "(", "assertionTypes", ".", "IS_NOT_ARRAY", ",", "value", ",", "'<array>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is not an array @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "not", "an", "array" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L564-L570
49,346
assertjs/assert.js
dist/assert.esm.js
isFunction
function isFunction(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value !== 'function') { throw TypeException.expectedType(assertionTypes.IS_FUNCTION, value, '<function>', message, id); } }
javascript
function isFunction(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value !== 'function') { throw TypeException.expectedType(assertionTypes.IS_FUNCTION, value, '<function>', message, id); } }
[ "function", "isFunction", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "typeof", "value", "!==", "'function'", ")", "{", "throw", "TypeException", ".", "expectedType", "(", "assertionTypes", ".", "IS_FUNCTION", ",", "value", ",", "'<function>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is function @param value @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "function" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L579-L585
49,347
assertjs/assert.js
dist/assert.esm.js
isNotFunction
function isNotFunction(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value === 'function') { throw TypeException.unexpectedType(assertionTypes.IS_NOT_FUNCTION, value, '<function>', message, id); } }
javascript
function isNotFunction(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value === 'function') { throw TypeException.unexpectedType(assertionTypes.IS_NOT_FUNCTION, value, '<function>', message, id); } }
[ "function", "isNotFunction", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "typeof", "value", "===", "'function'", ")", "{", "throw", "TypeException", ".", "unexpectedType", "(", "assertionTypes", ".", "IS_NOT_FUNCTION", ",", "value", ",", "'<function>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is not function @param value @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "not", "function" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L594-L600
49,348
assertjs/assert.js
dist/assert.esm.js
isSymbol
function isSymbol(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value !== 'symbol') { throw TypeException.unexpectedType(assertionTypes.IS_SYMBOL, value, '<symbol>', message, id); } }
javascript
function isSymbol(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value !== 'symbol') { throw TypeException.unexpectedType(assertionTypes.IS_SYMBOL, value, '<symbol>', message, id); } }
[ "function", "isSymbol", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "typeof", "value", "!==", "'symbol'", ")", "{", "throw", "TypeException", ".", "unexpectedType", "(", "assertionTypes", ".", "IS_SYMBOL", ",", "value", ",", "'<symbol>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is Symbol @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "Symbol" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L609-L615
49,349
assertjs/assert.js
dist/assert.esm.js
isNotSymbol
function isNotSymbol(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value === 'symbol') { throw TypeException.expectedType(assertionTypes.IS_NOT_SYMBOL, value, '<symbol>', message, id); } }
javascript
function isNotSymbol(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && typeof value === 'symbol') { throw TypeException.expectedType(assertionTypes.IS_NOT_SYMBOL, value, '<symbol>', message, id); } }
[ "function", "isNotSymbol", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "typeof", "value", "===", "'symbol'", ")", "{", "throw", "TypeException", ".", "expectedType", "(", "assertionTypes", ".", "IS_NOT_SYMBOL", ",", "value", ",", "'<symbol>'", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is not an Symbol @param value @param {string} message @param {string} id @returns void
[ "Check", "if", "provided", "value", "is", "not", "an", "Symbol" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L624-L630
49,350
assertjs/assert.js
dist/assert.esm.js
isInstanceOf
function isInstanceOf(value, expectedInstance, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !(value instanceof expectedInstance)) { throw ValueException.unexpectedValue(assertionTypes.INSTANCE_OF, value, expectedInstance, message, id); } }
javascript
function isInstanceOf(value, expectedInstance, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !(value instanceof expectedInstance)) { throw ValueException.unexpectedValue(assertionTypes.INSTANCE_OF, value, expectedInstance, message, id); } }
[ "function", "isInstanceOf", "(", "value", ",", "expectedInstance", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "!", "(", "value", "instanceof", "expectedInstance", ")", ")", "{", "throw", "ValueException", ".", "unexpectedValue", "(", "assertionTypes", ".", "INSTANCE_OF", ",", "value", ",", "expectedInstance", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is an expected instance @param value @param {Function} expectedInstance @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "an", "expected", "instance" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L686-L692
49,351
assertjs/assert.js
dist/assert.esm.js
isNotInstanceOf
function isNotInstanceOf(value, excludedInstance, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value instanceof excludedInstance) { throw ValueException.expectedValue(assertionTypes.NOT_INSTANCE_OF, value, excludedInstance, message, id); } }
javascript
function isNotInstanceOf(value, excludedInstance, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value instanceof excludedInstance) { throw ValueException.expectedValue(assertionTypes.NOT_INSTANCE_OF, value, excludedInstance, message, id); } }
[ "function", "isNotInstanceOf", "(", "value", ",", "excludedInstance", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "value", "instanceof", "excludedInstance", ")", "{", "throw", "ValueException", ".", "expectedValue", "(", "assertionTypes", ".", "NOT_INSTANCE_OF", ",", "value", ",", "excludedInstance", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is not instance of excluded instance @param value @param {Function} excludedInstance @param {string} message @param {string} id
[ "Check", "if", "provided", "value", "is", "not", "instance", "of", "excluded", "instance" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L701-L707
49,352
assertjs/assert.js
dist/assert.esm.js
isTrue
function isTrue(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value !== true) { throw ValueException.unexpectedValue(assertionTypes.IS_TRUE, value, true, message, id); } }
javascript
function isTrue(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value !== true) { throw ValueException.unexpectedValue(assertionTypes.IS_TRUE, value, true, message, id); } }
[ "function", "isTrue", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "value", "!==", "true", ")", "{", "throw", "ValueException", ".", "unexpectedValue", "(", "assertionTypes", ".", "IS_TRUE", ",", "value", ",", "true", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is true @param value @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "true" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L716-L722
49,353
assertjs/assert.js
dist/assert.esm.js
isNotTrue
function isNotTrue(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value === true) { throw ValueException.expectedValue(assertionTypes.IS_NOT_TRUE, value, true, message, id); } }
javascript
function isNotTrue(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value === true) { throw ValueException.expectedValue(assertionTypes.IS_NOT_TRUE, value, true, message, id); } }
[ "function", "isNotTrue", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "value", "===", "true", ")", "{", "throw", "ValueException", ".", "expectedValue", "(", "assertionTypes", ".", "IS_NOT_TRUE", ",", "value", ",", "true", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is not true @param value @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "not", "true" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L731-L737
49,354
assertjs/assert.js
dist/assert.esm.js
isFalse
function isFalse(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value !== false) { throw ValueException.unexpectedValue(assertionTypes.IS_FALSE, value, false, message, id); } }
javascript
function isFalse(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value !== false) { throw ValueException.unexpectedValue(assertionTypes.IS_FALSE, value, false, message, id); } }
[ "function", "isFalse", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "value", "!==", "false", ")", "{", "throw", "ValueException", ".", "unexpectedValue", "(", "assertionTypes", ".", "IS_FALSE", ",", "value", ",", "false", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is false @param value @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "false" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L746-L752
49,355
assertjs/assert.js
dist/assert.esm.js
isNotFalse
function isNotFalse(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value === false) { throw ValueException.expectedValue(assertionTypes.IS_NOT_FALSE, value, false, message, id); } }
javascript
function isNotFalse(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value === false) { throw ValueException.expectedValue(assertionTypes.IS_NOT_FALSE, value, false, message, id); } }
[ "function", "isNotFalse", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "value", "===", "false", ")", "{", "throw", "ValueException", ".", "expectedValue", "(", "assertionTypes", ".", "IS_NOT_FALSE", ",", "value", ",", "false", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is not false @param value @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "not", "false" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L761-L767
49,356
assertjs/assert.js
dist/assert.esm.js
isNull
function isNull(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value !== null) { throw ValueException.unexpectedValue(assertionTypes.IS_NULL, value, null, message, id); } }
javascript
function isNull(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value !== null) { throw ValueException.unexpectedValue(assertionTypes.IS_NULL, value, null, message, id); } }
[ "function", "isNull", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "value", "!==", "null", ")", "{", "throw", "ValueException", ".", "unexpectedValue", "(", "assertionTypes", ".", "IS_NULL", ",", "value", ",", "null", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is null @param value @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "null" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L776-L782
49,357
assertjs/assert.js
dist/assert.esm.js
isNotNull
function isNotNull(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value === null) { throw ValueException.expectedValue(assertionTypes.IS_NOT_NULL, value, null, message, id); } }
javascript
function isNotNull(value, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && value === null) { throw ValueException.expectedValue(assertionTypes.IS_NOT_NULL, value, null, message, id); } }
[ "function", "isNotNull", "(", "value", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "value", "===", "null", ")", "{", "throw", "ValueException", ".", "expectedValue", "(", "assertionTypes", ".", "IS_NOT_NULL", ",", "value", ",", "null", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value is not null @param value @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "is", "not", "null" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L791-L797
49,358
assertjs/assert.js
dist/assert.esm.js
match
function match(value, regExp, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !regExp.test(value)) { throw LogicException.throw(assertionTypes.MATCH, value, message, id); } }
javascript
function match(value, regExp, message, id) { if (message === void 0) { message = ''; } if (id === void 0) { id = ''; } if (this.enabled && !regExp.test(value)) { throw LogicException.throw(assertionTypes.MATCH, value, message, id); } }
[ "function", "match", "(", "value", ",", "regExp", ",", "message", ",", "id", ")", "{", "if", "(", "message", "===", "void", "0", ")", "{", "message", "=", "''", ";", "}", "if", "(", "id", "===", "void", "0", ")", "{", "id", "=", "''", ";", "}", "if", "(", "this", ".", "enabled", "&&", "!", "regExp", ".", "test", "(", "value", ")", ")", "{", "throw", "LogicException", ".", "throw", "(", "assertionTypes", ".", "MATCH", ",", "value", ",", "message", ",", "id", ")", ";", "}", "}" ]
Check if provided value match provided RegExp @param {string} value @param {RegExp} regExp @param {string} message @param {string} id @returns {void}
[ "Check", "if", "provided", "value", "match", "provided", "RegExp" ]
709656c2dc87ffa47f86e0e3d6442f199252260c
https://github.com/assertjs/assert.js/blob/709656c2dc87ffa47f86e0e3d6442f199252260c/dist/assert.esm.js#L807-L813
49,359
joaquinfq/jf-json-parse
index.js
loadJsonFile
function loadJsonFile(filename, cache, cwd) { let _content = null; if (filename.toLowerCase().endsWith('.json')) { const _filename = path.resolve(cwd, filename); if (fs.existsSync(_filename)) { if (_filename in cache) { _content = cache[_filename]; } else { //------------------------------------------------------------------------------ // La doble asignación se hace para evitar recursividades ya que si se trata de // incluir el mismo archivo al estar en caché no se analizaría. // Es un caso que no debería darse pero lo contemplamos. //------------------------------------------------------------------------------ cache[_filename] = _content = fs.readFileSync(_filename, 'utf8'); cache[_filename] = _content = parseJson(_content, cache, path.dirname(_filename)); } } else { cache[_filename] = null; } } else { try { JSON.parse(filename); _content = parseJson(filename, cache, cwd); } catch (e) { } } return _content; }
javascript
function loadJsonFile(filename, cache, cwd) { let _content = null; if (filename.toLowerCase().endsWith('.json')) { const _filename = path.resolve(cwd, filename); if (fs.existsSync(_filename)) { if (_filename in cache) { _content = cache[_filename]; } else { //------------------------------------------------------------------------------ // La doble asignación se hace para evitar recursividades ya que si se trata de // incluir el mismo archivo al estar en caché no se analizaría. // Es un caso que no debería darse pero lo contemplamos. //------------------------------------------------------------------------------ cache[_filename] = _content = fs.readFileSync(_filename, 'utf8'); cache[_filename] = _content = parseJson(_content, cache, path.dirname(_filename)); } } else { cache[_filename] = null; } } else { try { JSON.parse(filename); _content = parseJson(filename, cache, cwd); } catch (e) { } } return _content; }
[ "function", "loadJsonFile", "(", "filename", ",", "cache", ",", "cwd", ")", "{", "let", "_content", "=", "null", ";", "if", "(", "filename", ".", "toLowerCase", "(", ")", ".", "endsWith", "(", "'.json'", ")", ")", "{", "const", "_filename", "=", "path", ".", "resolve", "(", "cwd", ",", "filename", ")", ";", "if", "(", "fs", ".", "existsSync", "(", "_filename", ")", ")", "{", "if", "(", "_filename", "in", "cache", ")", "{", "_content", "=", "cache", "[", "_filename", "]", ";", "}", "else", "{", "//------------------------------------------------------------------------------", "// La doble asignación se hace para evitar recursividades ya que si se trata de", "// incluir el mismo archivo al estar en caché no se analizaría.", "// Es un caso que no debería darse pero lo contemplamos.", "//------------------------------------------------------------------------------", "cache", "[", "_filename", "]", "=", "_content", "=", "fs", ".", "readFileSync", "(", "_filename", ",", "'utf8'", ")", ";", "cache", "[", "_filename", "]", "=", "_content", "=", "parseJson", "(", "_content", ",", "cache", ",", "path", ".", "dirname", "(", "_filename", ")", ")", ";", "}", "}", "else", "{", "cache", "[", "_filename", "]", "=", "null", ";", "}", "}", "else", "{", "try", "{", "JSON", ".", "parse", "(", "filename", ")", ";", "_content", "=", "parseJson", "(", "filename", ",", "cache", ",", "cwd", ")", ";", "}", "catch", "(", "e", ")", "{", "}", "}", "return", "_content", ";", "}" ]
Lee el archivo JSON o el texto en formato JSON y busca los archivos JSON incluidos. Si un archivo no existe se deja el texto tal cual. @param {string} filename Ruta al archivo a leer o texto en formato JSON. @param {object} cache Archivos y textos procesados previamente. @param {object} cwd Directorio actual a usar para resolver las inclusiones. @return {string|null} Texto JSON luego de ser procesado o `null` si no se pudo procesar.
[ "Lee", "el", "archivo", "JSON", "o", "el", "texto", "en", "formato", "JSON", "y", "busca", "los", "archivos", "JSON", "incluidos", ".", "Si", "un", "archivo", "no", "existe", "se", "deja", "el", "texto", "tal", "cual", "." ]
73ad42e71de95426d51c98a9780419945fe2004e
https://github.com/joaquinfq/jf-json-parse/blob/73ad42e71de95426d51c98a9780419945fe2004e/index.js#L14-L55
49,360
joaquinfq/jf-json-parse
index.js
parseJson
function parseJson(json, cache, cwd) { return json.replace( /"([^"]+\.json)"/gi, (match, jsonFile) => { const _json = loadJsonFile(jsonFile, cache, cwd); return _json === null ? match : _json; } ); }
javascript
function parseJson(json, cache, cwd) { return json.replace( /"([^"]+\.json)"/gi, (match, jsonFile) => { const _json = loadJsonFile(jsonFile, cache, cwd); return _json === null ? match : _json; } ); }
[ "function", "parseJson", "(", "json", ",", "cache", ",", "cwd", ")", "{", "return", "json", ".", "replace", "(", "/", "\"([^\"]+\\.json)\"", "/", "gi", ",", "(", "match", ",", "jsonFile", ")", "=>", "{", "const", "_json", "=", "loadJsonFile", "(", "jsonFile", ",", "cache", ",", "cwd", ")", ";", "return", "_json", "===", "null", "?", "match", ":", "_json", ";", "}", ")", ";", "}" ]
Lee el texto en formato JSON y busca los archivos JSON incluidos. Si un archivo no existe se deja el texto tal cual. @param {string} json Texto en formato JSON a analizar. @param {object} cache Archivos y textos procesados previamente. @param {object} cwd Directorio actual a usar para resolver las inclusiones. @return {string} Texto en formato JSON con las inclusiones resueltas.
[ "Lee", "el", "texto", "en", "formato", "JSON", "y", "busca", "los", "archivos", "JSON", "incluidos", ".", "Si", "un", "archivo", "no", "existe", "se", "deja", "el", "texto", "tal", "cual", "." ]
73ad42e71de95426d51c98a9780419945fe2004e
https://github.com/joaquinfq/jf-json-parse/blob/73ad42e71de95426d51c98a9780419945fe2004e/index.js#L67-L80
49,361
erelsgl/languagemodel
LanguageModel.js
function(dataset) { // calculate counts for equation (3): var mapWordToTotalCount = {}; var totalNumberOfWordsInDataset = 0; for (var i in dataset) { var datum = dataset[i]; var totalPerDatum = 0; // for each input sentence, count the total number of words in it: for (var word in datum) { mapWordToTotalCount[word] |= 0; mapWordToTotalCount[word] += datum[word]; totalPerDatum += datum[word]; } datum["_total"] = totalPerDatum; totalNumberOfWordsInDataset += totalPerDatum; } mapWordToTotalCount["_total"] = totalNumberOfWordsInDataset; this.dataset = dataset; this.mapWordToTotalCount = mapWordToTotalCount; // calculate smoothing factor for equation (3): var mapWordToSmoothingFactor = {}; for (var word in mapWordToTotalCount) { mapWordToSmoothingFactor[word] = (1-this.smoothingCoefficient) * this.mapWordToTotalCount[word] / this.mapWordToTotalCount["_total"]; } this.mapWordToSmoothingFactor = mapWordToSmoothingFactor; this.globalSmoothingFactor = (1/totalNumberOfWordsInDataset) // a global smoother, for totally unseen words. }
javascript
function(dataset) { // calculate counts for equation (3): var mapWordToTotalCount = {}; var totalNumberOfWordsInDataset = 0; for (var i in dataset) { var datum = dataset[i]; var totalPerDatum = 0; // for each input sentence, count the total number of words in it: for (var word in datum) { mapWordToTotalCount[word] |= 0; mapWordToTotalCount[word] += datum[word]; totalPerDatum += datum[word]; } datum["_total"] = totalPerDatum; totalNumberOfWordsInDataset += totalPerDatum; } mapWordToTotalCount["_total"] = totalNumberOfWordsInDataset; this.dataset = dataset; this.mapWordToTotalCount = mapWordToTotalCount; // calculate smoothing factor for equation (3): var mapWordToSmoothingFactor = {}; for (var word in mapWordToTotalCount) { mapWordToSmoothingFactor[word] = (1-this.smoothingCoefficient) * this.mapWordToTotalCount[word] / this.mapWordToTotalCount["_total"]; } this.mapWordToSmoothingFactor = mapWordToSmoothingFactor; this.globalSmoothingFactor = (1/totalNumberOfWordsInDataset) // a global smoother, for totally unseen words. }
[ "function", "(", "dataset", ")", "{", "// calculate counts for equation (3):", "var", "mapWordToTotalCount", "=", "{", "}", ";", "var", "totalNumberOfWordsInDataset", "=", "0", ";", "for", "(", "var", "i", "in", "dataset", ")", "{", "var", "datum", "=", "dataset", "[", "i", "]", ";", "var", "totalPerDatum", "=", "0", ";", "// for each input sentence, count the total number of words in it:", "for", "(", "var", "word", "in", "datum", ")", "{", "mapWordToTotalCount", "[", "word", "]", "|=", "0", ";", "mapWordToTotalCount", "[", "word", "]", "+=", "datum", "[", "word", "]", ";", "totalPerDatum", "+=", "datum", "[", "word", "]", ";", "}", "datum", "[", "\"_total\"", "]", "=", "totalPerDatum", ";", "totalNumberOfWordsInDataset", "+=", "totalPerDatum", ";", "}", "mapWordToTotalCount", "[", "\"_total\"", "]", "=", "totalNumberOfWordsInDataset", ";", "this", ".", "dataset", "=", "dataset", ";", "this", ".", "mapWordToTotalCount", "=", "mapWordToTotalCount", ";", "// calculate smoothing factor for equation (3):", "var", "mapWordToSmoothingFactor", "=", "{", "}", ";", "for", "(", "var", "word", "in", "mapWordToTotalCount", ")", "{", "mapWordToSmoothingFactor", "[", "word", "]", "=", "(", "1", "-", "this", ".", "smoothingCoefficient", ")", "*", "this", ".", "mapWordToTotalCount", "[", "word", "]", "/", "this", ".", "mapWordToTotalCount", "[", "\"_total\"", "]", ";", "}", "this", ".", "mapWordToSmoothingFactor", "=", "mapWordToSmoothingFactor", ";", "this", ".", "globalSmoothingFactor", "=", "(", "1", "/", "totalNumberOfWordsInDataset", ")", "// a global smoother, for totally unseen words.", "}" ]
Train the language with all the given documents. @param dataset an array with hashes of the format: {word1:count1, word2:count2,...} each object represents the a sentence (it should be tokenized in advance).
[ "Train", "the", "language", "with", "all", "the", "given", "documents", "." ]
462644dc32f97a970e3f4827fe92d0e709db21db
https://github.com/erelsgl/languagemodel/blob/462644dc32f97a970e3f4827fe92d0e709db21db/LanguageModel.js#L32-L64
49,362
ottojs/otto-errors
lib/read.error.js
ErrorRead
function ErrorRead (message) { Error.call(this); // Add Information this.name = 'ErrorRead'; this.type = 'server'; this.status = 500; if (message) { this.message = message; } }
javascript
function ErrorRead (message) { Error.call(this); // Add Information this.name = 'ErrorRead'; this.type = 'server'; this.status = 500; if (message) { this.message = message; } }
[ "function", "ErrorRead", "(", "message", ")", "{", "Error", ".", "call", "(", "this", ")", ";", "// Add Information", "this", ".", "name", "=", "'ErrorRead'", ";", "this", ".", "type", "=", "'server'", ";", "this", ".", "status", "=", "500", ";", "if", "(", "message", ")", "{", "this", ".", "message", "=", "message", ";", "}", "}" ]
Error - ErrorRead
[ "Error", "-", "ErrorRead" ]
a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9
https://github.com/ottojs/otto-errors/blob/a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9/lib/read.error.js#L8-L20
49,363
kevinoid/promised-read
index.js
tryUnshift
function tryUnshift(stream, result, desiredLength, emptySlice) { if (typeof stream.unshift !== 'function') { debug('Unable to unshift, stream does not have an unshift method.'); return result; } const errorListeners = stream.listeners('error'); stream.removeAllListeners('error'); // Note: Don't rely on the EventEmitter throwing on 'error' without // listeners, since it may be thrown in the stream's attached domain. let unshiftErr; function onUnshiftError(err) { unshiftErr = err; } stream.on('error', onUnshiftError); let resultLength = result.length; try { if (Array.isArray(result)) { while (resultLength > desiredLength && !unshiftErr) { stream.unshift(result[resultLength - 1]); if (!unshiftErr) { resultLength -= 1; } } } else { stream.unshift(result.slice(desiredLength)); if (!unshiftErr) { resultLength = desiredLength; } } } catch (err) { unshiftErr = err; } if (unshiftErr) { debug('Unable to unshift data: ', unshiftErr); } stream.removeListener('error', onUnshiftError); errorListeners.forEach((errorListener) => { stream.on('error', errorListener); }); return resultLength === 0 && !emptySlice ? null : resultLength < result.length ? result.slice(0, resultLength) : result; }
javascript
function tryUnshift(stream, result, desiredLength, emptySlice) { if (typeof stream.unshift !== 'function') { debug('Unable to unshift, stream does not have an unshift method.'); return result; } const errorListeners = stream.listeners('error'); stream.removeAllListeners('error'); // Note: Don't rely on the EventEmitter throwing on 'error' without // listeners, since it may be thrown in the stream's attached domain. let unshiftErr; function onUnshiftError(err) { unshiftErr = err; } stream.on('error', onUnshiftError); let resultLength = result.length; try { if (Array.isArray(result)) { while (resultLength > desiredLength && !unshiftErr) { stream.unshift(result[resultLength - 1]); if (!unshiftErr) { resultLength -= 1; } } } else { stream.unshift(result.slice(desiredLength)); if (!unshiftErr) { resultLength = desiredLength; } } } catch (err) { unshiftErr = err; } if (unshiftErr) { debug('Unable to unshift data: ', unshiftErr); } stream.removeListener('error', onUnshiftError); errorListeners.forEach((errorListener) => { stream.on('error', errorListener); }); return resultLength === 0 && !emptySlice ? null : resultLength < result.length ? result.slice(0, resultLength) : result; }
[ "function", "tryUnshift", "(", "stream", ",", "result", ",", "desiredLength", ",", "emptySlice", ")", "{", "if", "(", "typeof", "stream", ".", "unshift", "!==", "'function'", ")", "{", "debug", "(", "'Unable to unshift, stream does not have an unshift method.'", ")", ";", "return", "result", ";", "}", "const", "errorListeners", "=", "stream", ".", "listeners", "(", "'error'", ")", ";", "stream", ".", "removeAllListeners", "(", "'error'", ")", ";", "// Note: Don't rely on the EventEmitter throwing on 'error' without", "// listeners, since it may be thrown in the stream's attached domain.", "let", "unshiftErr", ";", "function", "onUnshiftError", "(", "err", ")", "{", "unshiftErr", "=", "err", ";", "}", "stream", ".", "on", "(", "'error'", ",", "onUnshiftError", ")", ";", "let", "resultLength", "=", "result", ".", "length", ";", "try", "{", "if", "(", "Array", ".", "isArray", "(", "result", ")", ")", "{", "while", "(", "resultLength", ">", "desiredLength", "&&", "!", "unshiftErr", ")", "{", "stream", ".", "unshift", "(", "result", "[", "resultLength", "-", "1", "]", ")", ";", "if", "(", "!", "unshiftErr", ")", "{", "resultLength", "-=", "1", ";", "}", "}", "}", "else", "{", "stream", ".", "unshift", "(", "result", ".", "slice", "(", "desiredLength", ")", ")", ";", "if", "(", "!", "unshiftErr", ")", "{", "resultLength", "=", "desiredLength", ";", "}", "}", "}", "catch", "(", "err", ")", "{", "unshiftErr", "=", "err", ";", "}", "if", "(", "unshiftErr", ")", "{", "debug", "(", "'Unable to unshift data: '", ",", "unshiftErr", ")", ";", "}", "stream", ".", "removeListener", "(", "'error'", ",", "onUnshiftError", ")", ";", "errorListeners", ".", "forEach", "(", "(", "errorListener", ")", "=>", "{", "stream", ".", "on", "(", "'error'", ",", "errorListener", ")", ";", "}", ")", ";", "return", "resultLength", "===", "0", "&&", "!", "emptySlice", "?", "null", ":", "resultLength", "<", "result", ".", "length", "?", "result", ".", "slice", "(", "0", ",", "resultLength", ")", ":", "result", ";", "}" ]
Attempts to unshift result data down to a desired length. @param {stream.Readable} stream Stream into which to unshift data. @param {!Buffer|string|!Array} result Read result data. @param {number} desiredLength Desired length of result after unshifting. @param {boolean=} emptySlice Return an empty slice when all data is unshifted, rather than <code>null</code>. @return {Buffer|string|Array} Result data after unshifting, or <code>null</code> if all data was unshifted and <code>emptySlice</code> is falsey. @private
[ "Attempts", "to", "unshift", "result", "data", "down", "to", "a", "desired", "length", "." ]
c6adf477f4a64d5142363d84f7f83f5f07b8f682
https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/index.js#L28-L74
49,364
kevinoid/promised-read
index.js
checkUntil
function checkUntil(resultWithData, data, ended) { let desiredLength; try { desiredLength = until(resultWithData, data, ended); } catch (errUntil) { doReject(errUntil, true); return true; } const resultLength = result ? result.length : 0; if (typeof desiredLength === 'number') { if (desiredLength > resultLength) { debug( 'until returned a desired length of %d. ' + 'Only have %d. Reading up to %d.', desiredLength, resultLength, desiredLength ); numSize = desiredLength; size = desiredLength - resultLength; } else if (desiredLength >= 0) { debug( 'until returned a desired length of %d out of %d', desiredLength, resultLength ); if (desiredLength < resultLength) { if (ended) { debug('Unable to unshift: Can not unshift after end.'); } else { result = tryUnshift(stream, result, desiredLength, true); } } doResolve(); return true; } else { debug('until returned %d, continuing to read', desiredLength); } } else if (desiredLength === true) { debug('until returned true, read finished.'); doResolve(); return true; } else if (desiredLength !== undefined && desiredLength !== null && desiredLength !== false) { // Note: Although this could be allowed, it causes an Error so that // future versions may add behavior for these values without causing // breakage. doReject( new TypeError( `non-numeric, non-boolean until() result: ${desiredLength}` ), true ); } else { debug('until returned %s, continuing to read', desiredLength); } return false; }
javascript
function checkUntil(resultWithData, data, ended) { let desiredLength; try { desiredLength = until(resultWithData, data, ended); } catch (errUntil) { doReject(errUntil, true); return true; } const resultLength = result ? result.length : 0; if (typeof desiredLength === 'number') { if (desiredLength > resultLength) { debug( 'until returned a desired length of %d. ' + 'Only have %d. Reading up to %d.', desiredLength, resultLength, desiredLength ); numSize = desiredLength; size = desiredLength - resultLength; } else if (desiredLength >= 0) { debug( 'until returned a desired length of %d out of %d', desiredLength, resultLength ); if (desiredLength < resultLength) { if (ended) { debug('Unable to unshift: Can not unshift after end.'); } else { result = tryUnshift(stream, result, desiredLength, true); } } doResolve(); return true; } else { debug('until returned %d, continuing to read', desiredLength); } } else if (desiredLength === true) { debug('until returned true, read finished.'); doResolve(); return true; } else if (desiredLength !== undefined && desiredLength !== null && desiredLength !== false) { // Note: Although this could be allowed, it causes an Error so that // future versions may add behavior for these values without causing // breakage. doReject( new TypeError( `non-numeric, non-boolean until() result: ${desiredLength}` ), true ); } else { debug('until returned %s, continuing to read', desiredLength); } return false; }
[ "function", "checkUntil", "(", "resultWithData", ",", "data", ",", "ended", ")", "{", "let", "desiredLength", ";", "try", "{", "desiredLength", "=", "until", "(", "resultWithData", ",", "data", ",", "ended", ")", ";", "}", "catch", "(", "errUntil", ")", "{", "doReject", "(", "errUntil", ",", "true", ")", ";", "return", "true", ";", "}", "const", "resultLength", "=", "result", "?", "result", ".", "length", ":", "0", ";", "if", "(", "typeof", "desiredLength", "===", "'number'", ")", "{", "if", "(", "desiredLength", ">", "resultLength", ")", "{", "debug", "(", "'until returned a desired length of %d. '", "+", "'Only have %d. Reading up to %d.'", ",", "desiredLength", ",", "resultLength", ",", "desiredLength", ")", ";", "numSize", "=", "desiredLength", ";", "size", "=", "desiredLength", "-", "resultLength", ";", "}", "else", "if", "(", "desiredLength", ">=", "0", ")", "{", "debug", "(", "'until returned a desired length of %d out of %d'", ",", "desiredLength", ",", "resultLength", ")", ";", "if", "(", "desiredLength", "<", "resultLength", ")", "{", "if", "(", "ended", ")", "{", "debug", "(", "'Unable to unshift: Can not unshift after end.'", ")", ";", "}", "else", "{", "result", "=", "tryUnshift", "(", "stream", ",", "result", ",", "desiredLength", ",", "true", ")", ";", "}", "}", "doResolve", "(", ")", ";", "return", "true", ";", "}", "else", "{", "debug", "(", "'until returned %d, continuing to read'", ",", "desiredLength", ")", ";", "}", "}", "else", "if", "(", "desiredLength", "===", "true", ")", "{", "debug", "(", "'until returned true, read finished.'", ")", ";", "doResolve", "(", ")", ";", "return", "true", ";", "}", "else", "if", "(", "desiredLength", "!==", "undefined", "&&", "desiredLength", "!==", "null", "&&", "desiredLength", "!==", "false", ")", "{", "// Note: Although this could be allowed, it causes an Error so that", "// future versions may add behavior for these values without causing", "// breakage.", "doReject", "(", "new", "TypeError", "(", "`", "${", "desiredLength", "}", "`", ")", ",", "true", ")", ";", "}", "else", "{", "debug", "(", "'until returned %s, continuing to read'", ",", "desiredLength", ")", ";", "}", "return", "false", ";", "}" ]
Calls the until function and handles its result. @return {boolean} <code>true</code> if done reading, <code>false</code> otherwise. @private
[ "Calls", "the", "until", "function", "and", "handles", "its", "result", "." ]
c6adf477f4a64d5142363d84f7f83f5f07b8f682
https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/index.js#L242-L299
49,365
kevinoid/promised-read
index.js
read
function read(stream, size, options) { if (!options && typeof size === 'object') { options = size; size = null; } return readInternal(stream, size, undefined, options); }
javascript
function read(stream, size, options) { if (!options && typeof size === 'object') { options = size; size = null; } return readInternal(stream, size, undefined, options); }
[ "function", "read", "(", "stream", ",", "size", ",", "options", ")", "{", "if", "(", "!", "options", "&&", "typeof", "size", "===", "'object'", ")", "{", "options", "=", "size", ";", "size", "=", "null", ";", "}", "return", "readInternal", "(", "stream", ",", "size", ",", "undefined", ",", "options", ")", ";", "}" ]
Reads from a stream.Readable. @param {stream.Readable} stream Stream from which to read. @param {number=} size Number of bytes to read. If <code>stream.read</code> is a function, <code>size</code> is passed to it, guaranteeing maximum result size. Otherwise, <code>'data'</code> events will be consumed until <code>size</code> bytes are read, making it a minimum rather than an exact value. @param {ReadOptions=} options Options. @return {Promise<Buffer|string|*>|CancellableReadPromise<Buffer|string|*>} Promise with result of read or Error. Result may be shorter than <code>size</code> if <code>'end'</code> occurs and will be <code>null</code> if no data can be read. If an error occurs after reading some data, the <code>.read</code> property of the error object will contain the partial read result. The promise is resolved synchronously for streams in flowing mode (see README.md for details).
[ "Reads", "from", "a", "stream", ".", "Readable", "." ]
c6adf477f4a64d5142363d84f7f83f5f07b8f682
https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/index.js#L457-L463
49,366
kevinoid/promised-read
index.js
readUntil
function readUntil(stream, until, options) { if (typeof until !== 'function') { // Note: Synchronous Yaku emits unhandledRejection before returning. // Best current option is to use an async promise, even when flowing const ReadPromise = (options && options.Promise) || Promise; return ReadPromise.reject(new TypeError('until must be a function')); } return readInternal(stream, undefined, until, options); }
javascript
function readUntil(stream, until, options) { if (typeof until !== 'function') { // Note: Synchronous Yaku emits unhandledRejection before returning. // Best current option is to use an async promise, even when flowing const ReadPromise = (options && options.Promise) || Promise; return ReadPromise.reject(new TypeError('until must be a function')); } return readInternal(stream, undefined, until, options); }
[ "function", "readUntil", "(", "stream", ",", "until", ",", "options", ")", "{", "if", "(", "typeof", "until", "!==", "'function'", ")", "{", "// Note: Synchronous Yaku emits unhandledRejection before returning.", "// Best current option is to use an async promise, even when flowing", "const", "ReadPromise", "=", "(", "options", "&&", "options", ".", "Promise", ")", "||", "Promise", ";", "return", "ReadPromise", ".", "reject", "(", "new", "TypeError", "(", "'until must be a function'", ")", ")", ";", "}", "return", "readInternal", "(", "stream", ",", "undefined", ",", "until", ",", "options", ")", ";", "}" ]
Reads from a stream.Readable until a given test is satisfied. @param {stream.Readable} stream Stream from which to read. @param {function((!Buffer|string|!Array), (Buffer|string|*)): number|boolean} test Test function called with the data read so far and the most recent chunk read. If it returns a negative or falsey value, more data will be read. If it returns a non-negative number and the stream can be unshifted, that many bytes will be returned and the others will be unshifted into the stream. Otherwise, all data read will be returned. If it returns a number larger than the length of the data read so far, enough data to reach the requested length will be read before returning. Non-numeric, non-boolean values will result in an error. @param {ReadOptions=} options Options. @return {Promise<!Buffer|string|!Array>| CancellableReadPromise<!Buffer|string|!Array>} Promise with the data read and not unshifted, or an Error if one occurred. If <code>'end'</code> is emitted before <code>until</code> returns a non-negative/true value, an {@link EOFError} is returned. If an error occurs after reading some data, the <code>.read</code> property of the error object will contain the partial read result. The promise is resolved synchronously for streams in flowing mode (see README.md for details).
[ "Reads", "from", "a", "stream", ".", "Readable", "until", "a", "given", "test", "is", "satisfied", "." ]
c6adf477f4a64d5142363d84f7f83f5f07b8f682
https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/index.js#L486-L494
49,367
kevinoid/promised-read
index.js
readTo
function readTo(stream, needle, options) { const endOK = Boolean(options && (options.endOK || options.endOk)); let needleForIndexOf; let needleLength; function until(result, chunk, ended) { if (ended) { return endOK ? (result ? result.length : 0) : -1; } if (Array.isArray(result)) { // objectMode. Use strict equality, like Array.prototype.indexOf return chunk === needle ? result.length : -1; } // Calculate the length of the needle, as used by indexOf and perform the // type conversion done by indexOf once, to avoid converting on every call if (needleLength === undefined) { if (typeof result === 'string') { needleForIndexOf = String(needle); needleLength = needleForIndexOf.length; } else if (result instanceof Buffer) { if (typeof needle === 'number') { // buffertools requires a Buffer or string // buffer-indexof-polyfill converts number to Buffer on each call needleForIndexOf = result.indexOf ? needle : Buffer.from ? Buffer.from([needle]) // eslint-disable-next-line no-buffer-constructor : new Buffer([needle]); needleLength = 1; } else if (typeof needle === 'string') { needleForIndexOf = needle; needleLength = Buffer.byteLength(needle); } else if (needle instanceof Buffer) { needleForIndexOf = needle; needleLength = needle.length; } } if (needleLength === undefined) { throw new TypeError(`Unsupported indexOf argument types: ${ Object.prototype.toString.call(result)}.indexOf(${ Object.prototype.toString.call(needle)})`); } // Buffer.prototype.indexOf returns -1 for 0-length string/Buffer. // To be consistent with string, we return 0. // Note: If removing this check, remove + 1 from start calc when 0. if (needleLength === 0) { return 0; } } const start = Math.max((result.length - chunk.length - needleLength) + 1, 0); const needleIndex = result.indexOf(needleForIndexOf, start); if (needleIndex < 0) { return -1; } return needleIndex + needleLength; } return readInternal(stream, undefined, until, options); }
javascript
function readTo(stream, needle, options) { const endOK = Boolean(options && (options.endOK || options.endOk)); let needleForIndexOf; let needleLength; function until(result, chunk, ended) { if (ended) { return endOK ? (result ? result.length : 0) : -1; } if (Array.isArray(result)) { // objectMode. Use strict equality, like Array.prototype.indexOf return chunk === needle ? result.length : -1; } // Calculate the length of the needle, as used by indexOf and perform the // type conversion done by indexOf once, to avoid converting on every call if (needleLength === undefined) { if (typeof result === 'string') { needleForIndexOf = String(needle); needleLength = needleForIndexOf.length; } else if (result instanceof Buffer) { if (typeof needle === 'number') { // buffertools requires a Buffer or string // buffer-indexof-polyfill converts number to Buffer on each call needleForIndexOf = result.indexOf ? needle : Buffer.from ? Buffer.from([needle]) // eslint-disable-next-line no-buffer-constructor : new Buffer([needle]); needleLength = 1; } else if (typeof needle === 'string') { needleForIndexOf = needle; needleLength = Buffer.byteLength(needle); } else if (needle instanceof Buffer) { needleForIndexOf = needle; needleLength = needle.length; } } if (needleLength === undefined) { throw new TypeError(`Unsupported indexOf argument types: ${ Object.prototype.toString.call(result)}.indexOf(${ Object.prototype.toString.call(needle)})`); } // Buffer.prototype.indexOf returns -1 for 0-length string/Buffer. // To be consistent with string, we return 0. // Note: If removing this check, remove + 1 from start calc when 0. if (needleLength === 0) { return 0; } } const start = Math.max((result.length - chunk.length - needleLength) + 1, 0); const needleIndex = result.indexOf(needleForIndexOf, start); if (needleIndex < 0) { return -1; } return needleIndex + needleLength; } return readInternal(stream, undefined, until, options); }
[ "function", "readTo", "(", "stream", ",", "needle", ",", "options", ")", "{", "const", "endOK", "=", "Boolean", "(", "options", "&&", "(", "options", ".", "endOK", "||", "options", ".", "endOk", ")", ")", ";", "let", "needleForIndexOf", ";", "let", "needleLength", ";", "function", "until", "(", "result", ",", "chunk", ",", "ended", ")", "{", "if", "(", "ended", ")", "{", "return", "endOK", "?", "(", "result", "?", "result", ".", "length", ":", "0", ")", ":", "-", "1", ";", "}", "if", "(", "Array", ".", "isArray", "(", "result", ")", ")", "{", "// objectMode. Use strict equality, like Array.prototype.indexOf", "return", "chunk", "===", "needle", "?", "result", ".", "length", ":", "-", "1", ";", "}", "// Calculate the length of the needle, as used by indexOf and perform the", "// type conversion done by indexOf once, to avoid converting on every call", "if", "(", "needleLength", "===", "undefined", ")", "{", "if", "(", "typeof", "result", "===", "'string'", ")", "{", "needleForIndexOf", "=", "String", "(", "needle", ")", ";", "needleLength", "=", "needleForIndexOf", ".", "length", ";", "}", "else", "if", "(", "result", "instanceof", "Buffer", ")", "{", "if", "(", "typeof", "needle", "===", "'number'", ")", "{", "// buffertools requires a Buffer or string", "// buffer-indexof-polyfill converts number to Buffer on each call", "needleForIndexOf", "=", "result", ".", "indexOf", "?", "needle", ":", "Buffer", ".", "from", "?", "Buffer", ".", "from", "(", "[", "needle", "]", ")", "// eslint-disable-next-line no-buffer-constructor", ":", "new", "Buffer", "(", "[", "needle", "]", ")", ";", "needleLength", "=", "1", ";", "}", "else", "if", "(", "typeof", "needle", "===", "'string'", ")", "{", "needleForIndexOf", "=", "needle", ";", "needleLength", "=", "Buffer", ".", "byteLength", "(", "needle", ")", ";", "}", "else", "if", "(", "needle", "instanceof", "Buffer", ")", "{", "needleForIndexOf", "=", "needle", ";", "needleLength", "=", "needle", ".", "length", ";", "}", "}", "if", "(", "needleLength", "===", "undefined", ")", "{", "throw", "new", "TypeError", "(", "`", "${", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "result", ")", "}", "${", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "needle", ")", "}", "`", ")", ";", "}", "// Buffer.prototype.indexOf returns -1 for 0-length string/Buffer.", "// To be consistent with string, we return 0.", "// Note: If removing this check, remove + 1 from start calc when 0.", "if", "(", "needleLength", "===", "0", ")", "{", "return", "0", ";", "}", "}", "const", "start", "=", "Math", ".", "max", "(", "(", "result", ".", "length", "-", "chunk", ".", "length", "-", "needleLength", ")", "+", "1", ",", "0", ")", ";", "const", "needleIndex", "=", "result", ".", "indexOf", "(", "needleForIndexOf", ",", "start", ")", ";", "if", "(", "needleIndex", "<", "0", ")", "{", "return", "-", "1", ";", "}", "return", "needleIndex", "+", "needleLength", ";", "}", "return", "readInternal", "(", "stream", ",", "undefined", ",", "until", ",", "options", ")", ";", "}" ]
Reads from a stream.Readable until a given value is found. <p>This function calls {@link readUntil} with an <code>until</code> function which uses <code>.indexOf</code> to search for <code>needle</code>. When reading Buffers and performance is paramount, consider using {@link readUntil} directly with an optional function for the problem (e.g. {@link https://www.npmjs.com/package/buffer-indexof-fast buffer-indexof-fast} for single-character search).</p> <p>Doc note: options should be a ReadToOptions type which extends {@link ReadOptions}, but record types can't currently be extended. See {@link https://github.com/google/closure-compiler/issues/604}.</p> @param {stream.Readable} stream Stream from which to read. @param {!Buffer|string|*} needle Value to search for in the read result. The stream will be read until this value is found or <code>'end'</code> or <code>'error'</code> is emitted. @param {ReadOptions=} options Options. This function additionally supports an <code>endOK</code> option which prevents {@link EOFError} on <code>'end'</code>. @return {Promise<Buffer|string|Array>| CancellableReadPromise<Buffer|string|Array>} Promise with the data read, up to and including <code>needle</code>, or an Error if one occurs. If <code>stream</code> does not support <code>unshift</code>, the result may include additional data. If <code>'end'</code> is emitted before <code>needle</code> is found, an {@link EOFError} is returned, unless <code>options.endOK</code> is truthy in which case any remaining data is returned or <code>null</code> if none was read. If an error occurs after reading some data, the <code>.read</code> property of the error object will contain the partial read result. The promise is resolved synchronously for streams in flowing mode (see README.md for details).
[ "Reads", "from", "a", "stream", ".", "Readable", "until", "a", "given", "value", "is", "found", "." ]
c6adf477f4a64d5142363d84f7f83f5f07b8f682
https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/index.js#L529-L591
49,368
kevinoid/promised-read
index.js
readToEnd
function readToEnd(stream, options) { function until(result, chunk, ended) { return ended; } return readInternal(stream, undefined, until, options); }
javascript
function readToEnd(stream, options) { function until(result, chunk, ended) { return ended; } return readInternal(stream, undefined, until, options); }
[ "function", "readToEnd", "(", "stream", ",", "options", ")", "{", "function", "until", "(", "result", ",", "chunk", ",", "ended", ")", "{", "return", "ended", ";", "}", "return", "readInternal", "(", "stream", ",", "undefined", ",", "until", ",", "options", ")", ";", "}" ]
Reads from a stream.Readable until 'end' is emitted. @param {stream.Readable} stream Stream from which to read. @param {ReadOptions=} options Options. @return {Promise<!Buffer|string|!Array>| CancellableReadPromise<!Buffer|string|!Array>} Promise with the data read, <code>null</code> if no data was read, or an <code>Error</code> if one occurred. If an error occurs after reading some data, the <code>.read</code> property of the error object will contain the partial read result. The promise is resolved synchronously for streams in flowing mode (see README.md for details).
[ "Reads", "from", "a", "stream", ".", "Readable", "until", "end", "is", "emitted", "." ]
c6adf477f4a64d5142363d84f7f83f5f07b8f682
https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/index.js#L604-L609
49,369
kevinoid/promised-read
index.js
readToMatch
function readToMatch(stream, regexp, options) { const endOK = Boolean(options && (options.endOK || options.endOk)); const maxMatchLen = Number(options && options.maxMatchLen); // Convert to RegExp where necessary, like String.prototype.match // Make sure RegExp has global flag so lastIndex will be set if (!(regexp instanceof RegExp)) { try { regexp = new RegExp(regexp, 'g'); } catch (errRegExp) { // Note: Synchronous Yaku emits unhandledRejection before returning. // Best current option is to use an async promise, even when flowing const ReadPromise = (options && options.Promise) || Promise; return ReadPromise.reject(errRegExp); } } else if (!regexp.global) { regexp = new RegExp(regexp.source, `${regexp.flags || ''}g`); } function until(result, chunk, ended) { if (ended) { return endOK ? (result ? result.length : 0) : -1; } if (typeof result !== 'string') { throw new TypeError('readToMatch requires a string stream' + ' (use constructor options.encoding or .setEncoding method)'); } regexp.lastIndex = maxMatchLen ? Math.max((result.length - chunk.length - maxMatchLen) + 1, 0) : 0; if (regexp.test(result)) { return regexp.lastIndex; } return -1; } return readInternal(stream, undefined, until, options); }
javascript
function readToMatch(stream, regexp, options) { const endOK = Boolean(options && (options.endOK || options.endOk)); const maxMatchLen = Number(options && options.maxMatchLen); // Convert to RegExp where necessary, like String.prototype.match // Make sure RegExp has global flag so lastIndex will be set if (!(regexp instanceof RegExp)) { try { regexp = new RegExp(regexp, 'g'); } catch (errRegExp) { // Note: Synchronous Yaku emits unhandledRejection before returning. // Best current option is to use an async promise, even when flowing const ReadPromise = (options && options.Promise) || Promise; return ReadPromise.reject(errRegExp); } } else if (!regexp.global) { regexp = new RegExp(regexp.source, `${regexp.flags || ''}g`); } function until(result, chunk, ended) { if (ended) { return endOK ? (result ? result.length : 0) : -1; } if (typeof result !== 'string') { throw new TypeError('readToMatch requires a string stream' + ' (use constructor options.encoding or .setEncoding method)'); } regexp.lastIndex = maxMatchLen ? Math.max((result.length - chunk.length - maxMatchLen) + 1, 0) : 0; if (regexp.test(result)) { return regexp.lastIndex; } return -1; } return readInternal(stream, undefined, until, options); }
[ "function", "readToMatch", "(", "stream", ",", "regexp", ",", "options", ")", "{", "const", "endOK", "=", "Boolean", "(", "options", "&&", "(", "options", ".", "endOK", "||", "options", ".", "endOk", ")", ")", ";", "const", "maxMatchLen", "=", "Number", "(", "options", "&&", "options", ".", "maxMatchLen", ")", ";", "// Convert to RegExp where necessary, like String.prototype.match", "// Make sure RegExp has global flag so lastIndex will be set", "if", "(", "!", "(", "regexp", "instanceof", "RegExp", ")", ")", "{", "try", "{", "regexp", "=", "new", "RegExp", "(", "regexp", ",", "'g'", ")", ";", "}", "catch", "(", "errRegExp", ")", "{", "// Note: Synchronous Yaku emits unhandledRejection before returning.", "// Best current option is to use an async promise, even when flowing", "const", "ReadPromise", "=", "(", "options", "&&", "options", ".", "Promise", ")", "||", "Promise", ";", "return", "ReadPromise", ".", "reject", "(", "errRegExp", ")", ";", "}", "}", "else", "if", "(", "!", "regexp", ".", "global", ")", "{", "regexp", "=", "new", "RegExp", "(", "regexp", ".", "source", ",", "`", "${", "regexp", ".", "flags", "||", "''", "}", "`", ")", ";", "}", "function", "until", "(", "result", ",", "chunk", ",", "ended", ")", "{", "if", "(", "ended", ")", "{", "return", "endOK", "?", "(", "result", "?", "result", ".", "length", ":", "0", ")", ":", "-", "1", ";", "}", "if", "(", "typeof", "result", "!==", "'string'", ")", "{", "throw", "new", "TypeError", "(", "'readToMatch requires a string stream'", "+", "' (use constructor options.encoding or .setEncoding method)'", ")", ";", "}", "regexp", ".", "lastIndex", "=", "maxMatchLen", "?", "Math", ".", "max", "(", "(", "result", ".", "length", "-", "chunk", ".", "length", "-", "maxMatchLen", ")", "+", "1", ",", "0", ")", ":", "0", ";", "if", "(", "regexp", ".", "test", "(", "result", ")", ")", "{", "return", "regexp", ".", "lastIndex", ";", "}", "return", "-", "1", ";", "}", "return", "readInternal", "(", "stream", ",", "undefined", ",", "until", ",", "options", ")", ";", "}" ]
Reads from a stream.Readable until a given expression is matched. <p>This function calls {@link readUntil} with an <code>until</code> function which applies <code>regexp</code> to the data read.</p> <p>Doc note: options should be a ReadToMatchOptions type which extends ReadToOptions, but record types can't currently be extended. See {@link https://github.com/google/closure-compiler/issues/604}.</p> @param {stream.Readable<string>} stream Stream from which to read. This stream must produce strings (so call <code>.setEncoding</code> if necessary). @param {!RegExp|string} regexp Expression to find in the read result. The stream will be read until this value is matched or <code>'end'</code> or <code>'error'</code> is emitted. @param {ReadOptions=} options Options. This function additionally supports an <code>endOK</code> option which prevents {@link EOFError} on <code>'end'</code> and a <code>maxMatchLen</code> option which specifies the maximum length of a match, which allow additional search optimizations. @return {Promise<string>|CancellableReadPromise<string>} Promise with the data read, up to and including the data matched by <code>regexp</code>, or an Error if one occurs. If <code>stream</code> does not support <code>unshift</code>, the result may include additional data. If <code>'end'</code> is emitted before <code>regexp</code> is matched, an {@link EOFError} is returned, unless <code>options.endOK</code> is truthy in which case any remaining data is returned or <code>null</code> if none was read. If an error occurs after reading some data, the <code>.read</code> property of the error object will contain the partial read result. The promise is resolved synchronously for streams in flowing mode (see README.md for details).
[ "Reads", "from", "a", "stream", ".", "Readable", "until", "a", "given", "expression", "is", "matched", "." ]
c6adf477f4a64d5142363d84f7f83f5f07b8f682
https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/index.js#L641-L678
49,370
HaroldPutman/hubot-taboo-topics
src/main.js
loadList
function loadList(brain) { const taboolist = brain.get("taboo"); if (taboolist != null) { for (let topic of taboolist) { taboo.set(topic, new RegExp(`\\b${topic}\\b`, "i")); } } }
javascript
function loadList(brain) { const taboolist = brain.get("taboo"); if (taboolist != null) { for (let topic of taboolist) { taboo.set(topic, new RegExp(`\\b${topic}\\b`, "i")); } } }
[ "function", "loadList", "(", "brain", ")", "{", "const", "taboolist", "=", "brain", ".", "get", "(", "\"taboo\"", ")", ";", "if", "(", "taboolist", "!=", "null", ")", "{", "for", "(", "let", "topic", "of", "taboolist", ")", "{", "taboo", ".", "set", "(", "topic", ",", "new", "RegExp", "(", "`", "\\\\", "${", "topic", "}", "\\\\", "`", ",", "\"i\"", ")", ")", ";", "}", "}", "}" ]
Recall the Taboo list from brain
[ "Recall", "the", "Taboo", "list", "from", "brain" ]
0868ce82cd259dd8701d4b069014d295811d6904
https://github.com/HaroldPutman/hubot-taboo-topics/blob/0868ce82cd259dd8701d4b069014d295811d6904/src/main.js#L44-L51
49,371
HaroldPutman/hubot-taboo-topics
src/main.js
saveList
function saveList(brain) { const taboolist = []; taboo.forEach((re, topic) => { taboolist.push(topic); }); brain.set("taboo", taboolist); }
javascript
function saveList(brain) { const taboolist = []; taboo.forEach((re, topic) => { taboolist.push(topic); }); brain.set("taboo", taboolist); }
[ "function", "saveList", "(", "brain", ")", "{", "const", "taboolist", "=", "[", "]", ";", "taboo", ".", "forEach", "(", "(", "re", ",", "topic", ")", "=>", "{", "taboolist", ".", "push", "(", "topic", ")", ";", "}", ")", ";", "brain", ".", "set", "(", "\"taboo\"", ",", "taboolist", ")", ";", "}" ]
Stores the taboolist in brain.
[ "Stores", "the", "taboolist", "in", "brain", "." ]
0868ce82cd259dd8701d4b069014d295811d6904
https://github.com/HaroldPutman/hubot-taboo-topics/blob/0868ce82cd259dd8701d4b069014d295811d6904/src/main.js#L80-L86
49,372
HaroldPutman/hubot-taboo-topics
src/main.js
deleteTopic
function deleteTopic(res, topic) { const keyTopic = topic.toLowerCase(); if (taboo.delete(keyTopic)) { res.reply(capitalize(`${topic} is no longer taboo`)); saveList(res.robot.brain); } else { res.reply(`Oops, ${topic} is not taboo`); } }
javascript
function deleteTopic(res, topic) { const keyTopic = topic.toLowerCase(); if (taboo.delete(keyTopic)) { res.reply(capitalize(`${topic} is no longer taboo`)); saveList(res.robot.brain); } else { res.reply(`Oops, ${topic} is not taboo`); } }
[ "function", "deleteTopic", "(", "res", ",", "topic", ")", "{", "const", "keyTopic", "=", "topic", ".", "toLowerCase", "(", ")", ";", "if", "(", "taboo", ".", "delete", "(", "keyTopic", ")", ")", "{", "res", ".", "reply", "(", "capitalize", "(", "`", "${", "topic", "}", "`", ")", ")", ";", "saveList", "(", "res", ".", "robot", ".", "brain", ")", ";", "}", "else", "{", "res", ".", "reply", "(", "`", "${", "topic", "}", "`", ")", ";", "}", "}" ]
Removes a topic from the taboo list.
[ "Removes", "a", "topic", "from", "the", "taboo", "list", "." ]
0868ce82cd259dd8701d4b069014d295811d6904
https://github.com/HaroldPutman/hubot-taboo-topics/blob/0868ce82cd259dd8701d4b069014d295811d6904/src/main.js#L91-L99
49,373
HaroldPutman/hubot-taboo-topics
src/main.js
addTopic
function addTopic(res, topic) { const keyTopic = topic.toLowerCase(); if (!taboo.has(keyTopic)) { taboo.set(keyTopic, new RegExp(`\\b${topic}\\b`, "i")); saveList(res.robot.brain); res.reply(capitalize(`${topic} is now taboo`)); } else { res.reply(`Oops, ${topic} is already taboo`); } }
javascript
function addTopic(res, topic) { const keyTopic = topic.toLowerCase(); if (!taboo.has(keyTopic)) { taboo.set(keyTopic, new RegExp(`\\b${topic}\\b`, "i")); saveList(res.robot.brain); res.reply(capitalize(`${topic} is now taboo`)); } else { res.reply(`Oops, ${topic} is already taboo`); } }
[ "function", "addTopic", "(", "res", ",", "topic", ")", "{", "const", "keyTopic", "=", "topic", ".", "toLowerCase", "(", ")", ";", "if", "(", "!", "taboo", ".", "has", "(", "keyTopic", ")", ")", "{", "taboo", ".", "set", "(", "keyTopic", ",", "new", "RegExp", "(", "`", "\\\\", "${", "topic", "}", "\\\\", "`", ",", "\"i\"", ")", ")", ";", "saveList", "(", "res", ".", "robot", ".", "brain", ")", ";", "res", ".", "reply", "(", "capitalize", "(", "`", "${", "topic", "}", "`", ")", ")", ";", "}", "else", "{", "res", ".", "reply", "(", "`", "${", "topic", "}", "`", ")", ";", "}", "}" ]
Adds a new taboo topic.
[ "Adds", "a", "new", "taboo", "topic", "." ]
0868ce82cd259dd8701d4b069014d295811d6904
https://github.com/HaroldPutman/hubot-taboo-topics/blob/0868ce82cd259dd8701d4b069014d295811d6904/src/main.js#L104-L113
49,374
HaroldPutman/hubot-taboo-topics
src/main.js
listTopics
function listTopics(res) { loadList(res.robot.brain); // Not necessary, but helps for testing. if (taboo.size == 0) { res.reply("Nothing is taboo here."); } else { let topics = []; taboo.forEach((re, topic) => { topics.push(topic); }) res.reply("Taboo topics are: " + topics.join(", ")); } }
javascript
function listTopics(res) { loadList(res.robot.brain); // Not necessary, but helps for testing. if (taboo.size == 0) { res.reply("Nothing is taboo here."); } else { let topics = []; taboo.forEach((re, topic) => { topics.push(topic); }) res.reply("Taboo topics are: " + topics.join(", ")); } }
[ "function", "listTopics", "(", "res", ")", "{", "loadList", "(", "res", ".", "robot", ".", "brain", ")", ";", "// Not necessary, but helps for testing.", "if", "(", "taboo", ".", "size", "==", "0", ")", "{", "res", ".", "reply", "(", "\"Nothing is taboo here.\"", ")", ";", "}", "else", "{", "let", "topics", "=", "[", "]", ";", "taboo", ".", "forEach", "(", "(", "re", ",", "topic", ")", "=>", "{", "topics", ".", "push", "(", "topic", ")", ";", "}", ")", "res", ".", "reply", "(", "\"Taboo topics are: \"", "+", "topics", ".", "join", "(", "\", \"", ")", ")", ";", "}", "}" ]
Lists all the taboo topics.
[ "Lists", "all", "the", "taboo", "topics", "." ]
0868ce82cd259dd8701d4b069014d295811d6904
https://github.com/HaroldPutman/hubot-taboo-topics/blob/0868ce82cd259dd8701d4b069014d295811d6904/src/main.js#L118-L129
49,375
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
extend
function extend(what, whit) { Object.keys(whit).forEach(function(key) { var def = whit[key]; if (what[key] === undefined) { if (def.get && def.set) { // TODO: look at element.dataset polyfill (iOS?) } else { what[key] = def; } } }); }
javascript
function extend(what, whit) { Object.keys(whit).forEach(function(key) { var def = whit[key]; if (what[key] === undefined) { if (def.get && def.set) { // TODO: look at element.dataset polyfill (iOS?) } else { what[key] = def; } } }); }
[ "function", "extend", "(", "what", ",", "whit", ")", "{", "Object", ".", "keys", "(", "whit", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "var", "def", "=", "whit", "[", "key", "]", ";", "if", "(", "what", "[", "key", "]", "===", "undefined", ")", "{", "if", "(", "def", ".", "get", "&&", "def", ".", "set", ")", "{", "// TODO: look at element.dataset polyfill (iOS?)", "}", "else", "{", "what", "[", "key", "]", "=", "def", ";", "}", "}", "}", ")", ";", "}" ]
Extend one object with another. @param {object} what Native prototype @param {object} whit Extension methods
[ "Extend", "one", "object", "with", "another", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L20-L31
49,376
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
strings
function strings() { extend(String.prototype, { trim: function() { return this.replace(/^\s*/, "").replace(/\s*$/, ""); }, repeat: function(n) { return new Array(n + 1).join(this); }, startsWith: function(sub) { return this.indexOf(sub) === 0; }, endsWith: function(sub) { sub = String(sub); var i = this.lastIndexOf(sub); return i >= 0 && i === this.length - sub.length; }, contains: function(sub) { return this.indexOf(sub) > -1; }, toArray: function() { return this.split(""); } }); }
javascript
function strings() { extend(String.prototype, { trim: function() { return this.replace(/^\s*/, "").replace(/\s*$/, ""); }, repeat: function(n) { return new Array(n + 1).join(this); }, startsWith: function(sub) { return this.indexOf(sub) === 0; }, endsWith: function(sub) { sub = String(sub); var i = this.lastIndexOf(sub); return i >= 0 && i === this.length - sub.length; }, contains: function(sub) { return this.indexOf(sub) > -1; }, toArray: function() { return this.split(""); } }); }
[ "function", "strings", "(", ")", "{", "extend", "(", "String", ".", "prototype", ",", "{", "trim", ":", "function", "(", ")", "{", "return", "this", ".", "replace", "(", "/", "^\\s*", "/", ",", "\"\"", ")", ".", "replace", "(", "/", "\\s*$", "/", ",", "\"\"", ")", ";", "}", ",", "repeat", ":", "function", "(", "n", ")", "{", "return", "new", "Array", "(", "n", "+", "1", ")", ".", "join", "(", "this", ")", ";", "}", ",", "startsWith", ":", "function", "(", "sub", ")", "{", "return", "this", ".", "indexOf", "(", "sub", ")", "===", "0", ";", "}", ",", "endsWith", ":", "function", "(", "sub", ")", "{", "sub", "=", "String", "(", "sub", ")", ";", "var", "i", "=", "this", ".", "lastIndexOf", "(", "sub", ")", ";", "return", "i", ">=", "0", "&&", "i", "===", "this", ".", "length", "-", "sub", ".", "length", ";", "}", ",", "contains", ":", "function", "(", "sub", ")", "{", "return", "this", ".", "indexOf", "(", "sub", ")", ">", "-", "1", ";", "}", ",", "toArray", ":", "function", "(", ")", "{", "return", "this", ".", "split", "(", "\"\"", ")", ";", "}", "}", ")", ";", "}" ]
Patching `String.prototype`
[ "Patching", "String", ".", "prototype" ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L36-L59
49,377
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
arrays
function arrays() { extend(Array, { every: function every(array, fun, thisp) { var res = true, len = array.length >>> 0; for (var i = 0; i < len; i++) { if (array[i] !== undefined) { if (!fun.call(thisp, array[i], i, array)) { res = false; break; } } } return res; }, forEach: function forEach(array, fun, thisp) { var len = array.length >>> 0; for (var i = 0; i < len; i++) { if (array[i] !== undefined) { fun.call(thisp, array[i], i, array); } } }, map: function map(array, fun, thisp) { var m = [], len = array.length >>> 0; for (var i = 0; i < len; i++) { if (array[i] !== undefined) { m.push(fun.call(thisp, array[i], i, array)); } } return m; }, filter: function map(array, fun, thisp) { return Array.prototype.filter.call(array, fun, thisp); }, isArray: function isArray(o) { return Object.prototype.toString.call(o) === "[object Array]"; }, concat: function(a1, a2) { function map(e) { return e; } return this.map(a1, map).concat(this.map(a2, map)); } }); }
javascript
function arrays() { extend(Array, { every: function every(array, fun, thisp) { var res = true, len = array.length >>> 0; for (var i = 0; i < len; i++) { if (array[i] !== undefined) { if (!fun.call(thisp, array[i], i, array)) { res = false; break; } } } return res; }, forEach: function forEach(array, fun, thisp) { var len = array.length >>> 0; for (var i = 0; i < len; i++) { if (array[i] !== undefined) { fun.call(thisp, array[i], i, array); } } }, map: function map(array, fun, thisp) { var m = [], len = array.length >>> 0; for (var i = 0; i < len; i++) { if (array[i] !== undefined) { m.push(fun.call(thisp, array[i], i, array)); } } return m; }, filter: function map(array, fun, thisp) { return Array.prototype.filter.call(array, fun, thisp); }, isArray: function isArray(o) { return Object.prototype.toString.call(o) === "[object Array]"; }, concat: function(a1, a2) { function map(e) { return e; } return this.map(a1, map).concat(this.map(a2, map)); } }); }
[ "function", "arrays", "(", ")", "{", "extend", "(", "Array", ",", "{", "every", ":", "function", "every", "(", "array", ",", "fun", ",", "thisp", ")", "{", "var", "res", "=", "true", ",", "len", "=", "array", ".", "length", ">>>", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "array", "[", "i", "]", "!==", "undefined", ")", "{", "if", "(", "!", "fun", ".", "call", "(", "thisp", ",", "array", "[", "i", "]", ",", "i", ",", "array", ")", ")", "{", "res", "=", "false", ";", "break", ";", "}", "}", "}", "return", "res", ";", "}", ",", "forEach", ":", "function", "forEach", "(", "array", ",", "fun", ",", "thisp", ")", "{", "var", "len", "=", "array", ".", "length", ">>>", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "array", "[", "i", "]", "!==", "undefined", ")", "{", "fun", ".", "call", "(", "thisp", ",", "array", "[", "i", "]", ",", "i", ",", "array", ")", ";", "}", "}", "}", ",", "map", ":", "function", "map", "(", "array", ",", "fun", ",", "thisp", ")", "{", "var", "m", "=", "[", "]", ",", "len", "=", "array", ".", "length", ">>>", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "array", "[", "i", "]", "!==", "undefined", ")", "{", "m", ".", "push", "(", "fun", ".", "call", "(", "thisp", ",", "array", "[", "i", "]", ",", "i", ",", "array", ")", ")", ";", "}", "}", "return", "m", ";", "}", ",", "filter", ":", "function", "map", "(", "array", ",", "fun", ",", "thisp", ")", "{", "return", "Array", ".", "prototype", ".", "filter", ".", "call", "(", "array", ",", "fun", ",", "thisp", ")", ";", "}", ",", "isArray", ":", "function", "isArray", "(", "o", ")", "{", "return", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "o", ")", "===", "\"[object Array]\"", ";", "}", ",", "concat", ":", "function", "(", "a1", ",", "a2", ")", "{", "function", "map", "(", "e", ")", "{", "return", "e", ";", "}", "return", "this", ".", "map", "(", "a1", ",", "map", ")", ".", "concat", "(", "this", ".", "map", "(", "a2", ",", "map", ")", ")", ";", "}", "}", ")", ";", "}" ]
Patching arrays.
[ "Patching", "arrays", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L64-L110
49,378
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(action, thisp) { var is = this.initialized; if (arguments.length) { if (is) { action.call(thisp); } else { this._initcallbacks = this._initcallbacks || []; this._initcallbacks.push(function() { if (gui.debug) { try { action.call(thisp); } catch (exception) { console.error(action.toString()); throw exception; } } else { action.call(thisp); } }); } } return is; }
javascript
function(action, thisp) { var is = this.initialized; if (arguments.length) { if (is) { action.call(thisp); } else { this._initcallbacks = this._initcallbacks || []; this._initcallbacks.push(function() { if (gui.debug) { try { action.call(thisp); } catch (exception) { console.error(action.toString()); throw exception; } } else { action.call(thisp); } }); } } return is; }
[ "function", "(", "action", ",", "thisp", ")", "{", "var", "is", "=", "this", ".", "initialized", ";", "if", "(", "arguments", ".", "length", ")", "{", "if", "(", "is", ")", "{", "action", ".", "call", "(", "thisp", ")", ";", "}", "else", "{", "this", ".", "_initcallbacks", "=", "this", ".", "_initcallbacks", "||", "[", "]", ";", "this", ".", "_initcallbacks", ".", "push", "(", "function", "(", ")", "{", "if", "(", "gui", ".", "debug", ")", "{", "try", "{", "action", ".", "call", "(", "thisp", ")", ";", "}", "catch", "(", "exception", ")", "{", "console", ".", "error", "(", "action", ".", "toString", "(", ")", ")", ";", "throw", "exception", ";", "}", "}", "else", "{", "action", ".", "call", "(", "thisp", ")", ";", "}", "}", ")", ";", "}", "}", "return", "is", ";", "}" ]
Do something before the spirits get here. if that's already too late, just do it now. @param @optional {function} action @param @optional {object} thisp @returns {boolean} True when ready already
[ "Do", "something", "before", "the", "spirits", "get", "here", ".", "if", "that", "s", "already", "too", "late", "just", "do", "it", "now", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L531-L553
49,379
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(action, thisp) { this.init(action, thisp); if(gui.debug) { console.warn('gui.ready() is for spirits, use gui.init()'); } return false; }
javascript
function(action, thisp) { this.init(action, thisp); if(gui.debug) { console.warn('gui.ready() is for spirits, use gui.init()'); } return false; }
[ "function", "(", "action", ",", "thisp", ")", "{", "this", ".", "init", "(", "action", ",", "thisp", ")", ";", "if", "(", "gui", ".", "debug", ")", "{", "console", ".", "warn", "(", "'gui.ready() is for spirits, use gui.init()'", ")", ";", "}", "return", "false", ";", "}" ]
Featured in [email protected] @param @optional {function} action @param @optional {object} thisp @returns {boolean} True when ready already (so false)
[ "Featured", "in", "core", "-", "spirits" ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L561-L567
49,380
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(name, module) { var Module; if (gui.Type.isString(name) && name.length) { Module = gui.Module.extend(name, module || {}); module = gui.Module.$register(new Module(name)); return module; } else { throw new Error("Module needs an identity token"); } }
javascript
function(name, module) { var Module; if (gui.Type.isString(name) && name.length) { Module = gui.Module.extend(name, module || {}); module = gui.Module.$register(new Module(name)); return module; } else { throw new Error("Module needs an identity token"); } }
[ "function", "(", "name", ",", "module", ")", "{", "var", "Module", ";", "if", "(", "gui", ".", "Type", ".", "isString", "(", "name", ")", "&&", "name", ".", "length", ")", "{", "Module", "=", "gui", ".", "Module", ".", "extend", "(", "name", ",", "module", "||", "{", "}", ")", ";", "module", "=", "gui", ".", "Module", ".", "$register", "(", "new", "Module", "(", "name", ")", ")", ";", "return", "module", ";", "}", "else", "{", "throw", "new", "Error", "(", "\"Module needs an identity token\"", ")", ";", "}", "}" ]
Register module. @param {String} name @param {object} module @returns {gui.Module}
[ "Register", "module", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L575-L584
49,381
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(ns, members) { var no; if (gui.Type.isString(ns)) { no = gui.Object.lookup(ns); no = new gui.Namespace(ns); no = gui.Object.assert(ns, no); } else { throw new TypeError("Expected a namespace string"); } return gui.Object.extend(no, members || {}); }
javascript
function(ns, members) { var no; if (gui.Type.isString(ns)) { no = gui.Object.lookup(ns); no = new gui.Namespace(ns); no = gui.Object.assert(ns, no); } else { throw new TypeError("Expected a namespace string"); } return gui.Object.extend(no, members || {}); }
[ "function", "(", "ns", ",", "members", ")", "{", "var", "no", ";", "if", "(", "gui", ".", "Type", ".", "isString", "(", "ns", ")", ")", "{", "no", "=", "gui", ".", "Object", ".", "lookup", "(", "ns", ")", ";", "no", "=", "new", "gui", ".", "Namespace", "(", "ns", ")", ";", "no", "=", "gui", ".", "Object", ".", "assert", "(", "ns", ",", "no", ")", ";", "}", "else", "{", "throw", "new", "TypeError", "(", "\"Expected a namespace string\"", ")", ";", "}", "return", "gui", ".", "Object", ".", "extend", "(", "no", ",", "members", "||", "{", "}", ")", ";", "}" ]
Declare namespace. Optionally add members. @param {String} ns @param {Map<String,object>} members @returns {gui.Namespace}
[ "Declare", "namespace", ".", "Optionally", "add", "members", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L622-L632
49,382
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(msg, arg) { if (gui.Type.isEvent(arg)) { arg = new gui.EventSummary(arg); } gui.Broadcast.dispatchGlobal(msg, arg); }
javascript
function(msg, arg) { if (gui.Type.isEvent(arg)) { arg = new gui.EventSummary(arg); } gui.Broadcast.dispatchGlobal(msg, arg); }
[ "function", "(", "msg", ",", "arg", ")", "{", "if", "(", "gui", ".", "Type", ".", "isEvent", "(", "arg", ")", ")", "{", "arg", "=", "new", "gui", ".", "EventSummary", "(", "arg", ")", ";", "}", "gui", ".", "Broadcast", ".", "dispatchGlobal", "(", "msg", ",", "arg", ")", ";", "}" ]
Broadcast something globally. Events will be wrapped in an EventSummary. @param {String} message gui.BROADCAST_MOUSECLICK or similar @param @optional {object} arg This could well be a MouseEvent
[ "Broadcast", "something", "globally", ".", "Events", "will", "be", "wrapped", "in", "an", "EventSummary", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L639-L644
49,383
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(o, name) { gui.Object.each(o, function(key, value) { if (key !== "$superclass" && gui.Type.isConstructor(value)) { if (value.$classname === gui.Class.ANONYMOUS) { Object.defineProperty(value, '$classname', { value: name + "." + key, enumerable: true, writable: false }); this._spacename(value, name + "." + key); } } }, this); }
javascript
function(o, name) { gui.Object.each(o, function(key, value) { if (key !== "$superclass" && gui.Type.isConstructor(value)) { if (value.$classname === gui.Class.ANONYMOUS) { Object.defineProperty(value, '$classname', { value: name + "." + key, enumerable: true, writable: false }); this._spacename(value, name + "." + key); } } }, this); }
[ "function", "(", "o", ",", "name", ")", "{", "gui", ".", "Object", ".", "each", "(", "o", ",", "function", "(", "key", ",", "value", ")", "{", "if", "(", "key", "!==", "\"$superclass\"", "&&", "gui", ".", "Type", ".", "isConstructor", "(", "value", ")", ")", "{", "if", "(", "value", ".", "$classname", "===", "gui", ".", "Class", ".", "ANONYMOUS", ")", "{", "Object", ".", "defineProperty", "(", "value", ",", "'$classname'", ",", "{", "value", ":", "name", "+", "\".\"", "+", "key", ",", "enumerable", ":", "true", ",", "writable", ":", "false", "}", ")", ";", "this", ".", "_spacename", "(", "value", ",", "name", "+", "\".\"", "+", "key", ")", ";", "}", "}", "}", ",", "this", ")", ";", "}" ]
Name members recursively. @param {object|function} o @param {String} name
[ "Name", "members", "recursively", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L749-L762
49,384
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(string) { var hit = null, looks = false; if (gui.Type.isString(string)) { hit = this.extractKey(string); looks = hit && hit[0] === string; } return looks; }
javascript
function(string) { var hit = null, looks = false; if (gui.Type.isString(string)) { hit = this.extractKey(string); looks = hit && hit[0] === string; } return looks; }
[ "function", "(", "string", ")", "{", "var", "hit", "=", "null", ",", "looks", "=", "false", ";", "if", "(", "gui", ".", "Type", ".", "isString", "(", "string", ")", ")", "{", "hit", "=", "this", ".", "extractKey", "(", "string", ")", ";", "looks", "=", "hit", "&&", "hit", "[", "0", "]", "===", "string", ";", "}", "return", "looks", ";", "}" ]
String appears to be a generated key? We don't look it up in the key cache, so this method can be used to check a key that was generated in old session. @param {String} string @returns {boolean}
[ "String", "appears", "to", "be", "a", "generated", "key?", "We", "don", "t", "look", "it", "up", "in", "the", "key", "cache", "so", "this", "method", "can", "be", "used", "to", "check", "a", "key", "that", "was", "generated", "in", "old", "session", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L811-L819
49,385
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(proto, props) { var resolved = {}; Object.keys(props).forEach(function(prop) { resolved[prop] = { value: props[prop], writable: true, enumerable: true, configurable: true }; }); return Object.create(proto, resolved); }
javascript
function(proto, props) { var resolved = {}; Object.keys(props).forEach(function(prop) { resolved[prop] = { value: props[prop], writable: true, enumerable: true, configurable: true }; }); return Object.create(proto, resolved); }
[ "function", "(", "proto", ",", "props", ")", "{", "var", "resolved", "=", "{", "}", ";", "Object", ".", "keys", "(", "props", ")", ".", "forEach", "(", "function", "(", "prop", ")", "{", "resolved", "[", "prop", "]", "=", "{", "value", ":", "props", "[", "prop", "]", ",", "writable", ":", "true", ",", "enumerable", ":", "true", ",", "configurable", ":", "true", "}", ";", "}", ")", ";", "return", "Object", ".", "create", "(", "proto", ",", "resolved", ")", ";", "}" ]
Object.create with default property descriptors. @see http://wiki.ecmascript.org/doku.php?id=strawman:define_properties_operator @param {object} proto @param {object} props
[ "Object", ".", "create", "with", "default", "property", "descriptors", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L854-L865
49,386
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(source, domap, thisp) { var result = {}, mapping; this.each(source, function(key, value) { mapping = domap.call(thisp, key, value); if (mapping !== undefined) { result[key] = mapping; } }); return result; }
javascript
function(source, domap, thisp) { var result = {}, mapping; this.each(source, function(key, value) { mapping = domap.call(thisp, key, value); if (mapping !== undefined) { result[key] = mapping; } }); return result; }
[ "function", "(", "source", ",", "domap", ",", "thisp", ")", "{", "var", "result", "=", "{", "}", ",", "mapping", ";", "this", ".", "each", "(", "source", ",", "function", "(", "key", ",", "value", ")", "{", "mapping", "=", "domap", ".", "call", "(", "thisp", ",", "key", ",", "value", ")", ";", "if", "(", "mapping", "!==", "undefined", ")", "{", "result", "[", "key", "]", "=", "mapping", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Create new object by passing all property names and values through a resolver call. Eliminate values that map to `undefined`. @param {object} source @param {function} domap @param @optional {object} thisp @returns {object}
[ "Create", "new", "object", "by", "passing", "all", "property", "names", "and", "values", "through", "a", "resolver", "call", ".", "Eliminate", "values", "that", "map", "to", "undefined", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L957-L967
49,387
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(opath, context) { var result, struct = context || self; if (gui.Type.isString(opath)) { if (!opath.contains(".")) { result = struct[opath]; } else { var parts = opath.split("."); parts.every(function(part) { struct = struct[part]; return gui.Type.isDefined(struct); }); result = struct; } } else { throw new TypeError("Expected string, got " + gui.Type.of(opath)); } return result; }
javascript
function(opath, context) { var result, struct = context || self; if (gui.Type.isString(opath)) { if (!opath.contains(".")) { result = struct[opath]; } else { var parts = opath.split("."); parts.every(function(part) { struct = struct[part]; return gui.Type.isDefined(struct); }); result = struct; } } else { throw new TypeError("Expected string, got " + gui.Type.of(opath)); } return result; }
[ "function", "(", "opath", ",", "context", ")", "{", "var", "result", ",", "struct", "=", "context", "||", "self", ";", "if", "(", "gui", ".", "Type", ".", "isString", "(", "opath", ")", ")", "{", "if", "(", "!", "opath", ".", "contains", "(", "\".\"", ")", ")", "{", "result", "=", "struct", "[", "opath", "]", ";", "}", "else", "{", "var", "parts", "=", "opath", ".", "split", "(", "\".\"", ")", ";", "parts", ".", "every", "(", "function", "(", "part", ")", "{", "struct", "=", "struct", "[", "part", "]", ";", "return", "gui", ".", "Type", ".", "isDefined", "(", "struct", ")", ";", "}", ")", ";", "result", "=", "struct", ";", "}", "}", "else", "{", "throw", "new", "TypeError", "(", "\"Expected string, got \"", "+", "gui", ".", "Type", ".", "of", "(", "opath", ")", ")", ";", "}", "return", "result", ";", "}" ]
Lookup object for string of type "my.ns.Thing" in given context or this window. @param {String} opath Object path eg. "my.ns.Thing" @param @optional {Window} context @returns {object}
[ "Lookup", "object", "for", "string", "of", "type", "my", ".", "ns", ".", "Thing", "in", "given", "context", "or", "this", "window", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L975-L992
49,388
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(desc) { if (desc.value && gui.Type.isFunction(desc.value)) { if (desc.value.$hidden && desc.configurable) { desc.enumerable = false; } } return desc; }
javascript
function(desc) { if (desc.value && gui.Type.isFunction(desc.value)) { if (desc.value.$hidden && desc.configurable) { desc.enumerable = false; } } return desc; }
[ "function", "(", "desc", ")", "{", "if", "(", "desc", ".", "value", "&&", "gui", ".", "Type", ".", "isFunction", "(", "desc", ".", "value", ")", ")", "{", "if", "(", "desc", ".", "value", ".", "$hidden", "&&", "desc", ".", "configurable", ")", "{", "desc", ".", "enumerable", "=", "false", ";", "}", "}", "return", "desc", ";", "}" ]
Modify method descriptor to hide from inspection. Do note that the method may still be called upon. @param {object} desc @returns {object}
[ "Modify", "method", "descriptor", "to", "hide", "from", "inspection", ".", "Do", "note", "that", "the", "method", "may", "still", "be", "called", "upon", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1117-L1124
49,389
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(o) { var type = ({}).toString.call(o).match(this._typeexp)[1].toLowerCase(); if (type === "domwindow" && String(typeof o) === "undefined") { type = "undefined"; // some kind of degenerate bug in Safari on iPad } return type; }
javascript
function(o) { var type = ({}).toString.call(o).match(this._typeexp)[1].toLowerCase(); if (type === "domwindow" && String(typeof o) === "undefined") { type = "undefined"; // some kind of degenerate bug in Safari on iPad } return type; }
[ "function", "(", "o", ")", "{", "var", "type", "=", "(", "{", "}", ")", ".", "toString", ".", "call", "(", "o", ")", ".", "match", "(", "this", ".", "_typeexp", ")", "[", "1", "]", ".", "toLowerCase", "(", ")", ";", "if", "(", "type", "===", "\"domwindow\"", "&&", "String", "(", "typeof", "o", ")", "===", "\"undefined\"", ")", "{", "type", "=", "\"undefined\"", ";", "// some kind of degenerate bug in Safari on iPad", "}", "return", "type", ";", "}" ]
Get type of argument. Note that response may differ between user agents. @see http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator @param {object} o @returns {String}
[ "Get", "type", "of", "argument", ".", "Note", "that", "response", "may", "differ", "between", "user", "agents", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1140-L1146
49,390
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(o) { return o && o.document && o.location && o.alert && o.setInterval; }
javascript
function(o) { return o && o.document && o.location && o.alert && o.setInterval; }
[ "function", "(", "o", ")", "{", "return", "o", "&&", "o", ".", "document", "&&", "o", ".", "location", "&&", "o", ".", "alert", "&&", "o", ".", "setInterval", ";", "}" ]
Is Window object? @param {object} o @returns {boolean}
[ "Is", "Window", "object?" ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1180-L1182
49,391
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(what) { return this.isFunction(what) && this.isObject(what.prototype) && Object.keys(what.prototype).length; }
javascript
function(what) { return this.isFunction(what) && this.isObject(what.prototype) && Object.keys(what.prototype).length; }
[ "function", "(", "what", ")", "{", "return", "this", ".", "isFunction", "(", "what", ")", "&&", "this", ".", "isObject", "(", "what", ".", "prototype", ")", "&&", "Object", ".", "keys", "(", "what", ".", "prototype", ")", ".", "length", ";", "}" ]
Is function fit to be invoked via the "new" operator? We assume so if the prototype reveals any properties. @param {function} what @returns {boolean}
[ "Is", "function", "fit", "to", "be", "invoked", "via", "the", "new", "operator?", "We", "assume", "so", "if", "the", "prototype", "reveals", "any", "properties", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1226-L1230
49,392
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(string) { var result = String(string); switch (result) { case "null": result = null; break; case "true": case "false": result = (result === "true"); break; default: if (String(parseInt(result, 10)) === result) { result = parseInt(result, 10); } else if (String(parseFloat(result)) === result) { result = parseFloat(result); } break; } return result; }
javascript
function(string) { var result = String(string); switch (result) { case "null": result = null; break; case "true": case "false": result = (result === "true"); break; default: if (String(parseInt(result, 10)) === result) { result = parseInt(result, 10); } else if (String(parseFloat(result)) === result) { result = parseFloat(result); } break; } return result; }
[ "function", "(", "string", ")", "{", "var", "result", "=", "String", "(", "string", ")", ";", "switch", "(", "result", ")", "{", "case", "\"null\"", ":", "result", "=", "null", ";", "break", ";", "case", "\"true\"", ":", "case", "\"false\"", ":", "result", "=", "(", "result", "===", "\"true\"", ")", ";", "break", ";", "default", ":", "if", "(", "String", "(", "parseInt", "(", "result", ",", "10", ")", ")", "===", "result", ")", "{", "result", "=", "parseInt", "(", "result", ",", "10", ")", ";", "}", "else", "if", "(", "String", "(", "parseFloat", "(", "result", ")", ")", "===", "result", ")", "{", "result", "=", "parseFloat", "(", "result", ")", ";", "}", "break", ";", "}", "return", "result", ";", "}" ]
Autocast string to an inferred type. "123" will return a number, "false" will return a boolean. @param {String} string @returns {object}
[ "Autocast", "string", "to", "an", "inferred", "type", ".", "123", "will", "return", "a", "number", "false", "will", "return", "a", "boolean", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1265-L1284
49,393
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(/* ...types */) { var types = gui.Array.from(arguments); return function(action) { return function() { if (gui.Arguments._match(arguments, types)) { return action.apply(this, arguments); } }; }; }
javascript
function(/* ...types */) { var types = gui.Array.from(arguments); return function(action) { return function() { if (gui.Arguments._match(arguments, types)) { return action.apply(this, arguments); } }; }; }
[ "function", "(", "/* ...types */", ")", "{", "var", "types", "=", "gui", ".", "Array", ".", "from", "(", "arguments", ")", ";", "return", "function", "(", "action", ")", "{", "return", "function", "(", ")", "{", "if", "(", "gui", ".", "Arguments", ".", "_match", "(", "arguments", ",", "types", ")", ")", "{", "return", "action", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "}", ";", "}", ";", "}" ]
Forgiving arguments matcher. Ignores action if no match.
[ "Forgiving", "arguments", "matcher", ".", "Ignores", "action", "if", "no", "match", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1428-L1437
49,394
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(/* ...types */) { var types = gui.Array.from(arguments); return function(action) { return function() { if (gui.Arguments._validate(arguments, types)) { return action.apply(this, arguments); } else { gui.Arguments._abort(this); } }; }; }
javascript
function(/* ...types */) { var types = gui.Array.from(arguments); return function(action) { return function() { if (gui.Arguments._validate(arguments, types)) { return action.apply(this, arguments); } else { gui.Arguments._abort(this); } }; }; }
[ "function", "(", "/* ...types */", ")", "{", "var", "types", "=", "gui", ".", "Array", ".", "from", "(", "arguments", ")", ";", "return", "function", "(", "action", ")", "{", "return", "function", "(", ")", "{", "if", "(", "gui", ".", "Arguments", ".", "_validate", "(", "arguments", ",", "types", ")", ")", "{", "return", "action", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "else", "{", "gui", ".", "Arguments", ".", "_abort", "(", "this", ")", ";", "}", "}", ";", "}", ";", "}" ]
Revengeful arguments validator. Throws an exception if no match.
[ "Revengeful", "arguments", "validator", ".", "Throws", "an", "exception", "if", "no", "match", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1443-L1454
49,395
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(xpect, arg, index) { var needs = !xpect.startsWith("("); var split = this._xtract(xpect, !needs).split("|"); var input = gui.Type.of(arg); var match = (xpect === "*" || (xpect === 'node' && arg && arg.nodeType) || (xpect === 'element' && arg && arg.nodeType === Node.ELEMENT_NODE) || (xpect === 'spirit' && arg && arg.$instanceid && arg.element) || (!needs && input === "undefined") || (!needs && split.indexOf("*") > -1) || split.indexOf(input) > -1); if (!match && this._validating) { if (input === "string") { arg = '"' + arg + '"'; } this._bugsummary = [index, xpect, input, arg]; } return match; }
javascript
function(xpect, arg, index) { var needs = !xpect.startsWith("("); var split = this._xtract(xpect, !needs).split("|"); var input = gui.Type.of(arg); var match = (xpect === "*" || (xpect === 'node' && arg && arg.nodeType) || (xpect === 'element' && arg && arg.nodeType === Node.ELEMENT_NODE) || (xpect === 'spirit' && arg && arg.$instanceid && arg.element) || (!needs && input === "undefined") || (!needs && split.indexOf("*") > -1) || split.indexOf(input) > -1); if (!match && this._validating) { if (input === "string") { arg = '"' + arg + '"'; } this._bugsummary = [index, xpect, input, arg]; } return match; }
[ "function", "(", "xpect", ",", "arg", ",", "index", ")", "{", "var", "needs", "=", "!", "xpect", ".", "startsWith", "(", "\"(\"", ")", ";", "var", "split", "=", "this", ".", "_xtract", "(", "xpect", ",", "!", "needs", ")", ".", "split", "(", "\"|\"", ")", ";", "var", "input", "=", "gui", ".", "Type", ".", "of", "(", "arg", ")", ";", "var", "match", "=", "(", "xpect", "===", "\"*\"", "||", "(", "xpect", "===", "'node'", "&&", "arg", "&&", "arg", ".", "nodeType", ")", "||", "(", "xpect", "===", "'element'", "&&", "arg", "&&", "arg", ".", "nodeType", "===", "Node", ".", "ELEMENT_NODE", ")", "||", "(", "xpect", "===", "'spirit'", "&&", "arg", "&&", "arg", ".", "$instanceid", "&&", "arg", ".", "element", ")", "||", "(", "!", "needs", "&&", "input", "===", "\"undefined\"", ")", "||", "(", "!", "needs", "&&", "split", ".", "indexOf", "(", "\"*\"", ")", ">", "-", "1", ")", "||", "split", ".", "indexOf", "(", "input", ")", ">", "-", "1", ")", ";", "if", "(", "!", "match", "&&", "this", ".", "_validating", ")", "{", "if", "(", "input", "===", "\"string\"", ")", "{", "arg", "=", "'\"'", "+", "arg", "+", "'\"'", ";", "}", "this", ".", "_bugsummary", "=", "[", "index", ",", "xpect", ",", "input", ",", "arg", "]", ";", "}", "return", "match", ";", "}" ]
Check if argument matches expected type. @param {string} xpect @param {object} arg @param {number} index @returns {boolean}
[ "Check", "if", "argument", "matches", "expected", "type", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1515-L1533
49,396
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(that) { var summ = this._bugsummary; var name = that.constructor.$classname || String(that); console.error([ "Bad argument " + summ.shift(), "for " + name + ":", "Expected " + summ.shift() + ",", "got " + summ.shift() + ":", summ.shift() ].join(" ")); }
javascript
function(that) { var summ = this._bugsummary; var name = that.constructor.$classname || String(that); console.error([ "Bad argument " + summ.shift(), "for " + name + ":", "Expected " + summ.shift() + ",", "got " + summ.shift() + ":", summ.shift() ].join(" ")); }
[ "function", "(", "that", ")", "{", "var", "summ", "=", "this", ".", "_bugsummary", ";", "var", "name", "=", "that", ".", "constructor", ".", "$classname", "||", "String", "(", "that", ")", ";", "console", ".", "error", "(", "[", "\"Bad argument \"", "+", "summ", ".", "shift", "(", ")", ",", "\"for \"", "+", "name", "+", "\":\"", ",", "\"Expected \"", "+", "summ", ".", "shift", "(", ")", "+", "\",\"", ",", "\"got \"", "+", "summ", ".", "shift", "(", ")", "+", "\":\"", ",", "summ", ".", "shift", "(", ")", "]", ".", "join", "(", "\" \"", ")", ")", ";", "}" ]
Throw exception. @TODO: Rig up to report offended methods name. @param {object} that @param {Array<String>} report
[ "Throw", "exception", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1541-L1551
49,397
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(name, params, body, context) { var F = context ? context.Function : Function; name = this.safename(name); params = params ? params.join(",") : ""; body = body || ""; return new F( "return function " + name + " ( " + params + " ) {" + body + "}" )(); }
javascript
function(name, params, body, context) { var F = context ? context.Function : Function; name = this.safename(name); params = params ? params.join(",") : ""; body = body || ""; return new F( "return function " + name + " ( " + params + " ) {" + body + "}" )(); }
[ "function", "(", "name", ",", "params", ",", "body", ",", "context", ")", "{", "var", "F", "=", "context", "?", "context", ".", "Function", ":", "Function", ";", "name", "=", "this", ".", "safename", "(", "name", ")", ";", "params", "=", "params", "?", "params", ".", "join", "(", "\",\"", ")", ":", "\"\"", ";", "body", "=", "body", "||", "\"\"", ";", "return", "new", "F", "(", "\"return function \"", "+", "name", "+", "\" ( \"", "+", "params", "+", "\" ) {\"", "+", "body", "+", "\"}\"", ")", "(", ")", ";", "}" ]
Create named function. This may not be the most optimized thing to compile. @see https://mail.mozilla.org/pipermail/es-discuss/2009-March/008954.html @see http://wiki.ecmascript.org/doku.php?id=strawman:name_property_of_functions @param @optional {String} name @param @optional {Array<String>} params @param @optional {String} body @param @optional {Window} context @returns {function}
[ "Create", "named", "function", ".", "This", "may", "not", "be", "the", "most", "optimized", "thing", "to", "compile", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1571-L1579
49,398
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function() { var b = this._breakdown_base(arguments); var C = this._createclass(null, b.proto, b.name); gui.Object.extend(C.prototype, b.protos); gui.Object.extend(C, b.statics); gui.Property.extendall(b.protos, C.prototype); if (b.recurring) { gui.Object.each(b.recurring, function(key, val) { var desc = Object.getOwnPropertyDescriptor(C, key); if (!desc || desc.writable) { C[key] = C.$recurring[key] = val; } }); } return C; }
javascript
function() { var b = this._breakdown_base(arguments); var C = this._createclass(null, b.proto, b.name); gui.Object.extend(C.prototype, b.protos); gui.Object.extend(C, b.statics); gui.Property.extendall(b.protos, C.prototype); if (b.recurring) { gui.Object.each(b.recurring, function(key, val) { var desc = Object.getOwnPropertyDescriptor(C, key); if (!desc || desc.writable) { C[key] = C.$recurring[key] = val; } }); } return C; }
[ "function", "(", ")", "{", "var", "b", "=", "this", ".", "_breakdown_base", "(", "arguments", ")", ";", "var", "C", "=", "this", ".", "_createclass", "(", "null", ",", "b", ".", "proto", ",", "b", ".", "name", ")", ";", "gui", ".", "Object", ".", "extend", "(", "C", ".", "prototype", ",", "b", ".", "protos", ")", ";", "gui", ".", "Object", ".", "extend", "(", "C", ",", "b", ".", "statics", ")", ";", "gui", ".", "Property", ".", "extendall", "(", "b", ".", "protos", ",", "C", ".", "prototype", ")", ";", "if", "(", "b", ".", "recurring", ")", "{", "gui", ".", "Object", ".", "each", "(", "b", ".", "recurring", ",", "function", "(", "key", ",", "val", ")", "{", "var", "desc", "=", "Object", ".", "getOwnPropertyDescriptor", "(", "C", ",", "key", ")", ";", "if", "(", "!", "desc", "||", "desc", ".", "writable", ")", "{", "C", "[", "key", "]", "=", "C", ".", "$recurring", "[", "key", "]", "=", "val", ";", "}", "}", ")", ";", "}", "return", "C", ";", "}" ]
Create constructor. Use method `extend` on the constructor to subclass further. @param @optional {String} name @param {object} proto Base prototype @param {object} protos Prototype extensions @param {object} recurring Constructor and subconstructor extensions @param {object} statics Constructor extensions @returns {function}
[ "Create", "constructor", ".", "Use", "method", "extend", "on", "the", "constructor", "to", "subclass", "further", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1671-L1686
49,399
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(SuperC, args) { args = this._breakdown_subs(args); return this._extendclass( SuperC, args.protos, args.recurring, args.statics, args.name ); }
javascript
function(SuperC, args) { args = this._breakdown_subs(args); return this._extendclass( SuperC, args.protos, args.recurring, args.statics, args.name ); }
[ "function", "(", "SuperC", ",", "args", ")", "{", "args", "=", "this", ".", "_breakdown_subs", "(", "args", ")", ";", "return", "this", ".", "_extendclass", "(", "SuperC", ",", "args", ".", "protos", ",", "args", ".", "recurring", ",", "args", ".", "statics", ",", "args", ".", "name", ")", ";", "}" ]
Create subclass for given class. @param {funciton} SuperC @param {Object} args @return {function}
[ "Create", "subclass", "for", "given", "class", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L1826-L1835