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
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
52,400
berkeleybop/bbop-core
lib/core.js
function(len){ var random_base = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ]; var length = len || 10; var cache = new Array(); for( var ii = 0; ii < length; ii++ ){ var rbase_index = Math.floor(Math.random() * random_base.length); cache.push(random_base[rbase_index]); } return cache.join(''); }
javascript
function(len){ var random_base = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ]; var length = len || 10; var cache = new Array(); for( var ii = 0; ii < length; ii++ ){ var rbase_index = Math.floor(Math.random() * random_base.length); cache.push(random_base[rbase_index]); } return cache.join(''); }
[ "function", "(", "len", ")", "{", "var", "random_base", "=", "[", "'1'", ",", "'2'", ",", "'3'", ",", "'4'", ",", "'5'", ",", "'6'", ",", "'7'", ",", "'8'", ",", "'9'", ",", "'0'", ",", "'a'", ",", "'b'", ",", "'c'", ",", "'d'", ",", "'e'", ",", "'f'", ",", "'g'", ",", "'h'", ",", "'i'", ",", "'j'", ",", "'k'", ",", "'l'", ",", "'m'", ",", "'n'", ",", "'o'", ",", "'p'", ",", "'q'", ",", "'r'", ",", "'s'", ",", "'t'", ",", "'u'", ",", "'v'", ",", "'w'", ",", "'x'", ",", "'y'", ",", "'z'", "]", ";", "var", "length", "=", "len", "||", "10", ";", "var", "cache", "=", "new", "Array", "(", ")", ";", "for", "(", "var", "ii", "=", "0", ";", "ii", "<", "length", ";", "ii", "++", ")", "{", "var", "rbase_index", "=", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "random_base", ".", "length", ")", ";", "cache", ".", "push", "(", "random_base", "[", "rbase_index", "]", ")", ";", "}", "return", "cache", ".", "join", "(", "''", ")", ";", "}" ]
Random number generator of fixed length. Return a random number string of length len. @param {} len - the number of random character to return. @returns {string} string
[ "Random", "number", "generator", "of", "fixed", "length", ".", "Return", "a", "random", "number", "string", "of", "length", "len", "." ]
d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf
https://github.com/berkeleybop/bbop-core/blob/d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf/lib/core.js#L716-L730
52,401
berkeleybop/bbop-core
lib/core.js
function(url){ var retlist = []; // Pull parameters. var tmp = url.split('?'); var path = ''; var parms = []; if( ! tmp[1] ){ // catch bad url--nothing before '?' parms = tmp[0].split('&'); }else{ // normal structure path = tmp[0]; parms = tmp[1].split('&'); } // Decompose parameters. each(parms, function(p){ var c = _first_split('=', p); if( ! c[0] && ! c[1] ){ retlist.push([p]); }else{ retlist.push(c); } }); return retlist; }
javascript
function(url){ var retlist = []; // Pull parameters. var tmp = url.split('?'); var path = ''; var parms = []; if( ! tmp[1] ){ // catch bad url--nothing before '?' parms = tmp[0].split('&'); }else{ // normal structure path = tmp[0]; parms = tmp[1].split('&'); } // Decompose parameters. each(parms, function(p){ var c = _first_split('=', p); if( ! c[0] && ! c[1] ){ retlist.push([p]); }else{ retlist.push(c); } }); return retlist; }
[ "function", "(", "url", ")", "{", "var", "retlist", "=", "[", "]", ";", "// Pull parameters.", "var", "tmp", "=", "url", ".", "split", "(", "'?'", ")", ";", "var", "path", "=", "''", ";", "var", "parms", "=", "[", "]", ";", "if", "(", "!", "tmp", "[", "1", "]", ")", "{", "// catch bad url--nothing before '?'", "parms", "=", "tmp", "[", "0", "]", ".", "split", "(", "'&'", ")", ";", "}", "else", "{", "// normal structure", "path", "=", "tmp", "[", "0", "]", ";", "parms", "=", "tmp", "[", "1", "]", ".", "split", "(", "'&'", ")", ";", "}", "// Decompose parameters.", "each", "(", "parms", ",", "function", "(", "p", ")", "{", "var", "c", "=", "_first_split", "(", "'='", ",", "p", ")", ";", "if", "(", "!", "c", "[", "0", "]", "&&", "!", "c", "[", "1", "]", ")", "{", "retlist", ".", "push", "(", "[", "p", "]", ")", ";", "}", "else", "{", "retlist", ".", "push", "(", "c", ")", ";", "}", "}", ")", ";", "return", "retlist", ";", "}" ]
Return the parameters part of a URL. Unit tests make the edge cases clear. @param {} url - url (or similar string) @returns {Array} list of part lists
[ "Return", "the", "parameters", "part", "of", "a", "URL", "." ]
d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf
https://github.com/berkeleybop/bbop-core/blob/d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf/lib/core.js#L740-L766
52,402
berkeleybop/bbop-core
lib/core.js
function(str){ var retstr = str; if( ! us.isUndefined(str) && str.length > 2 ){ var end = str.length -1; if( str.charAt(0) == '"' && str.charAt(end) == '"' ){ retstr = str.substr(1, end -1); } } return retstr; }
javascript
function(str){ var retstr = str; if( ! us.isUndefined(str) && str.length > 2 ){ var end = str.length -1; if( str.charAt(0) == '"' && str.charAt(end) == '"' ){ retstr = str.substr(1, end -1); } } return retstr; }
[ "function", "(", "str", ")", "{", "var", "retstr", "=", "str", ";", "if", "(", "!", "us", ".", "isUndefined", "(", "str", ")", "&&", "str", ".", "length", ">", "2", ")", "{", "var", "end", "=", "str", ".", "length", "-", "1", ";", "if", "(", "str", ".", "charAt", "(", "0", ")", "==", "'\"'", "&&", "str", ".", "charAt", "(", "end", ")", "==", "'\"'", ")", "{", "retstr", "=", "str", ".", "substr", "(", "1", ",", "end", "-", "1", ")", ";", "}", "}", "return", "retstr", ";", "}" ]
Remove the quotes from a string. @param {string} str - the string to dequote @returns {string} the dequoted string (or the original string)
[ "Remove", "the", "quotes", "from", "a", "string", "." ]
d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf
https://github.com/berkeleybop/bbop-core/blob/d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf/lib/core.js#L845-L856
52,403
berkeleybop/bbop-core
lib/core.js
function(str, delimiter){ var retlist = null; if( ! us.isUndefined(str) ){ if( us.isUndefined(delimiter) ){ delimiter = /\s+/; } retlist = str.split(delimiter); } return retlist; }
javascript
function(str, delimiter){ var retlist = null; if( ! us.isUndefined(str) ){ if( us.isUndefined(delimiter) ){ delimiter = /\s+/; } retlist = str.split(delimiter); } return retlist; }
[ "function", "(", "str", ",", "delimiter", ")", "{", "var", "retlist", "=", "null", ";", "if", "(", "!", "us", ".", "isUndefined", "(", "str", ")", ")", "{", "if", "(", "us", ".", "isUndefined", "(", "delimiter", ")", ")", "{", "delimiter", "=", "/", "\\s+", "/", ";", "}", "retlist", "=", "str", ".", "split", "(", "delimiter", ")", ";", "}", "return", "retlist", ";", "}" ]
Break apart a string on certain delimiter. @param {} str - the string to ensure that has the property @param {} delimiter - *[optional]* either a string or a simple regexp; defaults to ws @returns {Array} a list of separated substrings
[ "Break", "apart", "a", "string", "on", "certain", "delimiter", "." ]
d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf
https://github.com/berkeleybop/bbop-core/blob/d9ce82a3a7d4f5e7300c0b637d8f7ff0e6969adf/lib/core.js#L936-L949
52,404
wshager/js-rrb-vector
lib/concat.js
insertRight
function insertRight(parent, node) { var index = parent.length - 1; parent[index] = node; parent.sizes[index] = (0, _util.length)(node) + (index > 0 ? parent.sizes[index - 1] : 0); }
javascript
function insertRight(parent, node) { var index = parent.length - 1; parent[index] = node; parent.sizes[index] = (0, _util.length)(node) + (index > 0 ? parent.sizes[index - 1] : 0); }
[ "function", "insertRight", "(", "parent", ",", "node", ")", "{", "var", "index", "=", "parent", ".", "length", "-", "1", ";", "parent", "[", "index", "]", "=", "node", ";", "parent", ".", "sizes", "[", "index", "]", "=", "(", "0", ",", "_util", ".", "length", ")", "(", "node", ")", "+", "(", "index", ">", "0", "?", "parent", ".", "sizes", "[", "index", "-", "1", "]", ":", "0", ")", ";", "}" ]
Helperfunctions for _concat. Replaces a child node at the side of the parent.
[ "Helperfunctions", "for", "_concat", ".", "Replaces", "a", "child", "node", "at", "the", "side", "of", "the", "parent", "." ]
766c3c12f658cc251dce028460c4eca4e33d5254
https://github.com/wshager/js-rrb-vector/blob/766c3c12f658cc251dce028460c4eca4e33d5254/lib/concat.js#L108-L112
52,405
integreat-io/great-uri-template
lib/utils/splitTemplate.js
splitTemplate
function splitTemplate (template) { if (!template) { return [] } return split(template).filter((seg) => seg !== '' && seg !== undefined) }
javascript
function splitTemplate (template) { if (!template) { return [] } return split(template).filter((seg) => seg !== '' && seg !== undefined) }
[ "function", "splitTemplate", "(", "template", ")", "{", "if", "(", "!", "template", ")", "{", "return", "[", "]", "}", "return", "split", "(", "template", ")", ".", "filter", "(", "(", "seg", ")", "=>", "seg", "!==", "''", "&&", "seg", "!==", "undefined", ")", "}" ]
Split the given template into segments. @param {string} template - The template to split @returns {string[]} An array of string segments
[ "Split", "the", "given", "template", "into", "segments", "." ]
0e896ead0567737cf31a4a8b76a26cfa6ce60759
https://github.com/integreat-io/great-uri-template/blob/0e896ead0567737cf31a4a8b76a26cfa6ce60759/lib/utils/splitTemplate.js#L34-L39
52,406
tjmehta/docker-frame
index.js
createHeader
function createHeader (type, size) { var header = new Buffer(8); header.writeUInt8(type, 0); header.writeUInt32BE(size, 4); return header; }
javascript
function createHeader (type, size) { var header = new Buffer(8); header.writeUInt8(type, 0); header.writeUInt32BE(size, 4); return header; }
[ "function", "createHeader", "(", "type", ",", "size", ")", "{", "var", "header", "=", "new", "Buffer", "(", "8", ")", ";", "header", ".", "writeUInt8", "(", "type", ",", "0", ")", ";", "header", ".", "writeUInt32BE", "(", "size", ",", "4", ")", ";", "return", "header", ";", "}" ]
create a docker frame header @param {number} ioConnectionType - 2=stderr, 1=stdout, 0=stdin @param {string|buffer} payloadData @returns {buffer} header - frame header (type, length) as buffer
[ "create", "a", "docker", "frame", "header" ]
8d22ed6a1ab5ad9ca3c5f82dca4efd92aa53b42b
https://github.com/tjmehta/docker-frame/blob/8d22ed6a1ab5ad9ca3c5f82dca4efd92aa53b42b/index.js#L30-L35
52,407
tjmehta/docker-frame
index.js
validateArgs
function validateArgs (type, payload) { if (!type) { return new Error('type is required'); } if (!payload) { return new Error('payload is required'); } if (!isNumber(type)) { return new Error('type must be a number'); } if (!isBuffer(payload) && !isString(payload)) { return new Error('payload must be buffer or string'); } if (type > 3) { return new Error('type must be a number less than 3'); } }
javascript
function validateArgs (type, payload) { if (!type) { return new Error('type is required'); } if (!payload) { return new Error('payload is required'); } if (!isNumber(type)) { return new Error('type must be a number'); } if (!isBuffer(payload) && !isString(payload)) { return new Error('payload must be buffer or string'); } if (type > 3) { return new Error('type must be a number less than 3'); } }
[ "function", "validateArgs", "(", "type", ",", "payload", ")", "{", "if", "(", "!", "type", ")", "{", "return", "new", "Error", "(", "'type is required'", ")", ";", "}", "if", "(", "!", "payload", ")", "{", "return", "new", "Error", "(", "'payload is required'", ")", ";", "}", "if", "(", "!", "isNumber", "(", "type", ")", ")", "{", "return", "new", "Error", "(", "'type must be a number'", ")", ";", "}", "if", "(", "!", "isBuffer", "(", "payload", ")", "&&", "!", "isString", "(", "payload", ")", ")", "{", "return", "new", "Error", "(", "'payload must be buffer or string'", ")", ";", "}", "if", "(", "type", ">", "3", ")", "{", "return", "new", "Error", "(", "'type must be a number less than 3'", ")", ";", "}", "}" ]
validates arguments for createFrame @param {number} ioConnectionType - 2=stderr, 1=stdout, 0=stdin @param {string|buffer} payloadData @return {undefined|error} error - returns error if an argument is invalid
[ "validates", "arguments", "for", "createFrame" ]
8d22ed6a1ab5ad9ca3c5f82dca4efd92aa53b42b
https://github.com/tjmehta/docker-frame/blob/8d22ed6a1ab5ad9ca3c5f82dca4efd92aa53b42b/index.js#L43-L59
52,408
hydrojs/co
index.js
sync
function sync(fn) { return function(done) { var res = isGenerator(fn) ? co(fn) : fn(done); if (isPromise(res)) { res.then(function(){ done(); }, done); } else { fn.length || done(); } }; }
javascript
function sync(fn) { return function(done) { var res = isGenerator(fn) ? co(fn) : fn(done); if (isPromise(res)) { res.then(function(){ done(); }, done); } else { fn.length || done(); } }; }
[ "function", "sync", "(", "fn", ")", "{", "return", "function", "(", "done", ")", "{", "var", "res", "=", "isGenerator", "(", "fn", ")", "?", "co", "(", "fn", ")", ":", "fn", "(", "done", ")", ";", "if", "(", "isPromise", "(", "res", ")", ")", "{", "res", ".", "then", "(", "function", "(", ")", "{", "done", "(", ")", ";", "}", ",", "done", ")", ";", "}", "else", "{", "fn", ".", "length", "||", "done", "(", ")", ";", "}", "}", ";", "}" ]
Wrap `fn` to handle any attempts at asynchrony @param {Function|GeneratorFunction} fn @return {Function}
[ "Wrap", "fn", "to", "handle", "any", "attempts", "at", "asynchrony" ]
8c429a795a27e6ebcae83adc69f73b06d9aca607
https://github.com/hydrojs/co/blob/8c429a795a27e6ebcae83adc69f73b06d9aca607/index.js#L36-L45
52,409
williamkapke/consumer
consumer.js
function(regex){ //if it isn't global, `exec()` will not start at `lastIndex` if(!regex.global) regex.compile(regex.source, flags(regex)); regex.lastIndex = this.position; var m = regex.exec(this.source); //all matches must start at the current position. if(m && m.index!=this.position){ return null; } if(m) this.position += m[0].length; return m; }
javascript
function(regex){ //if it isn't global, `exec()` will not start at `lastIndex` if(!regex.global) regex.compile(regex.source, flags(regex)); regex.lastIndex = this.position; var m = regex.exec(this.source); //all matches must start at the current position. if(m && m.index!=this.position){ return null; } if(m) this.position += m[0].length; return m; }
[ "function", "(", "regex", ")", "{", "//if it isn't global, `exec()` will not start at `lastIndex`", "if", "(", "!", "regex", ".", "global", ")", "regex", ".", "compile", "(", "regex", ".", "source", ",", "flags", "(", "regex", ")", ")", ";", "regex", ".", "lastIndex", "=", "this", ".", "position", ";", "var", "m", "=", "regex", ".", "exec", "(", "this", ".", "source", ")", ";", "//all matches must start at the current position.", "if", "(", "m", "&&", "m", ".", "index", "!=", "this", ".", "position", ")", "{", "return", "null", ";", "}", "if", "(", "m", ")", "this", ".", "position", "+=", "m", "[", "0", "]", ".", "length", ";", "return", "m", ";", "}" ]
Consume the characters matched by the 'regex'. @param {RegExp} regex
[ "Consume", "the", "characters", "matched", "by", "the", "regex", "." ]
03ad06f555447ba5dd626e3e94066452a3bc3f3f
https://github.com/williamkapke/consumer/blob/03ad06f555447ba5dd626e3e94066452a3bc3f3f/consumer.js#L40-L54
52,410
wshager/js-rrb-vector
lib/transient.js
get
function get(tree, i) { if (i < 0 || i >= tree.size) { return undefined; } var offset = (0, _util.tailOffset)(tree); if (i >= offset) { return tree.tail[i - offset]; } return (0, _util.getRoot)(i, tree.root); }
javascript
function get(tree, i) { if (i < 0 || i >= tree.size) { return undefined; } var offset = (0, _util.tailOffset)(tree); if (i >= offset) { return tree.tail[i - offset]; } return (0, _util.getRoot)(i, tree.root); }
[ "function", "get", "(", "tree", ",", "i", ")", "{", "if", "(", "i", "<", "0", "||", "i", ">=", "tree", ".", "size", ")", "{", "return", "undefined", ";", "}", "var", "offset", "=", "(", "0", ",", "_util", ".", "tailOffset", ")", "(", "tree", ")", ";", "if", "(", "i", ">=", "offset", ")", "{", "return", "tree", ".", "tail", "[", "i", "-", "offset", "]", ";", "}", "return", "(", "0", ",", "_util", ".", "getRoot", ")", "(", "i", ",", "tree", ".", "root", ")", ";", "}" ]
Gets the value at index i recursively.
[ "Gets", "the", "value", "at", "index", "i", "recursively", "." ]
766c3c12f658cc251dce028460c4eca4e33d5254
https://github.com/wshager/js-rrb-vector/blob/766c3c12f658cc251dce028460c4eca4e33d5254/lib/transient.js#L64-L73
52,411
wunderbyte/grunt-spiritual-edbml
tasks/things/assistant.js
formatjson
function formatjson(pis) { return pis.map(function(pi) { var newpi = {}; newpi[pi.tag] = pi.att; return newpi; }); }
javascript
function formatjson(pis) { return pis.map(function(pi) { var newpi = {}; newpi[pi.tag] = pi.att; return newpi; }); }
[ "function", "formatjson", "(", "pis", ")", "{", "return", "pis", ".", "map", "(", "function", "(", "pi", ")", "{", "var", "newpi", "=", "{", "}", ";", "newpi", "[", "pi", ".", "tag", "]", "=", "pi", ".", "att", ";", "return", "newpi", ";", "}", ")", ";", "}" ]
Format processing instructions for slight improved readability. @param {Array<Instruction>} pis @returns {Array<object>}
[ "Format", "processing", "instructions", "for", "slight", "improved", "readability", "." ]
2ba0aa8042eceee917f1ee48c7881345df3bce46
https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/assistant.js#L71-L77
52,412
LAJW/co-reduce-any
index.js
enumerate
function enumerate(collection) { if (isObject(collection)) { if (collection instanceof Map) { return enumerateMap(collection) } else if (isIterable(collection)) { return enumerateIterable(collection) } else { return enumerateObject(collection) } } else { throw new TypeError("Object cannot be enumerated") } }
javascript
function enumerate(collection) { if (isObject(collection)) { if (collection instanceof Map) { return enumerateMap(collection) } else if (isIterable(collection)) { return enumerateIterable(collection) } else { return enumerateObject(collection) } } else { throw new TypeError("Object cannot be enumerated") } }
[ "function", "enumerate", "(", "collection", ")", "{", "if", "(", "isObject", "(", "collection", ")", ")", "{", "if", "(", "collection", "instanceof", "Map", ")", "{", "return", "enumerateMap", "(", "collection", ")", "}", "else", "if", "(", "isIterable", "(", "collection", ")", ")", "{", "return", "enumerateIterable", "(", "collection", ")", "}", "else", "{", "return", "enumerateObject", "(", "collection", ")", "}", "}", "else", "{", "throw", "new", "TypeError", "(", "\"Object cannot be enumerated\"", ")", "}", "}" ]
Inspired by Python's enumerate
[ "Inspired", "by", "Python", "s", "enumerate" ]
3b1b7c57c8f3f8fe0deb6aec40022022b1c62b4e
https://github.com/LAJW/co-reduce-any/blob/3b1b7c57c8f3f8fe0deb6aec40022022b1c62b4e/index.js#L48-L60
52,413
andrewscwei/requiem
src/dom/sightread.js
sightread
function sightread(element, childRegistry) { if (!element || element === document) element = window; if (!childRegistry && !getChildRegistry(element)) return; // Clear the child registry. if (!childRegistry) { element.__private__.childRegistry = {}; childRegistry = getChildRegistry(element); } element = (element === window) ? document.body : (element.shadowRoot ? element.shadowRoot : element); assert(element, 'Element is invalid. Too early to sightread?'); const n = element.childNodes.length; for (let i = 0; i < n; i++) { let e = element.childNodes[i]; if (!(e instanceof Node)) continue; if (addToChildRegistry(childRegistry, e)) { if (!isCustomElement(e)) { if (!e.__private__) e.__private__ = {}; if (!e.__private__.childRegistry) e.__private__.childRegistry = {}; sightread(e); } } else { sightread(e, childRegistry); } } }
javascript
function sightread(element, childRegistry) { if (!element || element === document) element = window; if (!childRegistry && !getChildRegistry(element)) return; // Clear the child registry. if (!childRegistry) { element.__private__.childRegistry = {}; childRegistry = getChildRegistry(element); } element = (element === window) ? document.body : (element.shadowRoot ? element.shadowRoot : element); assert(element, 'Element is invalid. Too early to sightread?'); const n = element.childNodes.length; for (let i = 0; i < n; i++) { let e = element.childNodes[i]; if (!(e instanceof Node)) continue; if (addToChildRegistry(childRegistry, e)) { if (!isCustomElement(e)) { if (!e.__private__) e.__private__ = {}; if (!e.__private__.childRegistry) e.__private__.childRegistry = {}; sightread(e); } } else { sightread(e, childRegistry); } } }
[ "function", "sightread", "(", "element", ",", "childRegistry", ")", "{", "if", "(", "!", "element", "||", "element", "===", "document", ")", "element", "=", "window", ";", "if", "(", "!", "childRegistry", "&&", "!", "getChildRegistry", "(", "element", ")", ")", "return", ";", "// Clear the child registry.", "if", "(", "!", "childRegistry", ")", "{", "element", ".", "__private__", ".", "childRegistry", "=", "{", "}", ";", "childRegistry", "=", "getChildRegistry", "(", "element", ")", ";", "}", "element", "=", "(", "element", "===", "window", ")", "?", "document", ".", "body", ":", "(", "element", ".", "shadowRoot", "?", "element", ".", "shadowRoot", ":", "element", ")", ";", "assert", "(", "element", ",", "'Element is invalid. Too early to sightread?'", ")", ";", "const", "n", "=", "element", ".", "childNodes", ".", "length", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "let", "e", "=", "element", ".", "childNodes", "[", "i", "]", ";", "if", "(", "!", "(", "e", "instanceof", "Node", ")", ")", "continue", ";", "if", "(", "addToChildRegistry", "(", "childRegistry", ",", "e", ")", ")", "{", "if", "(", "!", "isCustomElement", "(", "e", ")", ")", "{", "if", "(", "!", "e", ".", "__private__", ")", "e", ".", "__private__", "=", "{", "}", ";", "if", "(", "!", "e", ".", "__private__", ".", "childRegistry", ")", "e", ".", "__private__", ".", "childRegistry", "=", "{", "}", ";", "sightread", "(", "e", ")", ";", "}", "}", "else", "{", "sightread", "(", "e", ",", "childRegistry", ")", ";", "}", "}", "}" ]
Crawls a DOM element, creates a child registry for the element and registers all of its children into the child registry, recursively. @param {Node} [element=document] - Target element for sightreading. By default this will be the document. @param {Object} [childRegistry] - Target child registry to register child elements with. If unspecified it will be inferred from the target element. @alias module:requiem~dom.sightread
[ "Crawls", "a", "DOM", "element", "creates", "a", "child", "registry", "for", "the", "element", "and", "registers", "all", "of", "its", "children", "into", "the", "child", "registry", "recursively", "." ]
c4182bfffc9841c6de5718f689ad3c2060511777
https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/sightread.js#L23-L53
52,414
inviqa/deck-task-registry
src/styles/lintStyles.js
lintStyles
function lintStyles(conf, undertaker) { const sassSrc = path.join(conf.themeConfig.root, conf.themeConfig.sass.src, '**', '*.scss'); let stylelintConf = { config: require('./stylelint.config'), reporters: [{ formatter: 'string', console: true }], failAfterError: conf.productionMode }; // If there are any stylelint overrides, then apply them now. if (conf.themeConfig.sass.hasOwnProperty('stylelint')) { stylelintConf = merge(stylelintConf, conf.themeConfig.sass.stylelint); } return undertaker.src(sassSrc) .pipe(stylelint(stylelintConf)); }
javascript
function lintStyles(conf, undertaker) { const sassSrc = path.join(conf.themeConfig.root, conf.themeConfig.sass.src, '**', '*.scss'); let stylelintConf = { config: require('./stylelint.config'), reporters: [{ formatter: 'string', console: true }], failAfterError: conf.productionMode }; // If there are any stylelint overrides, then apply them now. if (conf.themeConfig.sass.hasOwnProperty('stylelint')) { stylelintConf = merge(stylelintConf, conf.themeConfig.sass.stylelint); } return undertaker.src(sassSrc) .pipe(stylelint(stylelintConf)); }
[ "function", "lintStyles", "(", "conf", ",", "undertaker", ")", "{", "const", "sassSrc", "=", "path", ".", "join", "(", "conf", ".", "themeConfig", ".", "root", ",", "conf", ".", "themeConfig", ".", "sass", ".", "src", ",", "'**'", ",", "'*.scss'", ")", ";", "let", "stylelintConf", "=", "{", "config", ":", "require", "(", "'./stylelint.config'", ")", ",", "reporters", ":", "[", "{", "formatter", ":", "'string'", ",", "console", ":", "true", "}", "]", ",", "failAfterError", ":", "conf", ".", "productionMode", "}", ";", "// If there are any stylelint overrides, then apply them now.", "if", "(", "conf", ".", "themeConfig", ".", "sass", ".", "hasOwnProperty", "(", "'stylelint'", ")", ")", "{", "stylelintConf", "=", "merge", "(", "stylelintConf", ",", "conf", ".", "themeConfig", ".", "sass", ".", "stylelint", ")", ";", "}", "return", "undertaker", ".", "src", "(", "sassSrc", ")", ".", "pipe", "(", "stylelint", "(", "stylelintConf", ")", ")", ";", "}" ]
Lint project styles. @param {ConfigParser} conf A configuration parser object. @param {Undertaker} undertaker An Undertaker instance. @returns {Stream} A stream of files.
[ "Lint", "project", "styles", "." ]
4c31787b978e9d99a47052e090d4589a50cd3015
https://github.com/inviqa/deck-task-registry/blob/4c31787b978e9d99a47052e090d4589a50cd3015/src/styles/lintStyles.js#L15-L36
52,415
chanoch/simple-react-router
src/SimpleReactRouter.js
render
function render(history, routes, store) { const resolve = resolver(routes); return function(location) { resolve(location) .then(config => { renderPage(config.page(store, history), routes); const actionParams = config.matchRoute(location.pathname).params; config.driverInstance.dispatchAction(store.dispatch, actionParams); }) .catch(error => resolve({location, error}) .then(errorConfig => renderPage(errorConfig.page(store, history)))); } }
javascript
function render(history, routes, store) { const resolve = resolver(routes); return function(location) { resolve(location) .then(config => { renderPage(config.page(store, history), routes); const actionParams = config.matchRoute(location.pathname).params; config.driverInstance.dispatchAction(store.dispatch, actionParams); }) .catch(error => resolve({location, error}) .then(errorConfig => renderPage(errorConfig.page(store, history)))); } }
[ "function", "render", "(", "history", ",", "routes", ",", "store", ")", "{", "const", "resolve", "=", "resolver", "(", "routes", ")", ";", "return", "function", "(", "location", ")", "{", "resolve", "(", "location", ")", ".", "then", "(", "config", "=>", "{", "renderPage", "(", "config", ".", "page", "(", "store", ",", "history", ")", ",", "routes", ")", ";", "const", "actionParams", "=", "config", ".", "matchRoute", "(", "location", ".", "pathname", ")", ".", "params", ";", "config", ".", "driverInstance", ".", "dispatchAction", "(", "store", ".", "dispatch", ",", "actionParams", ")", ";", "}", ")", ".", "catch", "(", "error", "=>", "resolve", "(", "{", "location", ",", "error", "}", ")", ".", "then", "(", "errorConfig", "=>", "renderPage", "(", "errorConfig", ".", "page", "(", "store", ",", "history", ")", ")", ")", ")", ";", "}", "}" ]
Render the new 'page' given by the route. In order for this to work, each path or location in the application need to have the root component for it defined. The page component will be passed the store in the props to extract rendering data. 'page' here refers to the fact that the user will perceive the new application state as a new URL and associated HTML page in a traditional server-side HTML application. const routes = [ { path: '/menuplanner/', action: (store) => <MenuPlanner store={store} /> }, { path: '/menuplanner/selectmenu.html', action: (store) => <ChooseRecipes store={store}/> }, ]; export default routes;
[ "Render", "the", "new", "page", "given", "by", "the", "route", "." ]
3c71feeeb039111f33c934257732e2ea6ddde9ff
https://github.com/chanoch/simple-react-router/blob/3c71feeeb039111f33c934257732e2ea6ddde9ff/src/SimpleReactRouter.js#L75-L89
52,416
chanoch/simple-react-router
src/SimpleReactRouter.js
resolver
function resolver(routes) { return async function(context) { const uri = context.error ? '/error' : context.pathname; return routes.find(route => route.matchRoute(uri)); } }
javascript
function resolver(routes) { return async function(context) { const uri = context.error ? '/error' : context.pathname; return routes.find(route => route.matchRoute(uri)); } }
[ "function", "resolver", "(", "routes", ")", "{", "return", "async", "function", "(", "context", ")", "{", "const", "uri", "=", "context", ".", "error", "?", "'/error'", ":", "context", ".", "pathname", ";", "return", "routes", ".", "find", "(", "route", "=>", "route", ".", "matchRoute", "(", "uri", ")", ")", ";", "}", "}" ]
Resolve the component to render based on the pathname given as the parameter's property. If the location cannot be resolved then throw an error. The resolver will resolve the component configured against /error to render an error page @param {Object} context - an object containing a pathname to resove or an error TODO replace this error approach
[ "Resolve", "the", "component", "to", "render", "based", "on", "the", "pathname", "given", "as", "the", "parameter", "s", "property", "." ]
3c71feeeb039111f33c934257732e2ea6ddde9ff
https://github.com/chanoch/simple-react-router/blob/3c71feeeb039111f33c934257732e2ea6ddde9ff/src/SimpleReactRouter.js#L102-L107
52,417
sendanor/nor-db
lib/core/Connection.js
Connection
function Connection(conn) { if(!(this instanceof Connection)) { return new Connection(conn); } var self = this; if(!conn) { throw new TypeError("no connection set"); } self._connection = conn; }
javascript
function Connection(conn) { if(!(this instanceof Connection)) { return new Connection(conn); } var self = this; if(!conn) { throw new TypeError("no connection set"); } self._connection = conn; }
[ "function", "Connection", "(", "conn", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Connection", ")", ")", "{", "return", "new", "Connection", "(", "conn", ")", ";", "}", "var", "self", "=", "this", ";", "if", "(", "!", "conn", ")", "{", "throw", "new", "TypeError", "(", "\"no connection set\"", ")", ";", "}", "self", ".", "_connection", "=", "conn", ";", "}" ]
Base class `Connection` constructor
[ "Base", "class", "Connection", "constructor" ]
db4b78691956a49370fc9d9a4eed27e7d3720aeb
https://github.com/sendanor/nor-db/blob/db4b78691956a49370fc9d9a4eed27e7d3720aeb/lib/core/Connection.js#L9-L16
52,418
linyngfly/omelo-admin
lib/modules/monitorLog.js
function(opts) { opts = opts || {}; this.root = opts.path; this.interval = opts.interval || DEFAULT_INTERVAL; }
javascript
function(opts) { opts = opts || {}; this.root = opts.path; this.interval = opts.interval || DEFAULT_INTERVAL; }
[ "function", "(", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "this", ".", "root", "=", "opts", ".", "path", ";", "this", ".", "interval", "=", "opts", ".", "interval", "||", "DEFAULT_INTERVAL", ";", "}" ]
Initialize a new 'Module' with the given 'opts' @class Module @constructor @param {object} opts @api public
[ "Initialize", "a", "new", "Module", "with", "the", "given", "opts" ]
1cd692c16ab63b9c0d4009535f300f2ca584b691
https://github.com/linyngfly/omelo-admin/blob/1cd692c16ab63b9c0d4009535f300f2ca584b691/lib/modules/monitorLog.js#L26-L30
52,419
derdesign/protos
drivers/mysql.js
MySQL
function MySQL(config) { var self = this; config = config || {}; config.host = config.host || 'localhost'; config.port = config.port || 3306; this.className = this.constructor.name; this.config = config; // Set client this.client = mysql.createConnection(config); // Assign storage if (typeof config.storage == 'string') { this.storage = app.getResource('storages/' + config.storage); } else if (config.storage instanceof protos.lib.storage) { this.storage = config.storage; } // Set db this.db = config.database; // Only set important properties enumerable protos.util.onlySetEnumerable(this, ['className', 'db']); }
javascript
function MySQL(config) { var self = this; config = config || {}; config.host = config.host || 'localhost'; config.port = config.port || 3306; this.className = this.constructor.name; this.config = config; // Set client this.client = mysql.createConnection(config); // Assign storage if (typeof config.storage == 'string') { this.storage = app.getResource('storages/' + config.storage); } else if (config.storage instanceof protos.lib.storage) { this.storage = config.storage; } // Set db this.db = config.database; // Only set important properties enumerable protos.util.onlySetEnumerable(this, ['className', 'db']); }
[ "function", "MySQL", "(", "config", ")", "{", "var", "self", "=", "this", ";", "config", "=", "config", "||", "{", "}", ";", "config", ".", "host", "=", "config", ".", "host", "||", "'localhost'", ";", "config", ".", "port", "=", "config", ".", "port", "||", "3306", ";", "this", ".", "className", "=", "this", ".", "constructor", ".", "name", ";", "this", ".", "config", "=", "config", ";", "// Set client", "this", ".", "client", "=", "mysql", ".", "createConnection", "(", "config", ")", ";", "// Assign storage", "if", "(", "typeof", "config", ".", "storage", "==", "'string'", ")", "{", "this", ".", "storage", "=", "app", ".", "getResource", "(", "'storages/'", "+", "config", ".", "storage", ")", ";", "}", "else", "if", "(", "config", ".", "storage", "instanceof", "protos", ".", "lib", ".", "storage", ")", "{", "this", ".", "storage", "=", "config", ".", "storage", ";", "}", "// Set db", "this", ".", "db", "=", "config", ".", "database", ";", "// Only set important properties enumerable", "protos", ".", "util", ".", "onlySetEnumerable", "(", "this", ",", "[", "'className'", ",", "'db'", "]", ")", ";", "}" ]
MySQL Driver class Driver configuration config: { host: 'localhost', port: 3306, user: 'db_user', password: 'db_password', database: 'db_name', debug: false, storage: 'redis' } @class MySQL @extends Driver @constructor @param {object} app Application instance @param {object} config Driver configuration
[ "MySQL", "Driver", "class" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/drivers/mysql.js#L32-L60
52,420
arjunmehta/node-ansi-state
main.js
ANSIState
function ANSIState(legacy) { var feed = '', last_match = '', stream_match = [], _this = this; PassThrough.call(this); this.attrs = {}; this.reset(); this.is_reset = false; this.setEncoding('utf8'); this.on('data', function(chunk) { feed += chunk; if (feed.indexOf('\033') === -1) { feed = ''; } else { stream_match = feed.match(color_regex); if (stream_match.length > 0) { last_match = stream_match[stream_match.length - 1]; feed = feed.slice(feed.lastIndexOf(last_match) + last_match.length); _this.updateWithArray(stream_match); } } }); if (legacy !== undefined) { this.update(legacy); } }
javascript
function ANSIState(legacy) { var feed = '', last_match = '', stream_match = [], _this = this; PassThrough.call(this); this.attrs = {}; this.reset(); this.is_reset = false; this.setEncoding('utf8'); this.on('data', function(chunk) { feed += chunk; if (feed.indexOf('\033') === -1) { feed = ''; } else { stream_match = feed.match(color_regex); if (stream_match.length > 0) { last_match = stream_match[stream_match.length - 1]; feed = feed.slice(feed.lastIndexOf(last_match) + last_match.length); _this.updateWithArray(stream_match); } } }); if (legacy !== undefined) { this.update(legacy); } }
[ "function", "ANSIState", "(", "legacy", ")", "{", "var", "feed", "=", "''", ",", "last_match", "=", "''", ",", "stream_match", "=", "[", "]", ",", "_this", "=", "this", ";", "PassThrough", ".", "call", "(", "this", ")", ";", "this", ".", "attrs", "=", "{", "}", ";", "this", ".", "reset", "(", ")", ";", "this", ".", "is_reset", "=", "false", ";", "this", ".", "setEncoding", "(", "'utf8'", ")", ";", "this", ".", "on", "(", "'data'", ",", "function", "(", "chunk", ")", "{", "feed", "+=", "chunk", ";", "if", "(", "feed", ".", "indexOf", "(", "'\\033'", ")", "===", "-", "1", ")", "{", "feed", "=", "''", ";", "}", "else", "{", "stream_match", "=", "feed", ".", "match", "(", "color_regex", ")", ";", "if", "(", "stream_match", ".", "length", ">", "0", ")", "{", "last_match", "=", "stream_match", "[", "stream_match", ".", "length", "-", "1", "]", ";", "feed", "=", "feed", ".", "slice", "(", "feed", ".", "lastIndexOf", "(", "last_match", ")", "+", "last_match", ".", "length", ")", ";", "_this", ".", "updateWithArray", "(", "stream_match", ")", ";", "}", "}", "}", ")", ";", "if", "(", "legacy", "!==", "undefined", ")", "{", "this", ".", "update", "(", "legacy", ")", ";", "}", "}" ]
ANSI state constructor
[ "ANSI", "state", "constructor" ]
f667315f5223717c25e4c13d4072c4a0b650e202
https://github.com/arjunmehta/node-ansi-state/blob/f667315f5223717c25e4c13d4072c4a0b650e202/main.js#L26-L57
52,421
vkiding/jud-vue-render
src/render/browser/extend/components/tabheader/index.js
initClickEvent
function initClickEvent (tabheader) { const box = tabheader.box box.addEventListener('click', function (evt) { let target = evt.target if (target.nodeName === 'UL') { return } if (target.parentNode.nodeName === 'LI') { target = target.parentNode } const floor = target.getAttribute('data-floor') /* eslint-disable eqeqeq */ if (tabheader.data.attr.selectedIndex == floor) { // Duplicated clicking, not to trigger select event. return } /* eslint-enable eqeqeq */ fireEvent(target, 'select', { index: floor }) }) }
javascript
function initClickEvent (tabheader) { const box = tabheader.box box.addEventListener('click', function (evt) { let target = evt.target if (target.nodeName === 'UL') { return } if (target.parentNode.nodeName === 'LI') { target = target.parentNode } const floor = target.getAttribute('data-floor') /* eslint-disable eqeqeq */ if (tabheader.data.attr.selectedIndex == floor) { // Duplicated clicking, not to trigger select event. return } /* eslint-enable eqeqeq */ fireEvent(target, 'select', { index: floor }) }) }
[ "function", "initClickEvent", "(", "tabheader", ")", "{", "const", "box", "=", "tabheader", ".", "box", "box", ".", "addEventListener", "(", "'click'", ",", "function", "(", "evt", ")", "{", "let", "target", "=", "evt", ".", "target", "if", "(", "target", ".", "nodeName", "===", "'UL'", ")", "{", "return", "}", "if", "(", "target", ".", "parentNode", ".", "nodeName", "===", "'LI'", ")", "{", "target", "=", "target", ".", "parentNode", "}", "const", "floor", "=", "target", ".", "getAttribute", "(", "'data-floor'", ")", "/* eslint-disable eqeqeq */", "if", "(", "tabheader", ".", "data", ".", "attr", ".", "selectedIndex", "==", "floor", ")", "{", "// Duplicated clicking, not to trigger select event.", "return", "}", "/* eslint-enable eqeqeq */", "fireEvent", "(", "target", ",", "'select'", ",", "{", "index", ":", "floor", "}", ")", "}", ")", "}" ]
init events.
[ "init", "events", "." ]
07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47
https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/extend/components/tabheader/index.js#L101-L124
52,422
vkiding/jud-vue-render
src/render/browser/extend/components/tabheader/index.js
doScroll
function doScroll (node, val, finish) { if (!val) { return } if (finish === undefined) { finish = Math.abs(val) } if (finish <= 0) { return } setTimeout(function () { if (val > 0) { node.scrollLeft += 2 } else { node.scrollLeft -= 2 } finish -= 2 doScroll(node, val, finish) }) }
javascript
function doScroll (node, val, finish) { if (!val) { return } if (finish === undefined) { finish = Math.abs(val) } if (finish <= 0) { return } setTimeout(function () { if (val > 0) { node.scrollLeft += 2 } else { node.scrollLeft -= 2 } finish -= 2 doScroll(node, val, finish) }) }
[ "function", "doScroll", "(", "node", ",", "val", ",", "finish", ")", "{", "if", "(", "!", "val", ")", "{", "return", "}", "if", "(", "finish", "===", "undefined", ")", "{", "finish", "=", "Math", ".", "abs", "(", "val", ")", "}", "if", "(", "finish", "<=", "0", ")", "{", "return", "}", "setTimeout", "(", "function", "(", ")", "{", "if", "(", "val", ">", "0", ")", "{", "node", ".", "scrollLeft", "+=", "2", "}", "else", "{", "node", ".", "scrollLeft", "-=", "2", "}", "finish", "-=", "2", "doScroll", "(", "node", ",", "val", ",", "finish", ")", "}", ")", "}" ]
scroll the tabheader. positive val means to scroll right. negative val means to scroll left.
[ "scroll", "the", "tabheader", ".", "positive", "val", "means", "to", "scroll", "right", ".", "negative", "val", "means", "to", "scroll", "left", "." ]
07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47
https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/extend/components/tabheader/index.js#L164-L187
52,423
vkiding/jud-vue-render
src/render/browser/extend/components/tabheader/index.js
getScrollVal
function getScrollVal (rect, node) { const left = node.previousSibling const right = node.nextSibling let scrollVal // process left-side element first. if (left) { const leftRect = left.getBoundingClientRect() // only need to compare the value of left. if (leftRect.left < rect.left) { scrollVal = leftRect.left return scrollVal } } if (right) { const rightRect = right.getBoundingClientRect() // compare the value of right. if (rightRect.right > rect.right) { scrollVal = rightRect.right - rect.right return scrollVal } } // process current node, from left to right. const nodeRect = node.getBoundingClientRect() if (nodeRect.left < rect.left) { scrollVal = nodeRect.left } else if (nodeRect.right > rect.right) { scrollVal = nodeRect.right - rect.right } return scrollVal }
javascript
function getScrollVal (rect, node) { const left = node.previousSibling const right = node.nextSibling let scrollVal // process left-side element first. if (left) { const leftRect = left.getBoundingClientRect() // only need to compare the value of left. if (leftRect.left < rect.left) { scrollVal = leftRect.left return scrollVal } } if (right) { const rightRect = right.getBoundingClientRect() // compare the value of right. if (rightRect.right > rect.right) { scrollVal = rightRect.right - rect.right return scrollVal } } // process current node, from left to right. const nodeRect = node.getBoundingClientRect() if (nodeRect.left < rect.left) { scrollVal = nodeRect.left } else if (nodeRect.right > rect.right) { scrollVal = nodeRect.right - rect.right } return scrollVal }
[ "function", "getScrollVal", "(", "rect", ",", "node", ")", "{", "const", "left", "=", "node", ".", "previousSibling", "const", "right", "=", "node", ".", "nextSibling", "let", "scrollVal", "// process left-side element first.", "if", "(", "left", ")", "{", "const", "leftRect", "=", "left", ".", "getBoundingClientRect", "(", ")", "// only need to compare the value of left.", "if", "(", "leftRect", ".", "left", "<", "rect", ".", "left", ")", "{", "scrollVal", "=", "leftRect", ".", "left", "return", "scrollVal", "}", "}", "if", "(", "right", ")", "{", "const", "rightRect", "=", "right", ".", "getBoundingClientRect", "(", ")", "// compare the value of right.", "if", "(", "rightRect", ".", "right", ">", "rect", ".", "right", ")", "{", "scrollVal", "=", "rightRect", ".", "right", "-", "rect", ".", "right", "return", "scrollVal", "}", "}", "// process current node, from left to right.", "const", "nodeRect", "=", "node", ".", "getBoundingClientRect", "(", ")", "if", "(", "nodeRect", ".", "left", "<", "rect", ".", "left", ")", "{", "scrollVal", "=", "nodeRect", ".", "left", "}", "else", "if", "(", "nodeRect", ".", "right", ">", "rect", ".", "right", ")", "{", "scrollVal", "=", "nodeRect", ".", "right", "-", "rect", ".", "right", "}", "return", "scrollVal", "}" ]
get scroll distance.
[ "get", "scroll", "distance", "." ]
07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47
https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/extend/components/tabheader/index.js#L190-L224
52,424
vkiding/jud-vue-render
src/render/browser/extend/components/tabheader/index.js
fireEvent
function fireEvent (element, type, data) { const evt = document.createEvent('Event') evt.data = data for (const k in data) { if (data.hasOwnProperty(k)) { evt[k] = data[k] } } // need bubble. evt.initEvent(type, true, true) element.dispatchEvent(evt) }
javascript
function fireEvent (element, type, data) { const evt = document.createEvent('Event') evt.data = data for (const k in data) { if (data.hasOwnProperty(k)) { evt[k] = data[k] } } // need bubble. evt.initEvent(type, true, true) element.dispatchEvent(evt) }
[ "function", "fireEvent", "(", "element", ",", "type", ",", "data", ")", "{", "const", "evt", "=", "document", ".", "createEvent", "(", "'Event'", ")", "evt", ".", "data", "=", "data", "for", "(", "const", "k", "in", "data", ")", "{", "if", "(", "data", ".", "hasOwnProperty", "(", "k", ")", ")", "{", "evt", "[", "k", "]", "=", "data", "[", "k", "]", "}", "}", "// need bubble.", "evt", ".", "initEvent", "(", "type", ",", "true", ",", "true", ")", "element", ".", "dispatchEvent", "(", "evt", ")", "}" ]
trigger and broadcast events.
[ "trigger", "and", "broadcast", "events", "." ]
07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47
https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/extend/components/tabheader/index.js#L227-L239
52,425
gethuman/pancakes-angular
lib/transformers/ng.routing.transformer.js
getResolveHandlers
function getResolveHandlers(appName, routes, options) { var resolveHandlers = {}; var me = this; _.each(routes, function (route) { // if no route name, don't do anything if (!route.name) { return; } // else generate the UI part based on the name var uipart = me.getUIPart(appName, route); // if there is no model return without doing anything if (!uipart.model) { return; } var transOpts = _.extend({ raw: true, defaults: uipart.defaults, isClient: true }, options); // else we want to generate the initial model module resolveHandlers[route.name] = _.isFunction(uipart.model) ? me.transformers.basic.transform(uipart.model, transOpts) : JSON.stringify(uipart.model); }); return resolveHandlers || {}; }
javascript
function getResolveHandlers(appName, routes, options) { var resolveHandlers = {}; var me = this; _.each(routes, function (route) { // if no route name, don't do anything if (!route.name) { return; } // else generate the UI part based on the name var uipart = me.getUIPart(appName, route); // if there is no model return without doing anything if (!uipart.model) { return; } var transOpts = _.extend({ raw: true, defaults: uipart.defaults, isClient: true }, options); // else we want to generate the initial model module resolveHandlers[route.name] = _.isFunction(uipart.model) ? me.transformers.basic.transform(uipart.model, transOpts) : JSON.stringify(uipart.model); }); return resolveHandlers || {}; }
[ "function", "getResolveHandlers", "(", "appName", ",", "routes", ",", "options", ")", "{", "var", "resolveHandlers", "=", "{", "}", ";", "var", "me", "=", "this", ";", "_", ".", "each", "(", "routes", ",", "function", "(", "route", ")", "{", "// if no route name, don't do anything", "if", "(", "!", "route", ".", "name", ")", "{", "return", ";", "}", "// else generate the UI part based on the name", "var", "uipart", "=", "me", ".", "getUIPart", "(", "appName", ",", "route", ")", ";", "// if there is no model return without doing anything", "if", "(", "!", "uipart", ".", "model", ")", "{", "return", ";", "}", "var", "transOpts", "=", "_", ".", "extend", "(", "{", "raw", ":", "true", ",", "defaults", ":", "uipart", ".", "defaults", ",", "isClient", ":", "true", "}", ",", "options", ")", ";", "// else we want to generate the initial model module", "resolveHandlers", "[", "route", ".", "name", "]", "=", "_", ".", "isFunction", "(", "uipart", ".", "model", ")", "?", "me", ".", "transformers", ".", "basic", ".", "transform", "(", "uipart", ".", "model", ",", "transOpts", ")", ":", "JSON", ".", "stringify", "(", "uipart", ".", "model", ")", ";", "}", ")", ";", "return", "resolveHandlers", "||", "{", "}", ";", "}" ]
Get resolve handlers for all the given routes @param appName @param routes @param options
[ "Get", "resolve", "handlers", "for", "all", "the", "given", "routes" ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/transformers/ng.routing.transformer.js#L54-L82
52,426
gethuman/pancakes-angular
lib/transformers/ng.routing.transformer.js
getUIPart
function getUIPart(appName, route) { var rootDir = this.pancakes.getRootDir(); var filePath = path.join(rootDir, 'app', appName, 'pages', route.name + '.page.js'); return this.loadUIPart(appName, filePath); }
javascript
function getUIPart(appName, route) { var rootDir = this.pancakes.getRootDir(); var filePath = path.join(rootDir, 'app', appName, 'pages', route.name + '.page.js'); return this.loadUIPart(appName, filePath); }
[ "function", "getUIPart", "(", "appName", ",", "route", ")", "{", "var", "rootDir", "=", "this", ".", "pancakes", ".", "getRootDir", "(", ")", ";", "var", "filePath", "=", "path", ".", "join", "(", "rootDir", ",", "'app'", ",", "appName", ",", "'pages'", ",", "route", ".", "name", "+", "'.page.js'", ")", ";", "return", "this", ".", "loadUIPart", "(", "appName", ",", "filePath", ")", ";", "}" ]
Get the UI part module for a given app and route @param appName @param route @returns {injector.require|*|require}
[ "Get", "the", "UI", "part", "module", "for", "a", "given", "app", "and", "route" ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/transformers/ng.routing.transformer.js#L90-L94
52,427
redisjs/jsr-server
lib/command/transaction/multi.js
execute
function execute(req, res) { // setup the transaction req.conn.transaction = new Transaction(); res.send(null, Constants.OK); }
javascript
function execute(req, res) { // setup the transaction req.conn.transaction = new Transaction(); res.send(null, Constants.OK); }
[ "function", "execute", "(", "req", ",", "res", ")", "{", "// setup the transaction", "req", ".", "conn", ".", "transaction", "=", "new", "Transaction", "(", ")", ";", "res", ".", "send", "(", "null", ",", "Constants", ".", "OK", ")", ";", "}" ]
Respond to the MULTI command.
[ "Respond", "to", "the", "MULTI", "command", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/transaction/multi.js#L20-L24
52,428
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/RGraph/RGraph.pie.js
function () { obj.set('exploded', currentExplode + (step * frame) ); RGraph.clear(obj.canvas); RGraph.redrawCanvas(obj.canvas); if (frame++ < frames) { RGraph.Effects.updateCanvas(iterator); } else { callback(obj); } }
javascript
function () { obj.set('exploded', currentExplode + (step * frame) ); RGraph.clear(obj.canvas); RGraph.redrawCanvas(obj.canvas); if (frame++ < frames) { RGraph.Effects.updateCanvas(iterator); } else { callback(obj); } }
[ "function", "(", ")", "{", "obj", ".", "set", "(", "'exploded'", ",", "currentExplode", "+", "(", "step", "*", "frame", ")", ")", ";", "RGraph", ".", "clear", "(", "obj", ".", "canvas", ")", ";", "RGraph", ".", "redrawCanvas", "(", "obj", ".", "canvas", ")", ";", "if", "(", "frame", "++", "<", "frames", ")", "{", "RGraph", ".", "Effects", ".", "updateCanvas", "(", "iterator", ")", ";", "}", "else", "{", "callback", "(", "obj", ")", ";", "}", "}" ]
chart.exploded
[ "chart", ".", "exploded" ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/RGraph/RGraph.pie.js#L1540-L1552
52,429
Crafity/crafity-http
lib/Route.js
Route
function Route(path, options) { options = options || {}; this.path = path; this.method = 'GET'; this.regexp = pathtoRegexp(path , this.keys = [] , options.sensitive , options.strict); }
javascript
function Route(path, options) { options = options || {}; this.path = path; this.method = 'GET'; this.regexp = pathtoRegexp(path , this.keys = [] , options.sensitive , options.strict); }
[ "function", "Route", "(", "path", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "path", "=", "path", ";", "this", ".", "method", "=", "'GET'", ";", "this", ".", "regexp", "=", "pathtoRegexp", "(", "path", ",", "this", ".", "keys", "=", "[", "]", ",", "options", ".", "sensitive", ",", "options", ".", "strict", ")", ";", "}" ]
Initialize `Route` with the given HTTP `path`, and an array of `callbacks` and `options`. Options: - `sensitive` enable case-sensitive routes - `strict` enable strict matching for trailing slashes @param {String} path @param {Object} options. @api private
[ "Initialize", "Route", "with", "the", "given", "HTTP", "path", "and", "an", "array", "of", "callbacks", "and", "options", "." ]
f015eed86646e6b2ea82599c59b53a9f97fe92b4
https://github.com/Crafity/crafity-http/blob/f015eed86646e6b2ea82599c59b53a9f97fe92b4/lib/Route.js#L62-L70
52,430
RoboterHund/April1
modules/templates/build.js
insert
function insert (builder, node) { finishPending (builder); appendNode (builder, spec.insertNode (node [1])); }
javascript
function insert (builder, node) { finishPending (builder); appendNode (builder, spec.insertNode (node [1])); }
[ "function", "insert", "(", "builder", ",", "node", ")", "{", "finishPending", "(", "builder", ")", ";", "appendNode", "(", "builder", ",", "spec", ".", "insertNode", "(", "node", "[", "1", "]", ")", ")", ";", "}" ]
process 'insert' spec node append 'insert' template node @param builder template builder @param node the spec node should contain 1 item: the key of the 'insert' template node
[ "process", "insert", "spec", "node", "append", "insert", "template", "node" ]
f4fead4d8190d0b7bdc7b649f4c2c0e9728ef30b
https://github.com/RoboterHund/April1/blob/f4fead4d8190d0b7bdc7b649f4c2c0e9728ef30b/modules/templates/build.js#L92-L96
52,431
RoboterHund/April1
modules/templates/build.js
list
function list (builder, node) { finishPending (builder); var key = node [1]; var sub = subBuilder (builder); dispatch.nodes (sub, builder.dispatch, node, 2, node.length); var template = getTemplate (sub); appendNode (builder, spec.listNode (key, template)); }
javascript
function list (builder, node) { finishPending (builder); var key = node [1]; var sub = subBuilder (builder); dispatch.nodes (sub, builder.dispatch, node, 2, node.length); var template = getTemplate (sub); appendNode (builder, spec.listNode (key, template)); }
[ "function", "list", "(", "builder", ",", "node", ")", "{", "finishPending", "(", "builder", ")", ";", "var", "key", "=", "node", "[", "1", "]", ";", "var", "sub", "=", "subBuilder", "(", "builder", ")", ";", "dispatch", ".", "nodes", "(", "sub", ",", "builder", ".", "dispatch", ",", "node", ",", "2", ",", "node", ".", "length", ")", ";", "var", "template", "=", "getTemplate", "(", "sub", ")", ";", "appendNode", "(", "builder", ",", "spec", ".", "listNode", "(", "key", ",", "template", ")", ")", ";", "}" ]
process 'list' spec node append 'list' template node @param builder template builder @param node the spec node should contain at least 2 items: key of the list items the spec nodes of the template used to render the list items
[ "process", "list", "spec", "node", "append", "list", "template", "node" ]
f4fead4d8190d0b7bdc7b649f4c2c0e9728ef30b
https://github.com/RoboterHund/April1/blob/f4fead4d8190d0b7bdc7b649f4c2c0e9728ef30b/modules/templates/build.js#L107-L117
52,432
ecs-jbariel/js-cfclient
lib/cfclient.js
CFClient
function CFClient(config) { if (!(config instanceof CFConfig)) { throw CFClientException( new Error('Given tokens must be an instance of CFConfig'), 'tokens must be an instance of CFConfig that contains: "protocol", "host", "username", "password", "skipSslValidation'); } this.config = config; this.infoData = null; this.client = null; }
javascript
function CFClient(config) { if (!(config instanceof CFConfig)) { throw CFClientException( new Error('Given tokens must be an instance of CFConfig'), 'tokens must be an instance of CFConfig that contains: "protocol", "host", "username", "password", "skipSslValidation'); } this.config = config; this.infoData = null; this.client = null; }
[ "function", "CFClient", "(", "config", ")", "{", "if", "(", "!", "(", "config", "instanceof", "CFConfig", ")", ")", "{", "throw", "CFClientException", "(", "new", "Error", "(", "'Given tokens must be an instance of CFConfig'", ")", ",", "'tokens must be an instance of CFConfig that contains: \"protocol\", \"host\", \"username\", \"password\", \"skipSslValidation'", ")", ";", "}", "this", ".", "config", "=", "config", ";", "this", ".", "infoData", "=", "null", ";", "this", ".", "client", "=", "null", ";", "}" ]
Constructor for the CFClient. @param {CFConfig} config - configuration as defined in the README.md
[ "Constructor", "for", "the", "CFClient", "." ]
e912724e2b6320746b4b4297e604b54580068edd
https://github.com/ecs-jbariel/js-cfclient/blob/e912724e2b6320746b4b4297e604b54580068edd/lib/cfclient.js#L87-L97
52,433
ecs-jbariel/js-cfclient
lib/cfclient.js
CFConfig
function CFConfig(config) { const cf = this; extend(extend(cf, { protocol: 'http', host: 'api.bosh-lite.com', //port : null, // omitted to let it be based on config or protocol username: 'admin', password: 'admin', skipSslValidation: false }), config); cf.port = calculatePort(cf.port, cf.protocol); if (cf.skipSslValidation instanceof String) { cf.skipSslValidation = ('true' === cf.skipSslValidation); } }
javascript
function CFConfig(config) { const cf = this; extend(extend(cf, { protocol: 'http', host: 'api.bosh-lite.com', //port : null, // omitted to let it be based on config or protocol username: 'admin', password: 'admin', skipSslValidation: false }), config); cf.port = calculatePort(cf.port, cf.protocol); if (cf.skipSslValidation instanceof String) { cf.skipSslValidation = ('true' === cf.skipSslValidation); } }
[ "function", "CFConfig", "(", "config", ")", "{", "const", "cf", "=", "this", ";", "extend", "(", "extend", "(", "cf", ",", "{", "protocol", ":", "'http'", ",", "host", ":", "'api.bosh-lite.com'", ",", "//port : null, // omitted to let it be based on config or protocol\r", "username", ":", "'admin'", ",", "password", ":", "'admin'", ",", "skipSslValidation", ":", "false", "}", ")", ",", "config", ")", ";", "cf", ".", "port", "=", "calculatePort", "(", "cf", ".", "port", ",", "cf", ".", "protocol", ")", ";", "if", "(", "cf", ".", "skipSslValidation", "instanceof", "String", ")", "{", "cf", ".", "skipSslValidation", "=", "(", "'true'", "===", "cf", ".", "skipSslValidation", ")", ";", "}", "}" ]
Object that helps to manage the configuration options. @param {Object} config values properties are: <ul> <li><b>protocol</b> 'http' or 'https'</li> <li><b>host</b> FQDN or IP (e.g. api.mydomain.com)</li> <li><b>username</b> username for the CF API</li> <li><b>password</b> password for the given username</li> <li><b>skipSslValidation</b> enable for self-signed certs</li> </ul>
[ "Object", "that", "helps", "to", "manage", "the", "configuration", "options", "." ]
e912724e2b6320746b4b4297e604b54580068edd
https://github.com/ecs-jbariel/js-cfclient/blob/e912724e2b6320746b4b4297e604b54580068edd/lib/cfclient.js#L267-L282
52,434
vidi-insights/vidi-metrics
srv/demo.js
demo_plugin
function demo_plugin (opts) { // adds an emit plugin. Emit plugins are called on regular intervals and have // the opertunity to add to the payload being sent to collectors. Data sent // from emit plugins should not require tagging, and should be map ready. this.add({role: 'metrics', hook: 'emit'}, emit) // adds a tag plugin. When inbound data is missing a source:'name' pair the // data is sent to tag plugins for identification and sanitation. Tag plugins // allow data to be standardised enough for map plugins to match on the data. this.add({role: 'metrics', hook: 'tag'}, tag) // adds a map plugin. Maps recieve data once per payload via sources. A // map can additionally match on source:'' for granularity. Maps emit // arrarys of one or more metrics. this.add({role: 'metrics', hook: 'map'}, map) // adds a sink plugin. Metrics are sent to sinks one at a time. A sink // can additionally match on source:'' and name: '' for granularity. A // sink does not emit data but may persist or otherwise store metrics. this.add({role: 'metrics', hook: 'sink'}, sink) // Tagging just means returning a source and payload, it allows // plugins that understand the data to tag it for themselves. This // means inbound data does not need to be modified at source function tag (msg, done) { var clean_data = { source: 'demo-plugin', payload: msg.payload } done(null, clean_data) } // Map plugins return arrays of metrics. The only required fields are // source and name. All other fields depend on the sink you want to use. // Note that the fields below represent our 'plugin' standard. function map (msg, done) { var metric = { source: msg.source, name: 'my-metric', values: {val: msg.payload.val}, tags: {tag: msg.payload.tag} } done(null, [metric]) } // On interval, Vidi: Metrics will call all emitters and ask for data. // Multiple points of data can be sent in a single emit. function emit (msg, done) { var raw_data = [ {source: 'demo-plugin', payload: {val: 1, tag: 'foo'}}, {val: 2, tag: 'foo'} ] done(null, raw_data) } // A sink simply does something with each metric it gets. In our case // we are logging to the console but you can do anything you like with it. function sink (msg, done) { var metric = msg.metric var as_text = JSON.stringify(metric, null, 1) console.log(as_text) done() } // Seneca requires you return a plugin name return 'demo-plugin' }
javascript
function demo_plugin (opts) { // adds an emit plugin. Emit plugins are called on regular intervals and have // the opertunity to add to the payload being sent to collectors. Data sent // from emit plugins should not require tagging, and should be map ready. this.add({role: 'metrics', hook: 'emit'}, emit) // adds a tag plugin. When inbound data is missing a source:'name' pair the // data is sent to tag plugins for identification and sanitation. Tag plugins // allow data to be standardised enough for map plugins to match on the data. this.add({role: 'metrics', hook: 'tag'}, tag) // adds a map plugin. Maps recieve data once per payload via sources. A // map can additionally match on source:'' for granularity. Maps emit // arrarys of one or more metrics. this.add({role: 'metrics', hook: 'map'}, map) // adds a sink plugin. Metrics are sent to sinks one at a time. A sink // can additionally match on source:'' and name: '' for granularity. A // sink does not emit data but may persist or otherwise store metrics. this.add({role: 'metrics', hook: 'sink'}, sink) // Tagging just means returning a source and payload, it allows // plugins that understand the data to tag it for themselves. This // means inbound data does not need to be modified at source function tag (msg, done) { var clean_data = { source: 'demo-plugin', payload: msg.payload } done(null, clean_data) } // Map plugins return arrays of metrics. The only required fields are // source and name. All other fields depend on the sink you want to use. // Note that the fields below represent our 'plugin' standard. function map (msg, done) { var metric = { source: msg.source, name: 'my-metric', values: {val: msg.payload.val}, tags: {tag: msg.payload.tag} } done(null, [metric]) } // On interval, Vidi: Metrics will call all emitters and ask for data. // Multiple points of data can be sent in a single emit. function emit (msg, done) { var raw_data = [ {source: 'demo-plugin', payload: {val: 1, tag: 'foo'}}, {val: 2, tag: 'foo'} ] done(null, raw_data) } // A sink simply does something with each metric it gets. In our case // we are logging to the console but you can do anything you like with it. function sink (msg, done) { var metric = msg.metric var as_text = JSON.stringify(metric, null, 1) console.log(as_text) done() } // Seneca requires you return a plugin name return 'demo-plugin' }
[ "function", "demo_plugin", "(", "opts", ")", "{", "// adds an emit plugin. Emit plugins are called on regular intervals and have", "// the opertunity to add to the payload being sent to collectors. Data sent", "// from emit plugins should not require tagging, and should be map ready.", "this", ".", "add", "(", "{", "role", ":", "'metrics'", ",", "hook", ":", "'emit'", "}", ",", "emit", ")", "// adds a tag plugin. When inbound data is missing a source:'name' pair the", "// data is sent to tag plugins for identification and sanitation. Tag plugins", "// allow data to be standardised enough for map plugins to match on the data.", "this", ".", "add", "(", "{", "role", ":", "'metrics'", ",", "hook", ":", "'tag'", "}", ",", "tag", ")", "// adds a map plugin. Maps recieve data once per payload via sources. A", "// map can additionally match on source:'' for granularity. Maps emit", "// arrarys of one or more metrics.", "this", ".", "add", "(", "{", "role", ":", "'metrics'", ",", "hook", ":", "'map'", "}", ",", "map", ")", "// adds a sink plugin. Metrics are sent to sinks one at a time. A sink", "// can additionally match on source:'' and name: '' for granularity. A", "// sink does not emit data but may persist or otherwise store metrics.", "this", ".", "add", "(", "{", "role", ":", "'metrics'", ",", "hook", ":", "'sink'", "}", ",", "sink", ")", "// Tagging just means returning a source and payload, it allows", "// plugins that understand the data to tag it for themselves. This", "// means inbound data does not need to be modified at source", "function", "tag", "(", "msg", ",", "done", ")", "{", "var", "clean_data", "=", "{", "source", ":", "'demo-plugin'", ",", "payload", ":", "msg", ".", "payload", "}", "done", "(", "null", ",", "clean_data", ")", "}", "// Map plugins return arrays of metrics. The only required fields are", "// source and name. All other fields depend on the sink you want to use.", "// Note that the fields below represent our 'plugin' standard.", "function", "map", "(", "msg", ",", "done", ")", "{", "var", "metric", "=", "{", "source", ":", "msg", ".", "source", ",", "name", ":", "'my-metric'", ",", "values", ":", "{", "val", ":", "msg", ".", "payload", ".", "val", "}", ",", "tags", ":", "{", "tag", ":", "msg", ".", "payload", ".", "tag", "}", "}", "done", "(", "null", ",", "[", "metric", "]", ")", "}", "// On interval, Vidi: Metrics will call all emitters and ask for data.", "// Multiple points of data can be sent in a single emit.", "function", "emit", "(", "msg", ",", "done", ")", "{", "var", "raw_data", "=", "[", "{", "source", ":", "'demo-plugin'", ",", "payload", ":", "{", "val", ":", "1", ",", "tag", ":", "'foo'", "}", "}", ",", "{", "val", ":", "2", ",", "tag", ":", "'foo'", "}", "]", "done", "(", "null", ",", "raw_data", ")", "}", "// A sink simply does something with each metric it gets. In our case", "// we are logging to the console but you can do anything you like with it.", "function", "sink", "(", "msg", ",", "done", ")", "{", "var", "metric", "=", "msg", ".", "metric", "var", "as_text", "=", "JSON", ".", "stringify", "(", "metric", ",", "null", ",", "1", ")", "console", ".", "log", "(", "as_text", ")", "done", "(", ")", "}", "// Seneca requires you return a plugin name", "return", "'demo-plugin'", "}" ]
Vidi plugins are simple seneca plugins.
[ "Vidi", "plugins", "are", "simple", "seneca", "plugins", "." ]
10737d1a2b12ca81affc5ea58e701040e1f59e77
https://github.com/vidi-insights/vidi-metrics/blob/10737d1a2b12ca81affc5ea58e701040e1f59e77/srv/demo.js#L19-L91
52,435
vidi-insights/vidi-metrics
srv/demo.js
tag
function tag (msg, done) { var clean_data = { source: 'demo-plugin', payload: msg.payload } done(null, clean_data) }
javascript
function tag (msg, done) { var clean_data = { source: 'demo-plugin', payload: msg.payload } done(null, clean_data) }
[ "function", "tag", "(", "msg", ",", "done", ")", "{", "var", "clean_data", "=", "{", "source", ":", "'demo-plugin'", ",", "payload", ":", "msg", ".", "payload", "}", "done", "(", "null", ",", "clean_data", ")", "}" ]
Tagging just means returning a source and payload, it allows plugins that understand the data to tag it for themselves. This means inbound data does not need to be modified at source
[ "Tagging", "just", "means", "returning", "a", "source", "and", "payload", "it", "allows", "plugins", "that", "understand", "the", "data", "to", "tag", "it", "for", "themselves", ".", "This", "means", "inbound", "data", "does", "not", "need", "to", "be", "modified", "at", "source" ]
10737d1a2b12ca81affc5ea58e701040e1f59e77
https://github.com/vidi-insights/vidi-metrics/blob/10737d1a2b12ca81affc5ea58e701040e1f59e77/srv/demo.js#L44-L51
52,436
vidi-insights/vidi-metrics
srv/demo.js
map
function map (msg, done) { var metric = { source: msg.source, name: 'my-metric', values: {val: msg.payload.val}, tags: {tag: msg.payload.tag} } done(null, [metric]) }
javascript
function map (msg, done) { var metric = { source: msg.source, name: 'my-metric', values: {val: msg.payload.val}, tags: {tag: msg.payload.tag} } done(null, [metric]) }
[ "function", "map", "(", "msg", ",", "done", ")", "{", "var", "metric", "=", "{", "source", ":", "msg", ".", "source", ",", "name", ":", "'my-metric'", ",", "values", ":", "{", "val", ":", "msg", ".", "payload", ".", "val", "}", ",", "tags", ":", "{", "tag", ":", "msg", ".", "payload", ".", "tag", "}", "}", "done", "(", "null", ",", "[", "metric", "]", ")", "}" ]
Map plugins return arrays of metrics. The only required fields are source and name. All other fields depend on the sink you want to use. Note that the fields below represent our 'plugin' standard.
[ "Map", "plugins", "return", "arrays", "of", "metrics", ".", "The", "only", "required", "fields", "are", "source", "and", "name", ".", "All", "other", "fields", "depend", "on", "the", "sink", "you", "want", "to", "use", ".", "Note", "that", "the", "fields", "below", "represent", "our", "plugin", "standard", "." ]
10737d1a2b12ca81affc5ea58e701040e1f59e77
https://github.com/vidi-insights/vidi-metrics/blob/10737d1a2b12ca81affc5ea58e701040e1f59e77/srv/demo.js#L56-L65
52,437
vidi-insights/vidi-metrics
srv/demo.js
sink
function sink (msg, done) { var metric = msg.metric var as_text = JSON.stringify(metric, null, 1) console.log(as_text) done() }
javascript
function sink (msg, done) { var metric = msg.metric var as_text = JSON.stringify(metric, null, 1) console.log(as_text) done() }
[ "function", "sink", "(", "msg", ",", "done", ")", "{", "var", "metric", "=", "msg", ".", "metric", "var", "as_text", "=", "JSON", ".", "stringify", "(", "metric", ",", "null", ",", "1", ")", "console", ".", "log", "(", "as_text", ")", "done", "(", ")", "}" ]
A sink simply does something with each metric it gets. In our case we are logging to the console but you can do anything you like with it.
[ "A", "sink", "simply", "does", "something", "with", "each", "metric", "it", "gets", ".", "In", "our", "case", "we", "are", "logging", "to", "the", "console", "but", "you", "can", "do", "anything", "you", "like", "with", "it", "." ]
10737d1a2b12ca81affc5ea58e701040e1f59e77
https://github.com/vidi-insights/vidi-metrics/blob/10737d1a2b12ca81affc5ea58e701040e1f59e77/srv/demo.js#L80-L87
52,438
ottojs/otto-errors
lib/locked.error.js
ErrorLocked
function ErrorLocked (message) { Error.call(this); // Add Information this.name = 'ErrorLocked'; this.type = 'client'; this.status = 423; if (message) { this.message = message; } }
javascript
function ErrorLocked (message) { Error.call(this); // Add Information this.name = 'ErrorLocked'; this.type = 'client'; this.status = 423; if (message) { this.message = message; } }
[ "function", "ErrorLocked", "(", "message", ")", "{", "Error", ".", "call", "(", "this", ")", ";", "// Add Information", "this", ".", "name", "=", "'ErrorLocked'", ";", "this", ".", "type", "=", "'client'", ";", "this", ".", "status", "=", "423", ";", "if", "(", "message", ")", "{", "this", ".", "message", "=", "message", ";", "}", "}" ]
Error - ErrorLocked
[ "Error", "-", "ErrorLocked" ]
a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9
https://github.com/ottojs/otto-errors/blob/a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9/lib/locked.error.js#L8-L20
52,439
jonschlinkert/engines
index.js
cache
function cache(options, compiled) { // cachable if (compiled && options.filename && options.cache) { delete templates[options.filename]; cacheStore[options.filename] = compiled; return compiled; } // check cache if (options.filename && options.cache) { return cacheStore[options.filename]; } return compiled; }
javascript
function cache(options, compiled) { // cachable if (compiled && options.filename && options.cache) { delete templates[options.filename]; cacheStore[options.filename] = compiled; return compiled; } // check cache if (options.filename && options.cache) { return cacheStore[options.filename]; } return compiled; }
[ "function", "cache", "(", "options", ",", "compiled", ")", "{", "// cachable", "if", "(", "compiled", "&&", "options", ".", "filename", "&&", "options", ".", "cache", ")", "{", "delete", "templates", "[", "options", ".", "filename", "]", ";", "cacheStore", "[", "options", ".", "filename", "]", "=", "compiled", ";", "return", "compiled", ";", "}", "// check cache", "if", "(", "options", ".", "filename", "&&", "options", ".", "cache", ")", "{", "return", "cacheStore", "[", "options", ".", "filename", "]", ";", "}", "return", "compiled", ";", "}" ]
Conditionally cache `compiled` template based on the `options` filename and `.cache` boolean. @param {Object} options @param {Function} compiled @return {Function} @api private
[ "Conditionally", "cache", "compiled", "template", "based", "on", "the", "options", "filename", "and", ".", "cache", "boolean", "." ]
82c19e6013a3e6e77d8c8a8e976433bd322587fd
https://github.com/jonschlinkert/engines/blob/82c19e6013a3e6e77d8c8a8e976433bd322587fd/index.js#L68-L80
52,440
jonschlinkert/engines
index.js
store
function store(path, options) { var str = templates[path]; var cached = options.cache && str && typeof str === 'string'; // cached (only if cached is a string and not a compiled template function) if (cached) return str; // store str = options.str; // remove extraneous utf8 BOM marker str = str.replace(/^\uFEFF/, ''); if (options.cache) { templates[path] = str; } return str; }
javascript
function store(path, options) { var str = templates[path]; var cached = options.cache && str && typeof str === 'string'; // cached (only if cached is a string and not a compiled template function) if (cached) return str; // store str = options.str; // remove extraneous utf8 BOM marker str = str.replace(/^\uFEFF/, ''); if (options.cache) { templates[path] = str; } return str; }
[ "function", "store", "(", "path", ",", "options", ")", "{", "var", "str", "=", "templates", "[", "path", "]", ";", "var", "cached", "=", "options", ".", "cache", "&&", "str", "&&", "typeof", "str", "===", "'string'", ";", "// cached (only if cached is a string and not a compiled template function)", "if", "(", "cached", ")", "return", "str", ";", "// store", "str", "=", "options", ".", "str", ";", "// remove extraneous utf8 BOM marker", "str", "=", "str", ".", "replace", "(", "/", "^\\uFEFF", "/", ",", "''", ")", ";", "if", "(", "options", ".", "cache", ")", "{", "templates", "[", "path", "]", "=", "str", ";", "}", "return", "str", ";", "}" ]
Read `path` with `options` When `options.cache` is true the template string will be cached. @param {String} path @param {String} options @api private
[ "Read", "path", "with", "options", "When", "options", ".", "cache", "is", "true", "the", "template", "string", "will", "be", "cached", "." ]
82c19e6013a3e6e77d8c8a8e976433bd322587fd
https://github.com/jonschlinkert/engines/blob/82c19e6013a3e6e77d8c8a8e976433bd322587fd/index.js#L93-L109
52,441
gethuman/pancakes-angular
lib/ngapp/storage.js
set
function set(name, value) { // if no value then remove if (!value) { remove(name); return; } if (localStorage) { try { localStorage.setItem(name, value); } catch (ex) {} } _.isFunction($cookies.put) ? $cookies.put(name, value, { domain: cookieDomain }) : $cookies[name] = value; }
javascript
function set(name, value) { // if no value then remove if (!value) { remove(name); return; } if (localStorage) { try { localStorage.setItem(name, value); } catch (ex) {} } _.isFunction($cookies.put) ? $cookies.put(name, value, { domain: cookieDomain }) : $cookies[name] = value; }
[ "function", "set", "(", "name", ",", "value", ")", "{", "// if no value then remove", "if", "(", "!", "value", ")", "{", "remove", "(", "name", ")", ";", "return", ";", "}", "if", "(", "localStorage", ")", "{", "try", "{", "localStorage", ".", "setItem", "(", "name", ",", "value", ")", ";", "}", "catch", "(", "ex", ")", "{", "}", "}", "_", ".", "isFunction", "(", "$cookies", ".", "put", ")", "?", "$cookies", ".", "put", "(", "name", ",", "value", ",", "{", "domain", ":", "cookieDomain", "}", ")", ":", "$cookies", "[", "name", "]", "=", "value", ";", "}" ]
Set a value in both localStorage and cookies @param name @param value
[ "Set", "a", "value", "in", "both", "localStorage", "and", "cookies" ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/storage.js#L36-L55
52,442
gethuman/pancakes-angular
lib/ngapp/storage.js
get
function get(name) { var value = (_.isFunction($cookies.get) ? $cookies.get(name) : $cookies[name]); if (!value && localStorage) { try { value = localStorage.getItem(name); } catch (ex) {} if (value) { set(name, value); } } return value; }
javascript
function get(name) { var value = (_.isFunction($cookies.get) ? $cookies.get(name) : $cookies[name]); if (!value && localStorage) { try { value = localStorage.getItem(name); } catch (ex) {} if (value) { set(name, value); } } return value; }
[ "function", "get", "(", "name", ")", "{", "var", "value", "=", "(", "_", ".", "isFunction", "(", "$cookies", ".", "get", ")", "?", "$cookies", ".", "get", "(", "name", ")", ":", "$cookies", "[", "name", "]", ")", ";", "if", "(", "!", "value", "&&", "localStorage", ")", "{", "try", "{", "value", "=", "localStorage", ".", "getItem", "(", "name", ")", ";", "}", "catch", "(", "ex", ")", "{", "}", "if", "(", "value", ")", "{", "set", "(", "name", ",", "value", ")", ";", "}", "}", "return", "value", ";", "}" ]
First check cookie; if not present, however, check local storage @param name
[ "First", "check", "cookie", ";", "if", "not", "present", "however", "check", "local", "storage" ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/storage.js#L61-L77
52,443
origin1tech/chek
dist/modules/string.js
camelcase
function camelcase(val) { if (!is_1.isValue(val)) return null; var result = val.replace(/[^A-Za-z0-9]/g, ' ').replace(/^\w|[A-Z]|\b\w|\s+/g, function (m, i) { if (+m === 0 || /(\.|-|_)/.test(m)) return ''; return i === 0 ? m.toLowerCase() : m.toUpperCase(); }); return result.charAt(0).toLowerCase() + result.slice(1); }
javascript
function camelcase(val) { if (!is_1.isValue(val)) return null; var result = val.replace(/[^A-Za-z0-9]/g, ' ').replace(/^\w|[A-Z]|\b\w|\s+/g, function (m, i) { if (+m === 0 || /(\.|-|_)/.test(m)) return ''; return i === 0 ? m.toLowerCase() : m.toUpperCase(); }); return result.charAt(0).toLowerCase() + result.slice(1); }
[ "function", "camelcase", "(", "val", ")", "{", "if", "(", "!", "is_1", ".", "isValue", "(", "val", ")", ")", "return", "null", ";", "var", "result", "=", "val", ".", "replace", "(", "/", "[^A-Za-z0-9]", "/", "g", ",", "' '", ")", ".", "replace", "(", "/", "^\\w|[A-Z]|\\b\\w|\\s+", "/", "g", ",", "function", "(", "m", ",", "i", ")", "{", "if", "(", "+", "m", "===", "0", "||", "/", "(\\.|-|_)", "/", ".", "test", "(", "m", ")", ")", "return", "''", ";", "return", "i", "===", "0", "?", "m", ".", "toLowerCase", "(", ")", ":", "m", ".", "toUpperCase", "(", ")", ";", "}", ")", ";", "return", "result", ".", "charAt", "(", "0", ")", ".", "toLowerCase", "(", ")", "+", "result", ".", "slice", "(", "1", ")", ";", "}" ]
Camelcase Converts string to camelcase. @param val the value to be transformed.
[ "Camelcase", "Converts", "string", "to", "camelcase", "." ]
6bc3ab0ac36126cc7918a244a606009749897b2e
https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/string.js#L11-L20
52,444
origin1tech/chek
dist/modules/string.js
capitalize
function capitalize(val) { if (!is_1.isValue(val)) return null; val = val.toLowerCase(); return "" + val.charAt(0).toUpperCase() + val.slice(1); }
javascript
function capitalize(val) { if (!is_1.isValue(val)) return null; val = val.toLowerCase(); return "" + val.charAt(0).toUpperCase() + val.slice(1); }
[ "function", "capitalize", "(", "val", ")", "{", "if", "(", "!", "is_1", ".", "isValue", "(", "val", ")", ")", "return", "null", ";", "val", "=", "val", ".", "toLowerCase", "(", ")", ";", "return", "\"\"", "+", "val", ".", "charAt", "(", "0", ")", ".", "toUpperCase", "(", ")", "+", "val", ".", "slice", "(", "1", ")", ";", "}" ]
Capitalize Converts string to capitalize. @param val the value to be transformed.
[ "Capitalize", "Converts", "string", "to", "capitalize", "." ]
6bc3ab0ac36126cc7918a244a606009749897b2e
https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/string.js#L44-L49
52,445
origin1tech/chek
dist/modules/string.js
padLeft
function padLeft(val, len, offset, char) { /* istanbul ignore if */ if (!is_1.isValue(val) || !is_1.isString(val)) return null; // If offset is a string // count its length. if (is_1.isString(offset)) offset = offset.length; char = char || ' '; var pad = ''; while (len--) { pad += char; } if (offset) return padLeft('', offset, null, char) + pad + val; return pad + val; }
javascript
function padLeft(val, len, offset, char) { /* istanbul ignore if */ if (!is_1.isValue(val) || !is_1.isString(val)) return null; // If offset is a string // count its length. if (is_1.isString(offset)) offset = offset.length; char = char || ' '; var pad = ''; while (len--) { pad += char; } if (offset) return padLeft('', offset, null, char) + pad + val; return pad + val; }
[ "function", "padLeft", "(", "val", ",", "len", ",", "offset", ",", "char", ")", "{", "/* istanbul ignore if */", "if", "(", "!", "is_1", ".", "isValue", "(", "val", ")", "||", "!", "is_1", ".", "isString", "(", "val", ")", ")", "return", "null", ";", "// If offset is a string", "// count its length.", "if", "(", "is_1", ".", "isString", "(", "offset", ")", ")", "offset", "=", "offset", ".", "length", ";", "char", "=", "char", "||", "' '", ";", "var", "pad", "=", "''", ";", "while", "(", "len", "--", ")", "{", "pad", "+=", "char", ";", "}", "if", "(", "offset", ")", "return", "padLeft", "(", "''", ",", "offset", ",", "null", ",", "char", ")", "+", "pad", "+", "val", ";", "return", "pad", "+", "val", ";", "}" ]
Pad Left Pads a string on the left. @param val the string to be padded. @param len the length to pad. @param offset an offset number or string to be counted. @param char the character to pad with.
[ "Pad", "Left", "Pads", "a", "string", "on", "the", "left", "." ]
6bc3ab0ac36126cc7918a244a606009749897b2e
https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/string.js#L72-L88
52,446
origin1tech/chek
dist/modules/string.js
padRight
function padRight(val, len, offset, char) { /* istanbul ignore if */ if (!is_1.isValue(val) || !is_1.isString(val)) return null; // If offset is a string // count its length. if (is_1.isString(offset)) offset = offset.length; char = char || ' '; while (len--) { val += char; } if (offset) val += padRight('', offset, null, char); return val; }
javascript
function padRight(val, len, offset, char) { /* istanbul ignore if */ if (!is_1.isValue(val) || !is_1.isString(val)) return null; // If offset is a string // count its length. if (is_1.isString(offset)) offset = offset.length; char = char || ' '; while (len--) { val += char; } if (offset) val += padRight('', offset, null, char); return val; }
[ "function", "padRight", "(", "val", ",", "len", ",", "offset", ",", "char", ")", "{", "/* istanbul ignore if */", "if", "(", "!", "is_1", ".", "isValue", "(", "val", ")", "||", "!", "is_1", ".", "isString", "(", "val", ")", ")", "return", "null", ";", "// If offset is a string", "// count its length.", "if", "(", "is_1", ".", "isString", "(", "offset", ")", ")", "offset", "=", "offset", ".", "length", ";", "char", "=", "char", "||", "' '", ";", "while", "(", "len", "--", ")", "{", "val", "+=", "char", ";", "}", "if", "(", "offset", ")", "val", "+=", "padRight", "(", "''", ",", "offset", ",", "null", ",", "char", ")", ";", "return", "val", ";", "}" ]
Pad Right Pads a string to the right. @param val the string to be padded. @param len the length to pad. @param offset an offset value to add. @param char the character to pad with.
[ "Pad", "Right", "Pads", "a", "string", "to", "the", "right", "." ]
6bc3ab0ac36126cc7918a244a606009749897b2e
https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/string.js#L99-L114
52,447
origin1tech/chek
dist/modules/string.js
titlecase
function titlecase(val, conjunctions) { if (!is_1.isValue(val)) return null; // conjunctions var conj = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i; return val.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function (m, i, t) { if (i > 0 && i + m.length !== t.length && m.search(conj) > -1 && t.charAt(i - 2) !== ';' && (t.charAt(i + m.length) !== '-' || t.charAt(i - 1) === '-') && t.charAt(i - 1).search(/[^\s-]/) < 0) { if (conjunctions === false) return capitalize(m); return m.toLowerCase(); } if (m.substr(1).search(/[A-Z]|\../) > -1) /* istanbul ignore next */ return m; return m.charAt(0).toUpperCase() + m.substr(1); }); }
javascript
function titlecase(val, conjunctions) { if (!is_1.isValue(val)) return null; // conjunctions var conj = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i; return val.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function (m, i, t) { if (i > 0 && i + m.length !== t.length && m.search(conj) > -1 && t.charAt(i - 2) !== ';' && (t.charAt(i + m.length) !== '-' || t.charAt(i - 1) === '-') && t.charAt(i - 1).search(/[^\s-]/) < 0) { if (conjunctions === false) return capitalize(m); return m.toLowerCase(); } if (m.substr(1).search(/[A-Z]|\../) > -1) /* istanbul ignore next */ return m; return m.charAt(0).toUpperCase() + m.substr(1); }); }
[ "function", "titlecase", "(", "val", ",", "conjunctions", ")", "{", "if", "(", "!", "is_1", ".", "isValue", "(", "val", ")", ")", "return", "null", ";", "// conjunctions", "var", "conj", "=", "/", "^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\\.?|via)$", "/", "i", ";", "return", "val", ".", "replace", "(", "/", "[A-Za-z0-9\\u00C0-\\u00FF]+[^\\s-]*", "/", "g", ",", "function", "(", "m", ",", "i", ",", "t", ")", "{", "if", "(", "i", ">", "0", "&&", "i", "+", "m", ".", "length", "!==", "t", ".", "length", "&&", "m", ".", "search", "(", "conj", ")", ">", "-", "1", "&&", "t", ".", "charAt", "(", "i", "-", "2", ")", "!==", "';'", "&&", "(", "t", ".", "charAt", "(", "i", "+", "m", ".", "length", ")", "!==", "'-'", "||", "t", ".", "charAt", "(", "i", "-", "1", ")", "===", "'-'", ")", "&&", "t", ".", "charAt", "(", "i", "-", "1", ")", ".", "search", "(", "/", "[^\\s-]", "/", ")", "<", "0", ")", "{", "if", "(", "conjunctions", "===", "false", ")", "return", "capitalize", "(", "m", ")", ";", "return", "m", ".", "toLowerCase", "(", ")", ";", "}", "if", "(", "m", ".", "substr", "(", "1", ")", ".", "search", "(", "/", "[A-Z]|\\..", "/", ")", ">", "-", "1", ")", "/* istanbul ignore next */", "return", "m", ";", "return", "m", ".", "charAt", "(", "0", ")", ".", "toUpperCase", "(", ")", "+", "m", ".", "substr", "(", "1", ")", ";", "}", ")", ";", "}" ]
Titlecase Converts string to titlecase. This fine script refactored from: @see https://github.com/gouch/to-title-case @param val the value to be transformed. @param conjunctions when true words like and, a, but, for are also titlecased.
[ "Titlecase", "Converts", "string", "to", "titlecase", "." ]
6bc3ab0ac36126cc7918a244a606009749897b2e
https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/string.js#L224-L243
52,448
origin1tech/chek
dist/modules/string.js
uuid
function uuid() { var d = Date.now(); // Use high perf timer if avail. /* istanbul ignore next */ if (typeof performance !== 'undefined' && is_1.isFunction(performance.now)) d += performance.now(); return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); }
javascript
function uuid() { var d = Date.now(); // Use high perf timer if avail. /* istanbul ignore next */ if (typeof performance !== 'undefined' && is_1.isFunction(performance.now)) d += performance.now(); return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); }
[ "function", "uuid", "(", ")", "{", "var", "d", "=", "Date", ".", "now", "(", ")", ";", "// Use high perf timer if avail.", "/* istanbul ignore next */", "if", "(", "typeof", "performance", "!==", "'undefined'", "&&", "is_1", ".", "isFunction", "(", "performance", ".", "now", ")", ")", "d", "+=", "performance", ".", "now", "(", ")", ";", "return", "'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'", ".", "replace", "(", "/", "[xy]", "/", "g", ",", "function", "(", "c", ")", "{", "var", "r", "=", "(", "d", "+", "Math", ".", "random", "(", ")", "*", "16", ")", "%", "16", "|", "0", ";", "d", "=", "Math", ".", "floor", "(", "d", "/", "16", ")", ";", "return", "(", "c", "===", "'x'", "?", "r", ":", "(", "r", "&", "0x3", "|", "0x8", ")", ")", ".", "toString", "(", "16", ")", ";", "}", ")", ";", "}" ]
UUID Generates a UUID.
[ "UUID", "Generates", "a", "UUID", "." ]
6bc3ab0ac36126cc7918a244a606009749897b2e
https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/string.js#L261-L272
52,449
WebArtWork/derer
lib/swig.js
validateOptions
function validateOptions(options) { if (!options) { return; } utils.each(['varControls', 'tagControls', 'cmtControls'], function (key) { if (!options.hasOwnProperty(key)) { return; } if (!utils.isArray(options[key]) || options[key].length !== 2) { throw new Error('Option "' + key + '" must be an array containing 2 different control strings.'); } if (options[key][0] === options[key][1]) { throw new Error('Option "' + key + '" open and close controls must not be the same.'); } utils.each(options[key], function (a, i) { if (a.length < 2) { throw new Error('Option "' + key + '" ' + ((i) ? 'open ' : 'close ') + 'control must be at least 2 characters. Saw "' + a + '" instead.'); } }); }); if (options.hasOwnProperty('cache')) { if (options.cache && options.cache !== 'memory') { if (!options.cache.get || !options.cache.set) { throw new Error('Invalid cache option ' + JSON.stringify(options.cache) + ' found. Expected "memory" or { get: function (key) { ... }, set: function (key, value) { ... } }.'); } } } if (options.hasOwnProperty('loader')) { if (options.loader) { if (!options.loader.load || !options.loader.resolve) { throw new Error('Invalid loader option ' + JSON.stringify(options.loader) + ' found. Expected { load: function (pathname, cb) { ... }, resolve: function (to, from) { ... } }.'); } } } }
javascript
function validateOptions(options) { if (!options) { return; } utils.each(['varControls', 'tagControls', 'cmtControls'], function (key) { if (!options.hasOwnProperty(key)) { return; } if (!utils.isArray(options[key]) || options[key].length !== 2) { throw new Error('Option "' + key + '" must be an array containing 2 different control strings.'); } if (options[key][0] === options[key][1]) { throw new Error('Option "' + key + '" open and close controls must not be the same.'); } utils.each(options[key], function (a, i) { if (a.length < 2) { throw new Error('Option "' + key + '" ' + ((i) ? 'open ' : 'close ') + 'control must be at least 2 characters. Saw "' + a + '" instead.'); } }); }); if (options.hasOwnProperty('cache')) { if (options.cache && options.cache !== 'memory') { if (!options.cache.get || !options.cache.set) { throw new Error('Invalid cache option ' + JSON.stringify(options.cache) + ' found. Expected "memory" or { get: function (key) { ... }, set: function (key, value) { ... } }.'); } } } if (options.hasOwnProperty('loader')) { if (options.loader) { if (!options.loader.load || !options.loader.resolve) { throw new Error('Invalid loader option ' + JSON.stringify(options.loader) + ' found. Expected { load: function (pathname, cb) { ... }, resolve: function (to, from) { ... } }.'); } } } }
[ "function", "validateOptions", "(", "options", ")", "{", "if", "(", "!", "options", ")", "{", "return", ";", "}", "utils", ".", "each", "(", "[", "'varControls'", ",", "'tagControls'", ",", "'cmtControls'", "]", ",", "function", "(", "key", ")", "{", "if", "(", "!", "options", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "return", ";", "}", "if", "(", "!", "utils", ".", "isArray", "(", "options", "[", "key", "]", ")", "||", "options", "[", "key", "]", ".", "length", "!==", "2", ")", "{", "throw", "new", "Error", "(", "'Option \"'", "+", "key", "+", "'\" must be an array containing 2 different control strings.'", ")", ";", "}", "if", "(", "options", "[", "key", "]", "[", "0", "]", "===", "options", "[", "key", "]", "[", "1", "]", ")", "{", "throw", "new", "Error", "(", "'Option \"'", "+", "key", "+", "'\" open and close controls must not be the same.'", ")", ";", "}", "utils", ".", "each", "(", "options", "[", "key", "]", ",", "function", "(", "a", ",", "i", ")", "{", "if", "(", "a", ".", "length", "<", "2", ")", "{", "throw", "new", "Error", "(", "'Option \"'", "+", "key", "+", "'\" '", "+", "(", "(", "i", ")", "?", "'open '", ":", "'close '", ")", "+", "'control must be at least 2 characters. Saw \"'", "+", "a", "+", "'\" instead.'", ")", ";", "}", "}", ")", ";", "}", ")", ";", "if", "(", "options", ".", "hasOwnProperty", "(", "'cache'", ")", ")", "{", "if", "(", "options", ".", "cache", "&&", "options", ".", "cache", "!==", "'memory'", ")", "{", "if", "(", "!", "options", ".", "cache", ".", "get", "||", "!", "options", ".", "cache", ".", "set", ")", "{", "throw", "new", "Error", "(", "'Invalid cache option '", "+", "JSON", ".", "stringify", "(", "options", ".", "cache", ")", "+", "' found. Expected \"memory\" or { get: function (key) { ... }, set: function (key, value) { ... } }.'", ")", ";", "}", "}", "}", "if", "(", "options", ".", "hasOwnProperty", "(", "'loader'", ")", ")", "{", "if", "(", "options", ".", "loader", ")", "{", "if", "(", "!", "options", ".", "loader", ".", "load", "||", "!", "options", ".", "loader", ".", "resolve", ")", "{", "throw", "new", "Error", "(", "'Invalid loader option '", "+", "JSON", ".", "stringify", "(", "options", ".", "loader", ")", "+", "' found. Expected { load: function (pathname, cb) { ... }, resolve: function (to, from) { ... } }.'", ")", ";", "}", "}", "}", "}" ]
Validate the Swig options object. @param {?SwigOpts} options Swig options object. @return {undefined} This method will throw errors if anything is wrong. @private
[ "Validate", "the", "Swig", "options", "object", "." ]
edf9f82c8042b543e6f291f605430fac84702b2d
https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/swig.js#L88-L125
52,450
WebArtWork/derer
lib/swig.js
getLocals
function getLocals(options) { if (!options || !options.locals) { return self.options.locals; } return utils.extend({}, self.options.locals, options.locals); }
javascript
function getLocals(options) { if (!options || !options.locals) { return self.options.locals; } return utils.extend({}, self.options.locals, options.locals); }
[ "function", "getLocals", "(", "options", ")", "{", "if", "(", "!", "options", "||", "!", "options", ".", "locals", ")", "{", "return", "self", ".", "options", ".", "locals", ";", "}", "return", "utils", ".", "extend", "(", "{", "}", ",", "self", ".", "options", ".", "locals", ",", "options", ".", "locals", ")", ";", "}" ]
Get combined locals context. @param {?SwigOpts} [options] Swig options object. @return {object} Locals context. @private
[ "Get", "combined", "locals", "context", "." ]
edf9f82c8042b543e6f291f605430fac84702b2d
https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/swig.js#L186-L192
52,451
WebArtWork/derer
lib/swig.js
cacheGet
function cacheGet(key, options) { if (shouldCache(options)) { return; } if (self.options.cache === 'memory') { return self.cache[key]; } return self.options.cache.get(key); }
javascript
function cacheGet(key, options) { if (shouldCache(options)) { return; } if (self.options.cache === 'memory') { return self.cache[key]; } return self.options.cache.get(key); }
[ "function", "cacheGet", "(", "key", ",", "options", ")", "{", "if", "(", "shouldCache", "(", "options", ")", ")", "{", "return", ";", "}", "if", "(", "self", ".", "options", ".", "cache", "===", "'memory'", ")", "{", "return", "self", ".", "cache", "[", "key", "]", ";", "}", "return", "self", ".", "options", ".", "cache", ".", "get", "(", "key", ")", ";", "}" ]
Get compiled template from the cache. @param {string} key Name of template. @return {object|undefined} Template function and tokens. @private
[ "Get", "compiled", "template", "from", "the", "cache", "." ]
edf9f82c8042b543e6f291f605430fac84702b2d
https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/swig.js#L211-L221
52,452
WebArtWork/derer
lib/swig.js
cacheSet
function cacheSet(key, options, val) { if (shouldCache(options)) { return; } if (self.options.cache === 'memory') { self.cache[key] = val; return; } self.options.cache.set(key, val); }
javascript
function cacheSet(key, options, val) { if (shouldCache(options)) { return; } if (self.options.cache === 'memory') { self.cache[key] = val; return; } self.options.cache.set(key, val); }
[ "function", "cacheSet", "(", "key", ",", "options", ",", "val", ")", "{", "if", "(", "shouldCache", "(", "options", ")", ")", "{", "return", ";", "}", "if", "(", "self", ".", "options", ".", "cache", "===", "'memory'", ")", "{", "self", ".", "cache", "[", "key", "]", "=", "val", ";", "return", ";", "}", "self", ".", "options", ".", "cache", ".", "set", "(", "key", ",", "val", ")", ";", "}" ]
Store a template in the cache. @param {string} key Name of template. @param {object} val Template function and tokens. @return {undefined} @private
[ "Store", "a", "template", "in", "the", "cache", "." ]
edf9f82c8042b543e6f291f605430fac84702b2d
https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/swig.js#L230-L241
52,453
WebArtWork/derer
lib/swig.js
remapBlocks
function remapBlocks(blocks, tokens) { return utils.map(tokens, function (token) { var args = token.args ? token.args.join('') : ''; if (token.name === 'block' && blocks[args]) { token = blocks[args]; } if (token.content && token.content.length) { token.content = remapBlocks(blocks, token.content); } return token; }); }
javascript
function remapBlocks(blocks, tokens) { return utils.map(tokens, function (token) { var args = token.args ? token.args.join('') : ''; if (token.name === 'block' && blocks[args]) { token = blocks[args]; } if (token.content && token.content.length) { token.content = remapBlocks(blocks, token.content); } return token; }); }
[ "function", "remapBlocks", "(", "blocks", ",", "tokens", ")", "{", "return", "utils", ".", "map", "(", "tokens", ",", "function", "(", "token", ")", "{", "var", "args", "=", "token", ".", "args", "?", "token", ".", "args", ".", "join", "(", "''", ")", ":", "''", ";", "if", "(", "token", ".", "name", "===", "'block'", "&&", "blocks", "[", "args", "]", ")", "{", "token", "=", "blocks", "[", "args", "]", ";", "}", "if", "(", "token", ".", "content", "&&", "token", ".", "content", ".", "length", ")", "{", "token", ".", "content", "=", "remapBlocks", "(", "blocks", ",", "token", ".", "content", ")", ";", "}", "return", "token", ";", "}", ")", ";", "}" ]
Re-Map blocks within a list of tokens to the template's block objects. @param {array} tokens List of tokens for the parent object. @param {object} template Current template that needs to be mapped to the parent's block and token list. @return {array} @private
[ "Re", "-", "Map", "blocks", "within", "a", "list", "of", "tokens", "to", "the", "template", "s", "block", "objects", "." ]
edf9f82c8042b543e6f291f605430fac84702b2d
https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/swig.js#L390-L401
52,454
WebArtWork/derer
lib/swig.js
importNonBlocks
function importNonBlocks(blocks, tokens) { var temp = []; utils.each(blocks, function (block) { temp.push(block); }); utils.each(temp.reverse(), function (block) { if (block.name !== 'block') { tokens.unshift(block); } }); }
javascript
function importNonBlocks(blocks, tokens) { var temp = []; utils.each(blocks, function (block) { temp.push(block); }); utils.each(temp.reverse(), function (block) { if (block.name !== 'block') { tokens.unshift(block); } }); }
[ "function", "importNonBlocks", "(", "blocks", ",", "tokens", ")", "{", "var", "temp", "=", "[", "]", ";", "utils", ".", "each", "(", "blocks", ",", "function", "(", "block", ")", "{", "temp", ".", "push", "(", "block", ")", ";", "}", ")", ";", "utils", ".", "each", "(", "temp", ".", "reverse", "(", ")", ",", "function", "(", "block", ")", "{", "if", "(", "block", ".", "name", "!==", "'block'", ")", "{", "tokens", ".", "unshift", "(", "block", ")", ";", "}", "}", ")", ";", "}" ]
Import block-level tags to the token list that are not actual block tags. @param {array} blocks List of block-level tags. @param {array} tokens List of tokens to render. @return {undefined} @private
[ "Import", "block", "-", "level", "tags", "to", "the", "token", "list", "that", "are", "not", "actual", "block", "tags", "." ]
edf9f82c8042b543e6f291f605430fac84702b2d
https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/swig.js#L410-L418
52,455
WebArtWork/derer
lib/swig.js
getParents
function getParents(tokens, options) { var parentName = tokens.parent, parentFiles = [], parents = [], parentFile, parent, l; while (parentName) { if (!options || !options.filename) { throw new Error('Cannot extend "' + parentName + '" because current template has no filename.'); } parentFile = parentFile || options.filename; parentFile = self.options.loader.resolve(parentName, parentFile); parent = cacheGet(parentFile, options) || self.parseFile(parentFile, utils.extend({}, options, { filename: parentFile })); parentName = parent.parent; if (parentFiles.indexOf(parentFile) !== -1) { throw new Error('Illegal circular extends of "' + parentFile + '".'); } parentFiles.push(parentFile); parents.push(parent); } // Remap each parents'(1) blocks onto its own parent(2), receiving the full token list for rendering the original parent(1) on its own. l = parents.length; for (l = parents.length - 2; l >= 0; l -= 1) { parents[l].tokens = remapBlocks(parents[l].blocks, parents[l + 1].tokens); importNonBlocks(parents[l].blocks, parents[l].tokens); } return parents; }
javascript
function getParents(tokens, options) { var parentName = tokens.parent, parentFiles = [], parents = [], parentFile, parent, l; while (parentName) { if (!options || !options.filename) { throw new Error('Cannot extend "' + parentName + '" because current template has no filename.'); } parentFile = parentFile || options.filename; parentFile = self.options.loader.resolve(parentName, parentFile); parent = cacheGet(parentFile, options) || self.parseFile(parentFile, utils.extend({}, options, { filename: parentFile })); parentName = parent.parent; if (parentFiles.indexOf(parentFile) !== -1) { throw new Error('Illegal circular extends of "' + parentFile + '".'); } parentFiles.push(parentFile); parents.push(parent); } // Remap each parents'(1) blocks onto its own parent(2), receiving the full token list for rendering the original parent(1) on its own. l = parents.length; for (l = parents.length - 2; l >= 0; l -= 1) { parents[l].tokens = remapBlocks(parents[l].blocks, parents[l + 1].tokens); importNonBlocks(parents[l].blocks, parents[l].tokens); } return parents; }
[ "function", "getParents", "(", "tokens", ",", "options", ")", "{", "var", "parentName", "=", "tokens", ".", "parent", ",", "parentFiles", "=", "[", "]", ",", "parents", "=", "[", "]", ",", "parentFile", ",", "parent", ",", "l", ";", "while", "(", "parentName", ")", "{", "if", "(", "!", "options", "||", "!", "options", ".", "filename", ")", "{", "throw", "new", "Error", "(", "'Cannot extend \"'", "+", "parentName", "+", "'\" because current template has no filename.'", ")", ";", "}", "parentFile", "=", "parentFile", "||", "options", ".", "filename", ";", "parentFile", "=", "self", ".", "options", ".", "loader", ".", "resolve", "(", "parentName", ",", "parentFile", ")", ";", "parent", "=", "cacheGet", "(", "parentFile", ",", "options", ")", "||", "self", ".", "parseFile", "(", "parentFile", ",", "utils", ".", "extend", "(", "{", "}", ",", "options", ",", "{", "filename", ":", "parentFile", "}", ")", ")", ";", "parentName", "=", "parent", ".", "parent", ";", "if", "(", "parentFiles", ".", "indexOf", "(", "parentFile", ")", "!==", "-", "1", ")", "{", "throw", "new", "Error", "(", "'Illegal circular extends of \"'", "+", "parentFile", "+", "'\".'", ")", ";", "}", "parentFiles", ".", "push", "(", "parentFile", ")", ";", "parents", ".", "push", "(", "parent", ")", ";", "}", "// Remap each parents'(1) blocks onto its own parent(2), receiving the full token list for rendering the original parent(1) on its own.", "l", "=", "parents", ".", "length", ";", "for", "(", "l", "=", "parents", ".", "length", "-", "2", ";", "l", ">=", "0", ";", "l", "-=", "1", ")", "{", "parents", "[", "l", "]", ".", "tokens", "=", "remapBlocks", "(", "parents", "[", "l", "]", ".", "blocks", ",", "parents", "[", "l", "+", "1", "]", ".", "tokens", ")", ";", "importNonBlocks", "(", "parents", "[", "l", "]", ".", "blocks", ",", "parents", "[", "l", "]", ".", "tokens", ")", ";", "}", "return", "parents", ";", "}" ]
Recursively compile and get parents of given parsed token object. @param {object} tokens Parsed tokens from template. @param {SwigOpts} [options={}] Swig options object. @return {object} Parsed tokens from parent templates. @private
[ "Recursively", "compile", "and", "get", "parents", "of", "given", "parsed", "token", "object", "." ]
edf9f82c8042b543e6f291f605430fac84702b2d
https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/swig.js#L428-L462
52,456
base-apps/base-apps-router
dist/FrontRouter.js
FrontRouter
function FrontRouter() { var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; _classCallCheck(this, FrontRouter); this.options = { pageRoot: opts.pageRoot || process.cwd(), overwrite: opts.overwrite || false }; this.routes = []; // Figure out what library to load switch (_typeof(opts.library)) { // String: pull a library out of the built-in ones case 'string': { var lib = Libraries[opts.library]; if (typeof lib === 'undefined') { throw new Error('Front Router: there\'s no built-in plugin for "' + opts.library + '"'); } else { this.options.library = lib; } break; } // Function: add as-is case 'function': { this.options.library = opts.library; break; } // Nothing: use the default library adapter case 'undefined': { this.options.library = Libraries.default; break; } // Other weird values? Nope default: { throw new Error('Front Router: library must be a string or function.'); } } }
javascript
function FrontRouter() { var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; _classCallCheck(this, FrontRouter); this.options = { pageRoot: opts.pageRoot || process.cwd(), overwrite: opts.overwrite || false }; this.routes = []; // Figure out what library to load switch (_typeof(opts.library)) { // String: pull a library out of the built-in ones case 'string': { var lib = Libraries[opts.library]; if (typeof lib === 'undefined') { throw new Error('Front Router: there\'s no built-in plugin for "' + opts.library + '"'); } else { this.options.library = lib; } break; } // Function: add as-is case 'function': { this.options.library = opts.library; break; } // Nothing: use the default library adapter case 'undefined': { this.options.library = Libraries.default; break; } // Other weird values? Nope default: { throw new Error('Front Router: library must be a string or function.'); } } }
[ "function", "FrontRouter", "(", ")", "{", "var", "opts", "=", "arguments", ".", "length", "<=", "0", "||", "arguments", "[", "0", "]", "===", "undefined", "?", "{", "}", ":", "arguments", "[", "0", "]", ";", "_classCallCheck", "(", "this", ",", "FrontRouter", ")", ";", "this", ".", "options", "=", "{", "pageRoot", ":", "opts", ".", "pageRoot", "||", "process", ".", "cwd", "(", ")", ",", "overwrite", ":", "opts", ".", "overwrite", "||", "false", "}", ";", "this", ".", "routes", "=", "[", "]", ";", "// Figure out what library to load", "switch", "(", "_typeof", "(", "opts", ".", "library", ")", ")", "{", "// String: pull a library out of the built-in ones", "case", "'string'", ":", "{", "var", "lib", "=", "Libraries", "[", "opts", ".", "library", "]", ";", "if", "(", "typeof", "lib", "===", "'undefined'", ")", "{", "throw", "new", "Error", "(", "'Front Router: there\\'s no built-in plugin for \"'", "+", "opts", ".", "library", "+", "'\"'", ")", ";", "}", "else", "{", "this", ".", "options", ".", "library", "=", "lib", ";", "}", "break", ";", "}", "// Function: add as-is", "case", "'function'", ":", "{", "this", ".", "options", ".", "library", "=", "opts", ".", "library", ";", "break", ";", "}", "// Nothing: use the default library adapter", "case", "'undefined'", ":", "{", "this", ".", "options", ".", "library", "=", "Libraries", ".", "default", ";", "break", ";", "}", "// Other weird values? Nope", "default", ":", "{", "throw", "new", "Error", "(", "'Front Router: library must be a string or function.'", ")", ";", "}", "}", "}" ]
Creates a new instance of `FrontRouter`. @prop {FrontRouterOptions} opts - Class options.
[ "Creates", "a", "new", "instance", "of", "FrontRouter", "." ]
bf5e99987003635fbac0144c0be35d5a863065d9
https://github.com/base-apps/base-apps-router/blob/bf5e99987003635fbac0144c0be35d5a863065d9/dist/FrontRouter.js#L28-L70
52,457
toajs/toa-morgan
index.js
compileToken
function compileToken (token, arg) { let fn = tokens[token] || noOp return function () { return arg ? fn.call(this, arg) : fn.call(this) } }
javascript
function compileToken (token, arg) { let fn = tokens[token] || noOp return function () { return arg ? fn.call(this, arg) : fn.call(this) } }
[ "function", "compileToken", "(", "token", ",", "arg", ")", "{", "let", "fn", "=", "tokens", "[", "token", "]", "||", "noOp", "return", "function", "(", ")", "{", "return", "arg", "?", "fn", ".", "call", "(", "this", ",", "arg", ")", ":", "fn", ".", "call", "(", "this", ")", "}", "}" ]
Compile a token string into a function. @param {string} token @param {string} arg @return {function} @private
[ "Compile", "a", "token", "string", "into", "a", "function", "." ]
8308b474dff45a513c85ad90b0ddc5379bb5fb11
https://github.com/toajs/toa-morgan/blob/8308b474dff45a513c85ad90b0ddc5379bb5fb11/index.js#L269-L275
52,458
redisjs/jsr-server
lib/command/pubsub/punsubscribe.js
execute
function execute(req, res) { this.state.pubsub.punsubscribe(req.conn, req.args); }
javascript
function execute(req, res) { this.state.pubsub.punsubscribe(req.conn, req.args); }
[ "function", "execute", "(", "req", ",", "res", ")", "{", "this", ".", "state", ".", "pubsub", ".", "punsubscribe", "(", "req", ".", "conn", ",", "req", ".", "args", ")", ";", "}" ]
Respond to the PUNSUBSCRIBE command.
[ "Respond", "to", "the", "PUNSUBSCRIBE", "command", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/punsubscribe.js#L17-L19
52,459
emmetio/variable-resolver
index.js
createModel
function createModel(string) { const reVariable = /\$\{([a-z][\w\-]*)\}/ig; const escapeCharCode = 92; // `\` symbol const variables = []; // We have to replace unescaped (e.g. not preceded with `\`) tokens. // Instead of writing a stream parser, we’ll cut some edges here: // 1. Find all tokens // 2. Walk string char-by-char and resolve only tokens that are not escaped const tokens = new Map(); let m; while (m = reVariable.exec(string)) { tokens.set(m.index, m); } if (tokens.size) { let start = 0, pos = 0, len = string.length; let output = ''; while (pos < len) { if (string.charCodeAt(pos) === escapeCharCode && tokens.has(pos + 1)) { // Found escape symbol that escapes variable: we should // omit this symbol in output string and skip variable const token = tokens.get(pos + 1); output += string.slice(start, pos) + token[0]; start = pos = token.index + token[0].length; tokens.delete(pos + 1); continue; } pos++; } string = output + string.slice(start); // Not using `.map()` here to reduce memory allocations const validMatches = Array.from(tokens.values()); for (let i = 0, il = validMatches.length; i < il; i++) { const token = validMatches[i]; variables.push({ name: token[1], location: token.index, length: token[0].length }); } } return {string, variables}; }
javascript
function createModel(string) { const reVariable = /\$\{([a-z][\w\-]*)\}/ig; const escapeCharCode = 92; // `\` symbol const variables = []; // We have to replace unescaped (e.g. not preceded with `\`) tokens. // Instead of writing a stream parser, we’ll cut some edges here: // 1. Find all tokens // 2. Walk string char-by-char and resolve only tokens that are not escaped const tokens = new Map(); let m; while (m = reVariable.exec(string)) { tokens.set(m.index, m); } if (tokens.size) { let start = 0, pos = 0, len = string.length; let output = ''; while (pos < len) { if (string.charCodeAt(pos) === escapeCharCode && tokens.has(pos + 1)) { // Found escape symbol that escapes variable: we should // omit this symbol in output string and skip variable const token = tokens.get(pos + 1); output += string.slice(start, pos) + token[0]; start = pos = token.index + token[0].length; tokens.delete(pos + 1); continue; } pos++; } string = output + string.slice(start); // Not using `.map()` here to reduce memory allocations const validMatches = Array.from(tokens.values()); for (let i = 0, il = validMatches.length; i < il; i++) { const token = validMatches[i]; variables.push({ name: token[1], location: token.index, length: token[0].length }); } } return {string, variables}; }
[ "function", "createModel", "(", "string", ")", "{", "const", "reVariable", "=", "/", "\\$\\{([a-z][\\w\\-]*)\\}", "/", "ig", ";", "const", "escapeCharCode", "=", "92", ";", "// `\\` symbol", "const", "variables", "=", "[", "]", ";", "// We have to replace unescaped (e.g. not preceded with `\\`) tokens.", "// Instead of writing a stream parser, we’ll cut some edges here:", "// 1. Find all tokens", "// 2. Walk string char-by-char and resolve only tokens that are not escaped", "const", "tokens", "=", "new", "Map", "(", ")", ";", "let", "m", ";", "while", "(", "m", "=", "reVariable", ".", "exec", "(", "string", ")", ")", "{", "tokens", ".", "set", "(", "m", ".", "index", ",", "m", ")", ";", "}", "if", "(", "tokens", ".", "size", ")", "{", "let", "start", "=", "0", ",", "pos", "=", "0", ",", "len", "=", "string", ".", "length", ";", "let", "output", "=", "''", ";", "while", "(", "pos", "<", "len", ")", "{", "if", "(", "string", ".", "charCodeAt", "(", "pos", ")", "===", "escapeCharCode", "&&", "tokens", ".", "has", "(", "pos", "+", "1", ")", ")", "{", "// Found escape symbol that escapes variable: we should", "// omit this symbol in output string and skip variable", "const", "token", "=", "tokens", ".", "get", "(", "pos", "+", "1", ")", ";", "output", "+=", "string", ".", "slice", "(", "start", ",", "pos", ")", "+", "token", "[", "0", "]", ";", "start", "=", "pos", "=", "token", ".", "index", "+", "token", "[", "0", "]", ".", "length", ";", "tokens", ".", "delete", "(", "pos", "+", "1", ")", ";", "continue", ";", "}", "pos", "++", ";", "}", "string", "=", "output", "+", "string", ".", "slice", "(", "start", ")", ";", "// Not using `.map()` here to reduce memory allocations", "const", "validMatches", "=", "Array", ".", "from", "(", "tokens", ".", "values", "(", ")", ")", ";", "for", "(", "let", "i", "=", "0", ",", "il", "=", "validMatches", ".", "length", ";", "i", "<", "il", ";", "i", "++", ")", "{", "const", "token", "=", "validMatches", "[", "i", "]", ";", "variables", ".", "push", "(", "{", "name", ":", "token", "[", "1", "]", ",", "location", ":", "token", ".", "index", ",", "length", ":", "token", "[", "0", "]", ".", "length", "}", ")", ";", "}", "}", "return", "{", "string", ",", "variables", "}", ";", "}" ]
Creates variable model from given string. The model contains a `string` with all escaped variable tokens written without escape symbol and `variables` property with all unescaped variables and their ranges @param {String} string @return {Object}
[ "Creates", "variable", "model", "from", "given", "string", ".", "The", "model", "contains", "a", "string", "with", "all", "escaped", "variable", "tokens", "written", "without", "escape", "symbol", "and", "variables", "property", "with", "all", "unescaped", "variables", "and", "their", "ranges" ]
c6cf8ef476e731447418e718c8bd3f15fa518deb
https://github.com/emmetio/variable-resolver/blob/c6cf8ef476e731447418e718c8bd3f15fa518deb/index.js#L68-L115
52,460
asavoy/grunt-requirejs-auto-bundles
lib/reduce.js
reduceBundles
function reduceBundles(bundles, dependencies, maxBundles) { while (anyMainExceedsMaxBundles(bundles, maxBundles)) { var merge = findLeastCostMerge(bundles, dependencies, maxBundles); mergeBundles(merge.bundle1Name, merge.bundle2Name, bundles); } return bundles; }
javascript
function reduceBundles(bundles, dependencies, maxBundles) { while (anyMainExceedsMaxBundles(bundles, maxBundles)) { var merge = findLeastCostMerge(bundles, dependencies, maxBundles); mergeBundles(merge.bundle1Name, merge.bundle2Name, bundles); } return bundles; }
[ "function", "reduceBundles", "(", "bundles", ",", "dependencies", ",", "maxBundles", ")", "{", "while", "(", "anyMainExceedsMaxBundles", "(", "bundles", ",", "maxBundles", ")", ")", "{", "var", "merge", "=", "findLeastCostMerge", "(", "bundles", ",", "dependencies", ",", "maxBundles", ")", ";", "mergeBundles", "(", "merge", ".", "bundle1Name", ",", "merge", ".", "bundle2Name", ",", "bundles", ")", ";", "}", "return", "bundles", ";", "}" ]
Given a set of bundles, merge until no main module needs to fetch from more than maxBundles number of bundles.
[ "Given", "a", "set", "of", "bundles", "merge", "until", "no", "main", "module", "needs", "to", "fetch", "from", "more", "than", "maxBundles", "number", "of", "bundles", "." ]
c0f587c9720943dd32098203d2c71ab1387f1700
https://github.com/asavoy/grunt-requirejs-auto-bundles/blob/c0f587c9720943dd32098203d2c71ab1387f1700/lib/reduce.js#L10-L16
52,461
jonschlinkert/resolve-up
index.js
resolve
function resolve(files, opts) { var fn = opts.filter || function(fp) { return true; }; if (opts.realpath === true) { return files.filter(fn); } var len = files.length; var idx = -1; var res = []; while (++idx < len) { var fp = path.resolve(opts.cwd, files[idx]); if (!fn(fp) || ~res.indexOf(fp)) continue; res.push(fp); } return res; }
javascript
function resolve(files, opts) { var fn = opts.filter || function(fp) { return true; }; if (opts.realpath === true) { return files.filter(fn); } var len = files.length; var idx = -1; var res = []; while (++idx < len) { var fp = path.resolve(opts.cwd, files[idx]); if (!fn(fp) || ~res.indexOf(fp)) continue; res.push(fp); } return res; }
[ "function", "resolve", "(", "files", ",", "opts", ")", "{", "var", "fn", "=", "opts", ".", "filter", "||", "function", "(", "fp", ")", "{", "return", "true", ";", "}", ";", "if", "(", "opts", ".", "realpath", "===", "true", ")", "{", "return", "files", ".", "filter", "(", "fn", ")", ";", "}", "var", "len", "=", "files", ".", "length", ";", "var", "idx", "=", "-", "1", ";", "var", "res", "=", "[", "]", ";", "while", "(", "++", "idx", "<", "len", ")", "{", "var", "fp", "=", "path", ".", "resolve", "(", "opts", ".", "cwd", ",", "files", "[", "idx", "]", ")", ";", "if", "(", "!", "fn", "(", "fp", ")", "||", "~", "res", ".", "indexOf", "(", "fp", ")", ")", "continue", ";", "res", ".", "push", "(", "fp", ")", ";", "}", "return", "res", ";", "}" ]
Resolve the absolute path to a file using the given cwd.
[ "Resolve", "the", "absolute", "path", "to", "a", "file", "using", "the", "given", "cwd", "." ]
d4c566630e85c3ab83af44df1bba46ff49ddaadc
https://github.com/jonschlinkert/resolve-up/blob/d4c566630e85c3ab83af44df1bba46ff49ddaadc/index.js#L64-L83
52,462
halfblood369/monitor
lib/processMonitor.js
getPsInfo
function getPsInfo(param, callback) { if (process.platform === 'windows') return; var pid = param.pid; var cmd = "ps auxw | grep " + pid + " | grep -v 'grep'"; //var cmd = "ps auxw | grep -E '.+?\\s+" + pid + "\\s+'" ; exec(cmd, function(err, output) { if (!!err) { if (err.code === 1) { console.log('the content is null!'); } else { console.error('getPsInfo failed! ' + err.stack); } callback(err, null); return; } format(param, output, callback); }); }
javascript
function getPsInfo(param, callback) { if (process.platform === 'windows') return; var pid = param.pid; var cmd = "ps auxw | grep " + pid + " | grep -v 'grep'"; //var cmd = "ps auxw | grep -E '.+?\\s+" + pid + "\\s+'" ; exec(cmd, function(err, output) { if (!!err) { if (err.code === 1) { console.log('the content is null!'); } else { console.error('getPsInfo failed! ' + err.stack); } callback(err, null); return; } format(param, output, callback); }); }
[ "function", "getPsInfo", "(", "param", ",", "callback", ")", "{", "if", "(", "process", ".", "platform", "===", "'windows'", ")", "return", ";", "var", "pid", "=", "param", ".", "pid", ";", "var", "cmd", "=", "\"ps auxw | grep \"", "+", "pid", "+", "\" | grep -v 'grep'\"", ";", "//var cmd = \"ps auxw | grep -E '.+?\\\\s+\" + pid + \"\\\\s+'\" ;\r", "exec", "(", "cmd", ",", "function", "(", "err", ",", "output", ")", "{", "if", "(", "!", "!", "err", ")", "{", "if", "(", "err", ".", "code", "===", "1", ")", "{", "console", ".", "log", "(", "'the content is null!'", ")", ";", "}", "else", "{", "console", ".", "error", "(", "'getPsInfo failed! '", "+", "err", ".", "stack", ")", ";", "}", "callback", "(", "err", ",", "null", ")", ";", "return", ";", "}", "format", "(", "param", ",", "output", ",", "callback", ")", ";", "}", ")", ";", "}" ]
get the process information by command 'ps auxw | grep serverId | grep pid' @param {Object} param @param {Function} callback @api public
[ "get", "the", "process", "information", "by", "command", "ps", "auxw", "|", "grep", "serverId", "|", "grep", "pid" ]
900b5cadf59edcccac4754e5706a22719925ddb9
https://github.com/halfblood369/monitor/blob/900b5cadf59edcccac4754e5706a22719925ddb9/lib/processMonitor.js#L23-L40
52,463
arielschiavoni/commonjsify
src/commonjsify.js
browserifyTransform
function browserifyTransform(file) { var chunks = []; var write = function(buffer) { chunks.push(buffer); }; var end = function() { var content = Buffer.concat(chunks).toString('utf8'); // convention fileName == key for shim options var fileName = file.match(/([^\/]+)(?=\.\w+$)/)[0]; this.queue(commonjsify(content, options[fileName])); this.queue(null); }; return through(write, end); }
javascript
function browserifyTransform(file) { var chunks = []; var write = function(buffer) { chunks.push(buffer); }; var end = function() { var content = Buffer.concat(chunks).toString('utf8'); // convention fileName == key for shim options var fileName = file.match(/([^\/]+)(?=\.\w+$)/)[0]; this.queue(commonjsify(content, options[fileName])); this.queue(null); }; return through(write, end); }
[ "function", "browserifyTransform", "(", "file", ")", "{", "var", "chunks", "=", "[", "]", ";", "var", "write", "=", "function", "(", "buffer", ")", "{", "chunks", ".", "push", "(", "buffer", ")", ";", "}", ";", "var", "end", "=", "function", "(", ")", "{", "var", "content", "=", "Buffer", ".", "concat", "(", "chunks", ")", ".", "toString", "(", "'utf8'", ")", ";", "// convention fileName == key for shim options", "var", "fileName", "=", "file", ".", "match", "(", "/", "([^\\/]+)(?=\\.\\w+$)", "/", ")", "[", "0", "]", ";", "this", ".", "queue", "(", "commonjsify", "(", "content", ",", "options", "[", "fileName", "]", ")", ")", ";", "this", ".", "queue", "(", "null", ")", ";", "}", ";", "return", "through", "(", "write", ",", "end", ")", ";", "}" ]
The function Browserify will use to transform the input. @param {string} file @returns {stream}
[ "The", "function", "Browserify", "will", "use", "to", "transform", "the", "input", "." ]
544dff6bdf2f4aad8802cbfb60d2aa5852482c0f
https://github.com/arielschiavoni/commonjsify/blob/544dff6bdf2f4aad8802cbfb60d2aa5852482c0f/src/commonjsify.js#L25-L41
52,464
nknapp/deep-aplus
.thought/helpers.js
function (cwd, filename, options, customizeEngine) { var helpers = customizeEngine.engine.helpers var code = helpers.example(path.join(cwd, filename), { hash: { snippet: true } }) var result = helpers.exec(`node ${filename}`, { hash: { cwd: cwd, lang: 'raw' } }) return Q.all([code,result]).spread(function(code, result) { console.log(result) var output = result.split('\u0001') return code.replace(/console\.log\-output/g, function() { return output.shift().trim(); }) }) }
javascript
function (cwd, filename, options, customizeEngine) { var helpers = customizeEngine.engine.helpers var code = helpers.example(path.join(cwd, filename), { hash: { snippet: true } }) var result = helpers.exec(`node ${filename}`, { hash: { cwd: cwd, lang: 'raw' } }) return Q.all([code,result]).spread(function(code, result) { console.log(result) var output = result.split('\u0001') return code.replace(/console\.log\-output/g, function() { return output.shift().trim(); }) }) }
[ "function", "(", "cwd", ",", "filename", ",", "options", ",", "customizeEngine", ")", "{", "var", "helpers", "=", "customizeEngine", ".", "engine", ".", "helpers", "var", "code", "=", "helpers", ".", "example", "(", "path", ".", "join", "(", "cwd", ",", "filename", ")", ",", "{", "hash", ":", "{", "snippet", ":", "true", "}", "}", ")", "var", "result", "=", "helpers", ".", "exec", "(", "`", "${", "filename", "}", "`", ",", "{", "hash", ":", "{", "cwd", ":", "cwd", ",", "lang", ":", "'raw'", "}", "}", ")", "return", "Q", ".", "all", "(", "[", "code", ",", "result", "]", ")", ".", "spread", "(", "function", "(", "code", ",", "result", ")", "{", "console", ".", "log", "(", "result", ")", "var", "output", "=", "result", ".", "split", "(", "'\\u0001'", ")", "return", "code", ".", "replace", "(", "/", "console\\.log\\-output", "/", "g", ",", "function", "(", ")", "{", "return", "output", ".", "shift", "(", ")", ".", "trim", "(", ")", ";", "}", ")", "}", ")", "}" ]
Merges the example output into the source code. In the example, `console.log` must be wrapped so that `\u0001` is inserted before each output. `console.log` may not be called in loops.
[ "Merges", "the", "example", "output", "into", "the", "source", "code", ".", "In", "the", "example", "console", ".", "log", "must", "be", "wrapped", "so", "that", "\\", "u0001", "is", "inserted", "before", "each", "output", ".", "console", ".", "log", "may", "not", "be", "called", "in", "loops", "." ]
da8c5432e895c5087dc1f1a2234be4273ab0592c
https://github.com/nknapp/deep-aplus/blob/da8c5432e895c5087dc1f1a2234be4273ab0592c/.thought/helpers.js#L11-L34
52,465
redisjs/jsr-server
lib/network.js
NetworkServer
function NetworkServer(server) { this.server = server; function connection(socket) { server.connection(socket, this); } this.on('connection', connection); }
javascript
function NetworkServer(server) { this.server = server; function connection(socket) { server.connection(socket, this); } this.on('connection', connection); }
[ "function", "NetworkServer", "(", "server", ")", "{", "this", ".", "server", "=", "server", ";", "function", "connection", "(", "socket", ")", "{", "server", ".", "connection", "(", "socket", ",", "this", ")", ";", "}", "this", ".", "on", "(", "'connection'", ",", "connection", ")", ";", "}" ]
Abstract server class. @param server The main server instance.
[ "Abstract", "server", "class", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/network.js#L13-L19
52,466
redisjs/jsr-server
lib/network.js
listen
function listen(file, perm) { var args = [file] , perm = perm || 0700 , server = this; this.file = file; this.name = path.basename(file); if(this.name === file) { file = path.join(process.cwd(), file); } function onListen() { try { fs.chmodSync(file, perm); }catch(e){} log.notice('accepting connections at %s', file); } args.push(onListen); // jump through some hoops for stale sockets server.on('error', function (e) { if(e.code == 'EADDRINUSE') { var client = new net.Socket(); // handle error trying to talk to server client.on('error', function(e) { // no other server listening if(e.code == 'ECONNREFUSED') { fs.unlinkSync(file); TcpServer.prototype.listen.apply(server, args); } }); client.connect({path: file}, function() { // exit with original EADDRINUSE throw e; }); } }); Server.prototype.listen.apply(server, args); }
javascript
function listen(file, perm) { var args = [file] , perm = perm || 0700 , server = this; this.file = file; this.name = path.basename(file); if(this.name === file) { file = path.join(process.cwd(), file); } function onListen() { try { fs.chmodSync(file, perm); }catch(e){} log.notice('accepting connections at %s', file); } args.push(onListen); // jump through some hoops for stale sockets server.on('error', function (e) { if(e.code == 'EADDRINUSE') { var client = new net.Socket(); // handle error trying to talk to server client.on('error', function(e) { // no other server listening if(e.code == 'ECONNREFUSED') { fs.unlinkSync(file); TcpServer.prototype.listen.apply(server, args); } }); client.connect({path: file}, function() { // exit with original EADDRINUSE throw e; }); } }); Server.prototype.listen.apply(server, args); }
[ "function", "listen", "(", "file", ",", "perm", ")", "{", "var", "args", "=", "[", "file", "]", ",", "perm", "=", "perm", "||", "0700", ",", "server", "=", "this", ";", "this", ".", "file", "=", "file", ";", "this", ".", "name", "=", "path", ".", "basename", "(", "file", ")", ";", "if", "(", "this", ".", "name", "===", "file", ")", "{", "file", "=", "path", ".", "join", "(", "process", ".", "cwd", "(", ")", ",", "file", ")", ";", "}", "function", "onListen", "(", ")", "{", "try", "{", "fs", ".", "chmodSync", "(", "file", ",", "perm", ")", ";", "}", "catch", "(", "e", ")", "{", "}", "log", ".", "notice", "(", "'accepting connections at %s'", ",", "file", ")", ";", "}", "args", ".", "push", "(", "onListen", ")", ";", "// jump through some hoops for stale sockets", "server", ".", "on", "(", "'error'", ",", "function", "(", "e", ")", "{", "if", "(", "e", ".", "code", "==", "'EADDRINUSE'", ")", "{", "var", "client", "=", "new", "net", ".", "Socket", "(", ")", ";", "// handle error trying to talk to server", "client", ".", "on", "(", "'error'", ",", "function", "(", "e", ")", "{", "// no other server listening", "if", "(", "e", ".", "code", "==", "'ECONNREFUSED'", ")", "{", "fs", ".", "unlinkSync", "(", "file", ")", ";", "TcpServer", ".", "prototype", ".", "listen", ".", "apply", "(", "server", ",", "args", ")", ";", "}", "}", ")", ";", "client", ".", "connect", "(", "{", "path", ":", "file", "}", ",", "function", "(", ")", "{", "// exit with original EADDRINUSE", "throw", "e", ";", "}", ")", ";", "}", "}", ")", ";", "Server", ".", "prototype", ".", "listen", ".", "apply", "(", "server", ",", "args", ")", ";", "}" ]
Listen on a UNIX domain socket.
[ "Listen", "on", "a", "UNIX", "domain", "socket", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/network.js#L44-L83
52,467
redisjs/jsr-server
lib/network.js
close
function close() { log.notice('removing the unix socket file') try { fs.unlinkSync(file); }catch(e){} // nothing to do at this point Server.prototype.close.call(this); }
javascript
function close() { log.notice('removing the unix socket file') try { fs.unlinkSync(file); }catch(e){} // nothing to do at this point Server.prototype.close.call(this); }
[ "function", "close", "(", ")", "{", "log", ".", "notice", "(", "'removing the unix socket file'", ")", "try", "{", "fs", ".", "unlinkSync", "(", "file", ")", ";", "}", "catch", "(", "e", ")", "{", "}", "// nothing to do at this point", "Server", ".", "prototype", ".", "close", ".", "call", "(", "this", ")", ";", "}" ]
Close the UNIX domain socket server.
[ "Close", "the", "UNIX", "domain", "socket", "server", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/network.js#L88-L95
52,468
MoonHighway/mh-xmldown
index.js
function (next) { request(url, function (err, res, body) { if (err) { return next(err); } next(null, body); }); }
javascript
function (next) { request(url, function (err, res, body) { if (err) { return next(err); } next(null, body); }); }
[ "function", "(", "next", ")", "{", "request", "(", "url", ",", "function", "(", "err", ",", "res", ",", "body", ")", "{", "if", "(", "err", ")", "{", "return", "next", "(", "err", ")", ";", "}", "next", "(", "null", ",", "body", ")", ";", "}", ")", ";", "}" ]
1 - Request the XML File
[ "1", "-", "Request", "the", "XML", "File" ]
373e0301810e7c7ec905378703201a6067d73565
https://github.com/MoonHighway/mh-xmldown/blob/373e0301810e7c7ec905378703201a6067d73565/index.js#L31-L38
52,469
MoonHighway/mh-xmldown
index.js
function (body, next) { fs.writeFile(out + "/" + path.basename(url), body, function (err) { if (err) { return next(err); } next(null, body); }); }
javascript
function (body, next) { fs.writeFile(out + "/" + path.basename(url), body, function (err) { if (err) { return next(err); } next(null, body); }); }
[ "function", "(", "body", ",", "next", ")", "{", "fs", ".", "writeFile", "(", "out", "+", "\"/\"", "+", "path", ".", "basename", "(", "url", ")", ",", "body", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "return", "next", "(", "err", ")", ";", "}", "next", "(", "null", ",", "body", ")", ";", "}", ")", ";", "}" ]
2 - Save the XML File Locally
[ "2", "-", "Save", "the", "XML", "File", "Locally" ]
373e0301810e7c7ec905378703201a6067d73565
https://github.com/MoonHighway/mh-xmldown/blob/373e0301810e7c7ec905378703201a6067d73565/index.js#L41-L48
52,470
MoonHighway/mh-xmldown
index.js
function (body, next) { parseString(body, function (err, json) { if (err) { return next(err); } next(null, json); }); }
javascript
function (body, next) { parseString(body, function (err, json) { if (err) { return next(err); } next(null, json); }); }
[ "function", "(", "body", ",", "next", ")", "{", "parseString", "(", "body", ",", "function", "(", "err", ",", "json", ")", "{", "if", "(", "err", ")", "{", "return", "next", "(", "err", ")", ";", "}", "next", "(", "null", ",", "json", ")", ";", "}", ")", ";", "}" ]
3 - Parse the XML File as JSON
[ "3", "-", "Parse", "the", "XML", "File", "as", "JSON" ]
373e0301810e7c7ec905378703201a6067d73565
https://github.com/MoonHighway/mh-xmldown/blob/373e0301810e7c7ec905378703201a6067d73565/index.js#L51-L58
52,471
MoonHighway/mh-xmldown
index.js
function(json, next) { fs.writeFile(out + "/" + path.basename(url).replace('.xml', '.json'), JSON.stringify(json), function (err) { if (err) { return next(err); } next(null, json); }); }
javascript
function(json, next) { fs.writeFile(out + "/" + path.basename(url).replace('.xml', '.json'), JSON.stringify(json), function (err) { if (err) { return next(err); } next(null, json); }); }
[ "function", "(", "json", ",", "next", ")", "{", "fs", ".", "writeFile", "(", "out", "+", "\"/\"", "+", "path", ".", "basename", "(", "url", ")", ".", "replace", "(", "'.xml'", ",", "'.json'", ")", ",", "JSON", ".", "stringify", "(", "json", ")", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "return", "next", "(", "err", ")", ";", "}", "next", "(", "null", ",", "json", ")", ";", "}", ")", ";", "}" ]
4 - Save the JSON file locally
[ "4", "-", "Save", "the", "JSON", "file", "locally" ]
373e0301810e7c7ec905378703201a6067d73565
https://github.com/MoonHighway/mh-xmldown/blob/373e0301810e7c7ec905378703201a6067d73565/index.js#L61-L68
52,472
zerobias/knack
index.js
Knack
function Knack({ concurrency = 5, interval = 500, onDone = () => {} }={}) { const q = new Queue(concurrency, interval, onDone) /** * @func knack * @template T * @param {function(...args): Promise<T>} func * @returns {function(...args): Promise<T>} */ const knack = function(func, { priority = 50, onTimeout = timeouts.none, timeout = 30e3, repeats = 3 }={}) { return (...args) => q.task(func, { priority, onTimeout, timeout, repeats }, ...args) } knack.once = ({ priority = 50, onTimeout = timeouts.none, timeout = 30e3, repeats = 3 }={}) => (func, ...args) => q.task(func, { priority, onTimeout, timeout, repeats }, ...args) knack.isHalt = false knack.halt = () => { q.tryNext = () => {} q.task = () => {} knack.isHalt = true } Object.defineProperty(knack, 'active', { get: () => q.active }) Object.defineProperty(knack, 'concurrency', { get: () => q.concurrency // set: parallel => q.concurrency = parallel }) Object.defineProperty(knack, 'interval', { get: () => q.interval // set: delay => q.interval = delay }) knack.timeouts = timeouts return knack }
javascript
function Knack({ concurrency = 5, interval = 500, onDone = () => {} }={}) { const q = new Queue(concurrency, interval, onDone) /** * @func knack * @template T * @param {function(...args): Promise<T>} func * @returns {function(...args): Promise<T>} */ const knack = function(func, { priority = 50, onTimeout = timeouts.none, timeout = 30e3, repeats = 3 }={}) { return (...args) => q.task(func, { priority, onTimeout, timeout, repeats }, ...args) } knack.once = ({ priority = 50, onTimeout = timeouts.none, timeout = 30e3, repeats = 3 }={}) => (func, ...args) => q.task(func, { priority, onTimeout, timeout, repeats }, ...args) knack.isHalt = false knack.halt = () => { q.tryNext = () => {} q.task = () => {} knack.isHalt = true } Object.defineProperty(knack, 'active', { get: () => q.active }) Object.defineProperty(knack, 'concurrency', { get: () => q.concurrency // set: parallel => q.concurrency = parallel }) Object.defineProperty(knack, 'interval', { get: () => q.interval // set: delay => q.interval = delay }) knack.timeouts = timeouts return knack }
[ "function", "Knack", "(", "{", "concurrency", "=", "5", ",", "interval", "=", "500", ",", "onDone", "=", "(", ")", "=>", "{", "}", "}", "=", "{", "}", ")", "{", "const", "q", "=", "new", "Queue", "(", "concurrency", ",", "interval", ",", "onDone", ")", "/**\n * @func knack\n * @template T\n * @param {function(...args): Promise<T>} func\n * @returns {function(...args): Promise<T>}\n */", "const", "knack", "=", "function", "(", "func", ",", "{", "priority", "=", "50", ",", "onTimeout", "=", "timeouts", ".", "none", ",", "timeout", "=", "30e3", ",", "repeats", "=", "3", "}", "=", "{", "}", ")", "{", "return", "(", "...", "args", ")", "=>", "q", ".", "task", "(", "func", ",", "{", "priority", ",", "onTimeout", ",", "timeout", ",", "repeats", "}", ",", "...", "args", ")", "}", "knack", ".", "once", "=", "(", "{", "priority", "=", "50", ",", "onTimeout", "=", "timeouts", ".", "none", ",", "timeout", "=", "30e3", ",", "repeats", "=", "3", "}", "=", "{", "}", ")", "=>", "(", "func", ",", "...", "args", ")", "=>", "q", ".", "task", "(", "func", ",", "{", "priority", ",", "onTimeout", ",", "timeout", ",", "repeats", "}", ",", "...", "args", ")", "knack", ".", "isHalt", "=", "false", "knack", ".", "halt", "=", "(", ")", "=>", "{", "q", ".", "tryNext", "=", "(", ")", "=>", "{", "}", "q", ".", "task", "=", "(", ")", "=>", "{", "}", "knack", ".", "isHalt", "=", "true", "}", "Object", ".", "defineProperty", "(", "knack", ",", "'active'", ",", "{", "get", ":", "(", ")", "=>", "q", ".", "active", "}", ")", "Object", ".", "defineProperty", "(", "knack", ",", "'concurrency'", ",", "{", "get", ":", "(", ")", "=>", "q", ".", "concurrency", "// set: parallel => q.concurrency = parallel", "}", ")", "Object", ".", "defineProperty", "(", "knack", ",", "'interval'", ",", "{", "get", ":", "(", ")", "=>", "q", ".", "interval", "// set: delay => q.interval = delay", "}", ")", "knack", ".", "timeouts", "=", "timeouts", "return", "knack", "}" ]
Create Queue wrapper @param {any} [{ concurrency = 5, interval = 500 }={}] options
[ "Create", "Queue", "wrapper" ]
24a97f30edf0d06a0a6cd7d7a34d7a38f11c43dd
https://github.com/zerobias/knack/blob/24a97f30edf0d06a0a6cd7d7a34d7a38f11c43dd/index.js#L110-L149
52,473
tuunanen/camelton
lib/util.js
function(file) { var filePath = path.resolve(file); if (filePath && fs.existsSync(filePath)) { return filePath; } return false; }
javascript
function(file) { var filePath = path.resolve(file); if (filePath && fs.existsSync(filePath)) { return filePath; } return false; }
[ "function", "(", "file", ")", "{", "var", "filePath", "=", "path", ".", "resolve", "(", "file", ")", ";", "if", "(", "filePath", "&&", "fs", ".", "existsSync", "(", "filePath", ")", ")", "{", "return", "filePath", ";", "}", "return", "false", ";", "}" ]
Resolves file path. @param {string} file - File path. @returns {string|boolean} Resolved file path, or false if path does not exist.
[ "Resolves", "file", "path", "." ]
2beee32431e1b2867396e25f560f8dbd53535041
https://github.com/tuunanen/camelton/blob/2beee32431e1b2867396e25f560f8dbd53535041/lib/util.js#L42-L50
52,474
tuunanen/camelton
lib/util.js
function(file) { var filePath = path.resolve(file); if (filePath) { if (!fs.existsSync(filePath)) { fse.ensureFileSync(filePath); } return filePath; } return false; }
javascript
function(file) { var filePath = path.resolve(file); if (filePath) { if (!fs.existsSync(filePath)) { fse.ensureFileSync(filePath); } return filePath; } return false; }
[ "function", "(", "file", ")", "{", "var", "filePath", "=", "path", ".", "resolve", "(", "file", ")", ";", "if", "(", "filePath", ")", "{", "if", "(", "!", "fs", ".", "existsSync", "(", "filePath", ")", ")", "{", "fse", ".", "ensureFileSync", "(", "filePath", ")", ";", "}", "return", "filePath", ";", "}", "return", "false", ";", "}" ]
Resolves file path, and ensures the file exist. @param {string} file - File path. @returns {string|boolean} Resolved file path, or false if path cannot be created.
[ "Resolves", "file", "path", "and", "ensures", "the", "file", "exist", "." ]
2beee32431e1b2867396e25f560f8dbd53535041
https://github.com/tuunanen/camelton/blob/2beee32431e1b2867396e25f560f8dbd53535041/lib/util.js#L59-L70
52,475
Nazariglez/perenquen
lib/pixi/src/core/renderers/webgl/utils/Quad.js
Quad
function Quad(gl) { /* * the current WebGL drawing context * * @member {WebGLRenderingContext} */ this.gl = gl; // this.textures = new TextureUvs(); /** * An array of vertices * * @member {Float32Array} */ this.vertices = new Float32Array([ 0,0, 200,0, 200,200, 0,200 ]); /** * The Uvs of the quad * * @member {Float32Array} */ this.uvs = new Float32Array([ 0,0, 1,0, 1,1, 0,1 ]); // var white = (0xFFFFFF >> 16) + (0xFFFFFF & 0xff00) + ((0xFFFFFF & 0xff) << 16) + (1 * 255 << 24); //TODO convert this to a 32 unsigned int array /** * The color components of the triangles * * @member {Float32Array} */ this.colors = new Float32Array([ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1 ]); /* * @member {Uint16Array} An array containing the indices of the vertices */ this.indices = new Uint16Array([ 0, 1, 2, 0, 3, 2 ]); /* * @member {WebGLBuffer} The vertex buffer */ this.vertexBuffer = gl.createBuffer(); /* * @member {WebGLBuffer} The index buffer */ this.indexBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); gl.bufferData(gl.ARRAY_BUFFER, (8 + 8 + 16) * 4, gl.DYNAMIC_DRAW); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); this.upload(); }
javascript
function Quad(gl) { /* * the current WebGL drawing context * * @member {WebGLRenderingContext} */ this.gl = gl; // this.textures = new TextureUvs(); /** * An array of vertices * * @member {Float32Array} */ this.vertices = new Float32Array([ 0,0, 200,0, 200,200, 0,200 ]); /** * The Uvs of the quad * * @member {Float32Array} */ this.uvs = new Float32Array([ 0,0, 1,0, 1,1, 0,1 ]); // var white = (0xFFFFFF >> 16) + (0xFFFFFF & 0xff00) + ((0xFFFFFF & 0xff) << 16) + (1 * 255 << 24); //TODO convert this to a 32 unsigned int array /** * The color components of the triangles * * @member {Float32Array} */ this.colors = new Float32Array([ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1 ]); /* * @member {Uint16Array} An array containing the indices of the vertices */ this.indices = new Uint16Array([ 0, 1, 2, 0, 3, 2 ]); /* * @member {WebGLBuffer} The vertex buffer */ this.vertexBuffer = gl.createBuffer(); /* * @member {WebGLBuffer} The index buffer */ this.indexBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); gl.bufferData(gl.ARRAY_BUFFER, (8 + 8 + 16) * 4, gl.DYNAMIC_DRAW); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); this.upload(); }
[ "function", "Quad", "(", "gl", ")", "{", "/*\n * the current WebGL drawing context\n *\n * @member {WebGLRenderingContext}\n */", "this", ".", "gl", "=", "gl", ";", "// this.textures = new TextureUvs();", "/**\n * An array of vertices\n *\n * @member {Float32Array}\n */", "this", ".", "vertices", "=", "new", "Float32Array", "(", "[", "0", ",", "0", ",", "200", ",", "0", ",", "200", ",", "200", ",", "0", ",", "200", "]", ")", ";", "/**\n * The Uvs of the quad\n *\n * @member {Float32Array}\n */", "this", ".", "uvs", "=", "new", "Float32Array", "(", "[", "0", ",", "0", ",", "1", ",", "0", ",", "1", ",", "1", ",", "0", ",", "1", "]", ")", ";", "// var white = (0xFFFFFF >> 16) + (0xFFFFFF & 0xff00) + ((0xFFFFFF & 0xff) << 16) + (1 * 255 << 24);", "//TODO convert this to a 32 unsigned int array", "/**\n * The color components of the triangles\n *\n * @member {Float32Array}\n */", "this", ".", "colors", "=", "new", "Float32Array", "(", "[", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", ",", "1", "]", ")", ";", "/*\n * @member {Uint16Array} An array containing the indices of the vertices\n */", "this", ".", "indices", "=", "new", "Uint16Array", "(", "[", "0", ",", "1", ",", "2", ",", "0", ",", "3", ",", "2", "]", ")", ";", "/*\n * @member {WebGLBuffer} The vertex buffer\n */", "this", ".", "vertexBuffer", "=", "gl", ".", "createBuffer", "(", ")", ";", "/*\n * @member {WebGLBuffer} The index buffer\n */", "this", ".", "indexBuffer", "=", "gl", ".", "createBuffer", "(", ")", ";", "gl", ".", "bindBuffer", "(", "gl", ".", "ARRAY_BUFFER", ",", "this", ".", "vertexBuffer", ")", ";", "gl", ".", "bufferData", "(", "gl", ".", "ARRAY_BUFFER", ",", "(", "8", "+", "8", "+", "16", ")", "*", "4", ",", "gl", ".", "DYNAMIC_DRAW", ")", ";", "gl", ".", "bindBuffer", "(", "gl", ".", "ELEMENT_ARRAY_BUFFER", ",", "this", ".", "indexBuffer", ")", ";", "gl", ".", "bufferData", "(", "gl", ".", "ELEMENT_ARRAY_BUFFER", ",", "this", ".", "indices", ",", "gl", ".", "STATIC_DRAW", ")", ";", "this", ".", "upload", "(", ")", ";", "}" ]
Helper class to create a quad @class @memberof PIXI @param gl {WebGLRenderingContext} The gl context for this quad to use.
[ "Helper", "class", "to", "create", "a", "quad" ]
e023964d05afeefebdcac4e2044819fdfa3899ae
https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/renderers/webgl/utils/Quad.js#L7-L80
52,476
selfcontained/browserify-dev-bundler
lib/bundler.js
function(moduleRegex) { var self = this; moduleRegex = moduleRegex || /^(.+)\.js$/; return function(req, res, next) { var match = req.url.match(moduleRegex); if(!match) return next(); var module= match[1]; self.bundle(module, function(err, src) { res.setHeader('Content-Type', 'text/javascript; charset=utf-8'); res.setHeader('Cache-Control', 'no-cache'); // expose event to allow for custom headers self.emit('pre-response', err, res, module, src); res.send(src); }); }; }
javascript
function(moduleRegex) { var self = this; moduleRegex = moduleRegex || /^(.+)\.js$/; return function(req, res, next) { var match = req.url.match(moduleRegex); if(!match) return next(); var module= match[1]; self.bundle(module, function(err, src) { res.setHeader('Content-Type', 'text/javascript; charset=utf-8'); res.setHeader('Cache-Control', 'no-cache'); // expose event to allow for custom headers self.emit('pre-response', err, res, module, src); res.send(src); }); }; }
[ "function", "(", "moduleRegex", ")", "{", "var", "self", "=", "this", ";", "moduleRegex", "=", "moduleRegex", "||", "/", "^(.+)\\.js$", "/", ";", "return", "function", "(", "req", ",", "res", ",", "next", ")", "{", "var", "match", "=", "req", ".", "url", ".", "match", "(", "moduleRegex", ")", ";", "if", "(", "!", "match", ")", "return", "next", "(", ")", ";", "var", "module", "=", "match", "[", "1", "]", ";", "self", ".", "bundle", "(", "module", ",", "function", "(", "err", ",", "src", ")", "{", "res", ".", "setHeader", "(", "'Content-Type'", ",", "'text/javascript; charset=utf-8'", ")", ";", "res", ".", "setHeader", "(", "'Cache-Control'", ",", "'no-cache'", ")", ";", "// expose event to allow for custom headers", "self", ".", "emit", "(", "'pre-response'", ",", "err", ",", "res", ",", "module", ",", "src", ")", ";", "res", ".", "send", "(", "src", ")", ";", "}", ")", ";", "}", ";", "}" ]
Generate a middeware function + moduleRegex - regex - used to match urls - requires the first capture group to be the module
[ "Generate", "a", "middeware", "function", "+", "moduleRegex", "-", "regex", "-", "used", "to", "match", "urls", "-", "requires", "the", "first", "capture", "group", "to", "be", "the", "module" ]
7e3540ae9b42d0858495b0e99e9495b9ba14443d
https://github.com/selfcontained/browserify-dev-bundler/blob/7e3540ae9b42d0858495b0e99e9495b9ba14443d/lib/bundler.js#L46-L67
52,477
berkeleybop/bbopx-js
external/bbop.js
_same_set
function _same_set(set1, set2){ var h1 = {}; var h2 = {}; for( var h1i = 0; h1i < set1.length; h1i++ ){ h1[set1[h1i]] = 1; } for( var h2i = 0; h2i < set2.length; h2i++ ){ h2[set2[h2i]] = 1; } return _same_hash(h1, h2); }
javascript
function _same_set(set1, set2){ var h1 = {}; var h2 = {}; for( var h1i = 0; h1i < set1.length; h1i++ ){ h1[set1[h1i]] = 1; } for( var h2i = 0; h2i < set2.length; h2i++ ){ h2[set2[h2i]] = 1; } return _same_hash(h1, h2); }
[ "function", "_same_set", "(", "set1", ",", "set2", ")", "{", "var", "h1", "=", "{", "}", ";", "var", "h2", "=", "{", "}", ";", "for", "(", "var", "h1i", "=", "0", ";", "h1i", "<", "set1", ".", "length", ";", "h1i", "++", ")", "{", "h1", "[", "set1", "[", "h1i", "]", "]", "=", "1", ";", "}", "for", "(", "var", "h2i", "=", "0", ";", "h2i", "<", "set2", ".", "length", ";", "h2i", "++", ")", "{", "h2", "[", "set2", "[", "h2i", "]", "]", "=", "1", ";", "}", "return", "_same_hash", "(", "h1", ",", "h2", ")", ";", "}" ]
Looking at array as sets of...something. DEPRECATED
[ "Looking", "at", "array", "as", "sets", "of", "...", "something", ".", "DEPRECATED" ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L1341-L1347
52,478
berkeleybop/bbopx-js
external/bbop.js
_is_same
function _is_same(a, b){ //bark('typeof(a, b): ' + typeof(a) + ',' + typeof(b)); var ret = false; if( a == b ){ // atoms, incl. null and 'string' //bark('true on equal atoms: ' + a + '<>' + b); ret = true; }else{ // is list or obj (ignore func) if( typeof(a) === 'object' && typeof(b) === 'object' ){ //bark('...are objects'); // Null is an object, but not like the others. if( a == null || b == null ){ ret = false; }else if( Array.isArray(a) && Array.isArray(b) ){ // array equiv //bark('...are arrays'); // Recursively check array equiv. if( a.length == b.length ){ if( a.length == 0 ){ //bark('true on 0 length array'); ret = true; }else{ ret = true; // assume true until false here for( var i = 0; i < a.length; i++ ){ if( ! _is_same(a[i], b[i]) ){ //bark('false on diff @ index: ' + i); ret = false; break; } } } } }else{ // object equiv. // Get unique set of keys. var a_keys = Object.keys(a); var b_keys = Object.keys(b); var keys = a_keys.concat(b_keys.filter(function(it){ return a_keys.indexOf(it) < 0; })); // Assume true until false. ret = true; for( var j = 0; j < keys.length; j++ ){ // no forEach - break var k = keys[j]; if( ! _is_same(a[k], b[k]) ){ //bark('false on key: ' + k); ret = false; break; } } } }else{ //bark('false by default'); } } return ret; }
javascript
function _is_same(a, b){ //bark('typeof(a, b): ' + typeof(a) + ',' + typeof(b)); var ret = false; if( a == b ){ // atoms, incl. null and 'string' //bark('true on equal atoms: ' + a + '<>' + b); ret = true; }else{ // is list or obj (ignore func) if( typeof(a) === 'object' && typeof(b) === 'object' ){ //bark('...are objects'); // Null is an object, but not like the others. if( a == null || b == null ){ ret = false; }else if( Array.isArray(a) && Array.isArray(b) ){ // array equiv //bark('...are arrays'); // Recursively check array equiv. if( a.length == b.length ){ if( a.length == 0 ){ //bark('true on 0 length array'); ret = true; }else{ ret = true; // assume true until false here for( var i = 0; i < a.length; i++ ){ if( ! _is_same(a[i], b[i]) ){ //bark('false on diff @ index: ' + i); ret = false; break; } } } } }else{ // object equiv. // Get unique set of keys. var a_keys = Object.keys(a); var b_keys = Object.keys(b); var keys = a_keys.concat(b_keys.filter(function(it){ return a_keys.indexOf(it) < 0; })); // Assume true until false. ret = true; for( var j = 0; j < keys.length; j++ ){ // no forEach - break var k = keys[j]; if( ! _is_same(a[k], b[k]) ){ //bark('false on key: ' + k); ret = false; break; } } } }else{ //bark('false by default'); } } return ret; }
[ "function", "_is_same", "(", "a", ",", "b", ")", "{", "//bark('typeof(a, b): ' + typeof(a) + ',' + typeof(b));", "var", "ret", "=", "false", ";", "if", "(", "a", "==", "b", ")", "{", "// atoms, incl. null and 'string'", "//bark('true on equal atoms: ' + a + '<>' + b);", "ret", "=", "true", ";", "}", "else", "{", "// is list or obj (ignore func)", "if", "(", "typeof", "(", "a", ")", "===", "'object'", "&&", "typeof", "(", "b", ")", "===", "'object'", ")", "{", "//bark('...are objects');", "// Null is an object, but not like the others.", "if", "(", "a", "==", "null", "||", "b", "==", "null", ")", "{", "ret", "=", "false", ";", "}", "else", "if", "(", "Array", ".", "isArray", "(", "a", ")", "&&", "Array", ".", "isArray", "(", "b", ")", ")", "{", "// array equiv", "//bark('...are arrays');", "// Recursively check array equiv.", "if", "(", "a", ".", "length", "==", "b", ".", "length", ")", "{", "if", "(", "a", ".", "length", "==", "0", ")", "{", "//bark('true on 0 length array');", "ret", "=", "true", ";", "}", "else", "{", "ret", "=", "true", ";", "// assume true until false here", "for", "(", "var", "i", "=", "0", ";", "i", "<", "a", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "_is_same", "(", "a", "[", "i", "]", ",", "b", "[", "i", "]", ")", ")", "{", "//bark('false on diff @ index: ' + i);", "ret", "=", "false", ";", "break", ";", "}", "}", "}", "}", "}", "else", "{", "// object equiv.", "// Get unique set of keys.", "var", "a_keys", "=", "Object", ".", "keys", "(", "a", ")", ";", "var", "b_keys", "=", "Object", ".", "keys", "(", "b", ")", ";", "var", "keys", "=", "a_keys", ".", "concat", "(", "b_keys", ".", "filter", "(", "function", "(", "it", ")", "{", "return", "a_keys", ".", "indexOf", "(", "it", ")", "<", "0", ";", "}", ")", ")", ";", "// Assume true until false.", "ret", "=", "true", ";", "for", "(", "var", "j", "=", "0", ";", "j", "<", "keys", ".", "length", ";", "j", "++", ")", "{", "// no forEach - break", "var", "k", "=", "keys", "[", "j", "]", ";", "if", "(", "!", "_is_same", "(", "a", "[", "k", "]", ",", "b", "[", "k", "]", ")", ")", "{", "//bark('false on key: ' + k);", "ret", "=", "false", ";", "break", ";", "}", "}", "}", "}", "else", "{", "//bark('false by default');", "}", "}", "return", "ret", ";", "}" ]
Better general comparison function.
[ "Better", "general", "comparison", "function", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L1382-L1442
52,479
berkeleybop/bbopx-js
external/bbop.js
_in_list
function _in_list(in_item, list, comparator){ var retval = false; for(var li = 0; li < list.length; li++ ){ var list_item = list[li]; if( comparator ){ var comp_op = comparator(in_item, list_item); if( comp_op && comp_op == true ){ retval = true; } }else{ if( in_item == list_item ){ retval = true; } } } return retval; }
javascript
function _in_list(in_item, list, comparator){ var retval = false; for(var li = 0; li < list.length; li++ ){ var list_item = list[li]; if( comparator ){ var comp_op = comparator(in_item, list_item); if( comp_op && comp_op == true ){ retval = true; } }else{ if( in_item == list_item ){ retval = true; } } } return retval; }
[ "function", "_in_list", "(", "in_item", ",", "list", ",", "comparator", ")", "{", "var", "retval", "=", "false", ";", "for", "(", "var", "li", "=", "0", ";", "li", "<", "list", ".", "length", ";", "li", "++", ")", "{", "var", "list_item", "=", "list", "[", "li", "]", ";", "if", "(", "comparator", ")", "{", "var", "comp_op", "=", "comparator", "(", "in_item", ",", "list_item", ")", ";", "if", "(", "comp_op", "&&", "comp_op", "==", "true", ")", "{", "retval", "=", "true", ";", "}", "}", "else", "{", "if", "(", "in_item", "==", "list_item", ")", "{", "retval", "=", "true", ";", "}", "}", "}", "return", "retval", ";", "}" ]
Walk through the list and see if it's there. If compareator is not defined, just to atom comparison.
[ "Walk", "through", "the", "list", "and", "see", "if", "it", "s", "there", ".", "If", "compareator", "is", "not", "defined", "just", "to", "atom", "comparison", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L1486-L1505
52,480
berkeleybop/bbopx-js
external/bbop.js
_is_string_embedded
function _is_string_embedded(target_str, base_str, add_str){ // Walk through all of ways of splitting base_str and add // add_str in there to see if we get the target_str. var retval = false; for(var si = 0; si <= base_str.length; si++ ){ var car = base_str.substr(0, si); var cdr = base_str.substr(si, base_str.length); //bark(car + "|" + add_str + "|" + cdr); if( car + add_str + cdr == target_str){ retval = true; break; } } return retval; }
javascript
function _is_string_embedded(target_str, base_str, add_str){ // Walk through all of ways of splitting base_str and add // add_str in there to see if we get the target_str. var retval = false; for(var si = 0; si <= base_str.length; si++ ){ var car = base_str.substr(0, si); var cdr = base_str.substr(si, base_str.length); //bark(car + "|" + add_str + "|" + cdr); if( car + add_str + cdr == target_str){ retval = true; break; } } return retval; }
[ "function", "_is_string_embedded", "(", "target_str", ",", "base_str", ",", "add_str", ")", "{", "// Walk through all of ways of splitting base_str and add", "// add_str in there to see if we get the target_str.", "var", "retval", "=", "false", ";", "for", "(", "var", "si", "=", "0", ";", "si", "<=", "base_str", ".", "length", ";", "si", "++", ")", "{", "var", "car", "=", "base_str", ".", "substr", "(", "0", ",", "si", ")", ";", "var", "cdr", "=", "base_str", ".", "substr", "(", "si", ",", "base_str", ".", "length", ")", ";", "//bark(car + \"|\" + add_str + \"|\" + cdr);", "if", "(", "car", "+", "add_str", "+", "cdr", "==", "target_str", ")", "{", "retval", "=", "true", ";", "break", ";", "}", "}", "return", "retval", ";", "}" ]
Basically asking if you can make the target string from the base string with the add_str added into it somewhere. Strange, but another way of looking at URL creation in some cases.
[ "Basically", "asking", "if", "you", "can", "make", "the", "target", "string", "from", "the", "base", "string", "with", "the", "add_str", "added", "into", "it", "somewhere", ".", "Strange", "but", "another", "way", "of", "looking", "at", "URL", "creation", "in", "some", "cases", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L1510-L1526
52,481
berkeleybop/bbopx-js
external/bbop.js
rec_up
function rec_up(nid){ //print('rec_up on: ' + nid); var results = new Array(); var new_parent_edges = anchor.get_parent_edges(nid, pid); // Capture edge list for later adding. for( var e = 0; e < new_parent_edges.length; e++ ){ seen_edge_list.push(new_parent_edges[e]); } // Pull extant nodes from edges. NOTE: This is a retread // of what happens in get_parent_nodes to avoid another // call to get_parent_edges (as all this is now // implemented). var new_parents = new Array(); for( var n = 0; n < new_parent_edges.length; n++ ){ // Make sure that any found edges are in our // world. var obj_id = new_parent_edges[n].object_id(); var temp_node = anchor.get_node(obj_id); if( temp_node ){ new_parents.push( temp_node ); } } // Make sure we're in there too. var tmp_node = anchor.get_node(nid); if( tmp_node ){ new_parents.push( tmp_node ); } // Recur on unseen things and mark the current as seen. if( new_parents.length != 0 ){ for( var i = 0; i < new_parents.length; i++ ){ // Only do things we haven't ever seen before. var new_anc = new_parents[i]; var new_anc_id = new_anc.id(); if( ! seen_node_hash[ new_anc_id ] ){ seen_node_hash[ new_anc_id ] = new_anc; rec_up(new_anc_id); } } } return results; }
javascript
function rec_up(nid){ //print('rec_up on: ' + nid); var results = new Array(); var new_parent_edges = anchor.get_parent_edges(nid, pid); // Capture edge list for later adding. for( var e = 0; e < new_parent_edges.length; e++ ){ seen_edge_list.push(new_parent_edges[e]); } // Pull extant nodes from edges. NOTE: This is a retread // of what happens in get_parent_nodes to avoid another // call to get_parent_edges (as all this is now // implemented). var new_parents = new Array(); for( var n = 0; n < new_parent_edges.length; n++ ){ // Make sure that any found edges are in our // world. var obj_id = new_parent_edges[n].object_id(); var temp_node = anchor.get_node(obj_id); if( temp_node ){ new_parents.push( temp_node ); } } // Make sure we're in there too. var tmp_node = anchor.get_node(nid); if( tmp_node ){ new_parents.push( tmp_node ); } // Recur on unseen things and mark the current as seen. if( new_parents.length != 0 ){ for( var i = 0; i < new_parents.length; i++ ){ // Only do things we haven't ever seen before. var new_anc = new_parents[i]; var new_anc_id = new_anc.id(); if( ! seen_node_hash[ new_anc_id ] ){ seen_node_hash[ new_anc_id ] = new_anc; rec_up(new_anc_id); } } } return results; }
[ "function", "rec_up", "(", "nid", ")", "{", "//print('rec_up on: ' + nid);", "var", "results", "=", "new", "Array", "(", ")", ";", "var", "new_parent_edges", "=", "anchor", ".", "get_parent_edges", "(", "nid", ",", "pid", ")", ";", "// Capture edge list for later adding.", "for", "(", "var", "e", "=", "0", ";", "e", "<", "new_parent_edges", ".", "length", ";", "e", "++", ")", "{", "seen_edge_list", ".", "push", "(", "new_parent_edges", "[", "e", "]", ")", ";", "}", "// Pull extant nodes from edges. NOTE: This is a retread", "// of what happens in get_parent_nodes to avoid another", "// call to get_parent_edges (as all this is now", "// implemented).", "var", "new_parents", "=", "new", "Array", "(", ")", ";", "for", "(", "var", "n", "=", "0", ";", "n", "<", "new_parent_edges", ".", "length", ";", "n", "++", ")", "{", "// Make sure that any found edges are in our", "// world.", "var", "obj_id", "=", "new_parent_edges", "[", "n", "]", ".", "object_id", "(", ")", ";", "var", "temp_node", "=", "anchor", ".", "get_node", "(", "obj_id", ")", ";", "if", "(", "temp_node", ")", "{", "new_parents", ".", "push", "(", "temp_node", ")", ";", "}", "}", "// Make sure we're in there too.", "var", "tmp_node", "=", "anchor", ".", "get_node", "(", "nid", ")", ";", "if", "(", "tmp_node", ")", "{", "new_parents", ".", "push", "(", "tmp_node", ")", ";", "}", "// Recur on unseen things and mark the current as seen.", "if", "(", "new_parents", ".", "length", "!=", "0", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "new_parents", ".", "length", ";", "i", "++", ")", "{", "// Only do things we haven't ever seen before.", "var", "new_anc", "=", "new_parents", "[", "i", "]", ";", "var", "new_anc_id", "=", "new_anc", ".", "id", "(", ")", ";", "if", "(", "!", "seen_node_hash", "[", "new_anc_id", "]", ")", "{", "seen_node_hash", "[", "new_anc_id", "]", "=", "new_anc", ";", "rec_up", "(", "new_anc_id", ")", ";", "}", "}", "}", "return", "results", ";", "}" ]
Define recursive ascent.
[ "Define", "recursive", "ascent", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L5738-L5784
52,482
berkeleybop/bbopx-js
external/bbop.js
order_cohort
function order_cohort(in_brackets){ // Push into global cohort list list. for( var i = 0; i < in_brackets.length; i++ ){ var bracket_item = in_brackets[i]; // //_kvetch(' order_cohort: i: ' + i); //_kvetch(' order_cohort: lvl: ' + bracket_item.level); cohort_list[bracket_item.level - 1].push(bracket_item); // Drill down. if( bracket_item.brackets.length > 0 ){ //_kvetch(' order_cohort: down: ' + // bracket_item.brackets.length); order_cohort(bracket_item.brackets); } } }
javascript
function order_cohort(in_brackets){ // Push into global cohort list list. for( var i = 0; i < in_brackets.length; i++ ){ var bracket_item = in_brackets[i]; // //_kvetch(' order_cohort: i: ' + i); //_kvetch(' order_cohort: lvl: ' + bracket_item.level); cohort_list[bracket_item.level - 1].push(bracket_item); // Drill down. if( bracket_item.brackets.length > 0 ){ //_kvetch(' order_cohort: down: ' + // bracket_item.brackets.length); order_cohort(bracket_item.brackets); } } }
[ "function", "order_cohort", "(", "in_brackets", ")", "{", "// Push into global cohort list list.", "for", "(", "var", "i", "=", "0", ";", "i", "<", "in_brackets", ".", "length", ";", "i", "++", ")", "{", "var", "bracket_item", "=", "in_brackets", "[", "i", "]", ";", "//", "//_kvetch(' order_cohort: i: ' + i);", "//_kvetch(' order_cohort: lvl: ' + bracket_item.level);", "cohort_list", "[", "bracket_item", ".", "level", "-", "1", "]", ".", "push", "(", "bracket_item", ")", ";", "// Drill down.", "if", "(", "bracket_item", ".", "brackets", ".", "length", ">", "0", ")", "{", "//_kvetch(' order_cohort: down: ' +", "// bracket_item.brackets.length);", "order_cohort", "(", "bracket_item", ".", "brackets", ")", ";", "}", "}", "}" ]
Walk down and stack up.
[ "Walk", "down", "and", "stack", "up", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L6273-L6288
52,483
berkeleybop/bbopx-js
external/bbop.js
_new_node_at
function _new_node_at(bnode, level){ ll("adding " + bnode.id() + " at level " + level + "!"); // Create new vertex and add to set. var new_vertex = new bbop.layout.sugiyama.simple_vertex(bnode.id()); new_vertex.level = level; vertex_set[ new_vertex.id() ] = new_vertex; // Check the node in to the 'seen' references. first_seen_reference[ new_vertex.id() ] = level; last_seen_reference[ new_vertex.id() ] = level; }
javascript
function _new_node_at(bnode, level){ ll("adding " + bnode.id() + " at level " + level + "!"); // Create new vertex and add to set. var new_vertex = new bbop.layout.sugiyama.simple_vertex(bnode.id()); new_vertex.level = level; vertex_set[ new_vertex.id() ] = new_vertex; // Check the node in to the 'seen' references. first_seen_reference[ new_vertex.id() ] = level; last_seen_reference[ new_vertex.id() ] = level; }
[ "function", "_new_node_at", "(", "bnode", ",", "level", ")", "{", "ll", "(", "\"adding \"", "+", "bnode", ".", "id", "(", ")", "+", "\" at level \"", "+", "level", "+", "\"!\"", ")", ";", "// Create new vertex and add to set.", "var", "new_vertex", "=", "new", "bbop", ".", "layout", ".", "sugiyama", ".", "simple_vertex", "(", "bnode", ".", "id", "(", ")", ")", ";", "new_vertex", ".", "level", "=", "level", ";", "vertex_set", "[", "new_vertex", ".", "id", "(", ")", "]", "=", "new_vertex", ";", "// Check the node in to the 'seen' references.", "first_seen_reference", "[", "new_vertex", ".", "id", "(", ")", "]", "=", "level", ";", "last_seen_reference", "[", "new_vertex", ".", "id", "(", ")", "]", "=", "level", ";", "}" ]
Add a new node to the global variables.
[ "Add", "a", "new", "node", "to", "the", "global", "variables", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L7183-L7195
52,484
berkeleybop/bbopx-js
external/bbop.js
getSubjectBarycenter
function getSubjectBarycenter(subject){ var weighted_number_of_edges = 0; var number_of_edges = 0; for( var o = 1; o <= object_vector.length; o++ ){ if( relation_matrix[object_vector[o -1].id()] && relation_matrix[object_vector[o -1].id()][subject.id()]){ weighted_number_of_edges += o; number_of_edges++; } } // The '-1' is to offset the indexing. return ( weighted_number_of_edges / number_of_edges ) -1; }
javascript
function getSubjectBarycenter(subject){ var weighted_number_of_edges = 0; var number_of_edges = 0; for( var o = 1; o <= object_vector.length; o++ ){ if( relation_matrix[object_vector[o -1].id()] && relation_matrix[object_vector[o -1].id()][subject.id()]){ weighted_number_of_edges += o; number_of_edges++; } } // The '-1' is to offset the indexing. return ( weighted_number_of_edges / number_of_edges ) -1; }
[ "function", "getSubjectBarycenter", "(", "subject", ")", "{", "var", "weighted_number_of_edges", "=", "0", ";", "var", "number_of_edges", "=", "0", ";", "for", "(", "var", "o", "=", "1", ";", "o", "<=", "object_vector", ".", "length", ";", "o", "++", ")", "{", "if", "(", "relation_matrix", "[", "object_vector", "[", "o", "-", "1", "]", ".", "id", "(", ")", "]", "&&", "relation_matrix", "[", "object_vector", "[", "o", "-", "1", "]", ".", "id", "(", ")", "]", "[", "subject", ".", "id", "(", ")", "]", ")", "{", "weighted_number_of_edges", "+=", "o", ";", "number_of_edges", "++", ";", "}", "}", "// The '-1' is to offset the indexing.", "return", "(", "weighted_number_of_edges", "/", "number_of_edges", ")", "-", "1", ";", "}" ]
Gets barycenter for column s.
[ "Gets", "barycenter", "for", "column", "s", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L7465-L7478
52,485
berkeleybop/bbopx-js
external/bbop.js
on_error
function on_error(e) { console.log('problem with request: ' + e.message); var response = new anchor._response_handler(null); response.okay(false); response.message(e.message); response.message_type('error'); anchor.apply_callbacks('error', [response, anchor]); }
javascript
function on_error(e) { console.log('problem with request: ' + e.message); var response = new anchor._response_handler(null); response.okay(false); response.message(e.message); response.message_type('error'); anchor.apply_callbacks('error', [response, anchor]); }
[ "function", "on_error", "(", "e", ")", "{", "console", ".", "log", "(", "'problem with request: '", "+", "e", ".", "message", ")", ";", "var", "response", "=", "new", "anchor", ".", "_response_handler", "(", "null", ")", ";", "response", ".", "okay", "(", "false", ")", ";", "response", ".", "message", "(", "e", ".", "message", ")", ";", "response", ".", "message_type", "(", "'error'", ")", ";", "anchor", ".", "apply_callbacks", "(", "'error'", ",", "[", "response", ",", "anchor", "]", ")", ";", "}" ]
What to do if an error is triggered.
[ "What", "to", "do", "if", "an", "error", "is", "triggered", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L8782-L8789
52,486
berkeleybop/bbopx-js
external/bbop.js
on_error
function on_error(xhr, status, error) { var response = new anchor._response_handler(null); response.okay(false); response.message(error); response.message_type(status); anchor.apply_callbacks('error', [response, anchor]); }
javascript
function on_error(xhr, status, error) { var response = new anchor._response_handler(null); response.okay(false); response.message(error); response.message_type(status); anchor.apply_callbacks('error', [response, anchor]); }
[ "function", "on_error", "(", "xhr", ",", "status", ",", "error", ")", "{", "var", "response", "=", "new", "anchor", ".", "_response_handler", "(", "null", ")", ";", "response", ".", "okay", "(", "false", ")", ";", "response", ".", "message", "(", "error", ")", ";", "response", ".", "message_type", "(", "status", ")", ";", "anchor", ".", "apply_callbacks", "(", "'error'", ",", "[", "response", ",", "anchor", "]", ")", ";", "}" ]
What to do if an error is triggered. Remember that with jQuery, when using JSONP, there is no error.
[ "What", "to", "do", "if", "an", "error", "is", "triggered", ".", "Remember", "that", "with", "jQuery", "when", "using", "JSONP", "there", "is", "no", "error", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L9041-L9047
52,487
berkeleybop/bbopx-js
external/bbop.js
_full_delete
function _full_delete(hash, key1, key2){ if( key1 && key2 && hash && hash[key1] && hash[key1][key2] ){ delete hash[key1][key2]; } if( bbop.core.is_empty(hash[key1]) ){ delete hash[key1]; } }
javascript
function _full_delete(hash, key1, key2){ if( key1 && key2 && hash && hash[key1] && hash[key1][key2] ){ delete hash[key1][key2]; } if( bbop.core.is_empty(hash[key1]) ){ delete hash[key1]; } }
[ "function", "_full_delete", "(", "hash", ",", "key1", ",", "key2", ")", "{", "if", "(", "key1", "&&", "key2", "&&", "hash", "&&", "hash", "[", "key1", "]", "&&", "hash", "[", "key1", "]", "[", "key2", "]", ")", "{", "delete", "hash", "[", "key1", "]", "[", "key2", "]", ";", "}", "if", "(", "bbop", ".", "core", ".", "is_empty", "(", "hash", "[", "key1", "]", ")", ")", "{", "delete", "hash", "[", "key1", "]", ";", "}", "}" ]
Internal helper to delete a low level key, and then if the top-level is empty, get that one too.
[ "Internal", "helper", "to", "delete", "a", "low", "level", "key", "and", "then", "if", "the", "top", "-", "level", "is", "empty", "get", "that", "one", "too", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L11109-L11117
52,488
berkeleybop/bbopx-js
external/bbop.js
_lock_map
function _lock_map(field, id_list){ var fixed_list = []; bbop.core.each(id_list, function(item){ fixed_list.push(bbop.core.ensure(item, '"')); }); var base_id_list = '(' + fixed_list.join(' OR ') + ')'; var ret_query = field + ':' + base_id_list; return ret_query; }
javascript
function _lock_map(field, id_list){ var fixed_list = []; bbop.core.each(id_list, function(item){ fixed_list.push(bbop.core.ensure(item, '"')); }); var base_id_list = '(' + fixed_list.join(' OR ') + ')'; var ret_query = field + ':' + base_id_list; return ret_query; }
[ "function", "_lock_map", "(", "field", ",", "id_list", ")", "{", "var", "fixed_list", "=", "[", "]", ";", "bbop", ".", "core", ".", "each", "(", "id_list", ",", "function", "(", "item", ")", "{", "fixed_list", ".", "push", "(", "bbop", ".", "core", ".", "ensure", "(", "item", ",", "'\"'", ")", ")", ";", "}", ")", ";", "var", "base_id_list", "=", "'('", "+", "fixed_list", ".", "join", "(", "' OR '", ")", "+", "')'", ";", "var", "ret_query", "=", "field", "+", "':'", "+", "base_id_list", ";", "return", "ret_query", ";", "}" ]
Function to unwind and lock a list if identifiers onto a field.
[ "Function", "to", "unwind", "and", "lock", "a", "list", "if", "identifiers", "onto", "a", "field", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L11960-L11972
52,489
berkeleybop/bbopx-js
external/bbop.js
_create_select_box
function _create_select_box(val, id, name){ if( ! is_defined(name) ){ name = select_item_name; } var input_attrs = { 'value': val, 'name': name, 'type': 'checkbox' }; if( is_defined(id) ){ input_attrs['id'] = id; } var input = new bbop.html.input(input_attrs); return input; }
javascript
function _create_select_box(val, id, name){ if( ! is_defined(name) ){ name = select_item_name; } var input_attrs = { 'value': val, 'name': name, 'type': 'checkbox' }; if( is_defined(id) ){ input_attrs['id'] = id; } var input = new bbop.html.input(input_attrs); return input; }
[ "function", "_create_select_box", "(", "val", ",", "id", ",", "name", ")", "{", "if", "(", "!", "is_defined", "(", "name", ")", ")", "{", "name", "=", "select_item_name", ";", "}", "var", "input_attrs", "=", "{", "'value'", ":", "val", ",", "'name'", ":", "name", ",", "'type'", ":", "'checkbox'", "}", ";", "if", "(", "is_defined", "(", "id", ")", ")", "{", "input_attrs", "[", "'id'", "]", "=", "id", ";", "}", "var", "input", "=", "new", "bbop", ".", "html", ".", "input", "(", "input_attrs", ")", ";", "return", "input", ";", "}" ]
Create a locally mangled checkbox.
[ "Create", "a", "locally", "mangled", "checkbox", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L14702-L14717
52,490
berkeleybop/bbopx-js
external/bbop.js
_ignorable_event
function _ignorable_event(event){ var retval = false; if( event ){ var kc = event.keyCode; if( kc ){ if( kc == 39 || // right kc == 37 || // left kc == 32 || // space kc == 20 || // ctl? kc == 17 || // ctl? kc == 16 || // shift //kc == 8 || // delete kc == 0 ){ // super ll('ignorable key event: ' + kc); retval = true; } } } return retval; }
javascript
function _ignorable_event(event){ var retval = false; if( event ){ var kc = event.keyCode; if( kc ){ if( kc == 39 || // right kc == 37 || // left kc == 32 || // space kc == 20 || // ctl? kc == 17 || // ctl? kc == 16 || // shift //kc == 8 || // delete kc == 0 ){ // super ll('ignorable key event: ' + kc); retval = true; } } } return retval; }
[ "function", "_ignorable_event", "(", "event", ")", "{", "var", "retval", "=", "false", ";", "if", "(", "event", ")", "{", "var", "kc", "=", "event", ".", "keyCode", ";", "if", "(", "kc", ")", "{", "if", "(", "kc", "==", "39", "||", "// right", "kc", "==", "37", "||", "// left", "kc", "==", "32", "||", "// space", "kc", "==", "20", "||", "// ctl?", "kc", "==", "17", "||", "// ctl?", "kc", "==", "16", "||", "// shift", "//kc == 8 || // delete", "kc", "==", "0", ")", "{", "// super", "ll", "(", "'ignorable key event: '", "+", "kc", ")", ";", "retval", "=", "true", ";", "}", "}", "}", "return", "retval", ";", "}" ]
Detect whether or not a keyboard event is ignorable.
[ "Detect", "whether", "or", "not", "a", "keyboard", "event", "is", "ignorable", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L16505-L16526
52,491
berkeleybop/bbopx-js
external/bbop.js
_nothing_to_see_here
function _nothing_to_see_here(in_field){ var section_id = filter_accordion_widget.get_section_id(in_field); jQuery('#' + section_id).empty(); jQuery('#' + section_id).append('Nothing to filter.'); }
javascript
function _nothing_to_see_here(in_field){ var section_id = filter_accordion_widget.get_section_id(in_field); jQuery('#' + section_id).empty(); jQuery('#' + section_id).append('Nothing to filter.'); }
[ "function", "_nothing_to_see_here", "(", "in_field", ")", "{", "var", "section_id", "=", "filter_accordion_widget", ".", "get_section_id", "(", "in_field", ")", ";", "jQuery", "(", "'#'", "+", "section_id", ")", ".", "empty", "(", ")", ";", "jQuery", "(", "'#'", "+", "section_id", ")", ".", "append", "(", "'Nothing to filter.'", ")", ";", "}" ]
A helper function for when no filters are displayed.
[ "A", "helper", "function", "for", "when", "no", "filters", "are", "displayed", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L16851-L16855
52,492
berkeleybop/bbopx-js
external/bbop.js
draw_shield
function draw_shield(resp){ // ll("shield what: " + bbop.core.what_is(resp)); // ll("shield resp: " + bbop.core.dump(resp)); // First, extract the fields from the // minimal response. var fina = call_time_field_name; var flist = resp.facet_field(call_time_field_name); // Draw the proper contents of the shield. filter_shield.draw(fina, flist, manager); }
javascript
function draw_shield(resp){ // ll("shield what: " + bbop.core.what_is(resp)); // ll("shield resp: " + bbop.core.dump(resp)); // First, extract the fields from the // minimal response. var fina = call_time_field_name; var flist = resp.facet_field(call_time_field_name); // Draw the proper contents of the shield. filter_shield.draw(fina, flist, manager); }
[ "function", "draw_shield", "(", "resp", ")", "{", "// ll(\"shield what: \" + bbop.core.what_is(resp));", "// ll(\"shield resp: \" + bbop.core.dump(resp));", "// First, extract the fields from the", "// minimal response.", "var", "fina", "=", "call_time_field_name", ";", "var", "flist", "=", "resp", ".", "facet_field", "(", "call_time_field_name", ")", ";", "// Draw the proper contents of the shield.", "filter_shield", ".", "draw", "(", "fina", ",", "flist", ",", "manager", ")", ";", "}" ]
Open the populated shield.
[ "Open", "the", "populated", "shield", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L17104-L17116
52,493
berkeleybop/bbopx-js
external/bbop.js
function(layout_level){ loop(layout_level, // for every item at this level function(level_item){ var nid = level_item[0]; var lbl = level_item[1]; var rel = level_item[2]; // For various sections, decide to run image // (img) or text code depending on whether // or not it looks like we have a real URL. var use_img_p = true; if( base_icon_url == null || base_icon_url == '' ){ use_img_p = false; } // Clickable acc span. // No images, so the same either way. Ignore // it if we're current. var nav_b = null; if(anchor._current_acc == nid){ var inact_attrs = { 'class': 'bbop-js-text-button-sim-inactive', 'title': 'Current term.' }; nav_b = new bbop.html.span(nid, inact_attrs); }else{ var tbs = bbop.widget.display.text_button_sim; var bttn_title = 'Reorient neighborhood onto this node (' + nid + ').'; nav_b = new tbs(nid, bttn_title); nav_button_hash[nav_b.get_id()] = nid; } // Clickable info span. A little difference // if we have images. var info_b = null; if( use_img_p ){ // Do the icon version. var imgsrc = bbop.core.resourcify(base_icon_url, info_icon, image_type); info_b = new bbop.html.image({'alt': info_alt, 'title': info_alt, 'src': imgsrc, 'generate_id': true}); }else{ // Do a text-only version. info_b = new bbop.html.span('<b>[i]</b>', {'generate_id': true}); } info_button_hash[info_b.get_id()] = nid; // "Icon". If base_icon_url is defined as // something try for images, otherwise fall // back to this text ick. var icon = null; if( use_img_p ){ // Do the icon version. var ialt = '[' + rel + ']'; var isrc = null; if(anchor._current_acc == nid){ isrc = bbop.core.resourcify(base_icon_url, current_icon, image_type); }else{ isrc = bbop.core.resourcify(base_icon_url, rel, image_type); } icon = new bbop.html.image({'alt': ialt, 'title': rel, 'src': isrc, 'generate_id': true}); }else{ // Do a text-only version. if(anchor._current_acc == nid){ icon = '[[->]]'; }else if( rel && rel.length && rel.length > 0 ){ icon = '[' + rel + ']'; }else{ icon = '[???]'; } } // Stack the info, with the additional // spaces, into the div. top_level.add_to(spaces, icon, nav_b.to_string(), lbl, info_b.to_string()); }); spaces = spaces + spacing; }
javascript
function(layout_level){ loop(layout_level, // for every item at this level function(level_item){ var nid = level_item[0]; var lbl = level_item[1]; var rel = level_item[2]; // For various sections, decide to run image // (img) or text code depending on whether // or not it looks like we have a real URL. var use_img_p = true; if( base_icon_url == null || base_icon_url == '' ){ use_img_p = false; } // Clickable acc span. // No images, so the same either way. Ignore // it if we're current. var nav_b = null; if(anchor._current_acc == nid){ var inact_attrs = { 'class': 'bbop-js-text-button-sim-inactive', 'title': 'Current term.' }; nav_b = new bbop.html.span(nid, inact_attrs); }else{ var tbs = bbop.widget.display.text_button_sim; var bttn_title = 'Reorient neighborhood onto this node (' + nid + ').'; nav_b = new tbs(nid, bttn_title); nav_button_hash[nav_b.get_id()] = nid; } // Clickable info span. A little difference // if we have images. var info_b = null; if( use_img_p ){ // Do the icon version. var imgsrc = bbop.core.resourcify(base_icon_url, info_icon, image_type); info_b = new bbop.html.image({'alt': info_alt, 'title': info_alt, 'src': imgsrc, 'generate_id': true}); }else{ // Do a text-only version. info_b = new bbop.html.span('<b>[i]</b>', {'generate_id': true}); } info_button_hash[info_b.get_id()] = nid; // "Icon". If base_icon_url is defined as // something try for images, otherwise fall // back to this text ick. var icon = null; if( use_img_p ){ // Do the icon version. var ialt = '[' + rel + ']'; var isrc = null; if(anchor._current_acc == nid){ isrc = bbop.core.resourcify(base_icon_url, current_icon, image_type); }else{ isrc = bbop.core.resourcify(base_icon_url, rel, image_type); } icon = new bbop.html.image({'alt': ialt, 'title': rel, 'src': isrc, 'generate_id': true}); }else{ // Do a text-only version. if(anchor._current_acc == nid){ icon = '[[->]]'; }else if( rel && rel.length && rel.length > 0 ){ icon = '[' + rel + ']'; }else{ icon = '[???]'; } } // Stack the info, with the additional // spaces, into the div. top_level.add_to(spaces, icon, nav_b.to_string(), lbl, info_b.to_string()); }); spaces = spaces + spacing; }
[ "function", "(", "layout_level", ")", "{", "loop", "(", "layout_level", ",", "// for every item at this level", "function", "(", "level_item", ")", "{", "var", "nid", "=", "level_item", "[", "0", "]", ";", "var", "lbl", "=", "level_item", "[", "1", "]", ";", "var", "rel", "=", "level_item", "[", "2", "]", ";", "// For various sections, decide to run image", "// (img) or text code depending on whether", "// or not it looks like we have a real URL.", "var", "use_img_p", "=", "true", ";", "if", "(", "base_icon_url", "==", "null", "||", "base_icon_url", "==", "''", ")", "{", "use_img_p", "=", "false", ";", "}", "// Clickable acc span.", "// No images, so the same either way. Ignore", "// it if we're current.", "var", "nav_b", "=", "null", ";", "if", "(", "anchor", ".", "_current_acc", "==", "nid", ")", "{", "var", "inact_attrs", "=", "{", "'class'", ":", "'bbop-js-text-button-sim-inactive'", ",", "'title'", ":", "'Current term.'", "}", ";", "nav_b", "=", "new", "bbop", ".", "html", ".", "span", "(", "nid", ",", "inact_attrs", ")", ";", "}", "else", "{", "var", "tbs", "=", "bbop", ".", "widget", ".", "display", ".", "text_button_sim", ";", "var", "bttn_title", "=", "'Reorient neighborhood onto this node ('", "+", "nid", "+", "').'", ";", "nav_b", "=", "new", "tbs", "(", "nid", ",", "bttn_title", ")", ";", "nav_button_hash", "[", "nav_b", ".", "get_id", "(", ")", "]", "=", "nid", ";", "}", "// Clickable info span. A little difference", "// if we have images.", "var", "info_b", "=", "null", ";", "if", "(", "use_img_p", ")", "{", "// Do the icon version.", "var", "imgsrc", "=", "bbop", ".", "core", ".", "resourcify", "(", "base_icon_url", ",", "info_icon", ",", "image_type", ")", ";", "info_b", "=", "new", "bbop", ".", "html", ".", "image", "(", "{", "'alt'", ":", "info_alt", ",", "'title'", ":", "info_alt", ",", "'src'", ":", "imgsrc", ",", "'generate_id'", ":", "true", "}", ")", ";", "}", "else", "{", "// Do a text-only version.", "info_b", "=", "new", "bbop", ".", "html", ".", "span", "(", "'<b>[i]</b>'", ",", "{", "'generate_id'", ":", "true", "}", ")", ";", "}", "info_button_hash", "[", "info_b", ".", "get_id", "(", ")", "]", "=", "nid", ";", "// \"Icon\". If base_icon_url is defined as", "// something try for images, otherwise fall", "// back to this text ick.", "var", "icon", "=", "null", ";", "if", "(", "use_img_p", ")", "{", "// Do the icon version.", "var", "ialt", "=", "'['", "+", "rel", "+", "']'", ";", "var", "isrc", "=", "null", ";", "if", "(", "anchor", ".", "_current_acc", "==", "nid", ")", "{", "isrc", "=", "bbop", ".", "core", ".", "resourcify", "(", "base_icon_url", ",", "current_icon", ",", "image_type", ")", ";", "}", "else", "{", "isrc", "=", "bbop", ".", "core", ".", "resourcify", "(", "base_icon_url", ",", "rel", ",", "image_type", ")", ";", "}", "icon", "=", "new", "bbop", ".", "html", ".", "image", "(", "{", "'alt'", ":", "ialt", ",", "'title'", ":", "rel", ",", "'src'", ":", "isrc", ",", "'generate_id'", ":", "true", "}", ")", ";", "}", "else", "{", "// Do a text-only version.", "if", "(", "anchor", ".", "_current_acc", "==", "nid", ")", "{", "icon", "=", "'[[->]]'", ";", "}", "else", "if", "(", "rel", "&&", "rel", ".", "length", "&&", "rel", ".", "length", ">", "0", ")", "{", "icon", "=", "'['", "+", "rel", "+", "']'", ";", "}", "else", "{", "icon", "=", "'[???]'", ";", "}", "}", "// Stack the info, with the additional", "// spaces, into the div.", "top_level", ".", "add_to", "(", "spaces", ",", "icon", ",", "nav_b", ".", "to_string", "(", ")", ",", "lbl", ",", "info_b", ".", "to_string", "(", ")", ")", ";", "}", ")", ";", "spaces", "=", "spaces", "+", "spacing", ";", "}" ]
for every level
[ "for", "every", "level" ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L17811-L17908
52,494
berkeleybop/bbopx-js
external/bbop.js
function(request_data, response_hook) { anchor.jq_vars['success'] = function(json_data){ var retlist = []; var resp = new bbop.golr.response(json_data); // Reset the last return; remember: tri-state. result_count = null; return_count = null; if( resp.success() ){ // Get best shot at document counts. result_count = resp.total_documents(); return_count = resp.documents().length; loop(resp.documents(), function(doc){ // First, try and pull what we can out of our var lbl = label_tt.fill(doc); // Now the same thing for the return/value. var val = value_tt.fill(doc); // Add the discovered items to the return // save. var item = { 'label': lbl, 'value': val, 'document': doc }; retlist.push(item); }); } response_hook(retlist); }; // Get the selected term into the manager and fire. //anchor.set_query(request_data.term); anchor.set_comfy_query(request_data.term); anchor.JQ.ajax(anchor.get_query_url(), anchor.jq_vars); }
javascript
function(request_data, response_hook) { anchor.jq_vars['success'] = function(json_data){ var retlist = []; var resp = new bbop.golr.response(json_data); // Reset the last return; remember: tri-state. result_count = null; return_count = null; if( resp.success() ){ // Get best shot at document counts. result_count = resp.total_documents(); return_count = resp.documents().length; loop(resp.documents(), function(doc){ // First, try and pull what we can out of our var lbl = label_tt.fill(doc); // Now the same thing for the return/value. var val = value_tt.fill(doc); // Add the discovered items to the return // save. var item = { 'label': lbl, 'value': val, 'document': doc }; retlist.push(item); }); } response_hook(retlist); }; // Get the selected term into the manager and fire. //anchor.set_query(request_data.term); anchor.set_comfy_query(request_data.term); anchor.JQ.ajax(anchor.get_query_url(), anchor.jq_vars); }
[ "function", "(", "request_data", ",", "response_hook", ")", "{", "anchor", ".", "jq_vars", "[", "'success'", "]", "=", "function", "(", "json_data", ")", "{", "var", "retlist", "=", "[", "]", ";", "var", "resp", "=", "new", "bbop", ".", "golr", ".", "response", "(", "json_data", ")", ";", "// Reset the last return; remember: tri-state.", "result_count", "=", "null", ";", "return_count", "=", "null", ";", "if", "(", "resp", ".", "success", "(", ")", ")", "{", "// Get best shot at document counts.", "result_count", "=", "resp", ".", "total_documents", "(", ")", ";", "return_count", "=", "resp", ".", "documents", "(", ")", ".", "length", ";", "loop", "(", "resp", ".", "documents", "(", ")", ",", "function", "(", "doc", ")", "{", "// First, try and pull what we can out of our", "var", "lbl", "=", "label_tt", ".", "fill", "(", "doc", ")", ";", "// Now the same thing for the return/value.", "var", "val", "=", "value_tt", ".", "fill", "(", "doc", ")", ";", "// Add the discovered items to the return", "// save.", "var", "item", "=", "{", "'label'", ":", "lbl", ",", "'value'", ":", "val", ",", "'document'", ":", "doc", "}", ";", "retlist", ".", "push", "(", "item", ")", ";", "}", ")", ";", "}", "response_hook", "(", "retlist", ")", ";", "}", ";", "// Get the selected term into the manager and fire.", "//anchor.set_query(request_data.term);", "anchor", ".", "set_comfy_query", "(", "request_data", ".", "term", ")", ";", "anchor", ".", "JQ", ".", "ajax", "(", "anchor", ".", "get_query_url", "(", ")", ",", "anchor", ".", "jq_vars", ")", ";", "}" ]
Function for a successful data hit. The data getter, which is making it all more complicated than it needs to be...we need to close around those callback hooks so we have to do it inplace here.
[ "Function", "for", "a", "successful", "data", "hit", ".", "The", "data", "getter", "which", "is", "making", "it", "all", "more", "complicated", "than", "it", "needs", "to", "be", "...", "we", "need", "to", "close", "around", "those", "callback", "hooks", "so", "we", "have", "to", "do", "it", "inplace", "here", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L18069-L18110
52,495
berkeleybop/bbopx-js
external/bbop.js
function(event, ui){ // Prevent default selection input filling action (from // jQuery UI) when non-default marked. if( ! anchor._fill_p ){ event.preventDefault(); } var doc_to_apply = null; if( ui.item ){ doc_to_apply = ui.item.document; } // Only do the callback if it is defined. if( doc_to_apply && bbop.core.is_defined(anchor._list_select_callback) ){ anchor._list_select_callback(doc_to_apply); } }
javascript
function(event, ui){ // Prevent default selection input filling action (from // jQuery UI) when non-default marked. if( ! anchor._fill_p ){ event.preventDefault(); } var doc_to_apply = null; if( ui.item ){ doc_to_apply = ui.item.document; } // Only do the callback if it is defined. if( doc_to_apply && bbop.core.is_defined(anchor._list_select_callback) ){ anchor._list_select_callback(doc_to_apply); } }
[ "function", "(", "event", ",", "ui", ")", "{", "// Prevent default selection input filling action (from", "// jQuery UI) when non-default marked.", "if", "(", "!", "anchor", ".", "_fill_p", ")", "{", "event", ".", "preventDefault", "(", ")", ";", "}", "var", "doc_to_apply", "=", "null", ";", "if", "(", "ui", ".", "item", ")", "{", "doc_to_apply", "=", "ui", ".", "item", ".", "document", ";", "}", "// Only do the callback if it is defined.", "if", "(", "doc_to_apply", "&&", "bbop", ".", "core", ".", "is_defined", "(", "anchor", ".", "_list_select_callback", ")", ")", "{", "anchor", ".", "_list_select_callback", "(", "doc_to_apply", ")", ";", "}", "}" ]
What to do when an element is selected.
[ "What", "to", "do", "when", "an", "element", "is", "selected", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L18112-L18130
52,496
berkeleybop/bbopx-js
external/bbop.js
_draw_local_doc
function _draw_local_doc(doc){ //ll(doc['id']); var personality = anchor.get_personality(); var cclass = golr_conf_obj.get_class(personality); var txt = 'Nothing here...'; if( doc && cclass ){ var tbl = new bbop.html.table(); var results_order = cclass.field_order_by_weight('result'); var each = bbop.core.each; // convenience each(results_order, function(fid){ // var field = cclass.get_field(fid); var val = doc[fid]; // Determine if we have a list that we're working // with or not. if( field.is_multi() ){ if( val ){ val = val.join(', '); }else{ val = 'n/a'; } }else{ // When handling just the single value, see // if we can link out the value. var link = null; if( val ){ //link = linker.anchor({id: val}); //link = linker.anchor({id: val}, 'term'); link = linker.anchor({id: val}, fid); if( link ){ val = link; } }else{ val = 'n/a'; } } tbl.add_to([field.display_name(), val]); }); txt = tbl.to_string(); } // Create div. var div = new bbop.html.tag('div', {'generate_id': true}); var div_id = div.get_id(); // Append div to body. jQuery('body').append(div.to_string()); // Add text to div. jQuery('#' + div_id).append(txt); // Modal dialogify div; include self-destruct. var diargs = { modal: true, draggable: false, width: width, close: function(){ // TODO: Could maybe use .dialog('destroy') instead? jQuery('#' + div_id).remove(); } }; var dia = jQuery('#' + div_id).dialog(diargs); }
javascript
function _draw_local_doc(doc){ //ll(doc['id']); var personality = anchor.get_personality(); var cclass = golr_conf_obj.get_class(personality); var txt = 'Nothing here...'; if( doc && cclass ){ var tbl = new bbop.html.table(); var results_order = cclass.field_order_by_weight('result'); var each = bbop.core.each; // convenience each(results_order, function(fid){ // var field = cclass.get_field(fid); var val = doc[fid]; // Determine if we have a list that we're working // with or not. if( field.is_multi() ){ if( val ){ val = val.join(', '); }else{ val = 'n/a'; } }else{ // When handling just the single value, see // if we can link out the value. var link = null; if( val ){ //link = linker.anchor({id: val}); //link = linker.anchor({id: val}, 'term'); link = linker.anchor({id: val}, fid); if( link ){ val = link; } }else{ val = 'n/a'; } } tbl.add_to([field.display_name(), val]); }); txt = tbl.to_string(); } // Create div. var div = new bbop.html.tag('div', {'generate_id': true}); var div_id = div.get_id(); // Append div to body. jQuery('body').append(div.to_string()); // Add text to div. jQuery('#' + div_id).append(txt); // Modal dialogify div; include self-destruct. var diargs = { modal: true, draggable: false, width: width, close: function(){ // TODO: Could maybe use .dialog('destroy') instead? jQuery('#' + div_id).remove(); } }; var dia = jQuery('#' + div_id).dialog(diargs); }
[ "function", "_draw_local_doc", "(", "doc", ")", "{", "//ll(doc['id']);", "var", "personality", "=", "anchor", ".", "get_personality", "(", ")", ";", "var", "cclass", "=", "golr_conf_obj", ".", "get_class", "(", "personality", ")", ";", "var", "txt", "=", "'Nothing here...'", ";", "if", "(", "doc", "&&", "cclass", ")", "{", "var", "tbl", "=", "new", "bbop", ".", "html", ".", "table", "(", ")", ";", "var", "results_order", "=", "cclass", ".", "field_order_by_weight", "(", "'result'", ")", ";", "var", "each", "=", "bbop", ".", "core", ".", "each", ";", "// convenience", "each", "(", "results_order", ",", "function", "(", "fid", ")", "{", "// ", "var", "field", "=", "cclass", ".", "get_field", "(", "fid", ")", ";", "var", "val", "=", "doc", "[", "fid", "]", ";", "// Determine if we have a list that we're working", "// with or not.", "if", "(", "field", ".", "is_multi", "(", ")", ")", "{", "if", "(", "val", ")", "{", "val", "=", "val", ".", "join", "(", "', '", ")", ";", "}", "else", "{", "val", "=", "'n/a'", ";", "}", "}", "else", "{", "// When handling just the single value, see", "// if we can link out the value.", "var", "link", "=", "null", ";", "if", "(", "val", ")", "{", "//link = linker.anchor({id: val});", "//link = linker.anchor({id: val}, 'term');", "link", "=", "linker", ".", "anchor", "(", "{", "id", ":", "val", "}", ",", "fid", ")", ";", "if", "(", "link", ")", "{", "val", "=", "link", ";", "}", "}", "else", "{", "val", "=", "'n/a'", ";", "}", "}", "tbl", ".", "add_to", "(", "[", "field", ".", "display_name", "(", ")", ",", "val", "]", ")", ";", "}", ")", ";", "txt", "=", "tbl", ".", "to_string", "(", ")", ";", "}", "// Create div.", "var", "div", "=", "new", "bbop", ".", "html", ".", "tag", "(", "'div'", ",", "{", "'generate_id'", ":", "true", "}", ")", ";", "var", "div_id", "=", "div", ".", "get_id", "(", ")", ";", "// Append div to body.", "jQuery", "(", "'body'", ")", ".", "append", "(", "div", ".", "to_string", "(", ")", ")", ";", "// Add text to div.", "jQuery", "(", "'#'", "+", "div_id", ")", ".", "append", "(", "txt", ")", ";", "// Modal dialogify div; include self-destruct.", "var", "diargs", "=", "{", "modal", ":", "true", ",", "draggable", ":", "false", ",", "width", ":", "width", ",", "close", ":", "function", "(", ")", "{", "// TODO: Could maybe use .dialog('destroy') instead?", "jQuery", "(", "'#'", "+", "div_id", ")", ".", "remove", "(", ")", ";", "}", "}", ";", "var", "dia", "=", "jQuery", "(", "'#'", "+", "div_id", ")", ".", "dialog", "(", "diargs", ")", ";", "}" ]
Draw a locally help Solr response doc.
[ "Draw", "a", "locally", "help", "Solr", "response", "doc", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L18352-L18423
52,497
berkeleybop/bbopx-js
external/bbop.js
_get_selected
function _get_selected(){ var ret_list = []; var selected_strings = jQuery('#'+ sul_id).sortable('toArray', {'attribute': 'value'}); each(selected_strings, function(in_thing){ if( in_thing && in_thing != '' ){ ret_list.push(in_thing); } }); return ret_list; }
javascript
function _get_selected(){ var ret_list = []; var selected_strings = jQuery('#'+ sul_id).sortable('toArray', {'attribute': 'value'}); each(selected_strings, function(in_thing){ if( in_thing && in_thing != '' ){ ret_list.push(in_thing); } }); return ret_list; }
[ "function", "_get_selected", "(", ")", "{", "var", "ret_list", "=", "[", "]", ";", "var", "selected_strings", "=", "jQuery", "(", "'#'", "+", "sul_id", ")", ".", "sortable", "(", "'toArray'", ",", "{", "'attribute'", ":", "'value'", "}", ")", ";", "each", "(", "selected_strings", ",", "function", "(", "in_thing", ")", "{", "if", "(", "in_thing", "&&", "in_thing", "!=", "''", ")", "{", "ret_list", ".", "push", "(", "in_thing", ")", ";", "}", "}", ")", ";", "return", "ret_list", ";", "}" ]
Helper function to pull the values. Currently, JQuery adds a lot of extra non-attributes li tags when it creates the DnD, so filter those out to get just the fields ids.
[ "Helper", "function", "to", "pull", "the", "values", ".", "Currently", "JQuery", "adds", "a", "lot", "of", "extra", "non", "-", "attributes", "li", "tags", "when", "it", "creates", "the", "DnD", "so", "filter", "those", "out", "to", "get", "just", "the", "fields", "ids", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L18852-L18863
52,498
berkeleybop/bbopx-js
external/bbop.js
_button_wrapper
function _button_wrapper(str, title){ var b = new bbop.widget.display.text_button_sim(str, title, ''); return b.to_string(); }
javascript
function _button_wrapper(str, title){ var b = new bbop.widget.display.text_button_sim(str, title, ''); return b.to_string(); }
[ "function", "_button_wrapper", "(", "str", ",", "title", ")", "{", "var", "b", "=", "new", "bbop", ".", "widget", ".", "display", ".", "text_button_sim", "(", "str", ",", "title", ",", "''", ")", ";", "return", "b", ".", "to_string", "(", ")", ";", "}" ]
Our argument default hash.
[ "Our", "argument", "default", "hash", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L18998-L19001
52,499
berkeleybop/bbopx-js
external/bbop.js
_initial_runner
function _initial_runner(response, manager){ // I can't just remove the callback from the register // after the first run because it would be reconstituted // every time it was reset (established). if( anchor.initial_reset_p ){ anchor.initial_reset_p = false; anchor.initial_reset_callback(response, manager); //ll('unregister: ' + anchor.unregister('reset', 'first_run')); } }
javascript
function _initial_runner(response, manager){ // I can't just remove the callback from the register // after the first run because it would be reconstituted // every time it was reset (established). if( anchor.initial_reset_p ){ anchor.initial_reset_p = false; anchor.initial_reset_callback(response, manager); //ll('unregister: ' + anchor.unregister('reset', 'first_run')); } }
[ "function", "_initial_runner", "(", "response", ",", "manager", ")", "{", "// I can't just remove the callback from the register", "// after the first run because it would be reconstituted", "// every time it was reset (established).", "if", "(", "anchor", ".", "initial_reset_p", ")", "{", "anchor", ".", "initial_reset_p", "=", "false", ";", "anchor", ".", "initial_reset_callback", "(", "response", ",", "manager", ")", ";", "//ll('unregister: ' + anchor.unregister('reset', 'first_run'));", "}", "}" ]
Finally, we're going to add a first run behavior here. We'll wrap the user-defined function into a
[ "Finally", "we", "re", "going", "to", "add", "a", "first", "run", "behavior", "here", ".", "We", "ll", "wrap", "the", "user", "-", "defined", "function", "into", "a" ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L19123-L19132