id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
14,100
datproject/dat-node
lib/storage.js
defaultStorage
function defaultStorage (storage, opts) { // Use custom storage or ram if (typeof storage !== 'string') return storage if (opts.temp) return ram if (opts.latest === false) { // Store as SLEEP files inluding content.data return { metadata: function (name, opts) { // I don't think we want this, we may get multiple 'ogd' sources // if (name === 'secret_key') return secretStorage()(path.join(storage, 'metadata.ogd'), {key: opts.key, discoveryKey: opts.discoveryKey}) return raf(path.join(storage, 'metadata.' + name)) }, content: function (name, opts) { return raf(path.join(storage, 'content.' + name)) } } } try { // Store in .dat with secret in ~/.dat if (fs.statSync(storage).isDirectory()) { return datStore(storage, opts) } } catch (e) { // Does not exist, make dir try { fs.mkdirSync(storage) } catch (e) { // Invalid path throw new Error('Invalid storage path') } return datStore(storage, opts) } error() function error () { // TODO: single file sleep storage throw new Error('Storage must be dir or opts.temp') } }
javascript
function defaultStorage (storage, opts) { // Use custom storage or ram if (typeof storage !== 'string') return storage if (opts.temp) return ram if (opts.latest === false) { // Store as SLEEP files inluding content.data return { metadata: function (name, opts) { // I don't think we want this, we may get multiple 'ogd' sources // if (name === 'secret_key') return secretStorage()(path.join(storage, 'metadata.ogd'), {key: opts.key, discoveryKey: opts.discoveryKey}) return raf(path.join(storage, 'metadata.' + name)) }, content: function (name, opts) { return raf(path.join(storage, 'content.' + name)) } } } try { // Store in .dat with secret in ~/.dat if (fs.statSync(storage).isDirectory()) { return datStore(storage, opts) } } catch (e) { // Does not exist, make dir try { fs.mkdirSync(storage) } catch (e) { // Invalid path throw new Error('Invalid storage path') } return datStore(storage, opts) } error() function error () { // TODO: single file sleep storage throw new Error('Storage must be dir or opts.temp') } }
[ "function", "defaultStorage", "(", "storage", ",", "opts", ")", "{", "// Use custom storage or ram", "if", "(", "typeof", "storage", "!==", "'string'", ")", "return", "storage", "if", "(", "opts", ".", "temp", ")", "return", "ram", "if", "(", "opts", ".", "latest", "===", "false", ")", "{", "// Store as SLEEP files inluding content.data", "return", "{", "metadata", ":", "function", "(", "name", ",", "opts", ")", "{", "// I don't think we want this, we may get multiple 'ogd' sources", "// if (name === 'secret_key') return secretStorage()(path.join(storage, 'metadata.ogd'), {key: opts.key, discoveryKey: opts.discoveryKey})", "return", "raf", "(", "path", ".", "join", "(", "storage", ",", "'metadata.'", "+", "name", ")", ")", "}", ",", "content", ":", "function", "(", "name", ",", "opts", ")", "{", "return", "raf", "(", "path", ".", "join", "(", "storage", ",", "'content.'", "+", "name", ")", ")", "}", "}", "}", "try", "{", "// Store in .dat with secret in ~/.dat", "if", "(", "fs", ".", "statSync", "(", "storage", ")", ".", "isDirectory", "(", ")", ")", "{", "return", "datStore", "(", "storage", ",", "opts", ")", "}", "}", "catch", "(", "e", ")", "{", "// Does not exist, make dir", "try", "{", "fs", ".", "mkdirSync", "(", "storage", ")", "}", "catch", "(", "e", ")", "{", "// Invalid path", "throw", "new", "Error", "(", "'Invalid storage path'", ")", "}", "return", "datStore", "(", "storage", ",", "opts", ")", "}", "error", "(", ")", "function", "error", "(", ")", "{", "// TODO: single file sleep storage", "throw", "new", "Error", "(", "'Storage must be dir or opts.temp'", ")", "}", "}" ]
Parse the storage argument and return storage for hyperdrive. By default, uses dat-secret-storage to storage secret keys in user's home directory. @param {string|object} storage - Storage for hyperdrive. `string` is a directory or file. Directory: `/my-data`, storage will be in `/my-data/.dat`. Single File: `/my-file.zip`, storage will be in memory. Object is a hyperdrive storage object `{metadata: fn, content: fn}`. @param {object} [opts] - options @param {Boolean} [opts.temp] - Use temporary storage (random-access-memory) @returns {object} hyperdrive storage object
[ "Parse", "the", "storage", "argument", "and", "return", "storage", "for", "hyperdrive", ".", "By", "default", "uses", "dat", "-", "secret", "-", "storage", "to", "storage", "secret", "keys", "in", "user", "s", "home", "directory", "." ]
c5f377309ead92cbef57f726795e2d85e0720b24
https://github.com/datproject/dat-node/blob/c5f377309ead92cbef57f726795e2d85e0720b24/lib/storage.js#L21-L60
14,101
gka/d3-jetpack
src/polygonClip.js
polygonClosed
function polygonClosed(coordinates) { var a = coordinates[0], b = coordinates[coordinates.length - 1]; return !(a[0] - b[0] || a[1] - b[1]); }
javascript
function polygonClosed(coordinates) { var a = coordinates[0], b = coordinates[coordinates.length - 1]; return !(a[0] - b[0] || a[1] - b[1]); }
[ "function", "polygonClosed", "(", "coordinates", ")", "{", "var", "a", "=", "coordinates", "[", "0", "]", ",", "b", "=", "coordinates", "[", "coordinates", ".", "length", "-", "1", "]", ";", "return", "!", "(", "a", "[", "0", "]", "-", "b", "[", "0", "]", "||", "a", "[", "1", "]", "-", "b", "[", "1", "]", ")", ";", "}" ]
Returns true if the polygon is closed.
[ "Returns", "true", "if", "the", "polygon", "is", "closed", "." ]
2f68acf9805650bed7bd21aa293d32709f36833c
https://github.com/gka/d3-jetpack/blob/2f68acf9805650bed7bd21aa293d32709f36833c/src/polygonClip.js#L54-L58
14,102
krispo/angular-nvd3
dist/angular-nvd3.js
function (data){ // set data if (!arguments.length) { if (scope.options.chart.type === 'sunburstChart') { data = angular.copy(scope.data); } else { data = scope.data; } } else { scope.data = data; // return if data $watch is enabled if (scope._config.deepWatchData && !scope._config.disabled) return; } if (data) { // remove whole svg element with old data d3.select(element[0]).select('svg').remove(); var h, w; // Select the current element to add <svg> element and to render the chart in scope.svg = d3.select(element[0]).insert('svg', '.caption'); if (h = scope.options.chart.height) { if (!isNaN(+h)) h += 'px'; //check if height is number scope.svg.attr('height', h).style({height: h}); } if (w = scope.options.chart.width) { if (!isNaN(+w)) w += 'px'; //check if width is number scope.svg.attr('width', w).style({width: w}); } else { scope.svg.attr('width', '100%').style({width: '100%'}); } scope.svg.datum(data).call(scope.chart); // update zooming if exists if (scope.chart && scope.chart.zoomRender) scope.chart.zoomRender(); } }
javascript
function (data){ // set data if (!arguments.length) { if (scope.options.chart.type === 'sunburstChart') { data = angular.copy(scope.data); } else { data = scope.data; } } else { scope.data = data; // return if data $watch is enabled if (scope._config.deepWatchData && !scope._config.disabled) return; } if (data) { // remove whole svg element with old data d3.select(element[0]).select('svg').remove(); var h, w; // Select the current element to add <svg> element and to render the chart in scope.svg = d3.select(element[0]).insert('svg', '.caption'); if (h = scope.options.chart.height) { if (!isNaN(+h)) h += 'px'; //check if height is number scope.svg.attr('height', h).style({height: h}); } if (w = scope.options.chart.width) { if (!isNaN(+w)) w += 'px'; //check if width is number scope.svg.attr('width', w).style({width: w}); } else { scope.svg.attr('width', '100%').style({width: '100%'}); } scope.svg.datum(data).call(scope.chart); // update zooming if exists if (scope.chart && scope.chart.zoomRender) scope.chart.zoomRender(); } }
[ "function", "(", "data", ")", "{", "// set data", "if", "(", "!", "arguments", ".", "length", ")", "{", "if", "(", "scope", ".", "options", ".", "chart", ".", "type", "===", "'sunburstChart'", ")", "{", "data", "=", "angular", ".", "copy", "(", "scope", ".", "data", ")", ";", "}", "else", "{", "data", "=", "scope", ".", "data", ";", "}", "}", "else", "{", "scope", ".", "data", "=", "data", ";", "// return if data $watch is enabled", "if", "(", "scope", ".", "_config", ".", "deepWatchData", "&&", "!", "scope", ".", "_config", ".", "disabled", ")", "return", ";", "}", "if", "(", "data", ")", "{", "// remove whole svg element with old data", "d3", ".", "select", "(", "element", "[", "0", "]", ")", ".", "select", "(", "'svg'", ")", ".", "remove", "(", ")", ";", "var", "h", ",", "w", ";", "// Select the current element to add <svg> element and to render the chart in", "scope", ".", "svg", "=", "d3", ".", "select", "(", "element", "[", "0", "]", ")", ".", "insert", "(", "'svg'", ",", "'.caption'", ")", ";", "if", "(", "h", "=", "scope", ".", "options", ".", "chart", ".", "height", ")", "{", "if", "(", "!", "isNaN", "(", "+", "h", ")", ")", "h", "+=", "'px'", ";", "//check if height is number", "scope", ".", "svg", ".", "attr", "(", "'height'", ",", "h", ")", ".", "style", "(", "{", "height", ":", "h", "}", ")", ";", "}", "if", "(", "w", "=", "scope", ".", "options", ".", "chart", ".", "width", ")", "{", "if", "(", "!", "isNaN", "(", "+", "w", ")", ")", "w", "+=", "'px'", ";", "//check if width is number", "scope", ".", "svg", ".", "attr", "(", "'width'", ",", "w", ")", ".", "style", "(", "{", "width", ":", "w", "}", ")", ";", "}", "else", "{", "scope", ".", "svg", ".", "attr", "(", "'width'", ",", "'100%'", ")", ".", "style", "(", "{", "width", ":", "'100%'", "}", ")", ";", "}", "scope", ".", "svg", ".", "datum", "(", "data", ")", ".", "call", "(", "scope", ".", "chart", ")", ";", "// update zooming if exists", "if", "(", "scope", ".", "chart", "&&", "scope", ".", "chart", ".", "zoomRender", ")", "scope", ".", "chart", ".", "zoomRender", "(", ")", ";", "}", "}" ]
Update chart with new data
[ "Update", "chart", "with", "new", "data" ]
19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8
https://github.com/krispo/angular-nvd3/blob/19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8/dist/angular-nvd3.js#L237-L276
14,103
krispo/angular-nvd3
dist/angular-nvd3.js
function (){ element.find('.title').remove(); element.find('.subtitle').remove(); element.find('.caption').remove(); element.empty(); // remove tooltip if exists if (scope.chart && scope.chart.tooltip && scope.chart.tooltip.id) { d3.select('#' + scope.chart.tooltip.id()).remove(); } // To be compatible with old nvd3 (v1.7.1) if (nv.graphs && scope.chart) { for (var i = nv.graphs.length - 1; i >= 0; i--) { if (nv.graphs[i] && (nv.graphs[i].id === scope.chart.id)) { nv.graphs.splice(i, 1); } } } if (nv.tooltip && nv.tooltip.cleanup) { nv.tooltip.cleanup(); } if (scope.chart && scope.chart.resizeHandler) scope.chart.resizeHandler.clear(); scope.chart = null; }
javascript
function (){ element.find('.title').remove(); element.find('.subtitle').remove(); element.find('.caption').remove(); element.empty(); // remove tooltip if exists if (scope.chart && scope.chart.tooltip && scope.chart.tooltip.id) { d3.select('#' + scope.chart.tooltip.id()).remove(); } // To be compatible with old nvd3 (v1.7.1) if (nv.graphs && scope.chart) { for (var i = nv.graphs.length - 1; i >= 0; i--) { if (nv.graphs[i] && (nv.graphs[i].id === scope.chart.id)) { nv.graphs.splice(i, 1); } } } if (nv.tooltip && nv.tooltip.cleanup) { nv.tooltip.cleanup(); } if (scope.chart && scope.chart.resizeHandler) scope.chart.resizeHandler.clear(); scope.chart = null; }
[ "function", "(", ")", "{", "element", ".", "find", "(", "'.title'", ")", ".", "remove", "(", ")", ";", "element", ".", "find", "(", "'.subtitle'", ")", ".", "remove", "(", ")", ";", "element", ".", "find", "(", "'.caption'", ")", ".", "remove", "(", ")", ";", "element", ".", "empty", "(", ")", ";", "// remove tooltip if exists", "if", "(", "scope", ".", "chart", "&&", "scope", ".", "chart", ".", "tooltip", "&&", "scope", ".", "chart", ".", "tooltip", ".", "id", ")", "{", "d3", ".", "select", "(", "'#'", "+", "scope", ".", "chart", ".", "tooltip", ".", "id", "(", ")", ")", ".", "remove", "(", ")", ";", "}", "// To be compatible with old nvd3 (v1.7.1)", "if", "(", "nv", ".", "graphs", "&&", "scope", ".", "chart", ")", "{", "for", "(", "var", "i", "=", "nv", ".", "graphs", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "nv", ".", "graphs", "[", "i", "]", "&&", "(", "nv", ".", "graphs", "[", "i", "]", ".", "id", "===", "scope", ".", "chart", ".", "id", ")", ")", "{", "nv", ".", "graphs", ".", "splice", "(", "i", ",", "1", ")", ";", "}", "}", "}", "if", "(", "nv", ".", "tooltip", "&&", "nv", ".", "tooltip", ".", "cleanup", ")", "{", "nv", ".", "tooltip", ".", "cleanup", "(", ")", ";", "}", "if", "(", "scope", ".", "chart", "&&", "scope", ".", "chart", ".", "resizeHandler", ")", "scope", ".", "chart", ".", "resizeHandler", ".", "clear", "(", ")", ";", "scope", ".", "chart", "=", "null", ";", "}" ]
Fully clear directive element
[ "Fully", "clear", "directive", "element" ]
19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8
https://github.com/krispo/angular-nvd3/blob/19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8/dist/angular-nvd3.js#L279-L303
14,104
krispo/angular-nvd3
dist/angular-nvd3.js
configure
function configure(chart, options, chartType){ if (chart && options){ angular.forEach(chart, function(value, key){ if (key[0] === '_'); else if (key === 'dispatch') { if (options[key] === undefined || options[key] === null) { if (scope._config.extended) options[key] = {}; } configureEvents(value, options[key]); } else if (key === 'tooltip') { if (options[key] === undefined || options[key] === null) { if (scope._config.extended) options[key] = {}; } configure(chart[key], options[key], chartType); } else if (key === 'contentGenerator') { if (options[key]) chart[key](options[key]); } else if ([ 'axis', 'clearHighlights', 'defined', 'highlightPoint', 'nvPointerEventsClass', 'options', 'rangeBand', 'rangeBands', 'scatter', 'open', 'close', 'node' ].indexOf(key) === -1) { if (options[key] === undefined || options[key] === null){ if (scope._config.extended) options[key] = value(); } else chart[key](options[key]); } }); } }
javascript
function configure(chart, options, chartType){ if (chart && options){ angular.forEach(chart, function(value, key){ if (key[0] === '_'); else if (key === 'dispatch') { if (options[key] === undefined || options[key] === null) { if (scope._config.extended) options[key] = {}; } configureEvents(value, options[key]); } else if (key === 'tooltip') { if (options[key] === undefined || options[key] === null) { if (scope._config.extended) options[key] = {}; } configure(chart[key], options[key], chartType); } else if (key === 'contentGenerator') { if (options[key]) chart[key](options[key]); } else if ([ 'axis', 'clearHighlights', 'defined', 'highlightPoint', 'nvPointerEventsClass', 'options', 'rangeBand', 'rangeBands', 'scatter', 'open', 'close', 'node' ].indexOf(key) === -1) { if (options[key] === undefined || options[key] === null){ if (scope._config.extended) options[key] = value(); } else chart[key](options[key]); } }); } }
[ "function", "configure", "(", "chart", ",", "options", ",", "chartType", ")", "{", "if", "(", "chart", "&&", "options", ")", "{", "angular", ".", "forEach", "(", "chart", ",", "function", "(", "value", ",", "key", ")", "{", "if", "(", "key", "[", "0", "]", "===", "'_'", ")", ";", "else", "if", "(", "key", "===", "'dispatch'", ")", "{", "if", "(", "options", "[", "key", "]", "===", "undefined", "||", "options", "[", "key", "]", "===", "null", ")", "{", "if", "(", "scope", ".", "_config", ".", "extended", ")", "options", "[", "key", "]", "=", "{", "}", ";", "}", "configureEvents", "(", "value", ",", "options", "[", "key", "]", ")", ";", "}", "else", "if", "(", "key", "===", "'tooltip'", ")", "{", "if", "(", "options", "[", "key", "]", "===", "undefined", "||", "options", "[", "key", "]", "===", "null", ")", "{", "if", "(", "scope", ".", "_config", ".", "extended", ")", "options", "[", "key", "]", "=", "{", "}", ";", "}", "configure", "(", "chart", "[", "key", "]", ",", "options", "[", "key", "]", ",", "chartType", ")", ";", "}", "else", "if", "(", "key", "===", "'contentGenerator'", ")", "{", "if", "(", "options", "[", "key", "]", ")", "chart", "[", "key", "]", "(", "options", "[", "key", "]", ")", ";", "}", "else", "if", "(", "[", "'axis'", ",", "'clearHighlights'", ",", "'defined'", ",", "'highlightPoint'", ",", "'nvPointerEventsClass'", ",", "'options'", ",", "'rangeBand'", ",", "'rangeBands'", ",", "'scatter'", ",", "'open'", ",", "'close'", ",", "'node'", "]", ".", "indexOf", "(", "key", ")", "===", "-", "1", ")", "{", "if", "(", "options", "[", "key", "]", "===", "undefined", "||", "options", "[", "key", "]", "===", "null", ")", "{", "if", "(", "scope", ".", "_config", ".", "extended", ")", "options", "[", "key", "]", "=", "value", "(", ")", ";", "}", "else", "chart", "[", "key", "]", "(", "options", "[", "key", "]", ")", ";", "}", "}", ")", ";", "}", "}" ]
Configure the chart model with the passed options
[ "Configure", "the", "chart", "model", "with", "the", "passed", "options" ]
19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8
https://github.com/krispo/angular-nvd3/blob/19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8/dist/angular-nvd3.js#L313-L353
14,105
krispo/angular-nvd3
dist/angular-nvd3.js
configureWrapper
function configureWrapper(name){ var _ = nvd3Utils.deepExtend(defaultWrapper(name), scope.options[name] || {}); if (scope._config.extended) scope.options[name] = _; var wrapElement = angular.element('<div></div>').html(_['html'] || '') .addClass(name).addClass(_.className) .removeAttr('style') .css(_.css); if (!_['html']) wrapElement.text(_.text); if (_.enable) { if (name === 'title') element.prepend(wrapElement); else if (name === 'subtitle') angular.element(element[0].querySelector('.title')).after(wrapElement); else if (name === 'caption') element.append(wrapElement); } }
javascript
function configureWrapper(name){ var _ = nvd3Utils.deepExtend(defaultWrapper(name), scope.options[name] || {}); if (scope._config.extended) scope.options[name] = _; var wrapElement = angular.element('<div></div>').html(_['html'] || '') .addClass(name).addClass(_.className) .removeAttr('style') .css(_.css); if (!_['html']) wrapElement.text(_.text); if (_.enable) { if (name === 'title') element.prepend(wrapElement); else if (name === 'subtitle') angular.element(element[0].querySelector('.title')).after(wrapElement); else if (name === 'caption') element.append(wrapElement); } }
[ "function", "configureWrapper", "(", "name", ")", "{", "var", "_", "=", "nvd3Utils", ".", "deepExtend", "(", "defaultWrapper", "(", "name", ")", ",", "scope", ".", "options", "[", "name", "]", "||", "{", "}", ")", ";", "if", "(", "scope", ".", "_config", ".", "extended", ")", "scope", ".", "options", "[", "name", "]", "=", "_", ";", "var", "wrapElement", "=", "angular", ".", "element", "(", "'<div></div>'", ")", ".", "html", "(", "_", "[", "'html'", "]", "||", "''", ")", ".", "addClass", "(", "name", ")", ".", "addClass", "(", "_", ".", "className", ")", ".", "removeAttr", "(", "'style'", ")", ".", "css", "(", "_", ".", "css", ")", ";", "if", "(", "!", "_", "[", "'html'", "]", ")", "wrapElement", ".", "text", "(", "_", ".", "text", ")", ";", "if", "(", "_", ".", "enable", ")", "{", "if", "(", "name", "===", "'title'", ")", "element", ".", "prepend", "(", "wrapElement", ")", ";", "else", "if", "(", "name", "===", "'subtitle'", ")", "angular", ".", "element", "(", "element", "[", "0", "]", ".", "querySelector", "(", "'.title'", ")", ")", ".", "after", "(", "wrapElement", ")", ";", "else", "if", "(", "name", "===", "'caption'", ")", "element", ".", "append", "(", "wrapElement", ")", ";", "}", "}" ]
Configure 'title', 'subtitle', 'caption'. nvd3 has no sufficient models for it yet.
[ "Configure", "title", "subtitle", "caption", ".", "nvd3", "has", "no", "sufficient", "models", "for", "it", "yet", "." ]
19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8
https://github.com/krispo/angular-nvd3/blob/19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8/dist/angular-nvd3.js#L370-L387
14,106
krispo/angular-nvd3
dist/angular-nvd3.js
configureStyles
function configureStyles(){ var _ = nvd3Utils.deepExtend(defaultStyles(), scope.options['styles'] || {}); if (scope._config.extended) scope.options['styles'] = _; angular.forEach(_.classes, function(value, key){ value ? element.addClass(key) : element.removeClass(key); }); element.removeAttr('style').css(_.css); }
javascript
function configureStyles(){ var _ = nvd3Utils.deepExtend(defaultStyles(), scope.options['styles'] || {}); if (scope._config.extended) scope.options['styles'] = _; angular.forEach(_.classes, function(value, key){ value ? element.addClass(key) : element.removeClass(key); }); element.removeAttr('style').css(_.css); }
[ "function", "configureStyles", "(", ")", "{", "var", "_", "=", "nvd3Utils", ".", "deepExtend", "(", "defaultStyles", "(", ")", ",", "scope", ".", "options", "[", "'styles'", "]", "||", "{", "}", ")", ";", "if", "(", "scope", ".", "_config", ".", "extended", ")", "scope", ".", "options", "[", "'styles'", "]", "=", "_", ";", "angular", ".", "forEach", "(", "_", ".", "classes", ",", "function", "(", "value", ",", "key", ")", "{", "value", "?", "element", ".", "addClass", "(", "key", ")", ":", "element", ".", "removeClass", "(", "key", ")", ";", "}", ")", ";", "element", ".", "removeAttr", "(", "'style'", ")", ".", "css", "(", "_", ".", "css", ")", ";", "}" ]
Add some styles to the whole directive element
[ "Add", "some", "styles", "to", "the", "whole", "directive", "element" ]
19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8
https://github.com/krispo/angular-nvd3/blob/19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8/dist/angular-nvd3.js#L390-L400
14,107
krispo/angular-nvd3
dist/angular-nvd3.js
defaultWrapper
function defaultWrapper(_){ switch (_){ case 'title': return { enable: false, text: 'Write Your Title', className: 'h4', css: { width: scope.options.chart.width + 'px', textAlign: 'center' } }; case 'subtitle': return { enable: false, text: 'Write Your Subtitle', css: { width: scope.options.chart.width + 'px', textAlign: 'center' } }; case 'caption': return { enable: false, text: 'Figure 1. Write Your Caption text.', css: { width: scope.options.chart.width + 'px', textAlign: 'center' } }; } }
javascript
function defaultWrapper(_){ switch (_){ case 'title': return { enable: false, text: 'Write Your Title', className: 'h4', css: { width: scope.options.chart.width + 'px', textAlign: 'center' } }; case 'subtitle': return { enable: false, text: 'Write Your Subtitle', css: { width: scope.options.chart.width + 'px', textAlign: 'center' } }; case 'caption': return { enable: false, text: 'Figure 1. Write Your Caption text.', css: { width: scope.options.chart.width + 'px', textAlign: 'center' } }; } }
[ "function", "defaultWrapper", "(", "_", ")", "{", "switch", "(", "_", ")", "{", "case", "'title'", ":", "return", "{", "enable", ":", "false", ",", "text", ":", "'Write Your Title'", ",", "className", ":", "'h4'", ",", "css", ":", "{", "width", ":", "scope", ".", "options", ".", "chart", ".", "width", "+", "'px'", ",", "textAlign", ":", "'center'", "}", "}", ";", "case", "'subtitle'", ":", "return", "{", "enable", ":", "false", ",", "text", ":", "'Write Your Subtitle'", ",", "css", ":", "{", "width", ":", "scope", ".", "options", ".", "chart", ".", "width", "+", "'px'", ",", "textAlign", ":", "'center'", "}", "}", ";", "case", "'caption'", ":", "return", "{", "enable", ":", "false", ",", "text", ":", "'Figure 1. Write Your Caption text.'", ",", "css", ":", "{", "width", ":", "scope", ".", "options", ".", "chart", ".", "width", "+", "'px'", ",", "textAlign", ":", "'center'", "}", "}", ";", "}", "}" ]
Default values for 'title', 'subtitle', 'caption'
[ "Default", "values", "for", "title", "subtitle", "caption" ]
19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8
https://github.com/krispo/angular-nvd3/blob/19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8/dist/angular-nvd3.js#L403-L431
14,108
krispo/angular-nvd3
dist/angular-nvd3.js
dataWatchFn
function dataWatchFn(newData, oldData) { if (newData !== oldData){ if (!scope._config.disabled) { scope._config.refreshDataOnly ? scope.api.update() : scope.api.refresh(); // if wanted to refresh data only, use update method, otherwise use full refresh. } } }
javascript
function dataWatchFn(newData, oldData) { if (newData !== oldData){ if (!scope._config.disabled) { scope._config.refreshDataOnly ? scope.api.update() : scope.api.refresh(); // if wanted to refresh data only, use update method, otherwise use full refresh. } } }
[ "function", "dataWatchFn", "(", "newData", ",", "oldData", ")", "{", "if", "(", "newData", "!==", "oldData", ")", "{", "if", "(", "!", "scope", ".", "_config", ".", "disabled", ")", "{", "scope", ".", "_config", ".", "refreshDataOnly", "?", "scope", ".", "api", ".", "update", "(", ")", ":", "scope", ".", "api", ".", "refresh", "(", ")", ";", "// if wanted to refresh data only, use update method, otherwise use full refresh.", "}", "}", "}" ]
Watching on data changing
[ "Watching", "on", "data", "changing" ]
19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8
https://github.com/krispo/angular-nvd3/blob/19e6d97d2db1f92e84a18e3980c2c4e3f6329ae8/dist/angular-nvd3.js#L454-L460
14,109
yaronn/xml-crypto
lib/signed-xml.js
FileKeyInfo
function FileKeyInfo(file) { this.file = file this.getKeyInfo = function(key, prefix) { prefix = prefix || '' prefix = prefix ? prefix + ':' : prefix return "<" + prefix + "X509Data></" + prefix + "X509Data>" } this.getKey = function(keyInfo) { return fs.readFileSync(this.file) } }
javascript
function FileKeyInfo(file) { this.file = file this.getKeyInfo = function(key, prefix) { prefix = prefix || '' prefix = prefix ? prefix + ':' : prefix return "<" + prefix + "X509Data></" + prefix + "X509Data>" } this.getKey = function(keyInfo) { return fs.readFileSync(this.file) } }
[ "function", "FileKeyInfo", "(", "file", ")", "{", "this", ".", "file", "=", "file", "this", ".", "getKeyInfo", "=", "function", "(", "key", ",", "prefix", ")", "{", "prefix", "=", "prefix", "||", "''", "prefix", "=", "prefix", "?", "prefix", "+", "':'", ":", "prefix", "return", "\"<\"", "+", "prefix", "+", "\"X509Data></\"", "+", "prefix", "+", "\"X509Data>\"", "}", "this", ".", "getKey", "=", "function", "(", "keyInfo", ")", "{", "return", "fs", ".", "readFileSync", "(", "this", ".", "file", ")", "}", "}" ]
A key info provider implementation
[ "A", "key", "info", "provider", "implementation" ]
40bd9e8f8787c9c996572fe5937572506b9e43d1
https://github.com/yaronn/xml-crypto/blob/40bd9e8f8787c9c996572fe5937572506b9e43d1/lib/signed-xml.js#L17-L29
14,110
yaronn/xml-crypto
lib/signed-xml.js
RSASHA512
function RSASHA512() { /** * Sign the given string using the given key * */ this.getSignature = function(signedInfo, signingKey) { var signer = crypto.createSign("RSA-SHA512") signer.update(signedInfo) var res = signer.sign(signingKey, 'base64') return res } /** * Verify the given signature of the given string using key * */ this.verifySignature = function(str, key, signatureValue) { var verifier = crypto.createVerify("RSA-SHA512") verifier.update(str) var res = verifier.verify(key, signatureValue, 'base64') return res } this.getAlgorithmName = function() { return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512" } }
javascript
function RSASHA512() { /** * Sign the given string using the given key * */ this.getSignature = function(signedInfo, signingKey) { var signer = crypto.createSign("RSA-SHA512") signer.update(signedInfo) var res = signer.sign(signingKey, 'base64') return res } /** * Verify the given signature of the given string using key * */ this.verifySignature = function(str, key, signatureValue) { var verifier = crypto.createVerify("RSA-SHA512") verifier.update(str) var res = verifier.verify(key, signatureValue, 'base64') return res } this.getAlgorithmName = function() { return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512" } }
[ "function", "RSASHA512", "(", ")", "{", "/**\n * Sign the given string using the given key\n *\n */", "this", ".", "getSignature", "=", "function", "(", "signedInfo", ",", "signingKey", ")", "{", "var", "signer", "=", "crypto", ".", "createSign", "(", "\"RSA-SHA512\"", ")", "signer", ".", "update", "(", "signedInfo", ")", "var", "res", "=", "signer", ".", "sign", "(", "signingKey", ",", "'base64'", ")", "return", "res", "}", "/**\n * Verify the given signature of the given string using key\n *\n */", "this", ".", "verifySignature", "=", "function", "(", "str", ",", "key", ",", "signatureValue", ")", "{", "var", "verifier", "=", "crypto", ".", "createVerify", "(", "\"RSA-SHA512\"", ")", "verifier", ".", "update", "(", "str", ")", "var", "res", "=", "verifier", ".", "verify", "(", "key", ",", "signatureValue", ",", "'base64'", ")", "return", "res", "}", "this", ".", "getAlgorithmName", "=", "function", "(", ")", "{", "return", "\"http://www.w3.org/2001/04/xmldsig-more#rsa-sha512\"", "}", "}" ]
Signature algorithm implementation
[ "Signature", "algorithm", "implementation" ]
40bd9e8f8787c9c996572fe5937572506b9e43d1
https://github.com/yaronn/xml-crypto/blob/40bd9e8f8787c9c996572fe5937572506b9e43d1/lib/signed-xml.js#L151-L178
14,111
yaronn/xml-crypto
lib/signed-xml.js
findAncestorNs
function findAncestorNs(doc, docSubsetXpath){ var docSubset = xpath.select(docSubsetXpath, doc); if(!Array.isArray(docSubset) || docSubset.length < 1){ return []; } // Remove duplicate on ancestor namespace var ancestorNs = collectAncestorNamespaces(docSubset[0]); var ancestorNsWithoutDuplicate = []; for(var i=0;i<ancestorNs.length;i++){ var notOnTheList = true; for(var v in ancestorNsWithoutDuplicate){ if(ancestorNsWithoutDuplicate[v].prefix === ancestorNs[i].prefix){ notOnTheList = false; break; } } if(notOnTheList){ ancestorNsWithoutDuplicate.push(ancestorNs[i]); } } // Remove namespaces which are already declared in the subset with the same prefix var returningNs = []; var subsetAttributes = docSubset[0].attributes; for(var j=0;j<ancestorNsWithoutDuplicate.length;j++){ var isUnique = true; for(var k=0;k<subsetAttributes.length;k++){ var nodeName = subsetAttributes[k].nodeName; if(nodeName.search(/^xmlns:/) === -1) continue; var prefix = nodeName.replace(/^xmlns:/, ""); if(ancestorNsWithoutDuplicate[j].prefix === prefix){ isUnique = false; break; } } if(isUnique){ returningNs.push(ancestorNsWithoutDuplicate[j]); } } return returningNs; }
javascript
function findAncestorNs(doc, docSubsetXpath){ var docSubset = xpath.select(docSubsetXpath, doc); if(!Array.isArray(docSubset) || docSubset.length < 1){ return []; } // Remove duplicate on ancestor namespace var ancestorNs = collectAncestorNamespaces(docSubset[0]); var ancestorNsWithoutDuplicate = []; for(var i=0;i<ancestorNs.length;i++){ var notOnTheList = true; for(var v in ancestorNsWithoutDuplicate){ if(ancestorNsWithoutDuplicate[v].prefix === ancestorNs[i].prefix){ notOnTheList = false; break; } } if(notOnTheList){ ancestorNsWithoutDuplicate.push(ancestorNs[i]); } } // Remove namespaces which are already declared in the subset with the same prefix var returningNs = []; var subsetAttributes = docSubset[0].attributes; for(var j=0;j<ancestorNsWithoutDuplicate.length;j++){ var isUnique = true; for(var k=0;k<subsetAttributes.length;k++){ var nodeName = subsetAttributes[k].nodeName; if(nodeName.search(/^xmlns:/) === -1) continue; var prefix = nodeName.replace(/^xmlns:/, ""); if(ancestorNsWithoutDuplicate[j].prefix === prefix){ isUnique = false; break; } } if(isUnique){ returningNs.push(ancestorNsWithoutDuplicate[j]); } } return returningNs; }
[ "function", "findAncestorNs", "(", "doc", ",", "docSubsetXpath", ")", "{", "var", "docSubset", "=", "xpath", ".", "select", "(", "docSubsetXpath", ",", "doc", ")", ";", "if", "(", "!", "Array", ".", "isArray", "(", "docSubset", ")", "||", "docSubset", ".", "length", "<", "1", ")", "{", "return", "[", "]", ";", "}", "// Remove duplicate on ancestor namespace", "var", "ancestorNs", "=", "collectAncestorNamespaces", "(", "docSubset", "[", "0", "]", ")", ";", "var", "ancestorNsWithoutDuplicate", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "ancestorNs", ".", "length", ";", "i", "++", ")", "{", "var", "notOnTheList", "=", "true", ";", "for", "(", "var", "v", "in", "ancestorNsWithoutDuplicate", ")", "{", "if", "(", "ancestorNsWithoutDuplicate", "[", "v", "]", ".", "prefix", "===", "ancestorNs", "[", "i", "]", ".", "prefix", ")", "{", "notOnTheList", "=", "false", ";", "break", ";", "}", "}", "if", "(", "notOnTheList", ")", "{", "ancestorNsWithoutDuplicate", ".", "push", "(", "ancestorNs", "[", "i", "]", ")", ";", "}", "}", "// Remove namespaces which are already declared in the subset with the same prefix", "var", "returningNs", "=", "[", "]", ";", "var", "subsetAttributes", "=", "docSubset", "[", "0", "]", ".", "attributes", ";", "for", "(", "var", "j", "=", "0", ";", "j", "<", "ancestorNsWithoutDuplicate", ".", "length", ";", "j", "++", ")", "{", "var", "isUnique", "=", "true", ";", "for", "(", "var", "k", "=", "0", ";", "k", "<", "subsetAttributes", ".", "length", ";", "k", "++", ")", "{", "var", "nodeName", "=", "subsetAttributes", "[", "k", "]", ".", "nodeName", ";", "if", "(", "nodeName", ".", "search", "(", "/", "^xmlns:", "/", ")", "===", "-", "1", ")", "continue", ";", "var", "prefix", "=", "nodeName", ".", "replace", "(", "/", "^xmlns:", "/", ",", "\"\"", ")", ";", "if", "(", "ancestorNsWithoutDuplicate", "[", "j", "]", ".", "prefix", "===", "prefix", ")", "{", "isUnique", "=", "false", ";", "break", ";", "}", "}", "if", "(", "isUnique", ")", "{", "returningNs", ".", "push", "(", "ancestorNsWithoutDuplicate", "[", "j", "]", ")", ";", "}", "}", "return", "returningNs", ";", "}" ]
Extract ancestor namespaces in order to import it to root of document subset which is being canonicalized for non-exclusive c14n. @param {object} doc - Usually a product from `new DOMParser().parseFromString()` @param {string} docSubsetXpath - xpath query to get document subset being canonicalized @returns {Array} i.e. [{prefix: "saml", namespaceURI: "urn:oasis:names:tc:SAML:2.0:assertion"}]
[ "Extract", "ancestor", "namespaces", "in", "order", "to", "import", "it", "to", "root", "of", "document", "subset", "which", "is", "being", "canonicalized", "for", "non", "-", "exclusive", "c14n", "." ]
40bd9e8f8787c9c996572fe5937572506b9e43d1
https://github.com/yaronn/xml-crypto/blob/40bd9e8f8787c9c996572fe5937572506b9e43d1/lib/signed-xml.js#L210-L255
14,112
yaronn/xml-crypto
lib/signed-xml.js
SignedXml
function SignedXml(idMode, options) { this.options = options || {}; this.idMode = idMode this.references = [] this.id = 0 this.signingKey = null this.signatureAlgorithm = this.options.signatureAlgorithm || "http://www.w3.org/2000/09/xmldsig#rsa-sha1"; this.keyInfoProvider = null this.canonicalizationAlgorithm = this.options.canonicalizationAlgorithm || "http://www.w3.org/2001/10/xml-exc-c14n#" this.signedXml = "" this.signatureXml = "" this.signatureNode = null this.signatureValue = "" this.originalXmlWithIds = "" this.validationErrors = [] this.keyInfo = null this.idAttributes = [ 'Id', 'ID', 'id' ]; if (this.options.idAttribute) this.idAttributes.splice(0, 0, this.options.idAttribute); this.implicitTransforms = this.options.implicitTransforms || []; }
javascript
function SignedXml(idMode, options) { this.options = options || {}; this.idMode = idMode this.references = [] this.id = 0 this.signingKey = null this.signatureAlgorithm = this.options.signatureAlgorithm || "http://www.w3.org/2000/09/xmldsig#rsa-sha1"; this.keyInfoProvider = null this.canonicalizationAlgorithm = this.options.canonicalizationAlgorithm || "http://www.w3.org/2001/10/xml-exc-c14n#" this.signedXml = "" this.signatureXml = "" this.signatureNode = null this.signatureValue = "" this.originalXmlWithIds = "" this.validationErrors = [] this.keyInfo = null this.idAttributes = [ 'Id', 'ID', 'id' ]; if (this.options.idAttribute) this.idAttributes.splice(0, 0, this.options.idAttribute); this.implicitTransforms = this.options.implicitTransforms || []; }
[ "function", "SignedXml", "(", "idMode", ",", "options", ")", "{", "this", ".", "options", "=", "options", "||", "{", "}", ";", "this", ".", "idMode", "=", "idMode", "this", ".", "references", "=", "[", "]", "this", ".", "id", "=", "0", "this", ".", "signingKey", "=", "null", "this", ".", "signatureAlgorithm", "=", "this", ".", "options", ".", "signatureAlgorithm", "||", "\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"", ";", "this", ".", "keyInfoProvider", "=", "null", "this", ".", "canonicalizationAlgorithm", "=", "this", ".", "options", ".", "canonicalizationAlgorithm", "||", "\"http://www.w3.org/2001/10/xml-exc-c14n#\"", "this", ".", "signedXml", "=", "\"\"", "this", ".", "signatureXml", "=", "\"\"", "this", ".", "signatureNode", "=", "null", "this", ".", "signatureValue", "=", "\"\"", "this", ".", "originalXmlWithIds", "=", "\"\"", "this", ".", "validationErrors", "=", "[", "]", "this", ".", "keyInfo", "=", "null", "this", ".", "idAttributes", "=", "[", "'Id'", ",", "'ID'", ",", "'id'", "]", ";", "if", "(", "this", ".", "options", ".", "idAttribute", ")", "this", ".", "idAttributes", ".", "splice", "(", "0", ",", "0", ",", "this", ".", "options", ".", "idAttribute", ")", ";", "this", ".", "implicitTransforms", "=", "this", ".", "options", ".", "implicitTransforms", "||", "[", "]", ";", "}" ]
Xml signature implementation @param {string} idMode. Value of "wssecurity" will create/validate id's with the ws-security namespace @param {object} options. Initial configurations
[ "Xml", "signature", "implementation" ]
40bd9e8f8787c9c996572fe5937572506b9e43d1
https://github.com/yaronn/xml-crypto/blob/40bd9e8f8787c9c996572fe5937572506b9e43d1/lib/signed-xml.js#L288-L307
14,113
susielu/d3-annotation
indexRollupNext.js
wrap
function wrap(text, width, wrapSplitter) { var lineHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1.2; text.each(function () { var text = select(this), words = text.text().split(wrapSplitter || /[ \t\r\n]+/).reverse().filter(function (w) { return w !== ""; }); var word = void 0, line$$1 = [], tspan = text.text(null).append("tspan").attr("x", 0).attr("dy", 0.8 + "em"); while (word = words.pop()) { line$$1.push(word); tspan.text(line$$1.join(" ")); if (tspan.node().getComputedTextLength() > width && line$$1.length > 1) { line$$1.pop(); tspan.text(line$$1.join(" ")); line$$1 = [word]; tspan = text.append("tspan").attr("x", 0).attr("dy", lineHeight + "em").text(word); } } }); }
javascript
function wrap(text, width, wrapSplitter) { var lineHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1.2; text.each(function () { var text = select(this), words = text.text().split(wrapSplitter || /[ \t\r\n]+/).reverse().filter(function (w) { return w !== ""; }); var word = void 0, line$$1 = [], tspan = text.text(null).append("tspan").attr("x", 0).attr("dy", 0.8 + "em"); while (word = words.pop()) { line$$1.push(word); tspan.text(line$$1.join(" ")); if (tspan.node().getComputedTextLength() > width && line$$1.length > 1) { line$$1.pop(); tspan.text(line$$1.join(" ")); line$$1 = [word]; tspan = text.append("tspan").attr("x", 0).attr("dy", lineHeight + "em").text(word); } } }); }
[ "function", "wrap", "(", "text", ",", "width", ",", "wrapSplitter", ")", "{", "var", "lineHeight", "=", "arguments", ".", "length", ">", "3", "&&", "arguments", "[", "3", "]", "!==", "undefined", "?", "arguments", "[", "3", "]", ":", "1.2", ";", "text", ".", "each", "(", "function", "(", ")", "{", "var", "text", "=", "select", "(", "this", ")", ",", "words", "=", "text", ".", "text", "(", ")", ".", "split", "(", "wrapSplitter", "||", "/", "[ \\t\\r\\n]+", "/", ")", ".", "reverse", "(", ")", ".", "filter", "(", "function", "(", "w", ")", "{", "return", "w", "!==", "\"\"", ";", "}", ")", ";", "var", "word", "=", "void", "0", ",", "line$$1", "=", "[", "]", ",", "tspan", "=", "text", ".", "text", "(", "null", ")", ".", "append", "(", "\"tspan\"", ")", ".", "attr", "(", "\"x\"", ",", "0", ")", ".", "attr", "(", "\"dy\"", ",", "0.8", "+", "\"em\"", ")", ";", "while", "(", "word", "=", "words", ".", "pop", "(", ")", ")", "{", "line$$1", ".", "push", "(", "word", ")", ";", "tspan", ".", "text", "(", "line$$1", ".", "join", "(", "\" \"", ")", ")", ";", "if", "(", "tspan", ".", "node", "(", ")", ".", "getComputedTextLength", "(", ")", ">", "width", "&&", "line$$1", ".", "length", ">", "1", ")", "{", "line$$1", ".", "pop", "(", ")", ";", "tspan", ".", "text", "(", "line$$1", ".", "join", "(", "\" \"", ")", ")", ";", "line$$1", "=", "[", "word", "]", ";", "tspan", "=", "text", ".", "append", "(", "\"tspan\"", ")", ".", "attr", "(", "\"x\"", ",", "0", ")", ".", "attr", "(", "\"dy\"", ",", "lineHeight", "+", "\"em\"", ")", ".", "text", "(", "word", ")", ";", "}", "}", "}", ")", ";", "}" ]
Text wrapping code adapted from Mike Bostock
[ "Text", "wrapping", "code", "adapted", "from", "Mike", "Bostock" ]
5279464dfac828443988d4b2695beff46b02618d
https://github.com/susielu/d3-annotation/blob/5279464dfac828443988d4b2695beff46b02618d/indexRollupNext.js#L1862-L1885
14,114
siddii/angular-timer
bower_components/angular-scenario/jstd-scenario-adapter.js
JstdPlugin
function JstdPlugin() { var nop = function() {}; this.reportResult = nop; this.reportEnd = nop; this.runScenario = nop; this.name = 'Angular Scenario Adapter'; /** * Called for each JSTD TestCase * * Handles only SCENARIO_TYPE test cases. There should be only one fake TestCase. * Runs all scenario tests (under one fake TestCase) and report all results to JSTD. * * @param {jstestdriver.TestRunConfiguration} configuration * @param {Function} onTestDone * @param {Function} onAllTestsComplete * @returns {boolean} True if this type of test is handled by this plugin, false otherwise */ this.runTestConfiguration = function(configuration, onTestDone, onAllTestsComplete) { if (configuration.getTestCaseInfo().getType() != SCENARIO_TYPE) return false; this.reportResult = onTestDone; this.reportEnd = onAllTestsComplete; this.runScenario(); return true; }; this.getTestRunsConfigurationFor = function(testCaseInfos, expressions, testRunsConfiguration) { testRunsConfiguration.push( new jstestdriver.TestRunConfiguration( new jstestdriver.TestCaseInfo( 'Angular Scenario Tests', function() {}, SCENARIO_TYPE), [])); return true; }; }
javascript
function JstdPlugin() { var nop = function() {}; this.reportResult = nop; this.reportEnd = nop; this.runScenario = nop; this.name = 'Angular Scenario Adapter'; /** * Called for each JSTD TestCase * * Handles only SCENARIO_TYPE test cases. There should be only one fake TestCase. * Runs all scenario tests (under one fake TestCase) and report all results to JSTD. * * @param {jstestdriver.TestRunConfiguration} configuration * @param {Function} onTestDone * @param {Function} onAllTestsComplete * @returns {boolean} True if this type of test is handled by this plugin, false otherwise */ this.runTestConfiguration = function(configuration, onTestDone, onAllTestsComplete) { if (configuration.getTestCaseInfo().getType() != SCENARIO_TYPE) return false; this.reportResult = onTestDone; this.reportEnd = onAllTestsComplete; this.runScenario(); return true; }; this.getTestRunsConfigurationFor = function(testCaseInfos, expressions, testRunsConfiguration) { testRunsConfiguration.push( new jstestdriver.TestRunConfiguration( new jstestdriver.TestCaseInfo( 'Angular Scenario Tests', function() {}, SCENARIO_TYPE), [])); return true; }; }
[ "function", "JstdPlugin", "(", ")", "{", "var", "nop", "=", "function", "(", ")", "{", "}", ";", "this", ".", "reportResult", "=", "nop", ";", "this", ".", "reportEnd", "=", "nop", ";", "this", ".", "runScenario", "=", "nop", ";", "this", ".", "name", "=", "'Angular Scenario Adapter'", ";", "/**\n * Called for each JSTD TestCase\n *\n * Handles only SCENARIO_TYPE test cases. There should be only one fake TestCase.\n * Runs all scenario tests (under one fake TestCase) and report all results to JSTD.\n *\n * @param {jstestdriver.TestRunConfiguration} configuration\n * @param {Function} onTestDone\n * @param {Function} onAllTestsComplete\n * @returns {boolean} True if this type of test is handled by this plugin, false otherwise\n */", "this", ".", "runTestConfiguration", "=", "function", "(", "configuration", ",", "onTestDone", ",", "onAllTestsComplete", ")", "{", "if", "(", "configuration", ".", "getTestCaseInfo", "(", ")", ".", "getType", "(", ")", "!=", "SCENARIO_TYPE", ")", "return", "false", ";", "this", ".", "reportResult", "=", "onTestDone", ";", "this", ".", "reportEnd", "=", "onAllTestsComplete", ";", "this", ".", "runScenario", "(", ")", ";", "return", "true", ";", "}", ";", "this", ".", "getTestRunsConfigurationFor", "=", "function", "(", "testCaseInfos", ",", "expressions", ",", "testRunsConfiguration", ")", "{", "testRunsConfiguration", ".", "push", "(", "new", "jstestdriver", ".", "TestRunConfiguration", "(", "new", "jstestdriver", ".", "TestCaseInfo", "(", "'Angular Scenario Tests'", ",", "function", "(", ")", "{", "}", ",", "SCENARIO_TYPE", ")", ",", "[", "]", ")", ")", ";", "return", "true", ";", "}", ";", "}" ]
Plugin for JSTestDriver Connection point between scenario's jstd output and jstestdriver. @see jstestdriver.PluginRegistrar
[ "Plugin", "for", "JSTestDriver", "Connection", "point", "between", "scenario", "s", "jstd", "output", "and", "jstestdriver", "." ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/bower_components/angular-scenario/jstd-scenario-adapter.js#L58-L96
14,115
siddii/angular-timer
bower_components/jquery/src/css.js
css_defaultDisplay
function css_defaultDisplay( nodeName ) { var doc = document, display = elemdisplay[ nodeName ]; if ( !display ) { display = actualDisplay( nodeName, doc ); // If the simple way fails, read from inside an iframe if ( display === "none" || !display ) { // Use the already-created iframe if possible iframe = ( iframe || jQuery("<iframe frameborder='0' width='0' height='0'/>") .css( "cssText", "display:block !important" ) ).appendTo( doc.documentElement ); // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document; doc.write("<!doctype html><html><body>"); doc.close(); display = actualDisplay( nodeName, doc ); iframe.detach(); } // Store the correct default display elemdisplay[ nodeName ] = display; } return display; }
javascript
function css_defaultDisplay( nodeName ) { var doc = document, display = elemdisplay[ nodeName ]; if ( !display ) { display = actualDisplay( nodeName, doc ); // If the simple way fails, read from inside an iframe if ( display === "none" || !display ) { // Use the already-created iframe if possible iframe = ( iframe || jQuery("<iframe frameborder='0' width='0' height='0'/>") .css( "cssText", "display:block !important" ) ).appendTo( doc.documentElement ); // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document; doc.write("<!doctype html><html><body>"); doc.close(); display = actualDisplay( nodeName, doc ); iframe.detach(); } // Store the correct default display elemdisplay[ nodeName ] = display; } return display; }
[ "function", "css_defaultDisplay", "(", "nodeName", ")", "{", "var", "doc", "=", "document", ",", "display", "=", "elemdisplay", "[", "nodeName", "]", ";", "if", "(", "!", "display", ")", "{", "display", "=", "actualDisplay", "(", "nodeName", ",", "doc", ")", ";", "// If the simple way fails, read from inside an iframe", "if", "(", "display", "===", "\"none\"", "||", "!", "display", ")", "{", "// Use the already-created iframe if possible", "iframe", "=", "(", "iframe", "||", "jQuery", "(", "\"<iframe frameborder='0' width='0' height='0'/>\"", ")", ".", "css", "(", "\"cssText\"", ",", "\"display:block !important\"", ")", ")", ".", "appendTo", "(", "doc", ".", "documentElement", ")", ";", "// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse", "doc", "=", "(", "iframe", "[", "0", "]", ".", "contentWindow", "||", "iframe", "[", "0", "]", ".", "contentDocument", ")", ".", "document", ";", "doc", ".", "write", "(", "\"<!doctype html><html><body>\"", ")", ";", "doc", ".", "close", "(", ")", ";", "display", "=", "actualDisplay", "(", "nodeName", ",", "doc", ")", ";", "iframe", ".", "detach", "(", ")", ";", "}", "// Store the correct default display", "elemdisplay", "[", "nodeName", "]", "=", "display", ";", "}", "return", "display", ";", "}" ]
Try to determine the default display value of an element
[ "Try", "to", "determine", "the", "default", "display", "value", "of", "an", "element" ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/bower_components/jquery/src/css.js#L418-L447
14,116
siddii/angular-timer
bower_components/jquery/src/css.js
actualDisplay
function actualDisplay( name, doc ) { var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), display = jQuery.css( elem[0], "display" ); elem.remove(); return display; }
javascript
function actualDisplay( name, doc ) { var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), display = jQuery.css( elem[0], "display" ); elem.remove(); return display; }
[ "function", "actualDisplay", "(", "name", ",", "doc", ")", "{", "var", "elem", "=", "jQuery", "(", "doc", ".", "createElement", "(", "name", ")", ")", ".", "appendTo", "(", "doc", ".", "body", ")", ",", "display", "=", "jQuery", ".", "css", "(", "elem", "[", "0", "]", ",", "\"display\"", ")", ";", "elem", ".", "remove", "(", ")", ";", "return", "display", ";", "}" ]
Called ONLY from within css_defaultDisplay
[ "Called", "ONLY", "from", "within", "css_defaultDisplay" ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/bower_components/jquery/src/css.js#L450-L455
14,117
siddii/angular-timer
bower_components/jquery/src/core.js
function( code ) { var script, indirect = eval; code = jQuery.trim( code ); if ( code ) { // If the code includes a valid, prologue position // strict mode pragma, execute code by injecting a // script tag into the document. if ( code.indexOf("use strict") === 1 ) { script = document.createElement("script"); script.text = code; document.head.appendChild( script ).parentNode.removeChild( script ); } else { // Otherwise, avoid the DOM node creation, insertion // and removal by using an indirect global eval indirect( code ); } } }
javascript
function( code ) { var script, indirect = eval; code = jQuery.trim( code ); if ( code ) { // If the code includes a valid, prologue position // strict mode pragma, execute code by injecting a // script tag into the document. if ( code.indexOf("use strict") === 1 ) { script = document.createElement("script"); script.text = code; document.head.appendChild( script ).parentNode.removeChild( script ); } else { // Otherwise, avoid the DOM node creation, insertion // and removal by using an indirect global eval indirect( code ); } } }
[ "function", "(", "code", ")", "{", "var", "script", ",", "indirect", "=", "eval", ";", "code", "=", "jQuery", ".", "trim", "(", "code", ")", ";", "if", "(", "code", ")", "{", "// If the code includes a valid, prologue position", "// strict mode pragma, execute code by injecting a", "// script tag into the document.", "if", "(", "code", ".", "indexOf", "(", "\"use strict\"", ")", "===", "1", ")", "{", "script", "=", "document", ".", "createElement", "(", "\"script\"", ")", ";", "script", ".", "text", "=", "code", ";", "document", ".", "head", ".", "appendChild", "(", "script", ")", ".", "parentNode", ".", "removeChild", "(", "script", ")", ";", "}", "else", "{", "// Otherwise, avoid the DOM node creation, insertion", "// and removal by using an indirect global eval", "indirect", "(", "code", ")", ";", "}", "}", "}" ]
Evaluates a script in a global context
[ "Evaluates", "a", "script", "in", "a", "global", "context" ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/bower_components/jquery/src/core.js#L508-L528
14,118
siddii/angular-timer
bower_components/jquery/speed/benchmark.js
benchmark
function benchmark(fn, times, name){ fn = fn.toString(); var s = fn.indexOf('{')+1, e = fn.lastIndexOf('}'); fn = fn.substring(s,e); return benchmarkString(fn, times, name); }
javascript
function benchmark(fn, times, name){ fn = fn.toString(); var s = fn.indexOf('{')+1, e = fn.lastIndexOf('}'); fn = fn.substring(s,e); return benchmarkString(fn, times, name); }
[ "function", "benchmark", "(", "fn", ",", "times", ",", "name", ")", "{", "fn", "=", "fn", ".", "toString", "(", ")", ";", "var", "s", "=", "fn", ".", "indexOf", "(", "'{'", ")", "+", "1", ",", "e", "=", "fn", ".", "lastIndexOf", "(", "'}'", ")", ";", "fn", "=", "fn", ".", "substring", "(", "s", ",", "e", ")", ";", "return", "benchmarkString", "(", "fn", ",", "times", ",", "name", ")", ";", "}" ]
Runs a function many times without the function call overhead
[ "Runs", "a", "function", "many", "times", "without", "the", "function", "call", "overhead" ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/bower_components/jquery/speed/benchmark.js#L2-L9
14,119
siddii/angular-timer
dist/assets/js/angular-timer-all.min.js
getCzechForm
function getCzechForm (c) { if (c === 1) { return 0 } else if (Math.floor(c) !== c) { return 1 } else if (c % 10 >= 2 && c % 10 <= 4 && c % 100 < 10) { return 2 } else { return 3 } }
javascript
function getCzechForm (c) { if (c === 1) { return 0 } else if (Math.floor(c) !== c) { return 1 } else if (c % 10 >= 2 && c % 10 <= 4 && c % 100 < 10) { return 2 } else { return 3 } }
[ "function", "getCzechForm", "(", "c", ")", "{", "if", "(", "c", "===", "1", ")", "{", "return", "0", "}", "else", "if", "(", "Math", ".", "floor", "(", "c", ")", "!==", "c", ")", "{", "return", "1", "}", "else", "if", "(", "c", "%", "10", ">=", "2", "&&", "c", "%", "10", "<=", "4", "&&", "c", "%", "100", "<", "10", ")", "{", "return", "2", "}", "else", "{", "return", "3", "}", "}" ]
Internal helper function for Czech language.
[ "Internal", "helper", "function", "for", "Czech", "language", "." ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/dist/assets/js/angular-timer-all.min.js#L489-L499
14,120
siddii/angular-timer
dist/assets/js/angular-timer-all.min.js
getPolishForm
function getPolishForm (c) { if (c === 1) { return 0 } else if (Math.floor(c) !== c) { return 1 } else if (c % 10 >= 2 && c % 10 <= 4 && !(c % 100 > 10 && c % 100 < 20)) { return 2 } else { return 3 } }
javascript
function getPolishForm (c) { if (c === 1) { return 0 } else if (Math.floor(c) !== c) { return 1 } else if (c % 10 >= 2 && c % 10 <= 4 && !(c % 100 > 10 && c % 100 < 20)) { return 2 } else { return 3 } }
[ "function", "getPolishForm", "(", "c", ")", "{", "if", "(", "c", "===", "1", ")", "{", "return", "0", "}", "else", "if", "(", "Math", ".", "floor", "(", "c", ")", "!==", "c", ")", "{", "return", "1", "}", "else", "if", "(", "c", "%", "10", ">=", "2", "&&", "c", "%", "10", "<=", "4", "&&", "!", "(", "c", "%", "100", ">", "10", "&&", "c", "%", "100", "<", "20", ")", ")", "{", "return", "2", "}", "else", "{", "return", "3", "}", "}" ]
Internal helper function for Polish language.
[ "Internal", "helper", "function", "for", "Polish", "language", "." ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/dist/assets/js/angular-timer-all.min.js#L502-L512
14,121
siddii/angular-timer
dist/assets/js/angular-timer-all.min.js
getSlavicForm
function getSlavicForm (c) { if (Math.floor(c) !== c) { return 2 } else if ((c % 100 >= 5 && c % 100 <= 20) || (c % 10 >= 5 && c % 10 <= 9) || c % 10 === 0) { return 0 } else if (c % 10 === 1) { return 1 } else if (c > 1) { return 2 } else { return 0 } }
javascript
function getSlavicForm (c) { if (Math.floor(c) !== c) { return 2 } else if ((c % 100 >= 5 && c % 100 <= 20) || (c % 10 >= 5 && c % 10 <= 9) || c % 10 === 0) { return 0 } else if (c % 10 === 1) { return 1 } else if (c > 1) { return 2 } else { return 0 } }
[ "function", "getSlavicForm", "(", "c", ")", "{", "if", "(", "Math", ".", "floor", "(", "c", ")", "!==", "c", ")", "{", "return", "2", "}", "else", "if", "(", "(", "c", "%", "100", ">=", "5", "&&", "c", "%", "100", "<=", "20", ")", "||", "(", "c", "%", "10", ">=", "5", "&&", "c", "%", "10", "<=", "9", ")", "||", "c", "%", "10", "===", "0", ")", "{", "return", "0", "}", "else", "if", "(", "c", "%", "10", "===", "1", ")", "{", "return", "1", "}", "else", "if", "(", "c", ">", "1", ")", "{", "return", "2", "}", "else", "{", "return", "0", "}", "}" ]
Internal helper function for Russian and Ukranian languages.
[ "Internal", "helper", "function", "for", "Russian", "and", "Ukranian", "languages", "." ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/dist/assets/js/angular-timer-all.min.js#L515-L527
14,122
siddii/angular-timer
dist/assets/js/angular-timer-all.min.js
getLithuanianForm
function getLithuanianForm (c) { if (c === 1 || (c % 10 === 1 && c % 100 > 20)) { return 0 } else if (Math.floor(c) !== c || (c % 10 >= 2 && c % 100 > 20) || (c % 10 >= 2 && c % 100 < 10)) { return 1 } else { return 2 } }
javascript
function getLithuanianForm (c) { if (c === 1 || (c % 10 === 1 && c % 100 > 20)) { return 0 } else if (Math.floor(c) !== c || (c % 10 >= 2 && c % 100 > 20) || (c % 10 >= 2 && c % 100 < 10)) { return 1 } else { return 2 } }
[ "function", "getLithuanianForm", "(", "c", ")", "{", "if", "(", "c", "===", "1", "||", "(", "c", "%", "10", "===", "1", "&&", "c", "%", "100", ">", "20", ")", ")", "{", "return", "0", "}", "else", "if", "(", "Math", ".", "floor", "(", "c", ")", "!==", "c", "||", "(", "c", "%", "10", ">=", "2", "&&", "c", "%", "100", ">", "20", ")", "||", "(", "c", "%", "10", ">=", "2", "&&", "c", "%", "100", "<", "10", ")", ")", "{", "return", "1", "}", "else", "{", "return", "2", "}", "}" ]
Internal helper function for Lithuanian language.
[ "Internal", "helper", "function", "for", "Lithuanian", "language", "." ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/dist/assets/js/angular-timer-all.min.js#L530-L538
14,123
siddii/angular-timer
bower_components/momentjs/min/moment-with-locales.js
makeDateFromString
function makeDateFromString(config) { parseISO(config); if (config._isValid === false) { delete config._isValid; moment.createFromInputFallback(config); } }
javascript
function makeDateFromString(config) { parseISO(config); if (config._isValid === false) { delete config._isValid; moment.createFromInputFallback(config); } }
[ "function", "makeDateFromString", "(", "config", ")", "{", "parseISO", "(", "config", ")", ";", "if", "(", "config", ".", "_isValid", "===", "false", ")", "{", "delete", "config", ".", "_isValid", ";", "moment", ".", "createFromInputFallback", "(", "config", ")", ";", "}", "}" ]
date from iso format or fallback
[ "date", "from", "iso", "format", "or", "fallback" ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/bower_components/momentjs/min/moment-with-locales.js#L1672-L1678
14,124
siddii/angular-timer
bower_components/momentjs/min/moment-with-locales.js
function (key) { var newLocaleData; if (key === undefined) { return this._locale._abbr; } else { newLocaleData = moment.localeData(key); if (newLocaleData != null) { this._locale = newLocaleData; } return this; } }
javascript
function (key) { var newLocaleData; if (key === undefined) { return this._locale._abbr; } else { newLocaleData = moment.localeData(key); if (newLocaleData != null) { this._locale = newLocaleData; } return this; } }
[ "function", "(", "key", ")", "{", "var", "newLocaleData", ";", "if", "(", "key", "===", "undefined", ")", "{", "return", "this", ".", "_locale", ".", "_abbr", ";", "}", "else", "{", "newLocaleData", "=", "moment", ".", "localeData", "(", "key", ")", ";", "if", "(", "newLocaleData", "!=", "null", ")", "{", "this", ".", "_locale", "=", "newLocaleData", ";", "}", "return", "this", ";", "}", "}" ]
If passed a locale key, it will set the locale for this instance. Otherwise, it will return the locale configuration variables for this instance.
[ "If", "passed", "a", "locale", "key", "it", "will", "set", "the", "locale", "for", "this", "instance", ".", "Otherwise", "it", "will", "return", "the", "locale", "configuration", "variables", "for", "this", "instance", "." ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/bower_components/momentjs/min/moment-with-locales.js#L2647-L2659
14,125
siddii/angular-timer
bower_components/momentjs/min/moment-with-locales.js
function (number) { var b = number, output = '', lookup = [ '', 'af', 'il', 'ydd', 'ydd', 'ed', 'ed', 'ed', 'fed', 'fed', 'fed', // 1af to 10fed 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'fed' // 11eg to 20fed ]; if (b > 20) { if (b === 40 || b === 50 || b === 60 || b === 80 || b === 100) { output = 'fed'; // not 30ain, 70ain or 90ain } else { output = 'ain'; } } else if (b > 0) { output = lookup[b]; } return number + output; }
javascript
function (number) { var b = number, output = '', lookup = [ '', 'af', 'il', 'ydd', 'ydd', 'ed', 'ed', 'ed', 'fed', 'fed', 'fed', // 1af to 10fed 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'fed' // 11eg to 20fed ]; if (b > 20) { if (b === 40 || b === 50 || b === 60 || b === 80 || b === 100) { output = 'fed'; // not 30ain, 70ain or 90ain } else { output = 'ain'; } } else if (b > 0) { output = lookup[b]; } return number + output; }
[ "function", "(", "number", ")", "{", "var", "b", "=", "number", ",", "output", "=", "''", ",", "lookup", "=", "[", "''", ",", "'af'", ",", "'il'", ",", "'ydd'", ",", "'ydd'", ",", "'ed'", ",", "'ed'", ",", "'ed'", ",", "'fed'", ",", "'fed'", ",", "'fed'", ",", "// 1af to 10fed", "'eg'", ",", "'fed'", ",", "'eg'", ",", "'eg'", ",", "'fed'", ",", "'eg'", ",", "'eg'", ",", "'fed'", ",", "'eg'", ",", "'fed'", "// 11eg to 20fed", "]", ";", "if", "(", "b", ">", "20", ")", "{", "if", "(", "b", "===", "40", "||", "b", "===", "50", "||", "b", "===", "60", "||", "b", "===", "80", "||", "b", "===", "100", ")", "{", "output", "=", "'fed'", ";", "// not 30ain, 70ain or 90ain", "}", "else", "{", "output", "=", "'ain'", ";", "}", "}", "else", "if", "(", "b", ">", "0", ")", "{", "output", "=", "lookup", "[", "b", "]", ";", "}", "return", "number", "+", "output", ";", "}" ]
traditional ordinal numbers above 31 are not commonly used in colloquial Welsh
[ "traditional", "ordinal", "numbers", "above", "31", "are", "not", "commonly", "used", "in", "colloquial", "Welsh" ]
d58fbf8c3325f63e1fdb250ed1f1a0676c8344de
https://github.com/siddii/angular-timer/blob/d58fbf8c3325f63e1fdb250ed1f1a0676c8344de/bower_components/momentjs/min/moment-with-locales.js#L4491-L4510
14,126
antvis/data-set
src/transform/kernel-smooth/regression.js
weight
function weight(kernel, bandwidth, x_0, x_i) { const arg = (x_i - x_0) / bandwidth; return kernel(arg); }
javascript
function weight(kernel, bandwidth, x_0, x_i) { const arg = (x_i - x_0) / bandwidth; return kernel(arg); }
[ "function", "weight", "(", "kernel", ",", "bandwidth", ",", "x_0", ",", "x_i", ")", "{", "const", "arg", "=", "(", "x_i", "-", "x_0", ")", "/", "bandwidth", ";", "return", "kernel", "(", "arg", ")", ";", "}" ]
calculates weight for i-th obs
[ "calculates", "weight", "for", "i", "-", "th", "obs" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/src/transform/kernel-smooth/regression.js#L39-L42
14,127
antvis/data-set
demos/assets/g2.js
copy
function copy(out, a) { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; out[4] = a[4]; out[5] = a[5]; out[6] = a[6]; out[7] = a[7]; out[8] = a[8]; return out; }
javascript
function copy(out, a) { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; out[4] = a[4]; out[5] = a[5]; out[6] = a[6]; out[7] = a[7]; out[8] = a[8]; return out; }
[ "function", "copy", "(", "out", ",", "a", ")", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", ";", "out", "[", "2", "]", "=", "a", "[", "2", "]", ";", "out", "[", "3", "]", "=", "a", "[", "3", "]", ";", "out", "[", "4", "]", "=", "a", "[", "4", "]", ";", "out", "[", "5", "]", "=", "a", "[", "5", "]", ";", "out", "[", "6", "]", "=", "a", "[", "6", "]", ";", "out", "[", "7", "]", "=", "a", "[", "7", "]", ";", "out", "[", "8", "]", "=", "a", "[", "8", "]", ";", "return", "out", ";", "}" ]
Copy the values from one mat3 to another @param {mat3} out the receiving matrix @param {mat3} a the source matrix @returns {mat3} out
[ "Copy", "the", "values", "from", "one", "mat3", "to", "another" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L16688-L16699
14,128
antvis/data-set
demos/assets/g2.js
fromValues
function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { var out = new glMatrix.ARRAY_TYPE(9); out[0] = m00; out[1] = m01; out[2] = m02; out[3] = m10; out[4] = m11; out[5] = m12; out[6] = m20; out[7] = m21; out[8] = m22; return out; }
javascript
function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { var out = new glMatrix.ARRAY_TYPE(9); out[0] = m00; out[1] = m01; out[2] = m02; out[3] = m10; out[4] = m11; out[5] = m12; out[6] = m20; out[7] = m21; out[8] = m22; return out; }
[ "function", "fromValues", "(", "m00", ",", "m01", ",", "m02", ",", "m10", ",", "m11", ",", "m12", ",", "m20", ",", "m21", ",", "m22", ")", "{", "var", "out", "=", "new", "glMatrix", ".", "ARRAY_TYPE", "(", "9", ")", ";", "out", "[", "0", "]", "=", "m00", ";", "out", "[", "1", "]", "=", "m01", ";", "out", "[", "2", "]", "=", "m02", ";", "out", "[", "3", "]", "=", "m10", ";", "out", "[", "4", "]", "=", "m11", ";", "out", "[", "5", "]", "=", "m12", ";", "out", "[", "6", "]", "=", "m20", ";", "out", "[", "7", "]", "=", "m21", ";", "out", "[", "8", "]", "=", "m22", ";", "return", "out", ";", "}" ]
Create a new mat3 with the given values @param {Number} m00 Component in column 0, row 0 position (index 0) @param {Number} m01 Component in column 0, row 1 position (index 1) @param {Number} m02 Component in column 0, row 2 position (index 2) @param {Number} m10 Component in column 1, row 0 position (index 3) @param {Number} m11 Component in column 1, row 1 position (index 4) @param {Number} m12 Component in column 1, row 2 position (index 5) @param {Number} m20 Component in column 2, row 0 position (index 6) @param {Number} m21 Component in column 2, row 1 position (index 7) @param {Number} m22 Component in column 2, row 2 position (index 8) @returns {mat3} A new mat3
[ "Create", "a", "new", "mat3", "with", "the", "given", "values" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L16715-L16727
14,129
antvis/data-set
demos/assets/g2.js
set
function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { out[0] = m00; out[1] = m01; out[2] = m02; out[3] = m10; out[4] = m11; out[5] = m12; out[6] = m20; out[7] = m21; out[8] = m22; return out; }
javascript
function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { out[0] = m00; out[1] = m01; out[2] = m02; out[3] = m10; out[4] = m11; out[5] = m12; out[6] = m20; out[7] = m21; out[8] = m22; return out; }
[ "function", "set", "(", "out", ",", "m00", ",", "m01", ",", "m02", ",", "m10", ",", "m11", ",", "m12", ",", "m20", ",", "m21", ",", "m22", ")", "{", "out", "[", "0", "]", "=", "m00", ";", "out", "[", "1", "]", "=", "m01", ";", "out", "[", "2", "]", "=", "m02", ";", "out", "[", "3", "]", "=", "m10", ";", "out", "[", "4", "]", "=", "m11", ";", "out", "[", "5", "]", "=", "m12", ";", "out", "[", "6", "]", "=", "m20", ";", "out", "[", "7", "]", "=", "m21", ";", "out", "[", "8", "]", "=", "m22", ";", "return", "out", ";", "}" ]
Set the components of a mat3 to the given values @param {mat3} out the receiving matrix @param {Number} m00 Component in column 0, row 0 position (index 0) @param {Number} m01 Component in column 0, row 1 position (index 1) @param {Number} m02 Component in column 0, row 2 position (index 2) @param {Number} m10 Component in column 1, row 0 position (index 3) @param {Number} m11 Component in column 1, row 1 position (index 4) @param {Number} m12 Component in column 1, row 2 position (index 5) @param {Number} m20 Component in column 2, row 0 position (index 6) @param {Number} m21 Component in column 2, row 1 position (index 7) @param {Number} m22 Component in column 2, row 2 position (index 8) @returns {mat3} out
[ "Set", "the", "components", "of", "a", "mat3", "to", "the", "given", "values" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L16744-L16755
14,130
antvis/data-set
demos/assets/g2.js
identity
function identity(out) { out[0] = 1; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = 1; out[5] = 0; out[6] = 0; out[7] = 0; out[8] = 1; return out; }
javascript
function identity(out) { out[0] = 1; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = 1; out[5] = 0; out[6] = 0; out[7] = 0; out[8] = 1; return out; }
[ "function", "identity", "(", "out", ")", "{", "out", "[", "0", "]", "=", "1", ";", "out", "[", "1", "]", "=", "0", ";", "out", "[", "2", "]", "=", "0", ";", "out", "[", "3", "]", "=", "0", ";", "out", "[", "4", "]", "=", "1", ";", "out", "[", "5", "]", "=", "0", ";", "out", "[", "6", "]", "=", "0", ";", "out", "[", "7", "]", "=", "0", ";", "out", "[", "8", "]", "=", "1", ";", "return", "out", ";", "}" ]
Set a mat3 to the identity matrix @param {mat3} out the receiving matrix @returns {mat3} out
[ "Set", "a", "mat3", "to", "the", "identity", "matrix" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L16763-L16774
14,131
antvis/data-set
demos/assets/g2.js
transpose
function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache some values if (out === a) { var a01 = a[1], a02 = a[2], a12 = a[5]; out[1] = a[3]; out[2] = a[6]; out[3] = a01; out[5] = a[7]; out[6] = a02; out[7] = a12; } else { out[0] = a[0]; out[1] = a[3]; out[2] = a[6]; out[3] = a[1]; out[4] = a[4]; out[5] = a[7]; out[6] = a[2]; out[7] = a[5]; out[8] = a[8]; } return out; }
javascript
function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache some values if (out === a) { var a01 = a[1], a02 = a[2], a12 = a[5]; out[1] = a[3]; out[2] = a[6]; out[3] = a01; out[5] = a[7]; out[6] = a02; out[7] = a12; } else { out[0] = a[0]; out[1] = a[3]; out[2] = a[6]; out[3] = a[1]; out[4] = a[4]; out[5] = a[7]; out[6] = a[2]; out[7] = a[5]; out[8] = a[8]; } return out; }
[ "function", "transpose", "(", "out", ",", "a", ")", "{", "// If we are transposing ourselves we can skip a few steps but have to cache some values", "if", "(", "out", "===", "a", ")", "{", "var", "a01", "=", "a", "[", "1", "]", ",", "a02", "=", "a", "[", "2", "]", ",", "a12", "=", "a", "[", "5", "]", ";", "out", "[", "1", "]", "=", "a", "[", "3", "]", ";", "out", "[", "2", "]", "=", "a", "[", "6", "]", ";", "out", "[", "3", "]", "=", "a01", ";", "out", "[", "5", "]", "=", "a", "[", "7", "]", ";", "out", "[", "6", "]", "=", "a02", ";", "out", "[", "7", "]", "=", "a12", ";", "}", "else", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", ";", "out", "[", "1", "]", "=", "a", "[", "3", "]", ";", "out", "[", "2", "]", "=", "a", "[", "6", "]", ";", "out", "[", "3", "]", "=", "a", "[", "1", "]", ";", "out", "[", "4", "]", "=", "a", "[", "4", "]", ";", "out", "[", "5", "]", "=", "a", "[", "7", "]", ";", "out", "[", "6", "]", "=", "a", "[", "2", "]", ";", "out", "[", "7", "]", "=", "a", "[", "5", "]", ";", "out", "[", "8", "]", "=", "a", "[", "8", "]", ";", "}", "return", "out", ";", "}" ]
Transpose the values of a mat3 @param {mat3} out the receiving matrix @param {mat3} a the source matrix @returns {mat3} out
[ "Transpose", "the", "values", "of", "a", "mat3" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L16783-L16808
14,132
antvis/data-set
demos/assets/g2.js
multiply
function multiply(out, a, b) { var a00 = a[0], a01 = a[1], a02 = a[2]; var a10 = a[3], a11 = a[4], a12 = a[5]; var a20 = a[6], a21 = a[7], a22 = a[8]; var b00 = b[0], b01 = b[1], b02 = b[2]; var b10 = b[3], b11 = b[4], b12 = b[5]; var b20 = b[6], b21 = b[7], b22 = b[8]; out[0] = b00 * a00 + b01 * a10 + b02 * a20; out[1] = b00 * a01 + b01 * a11 + b02 * a21; out[2] = b00 * a02 + b01 * a12 + b02 * a22; out[3] = b10 * a00 + b11 * a10 + b12 * a20; out[4] = b10 * a01 + b11 * a11 + b12 * a21; out[5] = b10 * a02 + b11 * a12 + b12 * a22; out[6] = b20 * a00 + b21 * a10 + b22 * a20; out[7] = b20 * a01 + b21 * a11 + b22 * a21; out[8] = b20 * a02 + b21 * a12 + b22 * a22; return out; }
javascript
function multiply(out, a, b) { var a00 = a[0], a01 = a[1], a02 = a[2]; var a10 = a[3], a11 = a[4], a12 = a[5]; var a20 = a[6], a21 = a[7], a22 = a[8]; var b00 = b[0], b01 = b[1], b02 = b[2]; var b10 = b[3], b11 = b[4], b12 = b[5]; var b20 = b[6], b21 = b[7], b22 = b[8]; out[0] = b00 * a00 + b01 * a10 + b02 * a20; out[1] = b00 * a01 + b01 * a11 + b02 * a21; out[2] = b00 * a02 + b01 * a12 + b02 * a22; out[3] = b10 * a00 + b11 * a10 + b12 * a20; out[4] = b10 * a01 + b11 * a11 + b12 * a21; out[5] = b10 * a02 + b11 * a12 + b12 * a22; out[6] = b20 * a00 + b21 * a10 + b22 * a20; out[7] = b20 * a01 + b21 * a11 + b22 * a21; out[8] = b20 * a02 + b21 * a12 + b22 * a22; return out; }
[ "function", "multiply", "(", "out", ",", "a", ",", "b", ")", "{", "var", "a00", "=", "a", "[", "0", "]", ",", "a01", "=", "a", "[", "1", "]", ",", "a02", "=", "a", "[", "2", "]", ";", "var", "a10", "=", "a", "[", "3", "]", ",", "a11", "=", "a", "[", "4", "]", ",", "a12", "=", "a", "[", "5", "]", ";", "var", "a20", "=", "a", "[", "6", "]", ",", "a21", "=", "a", "[", "7", "]", ",", "a22", "=", "a", "[", "8", "]", ";", "var", "b00", "=", "b", "[", "0", "]", ",", "b01", "=", "b", "[", "1", "]", ",", "b02", "=", "b", "[", "2", "]", ";", "var", "b10", "=", "b", "[", "3", "]", ",", "b11", "=", "b", "[", "4", "]", ",", "b12", "=", "b", "[", "5", "]", ";", "var", "b20", "=", "b", "[", "6", "]", ",", "b21", "=", "b", "[", "7", "]", ",", "b22", "=", "b", "[", "8", "]", ";", "out", "[", "0", "]", "=", "b00", "*", "a00", "+", "b01", "*", "a10", "+", "b02", "*", "a20", ";", "out", "[", "1", "]", "=", "b00", "*", "a01", "+", "b01", "*", "a11", "+", "b02", "*", "a21", ";", "out", "[", "2", "]", "=", "b00", "*", "a02", "+", "b01", "*", "a12", "+", "b02", "*", "a22", ";", "out", "[", "3", "]", "=", "b10", "*", "a00", "+", "b11", "*", "a10", "+", "b12", "*", "a20", ";", "out", "[", "4", "]", "=", "b10", "*", "a01", "+", "b11", "*", "a11", "+", "b12", "*", "a21", ";", "out", "[", "5", "]", "=", "b10", "*", "a02", "+", "b11", "*", "a12", "+", "b12", "*", "a22", ";", "out", "[", "6", "]", "=", "b20", "*", "a00", "+", "b21", "*", "a10", "+", "b22", "*", "a20", ";", "out", "[", "7", "]", "=", "b20", "*", "a01", "+", "b21", "*", "a11", "+", "b22", "*", "a21", ";", "out", "[", "8", "]", "=", "b20", "*", "a02", "+", "b21", "*", "a12", "+", "b22", "*", "a22", ";", "return", "out", ";", "}" ]
Multiplies two mat3's @param {mat3} out the receiving matrix @param {mat3} a the first operand @param {mat3} b the second operand @returns {mat3} out
[ "Multiplies", "two", "mat3", "s" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L16910-L16943
14,133
antvis/data-set
demos/assets/g2.js
rotate
function rotate(out, a, rad) { var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], s = Math.sin(rad), c = Math.cos(rad); out[0] = c * a00 + s * a10; out[1] = c * a01 + s * a11; out[2] = c * a02 + s * a12; out[3] = c * a10 - s * a00; out[4] = c * a11 - s * a01; out[5] = c * a12 - s * a02; out[6] = a20; out[7] = a21; out[8] = a22; return out; }
javascript
function rotate(out, a, rad) { var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], s = Math.sin(rad), c = Math.cos(rad); out[0] = c * a00 + s * a10; out[1] = c * a01 + s * a11; out[2] = c * a02 + s * a12; out[3] = c * a10 - s * a00; out[4] = c * a11 - s * a01; out[5] = c * a12 - s * a02; out[6] = a20; out[7] = a21; out[8] = a22; return out; }
[ "function", "rotate", "(", "out", ",", "a", ",", "rad", ")", "{", "var", "a00", "=", "a", "[", "0", "]", ",", "a01", "=", "a", "[", "1", "]", ",", "a02", "=", "a", "[", "2", "]", ",", "a10", "=", "a", "[", "3", "]", ",", "a11", "=", "a", "[", "4", "]", ",", "a12", "=", "a", "[", "5", "]", ",", "a20", "=", "a", "[", "6", "]", ",", "a21", "=", "a", "[", "7", "]", ",", "a22", "=", "a", "[", "8", "]", ",", "s", "=", "Math", ".", "sin", "(", "rad", ")", ",", "c", "=", "Math", ".", "cos", "(", "rad", ")", ";", "out", "[", "0", "]", "=", "c", "*", "a00", "+", "s", "*", "a10", ";", "out", "[", "1", "]", "=", "c", "*", "a01", "+", "s", "*", "a11", ";", "out", "[", "2", "]", "=", "c", "*", "a02", "+", "s", "*", "a12", ";", "out", "[", "3", "]", "=", "c", "*", "a10", "-", "s", "*", "a00", ";", "out", "[", "4", "]", "=", "c", "*", "a11", "-", "s", "*", "a01", ";", "out", "[", "5", "]", "=", "c", "*", "a12", "-", "s", "*", "a02", ";", "out", "[", "6", "]", "=", "a20", ";", "out", "[", "7", "]", "=", "a21", ";", "out", "[", "8", "]", "=", "a22", ";", "return", "out", ";", "}" ]
Rotates a mat3 by the given angle @param {mat3} out the receiving matrix @param {mat3} a the matrix to rotate @param {Number} rad the angle to rotate the matrix by @returns {mat3} out
[ "Rotates", "a", "mat3", "by", "the", "given", "angle" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L16988-L17013
14,134
antvis/data-set
demos/assets/g2.js
scale
function scale(out, a, v) { var x = v[0], y = v[1]; out[0] = x * a[0]; out[1] = x * a[1]; out[2] = x * a[2]; out[3] = y * a[3]; out[4] = y * a[4]; out[5] = y * a[5]; out[6] = a[6]; out[7] = a[7]; out[8] = a[8]; return out; }
javascript
function scale(out, a, v) { var x = v[0], y = v[1]; out[0] = x * a[0]; out[1] = x * a[1]; out[2] = x * a[2]; out[3] = y * a[3]; out[4] = y * a[4]; out[5] = y * a[5]; out[6] = a[6]; out[7] = a[7]; out[8] = a[8]; return out; }
[ "function", "scale", "(", "out", ",", "a", ",", "v", ")", "{", "var", "x", "=", "v", "[", "0", "]", ",", "y", "=", "v", "[", "1", "]", ";", "out", "[", "0", "]", "=", "x", "*", "a", "[", "0", "]", ";", "out", "[", "1", "]", "=", "x", "*", "a", "[", "1", "]", ";", "out", "[", "2", "]", "=", "x", "*", "a", "[", "2", "]", ";", "out", "[", "3", "]", "=", "y", "*", "a", "[", "3", "]", ";", "out", "[", "4", "]", "=", "y", "*", "a", "[", "4", "]", ";", "out", "[", "5", "]", "=", "y", "*", "a", "[", "5", "]", ";", "out", "[", "6", "]", "=", "a", "[", "6", "]", ";", "out", "[", "7", "]", "=", "a", "[", "7", "]", ";", "out", "[", "8", "]", "=", "a", "[", "8", "]", ";", "return", "out", ";", "}" ]
Scales the mat3 by the dimensions in the given vec2 @param {mat3} out the receiving matrix @param {mat3} a the matrix to rotate @param {vec2} v the vec2 to scale the matrix by @returns {mat3} out
[ "Scales", "the", "mat3", "by", "the", "dimensions", "in", "the", "given", "vec2" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17023-L17039
14,135
antvis/data-set
demos/assets/g2.js
fromMat2d
function fromMat2d(out, a) { out[0] = a[0]; out[1] = a[1]; out[2] = 0; out[3] = a[2]; out[4] = a[3]; out[5] = 0; out[6] = a[4]; out[7] = a[5]; out[8] = 1; return out; }
javascript
function fromMat2d(out, a) { out[0] = a[0]; out[1] = a[1]; out[2] = 0; out[3] = a[2]; out[4] = a[3]; out[5] = 0; out[6] = a[4]; out[7] = a[5]; out[8] = 1; return out; }
[ "function", "fromMat2d", "(", "out", ",", "a", ")", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", ";", "out", "[", "2", "]", "=", "0", ";", "out", "[", "3", "]", "=", "a", "[", "2", "]", ";", "out", "[", "4", "]", "=", "a", "[", "3", "]", ";", "out", "[", "5", "]", "=", "0", ";", "out", "[", "6", "]", "=", "a", "[", "4", "]", ";", "out", "[", "7", "]", "=", "a", "[", "5", "]", ";", "out", "[", "8", "]", "=", "1", ";", "return", "out", ";", "}" ]
Copies the values from a mat2d into a mat3 @param {mat3} out the receiving matrix @param {mat2d} a the matrix to copy @returns {mat3} out
[ "Copies", "the", "values", "from", "a", "mat2d", "into", "a", "mat3" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17127-L17140
14,136
antvis/data-set
demos/assets/g2.js
projection
function projection(out, width, height) { out[0] = 2 / width; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = -2 / height; out[5] = 0; out[6] = -1; out[7] = 1; out[8] = 1; return out; }
javascript
function projection(out, width, height) { out[0] = 2 / width; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = -2 / height; out[5] = 0; out[6] = -1; out[7] = 1; out[8] = 1; return out; }
[ "function", "projection", "(", "out", ",", "width", ",", "height", ")", "{", "out", "[", "0", "]", "=", "2", "/", "width", ";", "out", "[", "1", "]", "=", "0", ";", "out", "[", "2", "]", "=", "0", ";", "out", "[", "3", "]", "=", "0", ";", "out", "[", "4", "]", "=", "-", "2", "/", "height", ";", "out", "[", "5", "]", "=", "0", ";", "out", "[", "6", "]", "=", "-", "1", ";", "out", "[", "7", "]", "=", "1", ";", "out", "[", "8", "]", "=", "1", ";", "return", "out", ";", "}" ]
Generates a 2D projection matrix with the given bounds @param {mat3} out mat3 frustum matrix will be written into @param {number} width Width of your gl context @param {number} height Height of gl context @returns {mat3} out
[ "Generates", "a", "2D", "projection", "matrix", "with", "the", "given", "bounds" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17254-L17265
14,137
antvis/data-set
demos/assets/g2.js
str
function str(a) { return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')'; }
javascript
function str(a) { return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')'; }
[ "function", "str", "(", "a", ")", "{", "return", "'mat3('", "+", "a", "[", "0", "]", "+", "', '", "+", "a", "[", "1", "]", "+", "', '", "+", "a", "[", "2", "]", "+", "', '", "+", "a", "[", "3", "]", "+", "', '", "+", "a", "[", "4", "]", "+", "', '", "+", "a", "[", "5", "]", "+", "', '", "+", "a", "[", "6", "]", "+", "', '", "+", "a", "[", "7", "]", "+", "', '", "+", "a", "[", "8", "]", "+", "')'", ";", "}" ]
Returns a string representation of a mat3 @param {mat3} a matrix to represent as a string @returns {String} string representation of the matrix
[ "Returns", "a", "string", "representation", "of", "a", "mat3" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17273-L17275
14,138
antvis/data-set
demos/assets/g2.js
add
function add(out, a, b) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; out[2] = a[2] + b[2]; out[3] = a[3] + b[3]; out[4] = a[4] + b[4]; out[5] = a[5] + b[5]; out[6] = a[6] + b[6]; out[7] = a[7] + b[7]; out[8] = a[8] + b[8]; return out; }
javascript
function add(out, a, b) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; out[2] = a[2] + b[2]; out[3] = a[3] + b[3]; out[4] = a[4] + b[4]; out[5] = a[5] + b[5]; out[6] = a[6] + b[6]; out[7] = a[7] + b[7]; out[8] = a[8] + b[8]; return out; }
[ "function", "add", "(", "out", ",", "a", ",", "b", ")", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", "+", "b", "[", "0", "]", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", "+", "b", "[", "1", "]", ";", "out", "[", "2", "]", "=", "a", "[", "2", "]", "+", "b", "[", "2", "]", ";", "out", "[", "3", "]", "=", "a", "[", "3", "]", "+", "b", "[", "3", "]", ";", "out", "[", "4", "]", "=", "a", "[", "4", "]", "+", "b", "[", "4", "]", ";", "out", "[", "5", "]", "=", "a", "[", "5", "]", "+", "b", "[", "5", "]", ";", "out", "[", "6", "]", "=", "a", "[", "6", "]", "+", "b", "[", "6", "]", ";", "out", "[", "7", "]", "=", "a", "[", "7", "]", "+", "b", "[", "7", "]", ";", "out", "[", "8", "]", "=", "a", "[", "8", "]", "+", "b", "[", "8", "]", ";", "return", "out", ";", "}" ]
Adds two mat3's @param {mat3} out the receiving matrix @param {mat3} a the first operand @param {mat3} b the second operand @returns {mat3} out
[ "Adds", "two", "mat3", "s" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17295-L17306
14,139
antvis/data-set
demos/assets/g2.js
subtract
function subtract(out, a, b) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; out[2] = a[2] - b[2]; out[3] = a[3] - b[3]; out[4] = a[4] - b[4]; out[5] = a[5] - b[5]; out[6] = a[6] - b[6]; out[7] = a[7] - b[7]; out[8] = a[8] - b[8]; return out; }
javascript
function subtract(out, a, b) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; out[2] = a[2] - b[2]; out[3] = a[3] - b[3]; out[4] = a[4] - b[4]; out[5] = a[5] - b[5]; out[6] = a[6] - b[6]; out[7] = a[7] - b[7]; out[8] = a[8] - b[8]; return out; }
[ "function", "subtract", "(", "out", ",", "a", ",", "b", ")", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", "-", "b", "[", "0", "]", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", "-", "b", "[", "1", "]", ";", "out", "[", "2", "]", "=", "a", "[", "2", "]", "-", "b", "[", "2", "]", ";", "out", "[", "3", "]", "=", "a", "[", "3", "]", "-", "b", "[", "3", "]", ";", "out", "[", "4", "]", "=", "a", "[", "4", "]", "-", "b", "[", "4", "]", ";", "out", "[", "5", "]", "=", "a", "[", "5", "]", "-", "b", "[", "5", "]", ";", "out", "[", "6", "]", "=", "a", "[", "6", "]", "-", "b", "[", "6", "]", ";", "out", "[", "7", "]", "=", "a", "[", "7", "]", "-", "b", "[", "7", "]", ";", "out", "[", "8", "]", "=", "a", "[", "8", "]", "-", "b", "[", "8", "]", ";", "return", "out", ";", "}" ]
Subtracts matrix b from matrix a @param {mat3} out the receiving matrix @param {mat3} a the first operand @param {mat3} b the second operand @returns {mat3} out
[ "Subtracts", "matrix", "b", "from", "matrix", "a" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17316-L17327
14,140
antvis/data-set
demos/assets/g2.js
multiplyScalar
function multiplyScalar(out, a, b) { out[0] = a[0] * b; out[1] = a[1] * b; out[2] = a[2] * b; out[3] = a[3] * b; out[4] = a[4] * b; out[5] = a[5] * b; out[6] = a[6] * b; out[7] = a[7] * b; out[8] = a[8] * b; return out; }
javascript
function multiplyScalar(out, a, b) { out[0] = a[0] * b; out[1] = a[1] * b; out[2] = a[2] * b; out[3] = a[3] * b; out[4] = a[4] * b; out[5] = a[5] * b; out[6] = a[6] * b; out[7] = a[7] * b; out[8] = a[8] * b; return out; }
[ "function", "multiplyScalar", "(", "out", ",", "a", ",", "b", ")", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", "*", "b", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", "*", "b", ";", "out", "[", "2", "]", "=", "a", "[", "2", "]", "*", "b", ";", "out", "[", "3", "]", "=", "a", "[", "3", "]", "*", "b", ";", "out", "[", "4", "]", "=", "a", "[", "4", "]", "*", "b", ";", "out", "[", "5", "]", "=", "a", "[", "5", "]", "*", "b", ";", "out", "[", "6", "]", "=", "a", "[", "6", "]", "*", "b", ";", "out", "[", "7", "]", "=", "a", "[", "7", "]", "*", "b", ";", "out", "[", "8", "]", "=", "a", "[", "8", "]", "*", "b", ";", "return", "out", ";", "}" ]
Multiply each element of the matrix by a scalar. @param {mat3} out the receiving matrix @param {mat3} a the matrix to scale @param {Number} b amount to scale the matrix's elements by @returns {mat3} out
[ "Multiply", "each", "element", "of", "the", "matrix", "by", "a", "scalar", "." ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17337-L17348
14,141
antvis/data-set
demos/assets/g2.js
multiplyScalarAndAdd
function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; out[1] = a[1] + b[1] * scale; out[2] = a[2] + b[2] * scale; out[3] = a[3] + b[3] * scale; out[4] = a[4] + b[4] * scale; out[5] = a[5] + b[5] * scale; out[6] = a[6] + b[6] * scale; out[7] = a[7] + b[7] * scale; out[8] = a[8] + b[8] * scale; return out; }
javascript
function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; out[1] = a[1] + b[1] * scale; out[2] = a[2] + b[2] * scale; out[3] = a[3] + b[3] * scale; out[4] = a[4] + b[4] * scale; out[5] = a[5] + b[5] * scale; out[6] = a[6] + b[6] * scale; out[7] = a[7] + b[7] * scale; out[8] = a[8] + b[8] * scale; return out; }
[ "function", "multiplyScalarAndAdd", "(", "out", ",", "a", ",", "b", ",", "scale", ")", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", "+", "b", "[", "0", "]", "*", "scale", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", "+", "b", "[", "1", "]", "*", "scale", ";", "out", "[", "2", "]", "=", "a", "[", "2", "]", "+", "b", "[", "2", "]", "*", "scale", ";", "out", "[", "3", "]", "=", "a", "[", "3", "]", "+", "b", "[", "3", "]", "*", "scale", ";", "out", "[", "4", "]", "=", "a", "[", "4", "]", "+", "b", "[", "4", "]", "*", "scale", ";", "out", "[", "5", "]", "=", "a", "[", "5", "]", "+", "b", "[", "5", "]", "*", "scale", ";", "out", "[", "6", "]", "=", "a", "[", "6", "]", "+", "b", "[", "6", "]", "*", "scale", ";", "out", "[", "7", "]", "=", "a", "[", "7", "]", "+", "b", "[", "7", "]", "*", "scale", ";", "out", "[", "8", "]", "=", "a", "[", "8", "]", "+", "b", "[", "8", "]", "*", "scale", ";", "return", "out", ";", "}" ]
Adds two mat3's after multiplying each element of the second operand by a scalar value. @param {mat3} out the receiving vector @param {mat3} a the first operand @param {mat3} b the second operand @param {Number} scale the amount to scale b's elements by before adding @returns {mat3} out
[ "Adds", "two", "mat3", "s", "after", "multiplying", "each", "element", "of", "the", "second", "operand", "by", "a", "scalar", "value", "." ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17359-L17370
14,142
antvis/data-set
demos/assets/g2.js
equals
function equals(a, b) { var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8]; var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8]; return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)); }
javascript
function equals(a, b) { var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8]; var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8]; return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)); }
[ "function", "equals", "(", "a", ",", "b", ")", "{", "var", "a0", "=", "a", "[", "0", "]", ",", "a1", "=", "a", "[", "1", "]", ",", "a2", "=", "a", "[", "2", "]", ",", "a3", "=", "a", "[", "3", "]", ",", "a4", "=", "a", "[", "4", "]", ",", "a5", "=", "a", "[", "5", "]", ",", "a6", "=", "a", "[", "6", "]", ",", "a7", "=", "a", "[", "7", "]", ",", "a8", "=", "a", "[", "8", "]", ";", "var", "b0", "=", "b", "[", "0", "]", ",", "b1", "=", "b", "[", "1", "]", ",", "b2", "=", "b", "[", "2", "]", ",", "b3", "=", "b", "[", "3", "]", ",", "b4", "=", "b", "[", "4", "]", ",", "b5", "=", "b", "[", "5", "]", ",", "b6", "=", "b", "[", "6", "]", ",", "b7", "=", "b", "[", "7", "]", ",", "b8", "=", "b", "[", "8", "]", ";", "return", "Math", ".", "abs", "(", "a0", "-", "b0", ")", "<=", "glMatrix", ".", "EPSILON", "*", "Math", ".", "max", "(", "1.0", ",", "Math", ".", "abs", "(", "a0", ")", ",", "Math", ".", "abs", "(", "b0", ")", ")", "&&", "Math", ".", "abs", "(", "a1", "-", "b1", ")", "<=", "glMatrix", ".", "EPSILON", "*", "Math", ".", "max", "(", "1.0", ",", "Math", ".", "abs", "(", "a1", ")", ",", "Math", ".", "abs", "(", "b1", ")", ")", "&&", "Math", ".", "abs", "(", "a2", "-", "b2", ")", "<=", "glMatrix", ".", "EPSILON", "*", "Math", ".", "max", "(", "1.0", ",", "Math", ".", "abs", "(", "a2", ")", ",", "Math", ".", "abs", "(", "b2", ")", ")", "&&", "Math", ".", "abs", "(", "a3", "-", "b3", ")", "<=", "glMatrix", ".", "EPSILON", "*", "Math", ".", "max", "(", "1.0", ",", "Math", ".", "abs", "(", "a3", ")", ",", "Math", ".", "abs", "(", "b3", ")", ")", "&&", "Math", ".", "abs", "(", "a4", "-", "b4", ")", "<=", "glMatrix", ".", "EPSILON", "*", "Math", ".", "max", "(", "1.0", ",", "Math", ".", "abs", "(", "a4", ")", ",", "Math", ".", "abs", "(", "b4", ")", ")", "&&", "Math", ".", "abs", "(", "a5", "-", "b5", ")", "<=", "glMatrix", ".", "EPSILON", "*", "Math", ".", "max", "(", "1.0", ",", "Math", ".", "abs", "(", "a5", ")", ",", "Math", ".", "abs", "(", "b5", ")", ")", "&&", "Math", ".", "abs", "(", "a6", "-", "b6", ")", "<=", "glMatrix", ".", "EPSILON", "*", "Math", ".", "max", "(", "1.0", ",", "Math", ".", "abs", "(", "a6", ")", ",", "Math", ".", "abs", "(", "b6", ")", ")", "&&", "Math", ".", "abs", "(", "a7", "-", "b7", ")", "<=", "glMatrix", ".", "EPSILON", "*", "Math", ".", "max", "(", "1.0", ",", "Math", ".", "abs", "(", "a7", ")", ",", "Math", ".", "abs", "(", "b7", ")", ")", "&&", "Math", ".", "abs", "(", "a8", "-", "b8", ")", "<=", "glMatrix", ".", "EPSILON", "*", "Math", ".", "max", "(", "1.0", ",", "Math", ".", "abs", "(", "a8", ")", ",", "Math", ".", "abs", "(", "b8", ")", ")", ";", "}" ]
Returns whether or not the matrices have approximately the same elements in the same position. @param {mat3} a The first matrix. @param {mat3} b The second matrix. @returns {Boolean} True if the matrices are equal, false otherwise.
[ "Returns", "whether", "or", "not", "the", "matrices", "have", "approximately", "the", "same", "elements", "in", "the", "same", "position", "." ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17390-L17410
14,143
antvis/data-set
demos/assets/g2.js
add
function add(out, a, b) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; out[2] = a[2] + b[2]; return out; }
javascript
function add(out, a, b) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; out[2] = a[2] + b[2]; return out; }
[ "function", "add", "(", "out", ",", "a", ",", "b", ")", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", "+", "b", "[", "0", "]", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", "+", "b", "[", "1", "]", ";", "out", "[", "2", "]", "=", "a", "[", "2", "]", "+", "b", "[", "2", "]", ";", "return", "out", ";", "}" ]
Adds two vec3's @param {vec3} out the receiving vector @param {vec3} a the first operand @param {vec3} b the second operand @returns {vec3} out
[ "Adds", "two", "vec3", "s" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17591-L17596
14,144
antvis/data-set
demos/assets/g2.js
subtract
function subtract(out, a, b) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; out[2] = a[2] - b[2]; return out; }
javascript
function subtract(out, a, b) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; out[2] = a[2] - b[2]; return out; }
[ "function", "subtract", "(", "out", ",", "a", ",", "b", ")", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", "-", "b", "[", "0", "]", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", "-", "b", "[", "1", "]", ";", "out", "[", "2", "]", "=", "a", "[", "2", "]", "-", "b", "[", "2", "]", ";", "return", "out", ";", "}" ]
Subtracts vector b from vector a @param {vec3} out the receiving vector @param {vec3} a the first operand @param {vec3} b the second operand @returns {vec3} out
[ "Subtracts", "vector", "b", "from", "vector", "a" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17606-L17611
14,145
antvis/data-set
demos/assets/g2.js
multiply
function multiply(out, a, b) { out[0] = a[0] * b[0]; out[1] = a[1] * b[1]; out[2] = a[2] * b[2]; return out; }
javascript
function multiply(out, a, b) { out[0] = a[0] * b[0]; out[1] = a[1] * b[1]; out[2] = a[2] * b[2]; return out; }
[ "function", "multiply", "(", "out", ",", "a", ",", "b", ")", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", "*", "b", "[", "0", "]", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", "*", "b", "[", "1", "]", ";", "out", "[", "2", "]", "=", "a", "[", "2", "]", "*", "b", "[", "2", "]", ";", "return", "out", ";", "}" ]
Multiplies two vec3's @param {vec3} out the receiving vector @param {vec3} a the first operand @param {vec3} b the second operand @returns {vec3} out
[ "Multiplies", "two", "vec3", "s" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17621-L17626
14,146
antvis/data-set
demos/assets/g2.js
ceil
function ceil(out, a) { out[0] = Math.ceil(a[0]); out[1] = Math.ceil(a[1]); out[2] = Math.ceil(a[2]); return out; }
javascript
function ceil(out, a) { out[0] = Math.ceil(a[0]); out[1] = Math.ceil(a[1]); out[2] = Math.ceil(a[2]); return out; }
[ "function", "ceil", "(", "out", ",", "a", ")", "{", "out", "[", "0", "]", "=", "Math", ".", "ceil", "(", "a", "[", "0", "]", ")", ";", "out", "[", "1", "]", "=", "Math", ".", "ceil", "(", "a", "[", "1", "]", ")", ";", "out", "[", "2", "]", "=", "Math", ".", "ceil", "(", "a", "[", "2", "]", ")", ";", "return", "out", ";", "}" ]
Math.ceil the components of a vec3 @param {vec3} out the receiving vector @param {vec3} a vector to ceil @returns {vec3} out
[ "Math", ".", "ceil", "the", "components", "of", "a", "vec3" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17650-L17655
14,147
antvis/data-set
demos/assets/g2.js
floor
function floor(out, a) { out[0] = Math.floor(a[0]); out[1] = Math.floor(a[1]); out[2] = Math.floor(a[2]); return out; }
javascript
function floor(out, a) { out[0] = Math.floor(a[0]); out[1] = Math.floor(a[1]); out[2] = Math.floor(a[2]); return out; }
[ "function", "floor", "(", "out", ",", "a", ")", "{", "out", "[", "0", "]", "=", "Math", ".", "floor", "(", "a", "[", "0", "]", ")", ";", "out", "[", "1", "]", "=", "Math", ".", "floor", "(", "a", "[", "1", "]", ")", ";", "out", "[", "2", "]", "=", "Math", ".", "floor", "(", "a", "[", "2", "]", ")", ";", "return", "out", ";", "}" ]
Math.floor the components of a vec3 @param {vec3} out the receiving vector @param {vec3} a vector to floor @returns {vec3} out
[ "Math", ".", "floor", "the", "components", "of", "a", "vec3" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17664-L17669
14,148
antvis/data-set
demos/assets/g2.js
round
function round(out, a) { out[0] = Math.round(a[0]); out[1] = Math.round(a[1]); out[2] = Math.round(a[2]); return out; }
javascript
function round(out, a) { out[0] = Math.round(a[0]); out[1] = Math.round(a[1]); out[2] = Math.round(a[2]); return out; }
[ "function", "round", "(", "out", ",", "a", ")", "{", "out", "[", "0", "]", "=", "Math", ".", "round", "(", "a", "[", "0", "]", ")", ";", "out", "[", "1", "]", "=", "Math", ".", "round", "(", "a", "[", "1", "]", ")", ";", "out", "[", "2", "]", "=", "Math", ".", "round", "(", "a", "[", "2", "]", ")", ";", "return", "out", ";", "}" ]
Math.round the components of a vec3 @param {vec3} out the receiving vector @param {vec3} a vector to round @returns {vec3} out
[ "Math", ".", "round", "the", "components", "of", "a", "vec3" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17708-L17713
14,149
antvis/data-set
demos/assets/g2.js
scale
function scale(out, a, b) { out[0] = a[0] * b; out[1] = a[1] * b; out[2] = a[2] * b; return out; }
javascript
function scale(out, a, b) { out[0] = a[0] * b; out[1] = a[1] * b; out[2] = a[2] * b; return out; }
[ "function", "scale", "(", "out", ",", "a", ",", "b", ")", "{", "out", "[", "0", "]", "=", "a", "[", "0", "]", "*", "b", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", "*", "b", ";", "out", "[", "2", "]", "=", "a", "[", "2", "]", "*", "b", ";", "return", "out", ";", "}" ]
Scales a vec3 by a scalar number @param {vec3} out the receiving vector @param {vec3} a the vector to scale @param {Number} b amount to scale the vector by @returns {vec3} out
[ "Scales", "a", "vec3", "by", "a", "scalar", "number" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17723-L17728
14,150
antvis/data-set
demos/assets/g2.js
hermite
function hermite(out, a, b, c, d, t) { var factorTimes2 = t * t; var factor1 = factorTimes2 * (2 * t - 3) + 1; var factor2 = factorTimes2 * (t - 2) + t; var factor3 = factorTimes2 * (t - 1); var factor4 = factorTimes2 * (3 - 2 * t); out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; return out; }
javascript
function hermite(out, a, b, c, d, t) { var factorTimes2 = t * t; var factor1 = factorTimes2 * (2 * t - 3) + 1; var factor2 = factorTimes2 * (t - 2) + t; var factor3 = factorTimes2 * (t - 1); var factor4 = factorTimes2 * (3 - 2 * t); out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; return out; }
[ "function", "hermite", "(", "out", ",", "a", ",", "b", ",", "c", ",", "d", ",", "t", ")", "{", "var", "factorTimes2", "=", "t", "*", "t", ";", "var", "factor1", "=", "factorTimes2", "*", "(", "2", "*", "t", "-", "3", ")", "+", "1", ";", "var", "factor2", "=", "factorTimes2", "*", "(", "t", "-", "2", ")", "+", "t", ";", "var", "factor3", "=", "factorTimes2", "*", "(", "t", "-", "1", ")", ";", "var", "factor4", "=", "factorTimes2", "*", "(", "3", "-", "2", "*", "t", ")", ";", "out", "[", "0", "]", "=", "a", "[", "0", "]", "*", "factor1", "+", "b", "[", "0", "]", "*", "factor2", "+", "c", "[", "0", "]", "*", "factor3", "+", "d", "[", "0", "]", "*", "factor4", ";", "out", "[", "1", "]", "=", "a", "[", "1", "]", "*", "factor1", "+", "b", "[", "1", "]", "*", "factor2", "+", "c", "[", "1", "]", "*", "factor3", "+", "d", "[", "1", "]", "*", "factor4", ";", "out", "[", "2", "]", "=", "a", "[", "2", "]", "*", "factor1", "+", "b", "[", "2", "]", "*", "factor2", "+", "c", "[", "2", "]", "*", "factor3", "+", "d", "[", "2", "]", "*", "factor4", ";", "return", "out", ";", "}" ]
Performs a hermite interpolation with two control points @param {vec3} out the receiving vector @param {vec3} a the first operand @param {vec3} b the second operand @param {vec3} c the third operand @param {vec3} d the fourth operand @param {Number} t interpolation amount, in the range [0-1], between the two inputs @returns {vec3} out
[ "Performs", "a", "hermite", "interpolation", "with", "two", "control", "points" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L17900-L17912
14,151
antvis/data-set
demos/assets/g2.js
rotate
function rotate(out, a, b, c) { //Translate point to the origin var p0 = a[0] - b[0], p1 = a[1] - b[1], sinC = Math.sin(c), cosC = Math.cos(c); //perform rotation and translate to correct position out[0] = p0 * cosC - p1 * sinC + b[0]; out[1] = p0 * sinC + p1 * cosC + b[1]; return out; }
javascript
function rotate(out, a, b, c) { //Translate point to the origin var p0 = a[0] - b[0], p1 = a[1] - b[1], sinC = Math.sin(c), cosC = Math.cos(c); //perform rotation and translate to correct position out[0] = p0 * cosC - p1 * sinC + b[0]; out[1] = p0 * sinC + p1 * cosC + b[1]; return out; }
[ "function", "rotate", "(", "out", ",", "a", ",", "b", ",", "c", ")", "{", "//Translate point to the origin", "var", "p0", "=", "a", "[", "0", "]", "-", "b", "[", "0", "]", ",", "p1", "=", "a", "[", "1", "]", "-", "b", "[", "1", "]", ",", "sinC", "=", "Math", ".", "sin", "(", "c", ")", ",", "cosC", "=", "Math", ".", "cos", "(", "c", ")", ";", "//perform rotation and translate to correct position", "out", "[", "0", "]", "=", "p0", "*", "cosC", "-", "p1", "*", "sinC", "+", "b", "[", "0", "]", ";", "out", "[", "1", "]", "=", "p0", "*", "sinC", "+", "p1", "*", "cosC", "+", "b", "[", "1", "]", ";", "return", "out", ";", "}" ]
Rotate a 2D vector @param {vec2} out The receiving vec2 @param {vec2} a The vec2 point to rotate @param {vec2} b The origin of the rotation @param {Number} c The angle of rotation @returns {vec2} out
[ "Rotate", "a", "2D", "vector" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L18794-L18806
14,152
antvis/data-set
demos/assets/g2.js
angle
function angle(a, b) { var x1 = a[0], y1 = a[1], x2 = b[0], y2 = b[1]; var len1 = x1 * x1 + y1 * y1; if (len1 > 0) { //TODO: evaluate use of glm_invsqrt here? len1 = 1 / Math.sqrt(len1); } var len2 = x2 * x2 + y2 * y2; if (len2 > 0) { //TODO: evaluate use of glm_invsqrt here? len2 = 1 / Math.sqrt(len2); } var cosine = (x1 * x2 + y1 * y2) * len1 * len2; if (cosine > 1.0) { return 0; } else if (cosine < -1.0) { return Math.PI; } else { return Math.acos(cosine); } }
javascript
function angle(a, b) { var x1 = a[0], y1 = a[1], x2 = b[0], y2 = b[1]; var len1 = x1 * x1 + y1 * y1; if (len1 > 0) { //TODO: evaluate use of glm_invsqrt here? len1 = 1 / Math.sqrt(len1); } var len2 = x2 * x2 + y2 * y2; if (len2 > 0) { //TODO: evaluate use of glm_invsqrt here? len2 = 1 / Math.sqrt(len2); } var cosine = (x1 * x2 + y1 * y2) * len1 * len2; if (cosine > 1.0) { return 0; } else if (cosine < -1.0) { return Math.PI; } else { return Math.acos(cosine); } }
[ "function", "angle", "(", "a", ",", "b", ")", "{", "var", "x1", "=", "a", "[", "0", "]", ",", "y1", "=", "a", "[", "1", "]", ",", "x2", "=", "b", "[", "0", "]", ",", "y2", "=", "b", "[", "1", "]", ";", "var", "len1", "=", "x1", "*", "x1", "+", "y1", "*", "y1", ";", "if", "(", "len1", ">", "0", ")", "{", "//TODO: evaluate use of glm_invsqrt here?", "len1", "=", "1", "/", "Math", ".", "sqrt", "(", "len1", ")", ";", "}", "var", "len2", "=", "x2", "*", "x2", "+", "y2", "*", "y2", ";", "if", "(", "len2", ">", "0", ")", "{", "//TODO: evaluate use of glm_invsqrt here?", "len2", "=", "1", "/", "Math", ".", "sqrt", "(", "len2", ")", ";", "}", "var", "cosine", "=", "(", "x1", "*", "x2", "+", "y1", "*", "y2", ")", "*", "len1", "*", "len2", ";", "if", "(", "cosine", ">", "1.0", ")", "{", "return", "0", ";", "}", "else", "if", "(", "cosine", "<", "-", "1.0", ")", "{", "return", "Math", ".", "PI", ";", "}", "else", "{", "return", "Math", ".", "acos", "(", "cosine", ")", ";", "}", "}" ]
Get the angle between two 2D vectors @param {vec2} a The first operand @param {vec2} b The second operand @returns {Number} The angle in radians
[ "Get", "the", "angle", "between", "two", "2D", "vectors" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L18814-L18841
14,153
antvis/data-set
demos/assets/g2.js
flatten
function flatten(arr) { if (!isArray(arr)) { return arr; } var result = []; each(arr, function (item) { if (isArray(item)) { each(item, function (subItem) { result.push(subItem); }); } else { result.push(item); } }); return result; }
javascript
function flatten(arr) { if (!isArray(arr)) { return arr; } var result = []; each(arr, function (item) { if (isArray(item)) { each(item, function (subItem) { result.push(subItem); }); } else { result.push(item); } }); return result; }
[ "function", "flatten", "(", "arr", ")", "{", "if", "(", "!", "isArray", "(", "arr", ")", ")", "{", "return", "arr", ";", "}", "var", "result", "=", "[", "]", ";", "each", "(", "arr", ",", "function", "(", "item", ")", "{", "if", "(", "isArray", "(", "item", ")", ")", "{", "each", "(", "item", ",", "function", "(", "subItem", ")", "{", "result", ".", "push", "(", "subItem", ")", ";", "}", ")", ";", "}", "else", "{", "result", ".", "push", "(", "item", ")", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Flattens `array` a single level deep. @param {Array} arr The array to flatten. @return {Array} Returns the new flattened array. @example _.flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]
[ "Flattens", "array", "a", "single", "level", "deep", "." ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L22323-L22338
14,154
antvis/data-set
demos/assets/g2.js
pick
function pick(object, keys) { if (object === null || !isPlaineObject(object)) { return {}; } var result = {}; each(keys, function (key) { if (hasOwnProperty.call(object, key)) { result[key] = object[key]; } }); return result; }
javascript
function pick(object, keys) { if (object === null || !isPlaineObject(object)) { return {}; } var result = {}; each(keys, function (key) { if (hasOwnProperty.call(object, key)) { result[key] = object[key]; } }); return result; }
[ "function", "pick", "(", "object", ",", "keys", ")", "{", "if", "(", "object", "===", "null", "||", "!", "isPlaineObject", "(", "object", ")", ")", "{", "return", "{", "}", ";", "}", "var", "result", "=", "{", "}", ";", "each", "(", "keys", ",", "function", "(", "key", ")", "{", "if", "(", "hasOwnProperty", ".", "call", "(", "object", ",", "key", ")", ")", "{", "result", "[", "key", "]", "=", "object", "[", "key", "]", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Creates an object composed of the picked `object` properties. @param {Object} object The source object. @param {...(string|string[])} [paths] The property paths to pick. @returns {Object} Returns the new object. @example var object = { 'a': 1, 'b': '2', 'c': 3 }; pick(object, ['a', 'c']); // => { 'a': 1, 'c': 3 }
[ "Creates", "an", "object", "composed", "of", "the", "picked", "object", "properties", "." ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L23319-L23330
14,155
antvis/data-set
demos/assets/g2.js
getPath
function getPath(cfg, smooth) { var path = void 0; var points = cfg.points; var isInCircle = cfg.isInCircle; var first = points[0]; if (Util.isArray(first.y)) { path = getRangePath(points, smooth, isInCircle, cfg); } else { path = getSinglePath(points, smooth, isInCircle, cfg); } return path; }
javascript
function getPath(cfg, smooth) { var path = void 0; var points = cfg.points; var isInCircle = cfg.isInCircle; var first = points[0]; if (Util.isArray(first.y)) { path = getRangePath(points, smooth, isInCircle, cfg); } else { path = getSinglePath(points, smooth, isInCircle, cfg); } return path; }
[ "function", "getPath", "(", "cfg", ",", "smooth", ")", "{", "var", "path", "=", "void", "0", ";", "var", "points", "=", "cfg", ".", "points", ";", "var", "isInCircle", "=", "cfg", ".", "isInCircle", ";", "var", "first", "=", "points", "[", "0", "]", ";", "if", "(", "Util", ".", "isArray", "(", "first", ".", "y", ")", ")", "{", "path", "=", "getRangePath", "(", "points", ",", "smooth", ",", "isInCircle", ",", "cfg", ")", ";", "}", "else", "{", "path", "=", "getSinglePath", "(", "points", ",", "smooth", ",", "isInCircle", ",", "cfg", ")", ";", "}", "return", "path", ";", "}" ]
get line path
[ "get", "line", "path" ]
55526ac5663b87cdc988fc579404df186603b2d9
https://github.com/antvis/data-set/blob/55526ac5663b87cdc988fc579404df186603b2d9/demos/assets/g2.js#L39845-L39856
14,156
brightcove/hot-shots
lib/statsFunctions.js
hrtimer
function hrtimer() { const start = process.hrtime(); return () => { const durationComponents = process.hrtime(start); const seconds = durationComponents[0]; const nanoseconds = durationComponents[1]; const duration = (seconds * 1000) + (nanoseconds / 1E6); return duration; }; }
javascript
function hrtimer() { const start = process.hrtime(); return () => { const durationComponents = process.hrtime(start); const seconds = durationComponents[0]; const nanoseconds = durationComponents[1]; const duration = (seconds * 1000) + (nanoseconds / 1E6); return duration; }; }
[ "function", "hrtimer", "(", ")", "{", "const", "start", "=", "process", ".", "hrtime", "(", ")", ";", "return", "(", ")", "=>", "{", "const", "durationComponents", "=", "process", ".", "hrtime", "(", "start", ")", ";", "const", "seconds", "=", "durationComponents", "[", "0", "]", ";", "const", "nanoseconds", "=", "durationComponents", "[", "1", "]", ";", "const", "duration", "=", "(", "seconds", "*", "1000", ")", "+", "(", "nanoseconds", "/", "1E6", ")", ";", "return", "duration", ";", "}", ";", "}" ]
High-resolution timer
[ "High", "-", "resolution", "timer" ]
8042839d9f51f68d319fcb9b6e6eee5f75e77423
https://github.com/brightcove/hot-shots/blob/8042839d9f51f68d319fcb9b6e6eee5f75e77423/lib/statsFunctions.js#L80-L90
14,157
brightcove/hot-shots
lib/helpers.js
sanitizeTags
function sanitizeTags(value, telegraf) { const blacklist = telegraf ? /:|\|/g : /:|\||@|,/g; // Replace reserved chars with underscores. return String(value).replace(blacklist, '_'); }
javascript
function sanitizeTags(value, telegraf) { const blacklist = telegraf ? /:|\|/g : /:|\||@|,/g; // Replace reserved chars with underscores. return String(value).replace(blacklist, '_'); }
[ "function", "sanitizeTags", "(", "value", ",", "telegraf", ")", "{", "const", "blacklist", "=", "telegraf", "?", "/", ":|\\|", "/", "g", ":", "/", ":|\\||@|,", "/", "g", ";", "// Replace reserved chars with underscores.", "return", "String", "(", "value", ")", ".", "replace", "(", "blacklist", ",", "'_'", ")", ";", "}" ]
Replace any characters that can't be sent on with an underscore
[ "Replace", "any", "characters", "that", "can", "t", "be", "sent", "on", "with", "an", "underscore" ]
8042839d9f51f68d319fcb9b6e6eee5f75e77423
https://github.com/brightcove/hot-shots/blob/8042839d9f51f68d319fcb9b6e6eee5f75e77423/lib/helpers.js#L6-L10
14,158
brightcove/hot-shots
lib/helpers.js
formatTags
function formatTags(tags, telegraf) { if (Array.isArray(tags)) { return tags; } else { return Object.keys(tags).map(key => { return `${sanitizeTags(key, telegraf)}:${sanitizeTags(tags[key], telegraf)}`; }); } }
javascript
function formatTags(tags, telegraf) { if (Array.isArray(tags)) { return tags; } else { return Object.keys(tags).map(key => { return `${sanitizeTags(key, telegraf)}:${sanitizeTags(tags[key], telegraf)}`; }); } }
[ "function", "formatTags", "(", "tags", ",", "telegraf", ")", "{", "if", "(", "Array", ".", "isArray", "(", "tags", ")", ")", "{", "return", "tags", ";", "}", "else", "{", "return", "Object", ".", "keys", "(", "tags", ")", ".", "map", "(", "key", "=>", "{", "return", "`", "${", "sanitizeTags", "(", "key", ",", "telegraf", ")", "}", "${", "sanitizeTags", "(", "tags", "[", "key", "]", ",", "telegraf", ")", "}", "`", ";", "}", ")", ";", "}", "}" ]
Format tags properly before sending on
[ "Format", "tags", "properly", "before", "sending", "on" ]
8042839d9f51f68d319fcb9b6e6eee5f75e77423
https://github.com/brightcove/hot-shots/blob/8042839d9f51f68d319fcb9b6e6eee5f75e77423/lib/helpers.js#L15-L24
14,159
brightcove/hot-shots
lib/helpers.js
formatDate
function formatDate(date) { let timestamp; if (date instanceof Date) { // Datadog expects seconds. timestamp = Math.round(date.getTime() / 1000); } else if (date instanceof Number) { // Make sure it is an integer, not a float. timestamp = Math.round(date); } return timestamp; }
javascript
function formatDate(date) { let timestamp; if (date instanceof Date) { // Datadog expects seconds. timestamp = Math.round(date.getTime() / 1000); } else if (date instanceof Number) { // Make sure it is an integer, not a float. timestamp = Math.round(date); } return timestamp; }
[ "function", "formatDate", "(", "date", ")", "{", "let", "timestamp", ";", "if", "(", "date", "instanceof", "Date", ")", "{", "// Datadog expects seconds.", "timestamp", "=", "Math", ".", "round", "(", "date", ".", "getTime", "(", ")", "/", "1000", ")", ";", "}", "else", "if", "(", "date", "instanceof", "Number", ")", "{", "// Make sure it is an integer, not a float.", "timestamp", "=", "Math", ".", "round", "(", "date", ")", ";", "}", "return", "timestamp", ";", "}" ]
Formats a date for use with DataDog
[ "Formats", "a", "date", "for", "use", "with", "DataDog" ]
8042839d9f51f68d319fcb9b6e6eee5f75e77423
https://github.com/brightcove/hot-shots/blob/8042839d9f51f68d319fcb9b6e6eee5f75e77423/lib/helpers.js#L63-L73
14,160
brightcove/hot-shots
lib/helpers.js
intToIP
function intToIP(int) { const part1 = int & 255; const part2 = ((int >> 8) & 255); const part3 = ((int >> 16) & 255); const part4 = ((int >> 24) & 255); return `${part4}.${part3}.${part2}.${part1}`; }
javascript
function intToIP(int) { const part1 = int & 255; const part2 = ((int >> 8) & 255); const part3 = ((int >> 16) & 255); const part4 = ((int >> 24) & 255); return `${part4}.${part3}.${part2}.${part1}`; }
[ "function", "intToIP", "(", "int", ")", "{", "const", "part1", "=", "int", "&", "255", ";", "const", "part2", "=", "(", "(", "int", ">>", "8", ")", "&", "255", ")", ";", "const", "part3", "=", "(", "(", "int", ">>", "16", ")", "&", "255", ")", ";", "const", "part4", "=", "(", "(", "int", ">>", "24", ")", "&", "255", ")", ";", "return", "`", "${", "part4", "}", "${", "part3", "}", "${", "part2", "}", "${", "part1", "}", "`", ";", "}" ]
Converts int to a string IP
[ "Converts", "int", "to", "a", "string", "IP" ]
8042839d9f51f68d319fcb9b6e6eee5f75e77423
https://github.com/brightcove/hot-shots/blob/8042839d9f51f68d319fcb9b6e6eee5f75e77423/lib/helpers.js#L78-L85
14,161
brightcove/hot-shots
lib/helpers.js
getDefaultRoute
function getDefaultRoute() { try { const fileContents = fs.readFileSync('/proc/net/route', 'utf8'); // eslint-disable-line no-sync const routes = fileContents.split('\n'); for (const routeIdx in routes) { const fields = routes[routeIdx].trim().split('\t'); if (fields[1] === '00000000') { const address = fields[2]; // Convert to little endian by splitting every 2 digits and reversing that list const littleEndianAddress = address.match(/.{2}/g).reverse().join(''); return intToIP(parseInt(littleEndianAddress, 16)); } } } catch (e) { console.error('Could not get default route from /proc/net/route'); } return null; }
javascript
function getDefaultRoute() { try { const fileContents = fs.readFileSync('/proc/net/route', 'utf8'); // eslint-disable-line no-sync const routes = fileContents.split('\n'); for (const routeIdx in routes) { const fields = routes[routeIdx].trim().split('\t'); if (fields[1] === '00000000') { const address = fields[2]; // Convert to little endian by splitting every 2 digits and reversing that list const littleEndianAddress = address.match(/.{2}/g).reverse().join(''); return intToIP(parseInt(littleEndianAddress, 16)); } } } catch (e) { console.error('Could not get default route from /proc/net/route'); } return null; }
[ "function", "getDefaultRoute", "(", ")", "{", "try", "{", "const", "fileContents", "=", "fs", ".", "readFileSync", "(", "'/proc/net/route'", ",", "'utf8'", ")", ";", "// eslint-disable-line no-sync", "const", "routes", "=", "fileContents", ".", "split", "(", "'\\n'", ")", ";", "for", "(", "const", "routeIdx", "in", "routes", ")", "{", "const", "fields", "=", "routes", "[", "routeIdx", "]", ".", "trim", "(", ")", ".", "split", "(", "'\\t'", ")", ";", "if", "(", "fields", "[", "1", "]", "===", "'00000000'", ")", "{", "const", "address", "=", "fields", "[", "2", "]", ";", "// Convert to little endian by splitting every 2 digits and reversing that list", "const", "littleEndianAddress", "=", "address", ".", "match", "(", "/", ".{2}", "/", "g", ")", ".", "reverse", "(", ")", ".", "join", "(", "''", ")", ";", "return", "intToIP", "(", "parseInt", "(", "littleEndianAddress", ",", "16", ")", ")", ";", "}", "}", "}", "catch", "(", "e", ")", "{", "console", ".", "error", "(", "'Could not get default route from /proc/net/route'", ")", ";", "}", "return", "null", ";", "}" ]
Returns the system default interface on Linux
[ "Returns", "the", "system", "default", "interface", "on", "Linux" ]
8042839d9f51f68d319fcb9b6e6eee5f75e77423
https://github.com/brightcove/hot-shots/blob/8042839d9f51f68d319fcb9b6e6eee5f75e77423/lib/helpers.js#L90-L107
14,162
brightcove/hot-shots
lib/statsd.js
onSend
function onSend(error, bytes) { completed += 1; if (calledback) { return; } if (error) { if (typeof callback === 'function') { calledback = true; callback(error); } else if (self.errorHandler) { calledback = true; self.errorHandler(error); } return; } if (bytes) { sentBytes += bytes; } if (completed === stat.length && typeof callback === 'function') { callback(null, sentBytes); } }
javascript
function onSend(error, bytes) { completed += 1; if (calledback) { return; } if (error) { if (typeof callback === 'function') { calledback = true; callback(error); } else if (self.errorHandler) { calledback = true; self.errorHandler(error); } return; } if (bytes) { sentBytes += bytes; } if (completed === stat.length && typeof callback === 'function') { callback(null, sentBytes); } }
[ "function", "onSend", "(", "error", ",", "bytes", ")", "{", "completed", "+=", "1", ";", "if", "(", "calledback", ")", "{", "return", ";", "}", "if", "(", "error", ")", "{", "if", "(", "typeof", "callback", "===", "'function'", ")", "{", "calledback", "=", "true", ";", "callback", "(", "error", ")", ";", "}", "else", "if", "(", "self", ".", "errorHandler", ")", "{", "calledback", "=", "true", ";", "self", ".", "errorHandler", "(", "error", ")", ";", "}", "return", ";", "}", "if", "(", "bytes", ")", "{", "sentBytes", "+=", "bytes", ";", "}", "if", "(", "completed", "===", "stat", ".", "length", "&&", "typeof", "callback", "===", "'function'", ")", "{", "callback", "(", "null", ",", "sentBytes", ")", ";", "}", "}" ]
Gets called once for each callback, when all callbacks return we will call back from the function @private
[ "Gets", "called", "once", "for", "each", "callback", "when", "all", "callbacks", "return", "we", "will", "call", "back", "from", "the", "function" ]
8042839d9f51f68d319fcb9b6e6eee5f75e77423
https://github.com/brightcove/hot-shots/blob/8042839d9f51f68d319fcb9b6e6eee5f75e77423/lib/statsd.js#L171-L195
14,163
sarriaroman/FabricPlugin
hooks/lib/utilities.js
getBuildGradlePath
function getBuildGradlePath() { var target = path.join("platforms", "android", "app", "build.gradle"); if (fs.existsSync(target)) { return target; } return path.join("platforms", "android", "build.gradle"); }
javascript
function getBuildGradlePath() { var target = path.join("platforms", "android", "app", "build.gradle"); if (fs.existsSync(target)) { return target; } return path.join("platforms", "android", "build.gradle"); }
[ "function", "getBuildGradlePath", "(", ")", "{", "var", "target", "=", "path", ".", "join", "(", "\"platforms\"", ",", "\"android\"", ",", "\"app\"", ",", "\"build.gradle\"", ")", ";", "if", "(", "fs", ".", "existsSync", "(", "target", ")", ")", "{", "return", "target", ";", "}", "return", "path", ".", "join", "(", "\"platforms\"", ",", "\"android\"", ",", "\"build.gradle\"", ")", ";", "}" ]
Used to get the path to the build.gradle file for the Android project. @returns {string} The path to the build.gradle file.
[ "Used", "to", "get", "the", "path", "to", "the", "build", ".", "gradle", "file", "for", "the", "Android", "project", "." ]
9363a290e071ccd262da9d718aaf5a10a284e144
https://github.com/sarriaroman/FabricPlugin/blob/9363a290e071ccd262da9d718aaf5a10a284e144/hooks/lib/utilities.js#L14-L21
14,164
sarriaroman/FabricPlugin
hooks/lib/utilities.js
function(platform) { var platformConfigPath = path.join("..", "..", "..", platform + ".json"); var platformConfig = require(platformConfigPath); var pluginId = this.getPluginId(); var apiKey = platformConfig.installed_plugins[pluginId].FABRIC_API_KEY; var apiSecret = platformConfig.installed_plugins[pluginId].FABRIC_API_SECRET; var config = { apiKey: apiKey, apiSecret: apiSecret }; return config; }
javascript
function(platform) { var platformConfigPath = path.join("..", "..", "..", platform + ".json"); var platformConfig = require(platformConfigPath); var pluginId = this.getPluginId(); var apiKey = platformConfig.installed_plugins[pluginId].FABRIC_API_KEY; var apiSecret = platformConfig.installed_plugins[pluginId].FABRIC_API_SECRET; var config = { apiKey: apiKey, apiSecret: apiSecret }; return config; }
[ "function", "(", "platform", ")", "{", "var", "platformConfigPath", "=", "path", ".", "join", "(", "\"..\"", ",", "\"..\"", ",", "\"..\"", ",", "platform", "+", "\".json\"", ")", ";", "var", "platformConfig", "=", "require", "(", "platformConfigPath", ")", ";", "var", "pluginId", "=", "this", ".", "getPluginId", "(", ")", ";", "var", "apiKey", "=", "platformConfig", ".", "installed_plugins", "[", "pluginId", "]", ".", "FABRIC_API_KEY", ";", "var", "apiSecret", "=", "platformConfig", ".", "installed_plugins", "[", "pluginId", "]", ".", "FABRIC_API_SECRET", ";", "var", "config", "=", "{", "apiKey", ":", "apiKey", ",", "apiSecret", ":", "apiSecret", "}", ";", "return", "config", ";", "}" ]
Used to get the plugin configuration for the given platform. The plugin configuration object will have the API and secret keys for the Fabric.io service that were specified when the plugin was installed. This configuration is obtained from, where "ios" is the platform name: platforms/ios/ios.json @param {string} platform - The platform to get plugin configuration for, either "ios" or "android". @returns {string} The path to the platform's plugin JSON configuration file.
[ "Used", "to", "get", "the", "plugin", "configuration", "for", "the", "given", "platform", "." ]
9363a290e071ccd262da9d718aaf5a10a284e144
https://github.com/sarriaroman/FabricPlugin/blob/9363a290e071ccd262da9d718aaf5a10a284e144/hooks/lib/utilities.js#L57-L74
14,165
abodelot/jquery.json-viewer
json-viewer/jquery.json-viewer.js
json2html
function json2html(json, options) { var html = ''; if (typeof json === 'string') { // Escape tags json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'); if (options.withLinks && isUrl(json)) { html += '<a href="' + json + '" class="json-string" target="_blank">' + json + '</a>'; } else { html += '<span class="json-string">"' + json + '"</span>'; } } else if (typeof json === 'number') { html += '<span class="json-literal">' + json + '</span>'; } else if (typeof json === 'boolean') { html += '<span class="json-literal">' + json + '</span>'; } else if (json === null) { html += '<span class="json-literal">null</span>'; } else if (json instanceof Array) { if (json.length > 0) { html += '[<ol class="json-array">'; for (var i = 0; i < json.length; ++i) { html += '<li>'; // Add toggle button if item is collapsable if (isCollapsable(json[i])) { html += '<a href class="json-toggle"></a>'; } html += json2html(json[i], options); // Add comma if item is not last if (i < json.length - 1) { html += ','; } html += '</li>'; } html += '</ol>]'; } else { html += '[]'; } } else if (typeof json === 'object') { var key_count = Object.keys(json).length; if (key_count > 0) { html += '{<ul class="json-dict">'; for (var key in json) { if (json.hasOwnProperty(key)) { html += '<li>'; var keyRepr = options.withQuotes ? '<span class="json-string">"' + key + '"</span>' : key; // Add toggle button if item is collapsable if (isCollapsable(json[key])) { html += '<a href class="json-toggle">' + keyRepr + '</a>'; } else { html += keyRepr; } html += ': ' + json2html(json[key], options); // Add comma if item is not last if (--key_count > 0) { html += ','; } html += '</li>'; } } html += '</ul>}'; } else { html += '{}'; } } return html; }
javascript
function json2html(json, options) { var html = ''; if (typeof json === 'string') { // Escape tags json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'); if (options.withLinks && isUrl(json)) { html += '<a href="' + json + '" class="json-string" target="_blank">' + json + '</a>'; } else { html += '<span class="json-string">"' + json + '"</span>'; } } else if (typeof json === 'number') { html += '<span class="json-literal">' + json + '</span>'; } else if (typeof json === 'boolean') { html += '<span class="json-literal">' + json + '</span>'; } else if (json === null) { html += '<span class="json-literal">null</span>'; } else if (json instanceof Array) { if (json.length > 0) { html += '[<ol class="json-array">'; for (var i = 0; i < json.length; ++i) { html += '<li>'; // Add toggle button if item is collapsable if (isCollapsable(json[i])) { html += '<a href class="json-toggle"></a>'; } html += json2html(json[i], options); // Add comma if item is not last if (i < json.length - 1) { html += ','; } html += '</li>'; } html += '</ol>]'; } else { html += '[]'; } } else if (typeof json === 'object') { var key_count = Object.keys(json).length; if (key_count > 0) { html += '{<ul class="json-dict">'; for (var key in json) { if (json.hasOwnProperty(key)) { html += '<li>'; var keyRepr = options.withQuotes ? '<span class="json-string">"' + key + '"</span>' : key; // Add toggle button if item is collapsable if (isCollapsable(json[key])) { html += '<a href class="json-toggle">' + keyRepr + '</a>'; } else { html += keyRepr; } html += ': ' + json2html(json[key], options); // Add comma if item is not last if (--key_count > 0) { html += ','; } html += '</li>'; } } html += '</ul>}'; } else { html += '{}'; } } return html; }
[ "function", "json2html", "(", "json", ",", "options", ")", "{", "var", "html", "=", "''", ";", "if", "(", "typeof", "json", "===", "'string'", ")", "{", "// Escape tags", "json", "=", "json", ".", "replace", "(", "/", "&", "/", "g", ",", "'&amp;'", ")", ".", "replace", "(", "/", "<", "/", "g", ",", "'&lt;'", ")", ".", "replace", "(", "/", ">", "/", "g", ",", "'&gt;'", ")", ";", "if", "(", "options", ".", "withLinks", "&&", "isUrl", "(", "json", ")", ")", "{", "html", "+=", "'<a href=\"'", "+", "json", "+", "'\" class=\"json-string\" target=\"_blank\">'", "+", "json", "+", "'</a>'", ";", "}", "else", "{", "html", "+=", "'<span class=\"json-string\">\"'", "+", "json", "+", "'\"</span>'", ";", "}", "}", "else", "if", "(", "typeof", "json", "===", "'number'", ")", "{", "html", "+=", "'<span class=\"json-literal\">'", "+", "json", "+", "'</span>'", ";", "}", "else", "if", "(", "typeof", "json", "===", "'boolean'", ")", "{", "html", "+=", "'<span class=\"json-literal\">'", "+", "json", "+", "'</span>'", ";", "}", "else", "if", "(", "json", "===", "null", ")", "{", "html", "+=", "'<span class=\"json-literal\">null</span>'", ";", "}", "else", "if", "(", "json", "instanceof", "Array", ")", "{", "if", "(", "json", ".", "length", ">", "0", ")", "{", "html", "+=", "'[<ol class=\"json-array\">'", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "json", ".", "length", ";", "++", "i", ")", "{", "html", "+=", "'<li>'", ";", "// Add toggle button if item is collapsable", "if", "(", "isCollapsable", "(", "json", "[", "i", "]", ")", ")", "{", "html", "+=", "'<a href class=\"json-toggle\"></a>'", ";", "}", "html", "+=", "json2html", "(", "json", "[", "i", "]", ",", "options", ")", ";", "// Add comma if item is not last", "if", "(", "i", "<", "json", ".", "length", "-", "1", ")", "{", "html", "+=", "','", ";", "}", "html", "+=", "'</li>'", ";", "}", "html", "+=", "'</ol>]'", ";", "}", "else", "{", "html", "+=", "'[]'", ";", "}", "}", "else", "if", "(", "typeof", "json", "===", "'object'", ")", "{", "var", "key_count", "=", "Object", ".", "keys", "(", "json", ")", ".", "length", ";", "if", "(", "key_count", ">", "0", ")", "{", "html", "+=", "'{<ul class=\"json-dict\">'", ";", "for", "(", "var", "key", "in", "json", ")", "{", "if", "(", "json", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "html", "+=", "'<li>'", ";", "var", "keyRepr", "=", "options", ".", "withQuotes", "?", "'<span class=\"json-string\">\"'", "+", "key", "+", "'\"</span>'", ":", "key", ";", "// Add toggle button if item is collapsable", "if", "(", "isCollapsable", "(", "json", "[", "key", "]", ")", ")", "{", "html", "+=", "'<a href class=\"json-toggle\">'", "+", "keyRepr", "+", "'</a>'", ";", "}", "else", "{", "html", "+=", "keyRepr", ";", "}", "html", "+=", "': '", "+", "json2html", "(", "json", "[", "key", "]", ",", "options", ")", ";", "// Add comma if item is not last", "if", "(", "--", "key_count", ">", "0", ")", "{", "html", "+=", "','", ";", "}", "html", "+=", "'</li>'", ";", "}", "}", "html", "+=", "'</ul>}'", ";", "}", "else", "{", "html", "+=", "'{}'", ";", "}", "}", "return", "html", ";", "}" ]
Transform a json object into html representation @return string
[ "Transform", "a", "json", "object", "into", "html", "representation" ]
72ded3f50ffbed28e304ad4fc761b2f3ac562506
https://github.com/abodelot/jquery.json-viewer/blob/72ded3f50ffbed28e304ad4fc761b2f3ac562506/json-viewer/jquery.json-viewer.js#L29-L94
14,166
FormidableLabs/builder
lib/config.js
function () { return _.map([].concat(this.pkgs, this.devPkgs), function (pkg) { return path.join(pkg.path, "node_modules/.bin"); }); }
javascript
function () { return _.map([].concat(this.pkgs, this.devPkgs), function (pkg) { return path.join(pkg.path, "node_modules/.bin"); }); }
[ "function", "(", ")", "{", "return", "_", ".", "map", "(", "[", "]", ".", "concat", "(", "this", ".", "pkgs", ",", "this", ".", "devPkgs", ")", ",", "function", "(", "pkg", ")", "{", "return", "path", ".", "join", "(", "pkg", ".", "path", ",", "\"node_modules/.bin\"", ")", ";", "}", ")", ";", "}" ]
Return `.bin` paths for archetypes in configured order. @returns {Array} Archetype bin paths
[ "Return", ".", "bin", "paths", "for", "archetypes", "in", "configured", "order", "." ]
7dc928ff3adf76f810f11358058cc32e27fd3d1c
https://github.com/FormidableLabs/builder/blob/7dc928ff3adf76f810f11358058cc32e27fd3d1c/lib/config.js#L307-L311
14,167
FormidableLabs/builder
lib/config.js
function () { var pkgs = this.pkgs; var configNames = _.chain(pkgs) .map(function (pkg) { return _.keys(pkg.config); }) .flatten() .uniq() .value(); // Take "first" config value in arrays as "winning" value. return _.chain(configNames) .map(function (name) { return [name, _.find(pkgs, function (pkg) { return _.has(pkg.config, name); }).config[name]]; }) // Object. .reduce(function (memo, pair) { memo[pair[0]] = pair[1]; return memo; }, {}) .value(); }
javascript
function () { var pkgs = this.pkgs; var configNames = _.chain(pkgs) .map(function (pkg) { return _.keys(pkg.config); }) .flatten() .uniq() .value(); // Take "first" config value in arrays as "winning" value. return _.chain(configNames) .map(function (name) { return [name, _.find(pkgs, function (pkg) { return _.has(pkg.config, name); }).config[name]]; }) // Object. .reduce(function (memo, pair) { memo[pair[0]] = pair[1]; return memo; }, {}) .value(); }
[ "function", "(", ")", "{", "var", "pkgs", "=", "this", ".", "pkgs", ";", "var", "configNames", "=", "_", ".", "chain", "(", "pkgs", ")", ".", "map", "(", "function", "(", "pkg", ")", "{", "return", "_", ".", "keys", "(", "pkg", ".", "config", ")", ";", "}", ")", ".", "flatten", "(", ")", ".", "uniq", "(", ")", ".", "value", "(", ")", ";", "// Take \"first\" config value in arrays as \"winning\" value.", "return", "_", ".", "chain", "(", "configNames", ")", ".", "map", "(", "function", "(", "name", ")", "{", "return", "[", "name", ",", "_", ".", "find", "(", "pkgs", ",", "function", "(", "pkg", ")", "{", "return", "_", ".", "has", "(", "pkg", ".", "config", ",", "name", ")", ";", "}", ")", ".", "config", "[", "name", "]", "]", ";", "}", ")", "// Object.", ".", "reduce", "(", "function", "(", "memo", ",", "pair", ")", "{", "memo", "[", "pair", "[", "0", "]", "]", "=", "pair", "[", "1", "]", ";", "return", "memo", ";", "}", ",", "{", "}", ")", ".", "value", "(", ")", ";", "}" ]
Return object of resolved package.json config fields. Resolves in order of "root wins", then in reverse archetype order. @returns {Object} environment object.
[ "Return", "object", "of", "resolved", "package", ".", "json", "config", "fields", "." ]
7dc928ff3adf76f810f11358058cc32e27fd3d1c
https://github.com/FormidableLabs/builder/blob/7dc928ff3adf76f810f11358058cc32e27fd3d1c/lib/config.js#L335-L356
14,168
FormidableLabs/builder
lib/args.js
function (flagKey) { var flags = _.isUndefined(flagKey) ? FLAGS.general : FLAGS[flagKey]; return !flags ? "" : _.map(flags, function (val, key) { return chalk.cyan("--" + key) + ": " + val.desc; }).join("\n\n "); }
javascript
function (flagKey) { var flags = _.isUndefined(flagKey) ? FLAGS.general : FLAGS[flagKey]; return !flags ? "" : _.map(flags, function (val, key) { return chalk.cyan("--" + key) + ": " + val.desc; }).join("\n\n "); }
[ "function", "(", "flagKey", ")", "{", "var", "flags", "=", "_", ".", "isUndefined", "(", "flagKey", ")", "?", "FLAGS", ".", "general", ":", "FLAGS", "[", "flagKey", "]", ";", "return", "!", "flags", "?", "\"\"", ":", "_", ".", "map", "(", "flags", ",", "function", "(", "val", ",", "key", ")", "{", "return", "chalk", ".", "cyan", "(", "\"--\"", "+", "key", ")", "+", "\": \"", "+", "val", ".", "desc", ";", "}", ")", ".", "join", "(", "\"\\n\\n \"", ")", ";", "}" ]
Retrieve help. @param {String} flagKey Key of flags to return or `undefined` for general @returns {String} Help string
[ "Retrieve", "help", "." ]
7dc928ff3adf76f810f11358058cc32e27fd3d1c
https://github.com/FormidableLabs/builder/blob/7dc928ff3adf76f810f11358058cc32e27fd3d1c/lib/args.js#L138-L144
14,169
eclipse/orion.client
bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js
function(url, org, space) { var targetObject = { 'Url': url }; if (org) targetObject.Org = org; if (space) targetObject.Space = space; return this._xhrV1("POST", require.toUrl("cfapi/target"), targetObject); }
javascript
function(url, org, space) { var targetObject = { 'Url': url }; if (org) targetObject.Org = org; if (space) targetObject.Space = space; return this._xhrV1("POST", require.toUrl("cfapi/target"), targetObject); }
[ "function", "(", "url", ",", "org", ",", "space", ")", "{", "var", "targetObject", "=", "{", "'Url'", ":", "url", "}", ";", "if", "(", "org", ")", "targetObject", ".", "Org", "=", "org", ";", "if", "(", "space", ")", "targetObject", ".", "Space", "=", "space", ";", "return", "this", ".", "_xhrV1", "(", "\"POST\"", ",", "require", ".", "toUrl", "(", "\"cfapi/target\"", ")", ",", "targetObject", ")", ";", "}" ]
Target CF v2 operations
[ "Target", "CF", "v2", "operations" ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js#L100-L108
14,170
eclipse/orion.client
bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js
function(target, name, contentLocation, manifest, packager, instrumentation) { var pushReq = {}; if (name) pushReq.Name = name; if (contentLocation) pushReq.ContentLocation = contentLocation; if (target) pushReq.Target = target; if(manifest) pushReq.Manifest = manifest; if(packager) pushReq.Packager = packager; if(instrumentation) pushReq.Instrumentation = instrumentation; return this._xhrV1("PUT", require.toUrl("cfapi/apps"), pushReq); }
javascript
function(target, name, contentLocation, manifest, packager, instrumentation) { var pushReq = {}; if (name) pushReq.Name = name; if (contentLocation) pushReq.ContentLocation = contentLocation; if (target) pushReq.Target = target; if(manifest) pushReq.Manifest = manifest; if(packager) pushReq.Packager = packager; if(instrumentation) pushReq.Instrumentation = instrumentation; return this._xhrV1("PUT", require.toUrl("cfapi/apps"), pushReq); }
[ "function", "(", "target", ",", "name", ",", "contentLocation", ",", "manifest", ",", "packager", ",", "instrumentation", ")", "{", "var", "pushReq", "=", "{", "}", ";", "if", "(", "name", ")", "pushReq", ".", "Name", "=", "name", ";", "if", "(", "contentLocation", ")", "pushReq", ".", "ContentLocation", "=", "contentLocation", ";", "if", "(", "target", ")", "pushReq", ".", "Target", "=", "target", ";", "if", "(", "manifest", ")", "pushReq", ".", "Manifest", "=", "manifest", ";", "if", "(", "packager", ")", "pushReq", ".", "Packager", "=", "packager", ";", "if", "(", "instrumentation", ")", "pushReq", ".", "Instrumentation", "=", "instrumentation", ";", "return", "this", ".", "_xhrV1", "(", "\"PUT\"", ",", "require", ".", "toUrl", "(", "\"cfapi/apps\"", ")", ",", "pushReq", ")", ";", "}" ]
Apps CF v2 operations
[ "Apps", "CF", "v2", "operations" ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js#L154-L176
14,171
eclipse/orion.client
bundles/org.eclipse.orion.client.editor/web/orion/editor/textModel.js
TextModel
function TextModel(text, lineDelimiter) { this._lastLineIndex = -1; this._text = [""]; this._lineOffsets = [0]; this.setText(text); this.setLineDelimiter(lineDelimiter); }
javascript
function TextModel(text, lineDelimiter) { this._lastLineIndex = -1; this._text = [""]; this._lineOffsets = [0]; this.setText(text); this.setLineDelimiter(lineDelimiter); }
[ "function", "TextModel", "(", "text", ",", "lineDelimiter", ")", "{", "this", ".", "_lastLineIndex", "=", "-", "1", ";", "this", ".", "_text", "=", "[", "\"\"", "]", ";", "this", ".", "_lineOffsets", "=", "[", "0", "]", ";", "this", ".", "setText", "(", "text", ")", ";", "this", ".", "setLineDelimiter", "(", "lineDelimiter", ")", ";", "}" ]
Constructs a new TextModel with the given text and default line delimiter. @param {String} [text=""] the text that the model will store @param {String} [lineDelimiter=platform delimiter] the line delimiter used when inserting new lines to the model. @name orion.editor.TextModel @class The TextModel is an interface that provides text for the view. Applications may implement the TextModel interface to provide a custom store for the view content. The view interacts with its text model in order to access and update the text that is being displayed and edited in the view. This is the default implementation. <p> <b>See:</b><br/> {@link orion.editor.TextView}<br/> {@link orion.editor.TextView#setModel} </p> @borrows orion.editor.EventTarget#addEventListener as #addEventListener @borrows orion.editor.EventTarget#removeEventListener as #removeEventListener @borrows orion.editor.EventTarget#dispatchEvent as #dispatchEvent
[ "Constructs", "a", "new", "TextModel", "with", "the", "given", "text", "and", "default", "line", "delimiter", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/textModel.js#L37-L43
14,172
eclipse/orion.client
bundles/org.eclipse.orion.client.editor/web/orion/editor/textModel.js
function() { var count = 0; for (var i = 0; i<this._text.length; i++) { count += this._text[i].length; } return count; }
javascript
function() { var count = 0; for (var i = 0; i<this._text.length; i++) { count += this._text[i].length; } return count; }
[ "function", "(", ")", "{", "var", "count", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "_text", ".", "length", ";", "i", "++", ")", "{", "count", "+=", "this", ".", "_text", "[", "i", "]", ".", "length", ";", "}", "return", "count", ";", "}" ]
Returns the number of characters in the model. @returns {Number} the number of characters in the model.
[ "Returns", "the", "number", "of", "characters", "in", "the", "model", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/textModel.js#L231-L237
14,173
eclipse/orion.client
releng/org.eclipse.orion.client.releng/builder/scripts/helpers.js
getBundles
function getBundles(buildObj) { var _self = self; var bundles = (buildObj.bundles || []); return bundles.map(function(bundle) { bundle = project.replaceProperties(bundle); var dir = project.resolveFile(bundle + Packages.java.io.File.separator + "web"); if (!dir.exists() || !dir.isDirectory()) { _self.log("Bundle folder " + dir.getPath() + " does not exist", Project.MSG_WARN); return null; } _self.log("Found bundle web folder: " + dir.getPath()); return { bundle: bundle, web: dir }; }).filter(function(b) { return !!b; }); }
javascript
function getBundles(buildObj) { var _self = self; var bundles = (buildObj.bundles || []); return bundles.map(function(bundle) { bundle = project.replaceProperties(bundle); var dir = project.resolveFile(bundle + Packages.java.io.File.separator + "web"); if (!dir.exists() || !dir.isDirectory()) { _self.log("Bundle folder " + dir.getPath() + " does not exist", Project.MSG_WARN); return null; } _self.log("Found bundle web folder: " + dir.getPath()); return { bundle: bundle, web: dir }; }).filter(function(b) { return !!b; }); }
[ "function", "getBundles", "(", "buildObj", ")", "{", "var", "_self", "=", "self", ";", "var", "bundles", "=", "(", "buildObj", ".", "bundles", "||", "[", "]", ")", ";", "return", "bundles", ".", "map", "(", "function", "(", "bundle", ")", "{", "bundle", "=", "project", ".", "replaceProperties", "(", "bundle", ")", ";", "var", "dir", "=", "project", ".", "resolveFile", "(", "bundle", "+", "Packages", ".", "java", ".", "io", ".", "File", ".", "separator", "+", "\"web\"", ")", ";", "if", "(", "!", "dir", ".", "exists", "(", ")", "||", "!", "dir", ".", "isDirectory", "(", ")", ")", "{", "_self", ".", "log", "(", "\"Bundle folder \"", "+", "dir", ".", "getPath", "(", ")", "+", "\" does not exist\"", ",", "Project", ".", "MSG_WARN", ")", ";", "return", "null", ";", "}", "_self", ".", "log", "(", "\"Found bundle web folder: \"", "+", "dir", ".", "getPath", "(", ")", ")", ";", "return", "{", "bundle", ":", "bundle", ",", "web", ":", "dir", "}", ";", "}", ")", ".", "filter", "(", "function", "(", "b", ")", "{", "return", "!", "!", "b", ";", "}", ")", ";", "}" ]
Returns bundle info from the build config. @param {Object} buildObj The build config object @returns { name: string, web: java.io.File }[] Array of bundle info objects.
[ "Returns", "bundle", "info", "from", "the", "build", "config", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/releng/org.eclipse.orion.client.releng/builder/scripts/helpers.js#L97-L112
14,174
eclipse/orion.client
bundles/org.eclipse.orion.client.editor/web/orion/editor/AsyncStyler.js
function() { if (this.textView) { this.textView.removeEventListener("ModelChanging", this.listener.onModelChanging); this.textView.removeEventListener("ModelChanged", this.listener.onModelChanged); this.textView.removeEventListener("Destroy", this.listener.onDestroy); this.textView.removeEventListener("LineStyle", this.listener.onLineStyle); this.textView = null; } if (this.services) { for (var i = 0; i < this.services.length; i++) { this.removeServiceListener(this.services[i]); } this.services = null; } if (this.serviceRegistry) { this.serviceRegistry.removeEventListener("registered", this.listener.onServiceAdded); this.serviceRegistry.removeEventListener("unregistering", this.listener.onServiceRemoved); this.serviceRegistry = null; } this.listener = null; this.lineStyles = null; }
javascript
function() { if (this.textView) { this.textView.removeEventListener("ModelChanging", this.listener.onModelChanging); this.textView.removeEventListener("ModelChanged", this.listener.onModelChanged); this.textView.removeEventListener("Destroy", this.listener.onDestroy); this.textView.removeEventListener("LineStyle", this.listener.onLineStyle); this.textView = null; } if (this.services) { for (var i = 0; i < this.services.length; i++) { this.removeServiceListener(this.services[i]); } this.services = null; } if (this.serviceRegistry) { this.serviceRegistry.removeEventListener("registered", this.listener.onServiceAdded); this.serviceRegistry.removeEventListener("unregistering", this.listener.onServiceRemoved); this.serviceRegistry = null; } this.listener = null; this.lineStyles = null; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "textView", ")", "{", "this", ".", "textView", ".", "removeEventListener", "(", "\"ModelChanging\"", ",", "this", ".", "listener", ".", "onModelChanging", ")", ";", "this", ".", "textView", ".", "removeEventListener", "(", "\"ModelChanged\"", ",", "this", ".", "listener", ".", "onModelChanged", ")", ";", "this", ".", "textView", ".", "removeEventListener", "(", "\"Destroy\"", ",", "this", ".", "listener", ".", "onDestroy", ")", ";", "this", ".", "textView", ".", "removeEventListener", "(", "\"LineStyle\"", ",", "this", ".", "listener", ".", "onLineStyle", ")", ";", "this", ".", "textView", "=", "null", ";", "}", "if", "(", "this", ".", "services", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "services", ".", "length", ";", "i", "++", ")", "{", "this", ".", "removeServiceListener", "(", "this", ".", "services", "[", "i", "]", ")", ";", "}", "this", ".", "services", "=", "null", ";", "}", "if", "(", "this", ".", "serviceRegistry", ")", "{", "this", ".", "serviceRegistry", ".", "removeEventListener", "(", "\"registered\"", ",", "this", ".", "listener", ".", "onServiceAdded", ")", ";", "this", ".", "serviceRegistry", ".", "removeEventListener", "(", "\"unregistering\"", ",", "this", ".", "listener", ".", "onServiceRemoved", ")", ";", "this", ".", "serviceRegistry", "=", "null", ";", "}", "this", ".", "listener", "=", "null", ";", "this", ".", "lineStyles", "=", "null", ";", "}" ]
Deactivates this styler and removes any listeners it registered.
[ "Deactivates", "this", "styler", "and", "removes", "any", "listeners", "it", "registered", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/AsyncStyler.js#L105-L126
14,175
eclipse/orion.client
modules/orionode/lib/api.js
sendStatus
function sendStatus(code, res){ try{ if (httpCodeMapping) { code = mapHttpStatusCode(code); } addStrictTransportHeaders(res); setResponseNoCache(res); return res.sendStatus(code); }catch(err){ logger.error(res.req.originalUrl , err.message); throw err; } }
javascript
function sendStatus(code, res){ try{ if (httpCodeMapping) { code = mapHttpStatusCode(code); } addStrictTransportHeaders(res); setResponseNoCache(res); return res.sendStatus(code); }catch(err){ logger.error(res.req.originalUrl , err.message); throw err; } }
[ "function", "sendStatus", "(", "code", ",", "res", ")", "{", "try", "{", "if", "(", "httpCodeMapping", ")", "{", "code", "=", "mapHttpStatusCode", "(", "code", ")", ";", "}", "addStrictTransportHeaders", "(", "res", ")", ";", "setResponseNoCache", "(", "res", ")", ";", "return", "res", ".", "sendStatus", "(", "code", ")", ";", "}", "catch", "(", "err", ")", "{", "logger", ".", "error", "(", "res", ".", "req", ".", "originalUrl", ",", "err", ".", "message", ")", ";", "throw", "err", ";", "}", "}" ]
Helper for send a status response @param {Number} code @param {HttpResponse} res
[ "Helper", "for", "send", "a", "status", "response" ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/api.js#L72-L84
14,176
eclipse/orion.client
modules/orionode/lib/api.js
writeResponse
function writeResponse(code, res, headers, body, needEncodeLocation, noCachedStringRes) { try{ if (res.headerSent) { logger.error("header Sent:", res.req.method, res.req.originalUrl); } if (typeof code === 'number') { if (httpCodeMapping) { code = mapHttpStatusCode(code); } res.status(code); } if (headers && typeof headers === 'object') { Object.keys(headers).forEach(function(header) { var value = headers[header]; res.setHeader( header.replace(REGEX_CRLF, ""), typeof value === "string" ? value.replace(REGEX_CRLF, "") : value ); }); } addStrictTransportHeaders(res); if (typeof body !== 'undefined') { if (typeof body === 'object') { needEncodeLocation && encodeLocation(body); setResponseNoCache(res); return res.json(body); } if (noCachedStringRes){ setResponseNoCache(res); } res.send(body); } else { setResponseNoCache(res); res.end(); } } catch(err) { logger.error(res.req.originalUrl, err.message); throw err; } }
javascript
function writeResponse(code, res, headers, body, needEncodeLocation, noCachedStringRes) { try{ if (res.headerSent) { logger.error("header Sent:", res.req.method, res.req.originalUrl); } if (typeof code === 'number') { if (httpCodeMapping) { code = mapHttpStatusCode(code); } res.status(code); } if (headers && typeof headers === 'object') { Object.keys(headers).forEach(function(header) { var value = headers[header]; res.setHeader( header.replace(REGEX_CRLF, ""), typeof value === "string" ? value.replace(REGEX_CRLF, "") : value ); }); } addStrictTransportHeaders(res); if (typeof body !== 'undefined') { if (typeof body === 'object') { needEncodeLocation && encodeLocation(body); setResponseNoCache(res); return res.json(body); } if (noCachedStringRes){ setResponseNoCache(res); } res.send(body); } else { setResponseNoCache(res); res.end(); } } catch(err) { logger.error(res.req.originalUrl, err.message); throw err; } }
[ "function", "writeResponse", "(", "code", ",", "res", ",", "headers", ",", "body", ",", "needEncodeLocation", ",", "noCachedStringRes", ")", "{", "try", "{", "if", "(", "res", ".", "headerSent", ")", "{", "logger", ".", "error", "(", "\"header Sent:\"", ",", "res", ".", "req", ".", "method", ",", "res", ".", "req", ".", "originalUrl", ")", ";", "}", "if", "(", "typeof", "code", "===", "'number'", ")", "{", "if", "(", "httpCodeMapping", ")", "{", "code", "=", "mapHttpStatusCode", "(", "code", ")", ";", "}", "res", ".", "status", "(", "code", ")", ";", "}", "if", "(", "headers", "&&", "typeof", "headers", "===", "'object'", ")", "{", "Object", ".", "keys", "(", "headers", ")", ".", "forEach", "(", "function", "(", "header", ")", "{", "var", "value", "=", "headers", "[", "header", "]", ";", "res", ".", "setHeader", "(", "header", ".", "replace", "(", "REGEX_CRLF", ",", "\"\"", ")", ",", "typeof", "value", "===", "\"string\"", "?", "value", ".", "replace", "(", "REGEX_CRLF", ",", "\"\"", ")", ":", "value", ")", ";", "}", ")", ";", "}", "addStrictTransportHeaders", "(", "res", ")", ";", "if", "(", "typeof", "body", "!==", "'undefined'", ")", "{", "if", "(", "typeof", "body", "===", "'object'", ")", "{", "needEncodeLocation", "&&", "encodeLocation", "(", "body", ")", ";", "setResponseNoCache", "(", "res", ")", ";", "return", "res", ".", "json", "(", "body", ")", ";", "}", "if", "(", "noCachedStringRes", ")", "{", "setResponseNoCache", "(", "res", ")", ";", "}", "res", ".", "send", "(", "body", ")", ";", "}", "else", "{", "setResponseNoCache", "(", "res", ")", ";", "res", ".", "end", "(", ")", ";", "}", "}", "catch", "(", "err", ")", "{", "logger", ".", "error", "(", "res", ".", "req", ".", "originalUrl", ",", "err", ".", "message", ")", ";", "throw", "err", ";", "}", "}" ]
Helper for writing a JSON response. @param {Number} code @param {HttpResponse} res @param {Object} [headers] @param {Object|String} [body] If Object, response will be JSON. If string, response will be text/plain. @param {Boolean} needEncodeLocation @param {Boolean} noCachedStringRes,set to true in case if the response is text/plain, but still need nocache cache-control
[ "Helper", "for", "writing", "a", "JSON", "response", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/api.js#L95-L134
14,177
eclipse/orion.client
modules/orionode/lib/api.js
writeError
function writeError(code, res, msg) { try{ if (res.headerSent) { logger.error("header Sent:", res.req.method, res.req.originalUrl); } if (httpCodeMapping) { code = mapHttpStatusCode(code); } msg = msg instanceof Error ? msg.message : msg; addStrictTransportHeaders(res); setResponseNoCache(res); if (typeof msg === 'string') { var err = JSON.stringify({Severity: "Error", Message: msg}); res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Length', err.length); res.writeHead(code); res.end(err); } else { res.writeHead(code); res.end(); } }catch(err){ logger.error(res.req.originalUrl , err.message); throw err; } }
javascript
function writeError(code, res, msg) { try{ if (res.headerSent) { logger.error("header Sent:", res.req.method, res.req.originalUrl); } if (httpCodeMapping) { code = mapHttpStatusCode(code); } msg = msg instanceof Error ? msg.message : msg; addStrictTransportHeaders(res); setResponseNoCache(res); if (typeof msg === 'string') { var err = JSON.stringify({Severity: "Error", Message: msg}); res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Length', err.length); res.writeHead(code); res.end(err); } else { res.writeHead(code); res.end(); } }catch(err){ logger.error(res.req.originalUrl , err.message); throw err; } }
[ "function", "writeError", "(", "code", ",", "res", ",", "msg", ")", "{", "try", "{", "if", "(", "res", ".", "headerSent", ")", "{", "logger", ".", "error", "(", "\"header Sent:\"", ",", "res", ".", "req", ".", "method", ",", "res", ".", "req", ".", "originalUrl", ")", ";", "}", "if", "(", "httpCodeMapping", ")", "{", "code", "=", "mapHttpStatusCode", "(", "code", ")", ";", "}", "msg", "=", "msg", "instanceof", "Error", "?", "msg", ".", "message", ":", "msg", ";", "addStrictTransportHeaders", "(", "res", ")", ";", "setResponseNoCache", "(", "res", ")", ";", "if", "(", "typeof", "msg", "===", "'string'", ")", "{", "var", "err", "=", "JSON", ".", "stringify", "(", "{", "Severity", ":", "\"Error\"", ",", "Message", ":", "msg", "}", ")", ";", "res", ".", "setHeader", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "res", ".", "setHeader", "(", "'Content-Length'", ",", "err", ".", "length", ")", ";", "res", ".", "writeHead", "(", "code", ")", ";", "res", ".", "end", "(", "err", ")", ";", "}", "else", "{", "res", ".", "writeHead", "(", "code", ")", ";", "res", ".", "end", "(", ")", ";", "}", "}", "catch", "(", "err", ")", "{", "logger", ".", "error", "(", "res", ".", "req", ".", "originalUrl", ",", "err", ".", "message", ")", ";", "throw", "err", ";", "}", "}" ]
Helper for writing an error JSON response. @param {Number} code @param {HttpResponse} res @param {String|Error} [msg]
[ "Helper", "for", "writing", "an", "error", "JSON", "response", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/api.js#L142-L167
14,178
eclipse/orion.client
bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js
function(annotationModel, start, end) { var iter = annotationModel.getAnnotations(start, end); var annotation, annotations = []; while (iter.hasNext()) { annotation = iter.next(); if (!this.isAnnotationTypeVisible(annotation.type)) { continue; } annotations.push(annotation); } var self = this; annotations.sort(function(a, b) { return self.getAnnotationTypePriority(a.type) - self.getAnnotationTypePriority(b.type); }); return annotations; }
javascript
function(annotationModel, start, end) { var iter = annotationModel.getAnnotations(start, end); var annotation, annotations = []; while (iter.hasNext()) { annotation = iter.next(); if (!this.isAnnotationTypeVisible(annotation.type)) { continue; } annotations.push(annotation); } var self = this; annotations.sort(function(a, b) { return self.getAnnotationTypePriority(a.type) - self.getAnnotationTypePriority(b.type); }); return annotations; }
[ "function", "(", "annotationModel", ",", "start", ",", "end", ")", "{", "var", "iter", "=", "annotationModel", ".", "getAnnotations", "(", "start", ",", "end", ")", ";", "var", "annotation", ",", "annotations", "=", "[", "]", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "annotation", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "!", "this", ".", "isAnnotationTypeVisible", "(", "annotation", ".", "type", ")", ")", "{", "continue", ";", "}", "annotations", ".", "push", "(", "annotation", ")", ";", "}", "var", "self", "=", "this", ";", "annotations", ".", "sort", "(", "function", "(", "a", ",", "b", ")", "{", "return", "self", ".", "getAnnotationTypePriority", "(", "a", ".", "type", ")", "-", "self", ".", "getAnnotationTypePriority", "(", "b", ".", "type", ")", ";", "}", ")", ";", "return", "annotations", ";", "}" ]
Returns an array of annotations in the specified annotation model for the given range of text sorted by type. @param {orion.editor.AnnotationModel} annotationModel the annotation model. @param {Number} start the start offset of the range. @param {Number} end the end offset of the range. @return {orion.editor.Annotation[]} an annotation array.
[ "Returns", "an", "array", "of", "annotations", "in", "the", "specified", "annotation", "model", "for", "the", "given", "range", "of", "text", "sorted", "by", "type", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js#L431-L444
14,179
eclipse/orion.client
bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js
function(type) { if (this.getAnnotationTypePriority(type) === 0) return false; return !this._visibleAnnotationTypes || this._visibleAnnotationTypes[type] === undefined || this._visibleAnnotationTypes[type] === true; }
javascript
function(type) { if (this.getAnnotationTypePriority(type) === 0) return false; return !this._visibleAnnotationTypes || this._visibleAnnotationTypes[type] === undefined || this._visibleAnnotationTypes[type] === true; }
[ "function", "(", "type", ")", "{", "if", "(", "this", ".", "getAnnotationTypePriority", "(", "type", ")", "===", "0", ")", "return", "false", ";", "return", "!", "this", ".", "_visibleAnnotationTypes", "||", "this", ".", "_visibleAnnotationTypes", "[", "type", "]", "===", "undefined", "||", "this", ".", "_visibleAnnotationTypes", "[", "type", "]", "===", "true", ";", "}" ]
Returns whether the receiver shows annotations of the specified type. @param {Object} type the annotation type @returns {Boolean} whether the specified annotation type is shown @see orion.editor.AnnotationTypeList#addAnnotationType @see orion.editor.AnnotationTypeList#removeAnnotationType
[ "Returns", "whether", "the", "receiver", "shows", "annotations", "of", "the", "specified", "type", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js#L454-L457
14,180
eclipse/orion.client
bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js
function(type, visible) { if (typeof type === "object") { this._visibleAnnotationTypes = type; } else { if (!this._visibleAnnotationTypes) this._visibleAnnotationTypes = {}; this._visibleAnnotationTypes[type] = visible; } }
javascript
function(type, visible) { if (typeof type === "object") { this._visibleAnnotationTypes = type; } else { if (!this._visibleAnnotationTypes) this._visibleAnnotationTypes = {}; this._visibleAnnotationTypes[type] = visible; } }
[ "function", "(", "type", ",", "visible", ")", "{", "if", "(", "typeof", "type", "===", "\"object\"", ")", "{", "this", ".", "_visibleAnnotationTypes", "=", "type", ";", "}", "else", "{", "if", "(", "!", "this", ".", "_visibleAnnotationTypes", ")", "this", ".", "_visibleAnnotationTypes", "=", "{", "}", ";", "this", ".", "_visibleAnnotationTypes", "[", "type", "]", "=", "visible", ";", "}", "}" ]
Sets whether annotations of the given annotation type are visble. By default all annotations added to the receiver are visible. @param {Object} type @param {Boolean} visible @since 14.0
[ "Sets", "whether", "annotations", "of", "the", "given", "annotation", "type", "are", "visble", ".", "By", "default", "all", "annotations", "added", "to", "the", "receiver", "are", "visible", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js#L466-L473
14,181
eclipse/orion.client
bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js
AnnotationModel
function AnnotationModel(textModel) { this._annotations = []; var self = this; this._listener = { onChanged: function(modelChangedEvent) { self._onChanged(modelChangedEvent); } }; this.setTextModel(textModel); }
javascript
function AnnotationModel(textModel) { this._annotations = []; var self = this; this._listener = { onChanged: function(modelChangedEvent) { self._onChanged(modelChangedEvent); } }; this.setTextModel(textModel); }
[ "function", "AnnotationModel", "(", "textModel", ")", "{", "this", ".", "_annotations", "=", "[", "]", ";", "var", "self", "=", "this", ";", "this", ".", "_listener", "=", "{", "onChanged", ":", "function", "(", "modelChangedEvent", ")", "{", "self", ".", "_onChanged", "(", "modelChangedEvent", ")", ";", "}", "}", ";", "this", ".", "setTextModel", "(", "textModel", ")", ";", "}" ]
Constructs an annotation model. @param {orion.editor.TextModel} textModel The text model. @class This object manages annotations for a <code>TextModel</code>. <p> <b>See:</b><br/> {@link orion.editor.Annotation}<br/> {@link orion.editor.TextModel}<br/> </p> @name orion.editor.AnnotationModel @borrows orion.editor.EventTarget#addEventListener as #addEventListener @borrows orion.editor.EventTarget#removeEventListener as #removeEventListener @borrows orion.editor.EventTarget#dispatchEvent as #dispatchEvent
[ "Constructs", "an", "annotation", "model", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js#L528-L537
14,182
eclipse/orion.client
bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js
function(textModel) { if (this._model) { this._model.removeEventListener("Changed", this._listener.onChanged); //$NON-NLS-0$ } this._model = textModel; if (this._model) { this._model.addEventListener("Changed", this._listener.onChanged); //$NON-NLS-0$ } }
javascript
function(textModel) { if (this._model) { this._model.removeEventListener("Changed", this._listener.onChanged); //$NON-NLS-0$ } this._model = textModel; if (this._model) { this._model.addEventListener("Changed", this._listener.onChanged); //$NON-NLS-0$ } }
[ "function", "(", "textModel", ")", "{", "if", "(", "this", ".", "_model", ")", "{", "this", ".", "_model", ".", "removeEventListener", "(", "\"Changed\"", ",", "this", ".", "_listener", ".", "onChanged", ")", ";", "//$NON-NLS-0$", "}", "this", ".", "_model", "=", "textModel", ";", "if", "(", "this", ".", "_model", ")", "{", "this", ".", "_model", ".", "addEventListener", "(", "\"Changed\"", ",", "this", ".", "_listener", ".", "onChanged", ")", ";", "//$NON-NLS-0$", "}", "}" ]
Sets the text model of the annotation model. The annotation model listens for changes in the text model to update and remove annotations that are affected by the change. @param {orion.editor.TextModel} textModel the text model. @see orion.editor.AnnotationModel#getTextModel
[ "Sets", "the", "text", "model", "of", "the", "annotation", "model", ".", "The", "annotation", "model", "listens", "for", "changes", "in", "the", "text", "model", "to", "update", "and", "remove", "annotations", "that", "are", "affected", "by", "the", "change", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js#L758-L766
14,183
eclipse/orion.client
bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js
AnnotationStyler
function AnnotationStyler (view, annotationModel) { this._view = view; this._annotationModel = annotationModel; var self = this; this._listener = { onDestroy: function(e) { self._onDestroy(e); }, onLineStyle: function(e) { self._onLineStyle(e); }, onChanged: function(e) { self._onAnnotationModelChanged(e); } }; view.addEventListener("Destroy", this._listener.onDestroy); //$NON-NLS-0$ view.addEventListener("postLineStyle", this._listener.onLineStyle); //$NON-NLS-0$ annotationModel.addEventListener("Changed", this._listener.onChanged); //$NON-NLS-0$ }
javascript
function AnnotationStyler (view, annotationModel) { this._view = view; this._annotationModel = annotationModel; var self = this; this._listener = { onDestroy: function(e) { self._onDestroy(e); }, onLineStyle: function(e) { self._onLineStyle(e); }, onChanged: function(e) { self._onAnnotationModelChanged(e); } }; view.addEventListener("Destroy", this._listener.onDestroy); //$NON-NLS-0$ view.addEventListener("postLineStyle", this._listener.onLineStyle); //$NON-NLS-0$ annotationModel.addEventListener("Changed", this._listener.onChanged); //$NON-NLS-0$ }
[ "function", "AnnotationStyler", "(", "view", ",", "annotationModel", ")", "{", "this", ".", "_view", "=", "view", ";", "this", ".", "_annotationModel", "=", "annotationModel", ";", "var", "self", "=", "this", ";", "this", ".", "_listener", "=", "{", "onDestroy", ":", "function", "(", "e", ")", "{", "self", ".", "_onDestroy", "(", "e", ")", ";", "}", ",", "onLineStyle", ":", "function", "(", "e", ")", "{", "self", ".", "_onLineStyle", "(", "e", ")", ";", "}", ",", "onChanged", ":", "function", "(", "e", ")", "{", "self", ".", "_onAnnotationModelChanged", "(", "e", ")", ";", "}", "}", ";", "view", ".", "addEventListener", "(", "\"Destroy\"", ",", "this", ".", "_listener", ".", "onDestroy", ")", ";", "//$NON-NLS-0$", "view", ".", "addEventListener", "(", "\"postLineStyle\"", ",", "this", ".", "_listener", ".", "onLineStyle", ")", ";", "//$NON-NLS-0$", "annotationModel", ".", "addEventListener", "(", "\"Changed\"", ",", "this", ".", "_listener", ".", "onChanged", ")", ";", "//$NON-NLS-0$", "}" ]
Constructs a new styler for annotations. @param {orion.editor.TextView} view The styler view. @param {orion.editor.AnnotationModel} view The styler annotation model. @class This object represents a styler for annotation attached to a text view. @name orion.editor.AnnotationStyler @borrows orion.editor.AnnotationTypeList#addAnnotationType as #addAnnotationType @borrows orion.editor.AnnotationTypeList#getAnnotationTypePriority as #getAnnotationTypePriority @borrows orion.editor.AnnotationTypeList#getAnnotationsByType as #getAnnotationsByType @borrows orion.editor.AnnotationTypeList#isAnnotationTypeVisible as #isAnnotationTypeVisible @borrows orion.editor.AnnotationTypeList#removeAnnotationType as #removeAnnotationType
[ "Constructs", "a", "new", "styler", "for", "annotations", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.js#L842-L860
14,184
eclipse/orion.client
bundles/org.eclipse.orion.client.collab/web/orion/collab/collabFileAnnotation.js
function(name, color, location, displayedLocation, editing) { this.name = name; this.color = color; // Remove trailing "/" if(location.substr(-1) === '/') { location = location.substr(0, location.length - 1); } this.location = location; this.displayedLocation = displayedLocation || location; this.editing = editing; }
javascript
function(name, color, location, displayedLocation, editing) { this.name = name; this.color = color; // Remove trailing "/" if(location.substr(-1) === '/') { location = location.substr(0, location.length - 1); } this.location = location; this.displayedLocation = displayedLocation || location; this.editing = editing; }
[ "function", "(", "name", ",", "color", ",", "location", ",", "displayedLocation", ",", "editing", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "color", "=", "color", ";", "// Remove trailing \"/\"", "if", "(", "location", ".", "substr", "(", "-", "1", ")", "===", "'/'", ")", "{", "location", "=", "location", ".", "substr", "(", "0", ",", "location", ".", "length", "-", "1", ")", ";", "}", "this", ".", "location", "=", "location", ";", "this", ".", "displayedLocation", "=", "displayedLocation", "||", "location", ";", "this", ".", "editing", "=", "editing", ";", "}" ]
A record of a collaborator annotation in the file tree @constructor @name {orion.collab.CollabFileAnnotation} @implements {orion.treetable.TableTree.IAnnotation} @param {string} name - displayed name @param {string} color - user color @param {string} location - file location @param {string} displayedLocation - read friendly location @param {boolean} editing
[ "A", "record", "of", "a", "collaborator", "annotation", "in", "the", "file", "tree" ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.collab/web/orion/collab/collabFileAnnotation.js#L30-L40
14,185
eclipse/orion.client
bundles/org.eclipse.orion.client.collab/web/orion/collab/collabFileAnnotation.js
function(model, callback) { var self = this; model.getRoot(function(root) { // Find the existing ID reversely var location = self.location; while (location.length > 0) { // Create a fake item // NOTE: it's a hack because we don't have any efficient // way to get the actual file node. Instead, we have // to do it recursively starting from the root. If // you find anything wierd happens, change it to the // actual item object. var item = { Location: location }; var id = model.getId(item); // Test if this element exists var exists = !!document.getElementById(id); if (exists) { callback(id); return; } // Not found. This probably means this item is collapsed. // Try to find one level upper. // Here I assume every url starts from "/" location = location.substr(0, location.lastIndexOf('/')); } // Nothing found callback(''); }); }
javascript
function(model, callback) { var self = this; model.getRoot(function(root) { // Find the existing ID reversely var location = self.location; while (location.length > 0) { // Create a fake item // NOTE: it's a hack because we don't have any efficient // way to get the actual file node. Instead, we have // to do it recursively starting from the root. If // you find anything wierd happens, change it to the // actual item object. var item = { Location: location }; var id = model.getId(item); // Test if this element exists var exists = !!document.getElementById(id); if (exists) { callback(id); return; } // Not found. This probably means this item is collapsed. // Try to find one level upper. // Here I assume every url starts from "/" location = location.substr(0, location.lastIndexOf('/')); } // Nothing found callback(''); }); }
[ "function", "(", "model", ",", "callback", ")", "{", "var", "self", "=", "this", ";", "model", ".", "getRoot", "(", "function", "(", "root", ")", "{", "// Find the existing ID reversely", "var", "location", "=", "self", ".", "location", ";", "while", "(", "location", ".", "length", ">", "0", ")", "{", "// Create a fake item", "// NOTE: it's a hack because we don't have any efficient", "// way to get the actual file node. Instead, we have", "// to do it recursively starting from the root. If", "// you find anything wierd happens, change it to the", "// actual item object.", "var", "item", "=", "{", "Location", ":", "location", "}", ";", "var", "id", "=", "model", ".", "getId", "(", "item", ")", ";", "// Test if this element exists", "var", "exists", "=", "!", "!", "document", ".", "getElementById", "(", "id", ")", ";", "if", "(", "exists", ")", "{", "callback", "(", "id", ")", ";", "return", ";", "}", "// Not found. This probably means this item is collapsed.", "// Try to find one level upper.", "// Here I assume every url starts from \"/\"", "location", "=", "location", ".", "substr", "(", "0", ",", "location", ".", "lastIndexOf", "(", "'/'", ")", ")", ";", "}", "// Nothing found", "callback", "(", "''", ")", ";", "}", ")", ";", "}" ]
Find the deepest expanded folder item that contains the file having this annotation. @see IAnnotation for details. @param {orion.explorer.ExplorerModel} model - @param {Function} callback -
[ "Find", "the", "deepest", "expanded", "folder", "item", "that", "contains", "the", "file", "having", "this", "annotation", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.collab/web/orion/collab/collabFileAnnotation.js#L52-L82
14,186
eclipse/orion.client
bundles/org.eclipse.orion.client.collab/web/orion/collab/collabFileAnnotation.js
function() { var element = document.createElement('div'); element.innerHTML = mUIUtils.getNameInitial(this.name); element.style.backgroundColor = this.color; element.classList.add('collabAnnotation'); if (this.editing) { element.classList.add('collabEditing'); } return element; }
javascript
function() { var element = document.createElement('div'); element.innerHTML = mUIUtils.getNameInitial(this.name); element.style.backgroundColor = this.color; element.classList.add('collabAnnotation'); if (this.editing) { element.classList.add('collabEditing'); } return element; }
[ "function", "(", ")", "{", "var", "element", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "element", ".", "innerHTML", "=", "mUIUtils", ".", "getNameInitial", "(", "this", ".", "name", ")", ";", "element", ".", "style", ".", "backgroundColor", "=", "this", ".", "color", ";", "element", ".", "classList", ".", "add", "(", "'collabAnnotation'", ")", ";", "if", "(", "this", ".", "editing", ")", "{", "element", ".", "classList", ".", "add", "(", "'collabEditing'", ")", ";", "}", "return", "element", ";", "}" ]
Generate a new HTML element of this annotation. @return {Element} - the HTML element of this annotation
[ "Generate", "a", "new", "HTML", "element", "of", "this", "annotation", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.collab/web/orion/collab/collabFileAnnotation.js#L99-L108
14,187
eclipse/orion.client
bundles/org.eclipse.orion.client.core/web/orion/keyBinding.js
function(kb) { if (!kb) { return false; } if (this.keyCode !== kb.keyCode) { return false; } if (this.mod1 !== kb.mod1) { return false; } if (this.mod2 !== kb.mod2) { return false; } if (this.mod3 !== kb.mod3) { return false; } if (this.mod4 !== kb.mod4) { return false; } if (this.type !== kb.type) { return false; } return true; }
javascript
function(kb) { if (!kb) { return false; } if (this.keyCode !== kb.keyCode) { return false; } if (this.mod1 !== kb.mod1) { return false; } if (this.mod2 !== kb.mod2) { return false; } if (this.mod3 !== kb.mod3) { return false; } if (this.mod4 !== kb.mod4) { return false; } if (this.type !== kb.type) { return false; } return true; }
[ "function", "(", "kb", ")", "{", "if", "(", "!", "kb", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "keyCode", "!==", "kb", ".", "keyCode", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "mod1", "!==", "kb", ".", "mod1", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "mod2", "!==", "kb", ".", "mod2", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "mod3", "!==", "kb", ".", "mod3", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "mod4", "!==", "kb", ".", "mod4", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "type", "!==", "kb", ".", "type", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Returns whether this key stroke is the same as the given parameter. @param {orion.KeyBinding} kb the key binding to compare with. @returns {Boolean} whether or not the parameter and the receiver describe the same key binding.
[ "Returns", "whether", "this", "key", "stroke", "is", "the", "same", "as", "the", "given", "parameter", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.core/web/orion/keyBinding.js#L115-L124
14,188
eclipse/orion.client
bundles/org.eclipse.orion.client.core/web/orion/keyBinding.js
function(kb) { if (!kb.keys) { return false; } if (kb.keys.length !== this.keys.length) { return false; } for (var i=0; i<kb.keys.length; i++) { if (!kb.keys[i].equals(this.keys[i])) { return false; } } return true; }
javascript
function(kb) { if (!kb.keys) { return false; } if (kb.keys.length !== this.keys.length) { return false; } for (var i=0; i<kb.keys.length; i++) { if (!kb.keys[i].equals(this.keys[i])) { return false; } } return true; }
[ "function", "(", "kb", ")", "{", "if", "(", "!", "kb", ".", "keys", ")", "{", "return", "false", ";", "}", "if", "(", "kb", ".", "keys", ".", "length", "!==", "this", ".", "keys", ".", "length", ")", "{", "return", "false", ";", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "kb", ".", "keys", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "kb", ".", "keys", "[", "i", "]", ".", "equals", "(", "this", ".", "keys", "[", "i", "]", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Returns whether this key sequence is the same as the given parameter. @param {orion.KeyBinding|orion.KeySequence} kb the key binding to compare with. @returns {Boolean} whether or not the parameter and the receiver describe the same key binding.
[ "Returns", "whether", "this", "key", "sequence", "is", "the", "same", "as", "the", "given", "parameter", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.core/web/orion/keyBinding.js#L184-L191
14,189
eclipse/orion.client
bundles/org.eclipse.orion.client.ui/web/orion/settings/settingsRegistry.js
function(category) { var settingsMap = this.settingsMap; var pids = typeof category === 'string' ? this.categories[category] : Object.keys(settingsMap); //$NON-NLS-0$ if (!pids) { return []; } return pids.map(function(pid) { return settingsMap[pid]; }); }
javascript
function(category) { var settingsMap = this.settingsMap; var pids = typeof category === 'string' ? this.categories[category] : Object.keys(settingsMap); //$NON-NLS-0$ if (!pids) { return []; } return pids.map(function(pid) { return settingsMap[pid]; }); }
[ "function", "(", "category", ")", "{", "var", "settingsMap", "=", "this", ".", "settingsMap", ";", "var", "pids", "=", "typeof", "category", "===", "'string'", "?", "this", ".", "categories", "[", "category", "]", ":", "Object", ".", "keys", "(", "settingsMap", ")", ";", "//$NON-NLS-0$", "if", "(", "!", "pids", ")", "{", "return", "[", "]", ";", "}", "return", "pids", ".", "map", "(", "function", "(", "pid", ")", "{", "return", "settingsMap", "[", "pid", "]", ";", "}", ")", ";", "}" ]
Returns settings. @param {String} [category] If passed, returns only the settings in the given category. Otherwise, returns all settings. @returns {orion.settings.Setting[]}
[ "Returns", "settings", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/settings/settingsRegistry.js#L245-L254
14,190
eclipse/orion.client
bundles/org.eclipse.orion.client.ui/web/orion/settings/settingsRegistry.js
function(category) { var settings = this.getSettings(category); for (var i = 0; i < settings.length; i++){ var label = settings[i].getCategoryLabel(); if (label) { return label; } } return null; }
javascript
function(category) { var settings = this.getSettings(category); for (var i = 0; i < settings.length; i++){ var label = settings[i].getCategoryLabel(); if (label) { return label; } } return null; }
[ "function", "(", "category", ")", "{", "var", "settings", "=", "this", ".", "getSettings", "(", "category", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "settings", ".", "length", ";", "i", "++", ")", "{", "var", "label", "=", "settings", "[", "i", "]", ".", "getCategoryLabel", "(", ")", ";", "if", "(", "label", ")", "{", "return", "label", ";", "}", "}", "return", "null", ";", "}" ]
Returns the localized label for a category. @returns {String} The category label, or <code>null</code> if no localized label is available.
[ "Returns", "the", "localized", "label", "for", "a", "category", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/settings/settingsRegistry.js#L266-L275
14,191
eclipse/orion.client
bundles/org.eclipse.orion.client.collab/web/orion/collab/otAdapters.js
function(client, socket) { OrionSocketAdapter.call(this, client); var self = this; this.socket = socket; this.authenticated = false; // Register incoming message handler this.socket.addEventListener('message', function(e) { self._onMessage(JSON.parse(e.data)); }); }
javascript
function(client, socket) { OrionSocketAdapter.call(this, client); var self = this; this.socket = socket; this.authenticated = false; // Register incoming message handler this.socket.addEventListener('message', function(e) { self._onMessage(JSON.parse(e.data)); }); }
[ "function", "(", "client", ",", "socket", ")", "{", "OrionSocketAdapter", ".", "call", "(", "this", ",", "client", ")", ";", "var", "self", "=", "this", ";", "this", ".", "socket", "=", "socket", ";", "this", ".", "authenticated", "=", "false", ";", "// Register incoming message handler", "this", ".", "socket", ".", "addEventListener", "(", "'message'", ",", "function", "(", "e", ")", "{", "self", ".", "_onMessage", "(", "JSON", ".", "parse", "(", "e", ".", "data", ")", ")", ";", "}", ")", ";", "}" ]
The socket adapter for OT using CollabSocket as the communitation socket @class @extends orion.collab.OrionSocketAdapter @name orion.collab.OrionCollabSocketAdapter @param {orion.collabClient.CollabClient} client @param {orion.collabClient.CollabSocket} socket
[ "The", "socket", "adapter", "for", "OT", "using", "CollabSocket", "as", "the", "communitation", "socket" ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.collab/web/orion/collab/otAdapters.js#L228-L239
14,192
eclipse/orion.client
bundles/org.eclipse.orion.client.javascript/web/escope/escope.js
Reference
function Reference(ident, scope, flag,writeExpr, maybeImplicitGlobal, partial, init) { /** * Identifier syntax node. * @member {esprima#Identifier} Reference#identifier */ this.identifier = ident; /** * Reference to the enclosing Scope. * @member {Scope} Reference#from */ this.from = scope; /** * Whether the reference comes from a dynamic scope (such as 'eval', * 'with', etc.), and may be trapped by dynamic scopes. * @member {boolean} Reference#tainted */ this.tainted = false; /** * The variable this reference is resolved with. * @member {Variable} Reference#resolved */ this.resolved = null; /** * The read-write mode of the reference. (Value is one of {@link * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}). * @member {number} Reference#flag * @private */ this.flag = flag; if (this.isWrite()) { /** * If reference is writeable, this is the tree being written to it. * @member {esprima#Node} Reference#writeExpr */ this.writeExpr = writeExpr; /** * Whether the Reference might refer to a partial value of writeExpr. * @member {boolean} Reference#partial */ this.partial = partial; /** * Whether the Reference is to write of initialization. * @member {boolean} Reference#init */ this.init = init; } this.__maybeImplicitGlobal = maybeImplicitGlobal; }
javascript
function Reference(ident, scope, flag,writeExpr, maybeImplicitGlobal, partial, init) { /** * Identifier syntax node. * @member {esprima#Identifier} Reference#identifier */ this.identifier = ident; /** * Reference to the enclosing Scope. * @member {Scope} Reference#from */ this.from = scope; /** * Whether the reference comes from a dynamic scope (such as 'eval', * 'with', etc.), and may be trapped by dynamic scopes. * @member {boolean} Reference#tainted */ this.tainted = false; /** * The variable this reference is resolved with. * @member {Variable} Reference#resolved */ this.resolved = null; /** * The read-write mode of the reference. (Value is one of {@link * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}). * @member {number} Reference#flag * @private */ this.flag = flag; if (this.isWrite()) { /** * If reference is writeable, this is the tree being written to it. * @member {esprima#Node} Reference#writeExpr */ this.writeExpr = writeExpr; /** * Whether the Reference might refer to a partial value of writeExpr. * @member {boolean} Reference#partial */ this.partial = partial; /** * Whether the Reference is to write of initialization. * @member {boolean} Reference#init */ this.init = init; } this.__maybeImplicitGlobal = maybeImplicitGlobal; }
[ "function", "Reference", "(", "ident", ",", "scope", ",", "flag", ",", "writeExpr", ",", "maybeImplicitGlobal", ",", "partial", ",", "init", ")", "{", "/**\n * Identifier syntax node.\n * @member {esprima#Identifier} Reference#identifier\n */", "this", ".", "identifier", "=", "ident", ";", "/**\n * Reference to the enclosing Scope.\n * @member {Scope} Reference#from\n */", "this", ".", "from", "=", "scope", ";", "/**\n * Whether the reference comes from a dynamic scope (such as 'eval',\n * 'with', etc.), and may be trapped by dynamic scopes.\n * @member {boolean} Reference#tainted\n */", "this", ".", "tainted", "=", "false", ";", "/**\n * The variable this reference is resolved with.\n * @member {Variable} Reference#resolved\n */", "this", ".", "resolved", "=", "null", ";", "/**\n * The read-write mode of the reference. (Value is one of {@link\n * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}).\n * @member {number} Reference#flag\n * @private\n */", "this", ".", "flag", "=", "flag", ";", "if", "(", "this", ".", "isWrite", "(", ")", ")", "{", "/**\n * If reference is writeable, this is the tree being written to it.\n * @member {esprima#Node} Reference#writeExpr\n */", "this", ".", "writeExpr", "=", "writeExpr", ";", "/**\n * Whether the Reference might refer to a partial value of writeExpr.\n * @member {boolean} Reference#partial\n */", "this", ".", "partial", "=", "partial", ";", "/**\n * Whether the Reference is to write of initialization.\n * @member {boolean} Reference#init\n */", "this", ".", "init", "=", "init", ";", "}", "this", ".", "__maybeImplicitGlobal", "=", "maybeImplicitGlobal", ";", "}" ]
A Reference represents a single occurrence of an identifier in code. @class Reference
[ "A", "Reference", "represents", "a", "single", "occurrence", "of", "an", "identifier", "in", "code", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/escope/escope.js#L42-L89
14,193
eclipse/orion.client
bundles/org.eclipse.orion.client.javascript/web/escope/escope.js
analyze
function analyze(tree, providedOptions) { var scopeManager, referencer, options; options = updateDeeply(defaultOptions(), providedOptions); scopeManager = new ScopeManager(options); referencer = new Referencer(options, scopeManager); referencer.visit(tree); if(scopeManager.__currentScope !== null) { throw new Error('currentScope should be null.'); } return scopeManager; }
javascript
function analyze(tree, providedOptions) { var scopeManager, referencer, options; options = updateDeeply(defaultOptions(), providedOptions); scopeManager = new ScopeManager(options); referencer = new Referencer(options, scopeManager); referencer.visit(tree); if(scopeManager.__currentScope !== null) { throw new Error('currentScope should be null.'); } return scopeManager; }
[ "function", "analyze", "(", "tree", ",", "providedOptions", ")", "{", "var", "scopeManager", ",", "referencer", ",", "options", ";", "options", "=", "updateDeeply", "(", "defaultOptions", "(", ")", ",", "providedOptions", ")", ";", "scopeManager", "=", "new", "ScopeManager", "(", "options", ")", ";", "referencer", "=", "new", "Referencer", "(", "options", ",", "scopeManager", ")", ";", "referencer", ".", "visit", "(", "tree", ")", ";", "if", "(", "scopeManager", ".", "__currentScope", "!==", "null", ")", "{", "throw", "new", "Error", "(", "'currentScope should be null.'", ")", ";", "}", "return", "scopeManager", ";", "}" ]
Main interface function. Takes an Esprima syntax tree and returns the analyzed scopes. @function analyze @param {esprima.Tree} tree @param {Object} providedOptions - Options that tailor the scope analysis @param {boolean} [providedOptions.optimistic=false] - the optimistic flag @param {boolean} [providedOptions.directive=false]- the directive flag @param {boolean} [providedOptions.ignoreEval=false]- whether to check 'eval()' calls @param {boolean} [providedOptions.nodejsScope=false]- whether the whole script is executed under node.js environment. When enabled, escope adds a function scope immediately following the global scope. @param {boolean} [providedOptions.impliedStrict=false]- implied strict mode (if ecmaVersion >= 5). @param {string} [providedOptions.sourceType='script']- the source type of the script. one of 'script' and 'module' @param {number} [providedOptions.ecmaVersion=5]- which ECMAScript version is considered @param {Object} [providedOptions.childVisitorKeys=null] - Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option. @param {string} [providedOptions.fallback='iteration'] - A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option. @return {ScopeManager}
[ "Main", "interface", "function", ".", "Takes", "an", "Esprima", "syntax", "tree", "and", "returns", "the", "analyzed", "scopes", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/escope/escope.js#L2117-L2131
14,194
eclipse/orion.client
modules/orionode/lib/shared/db/sharedProjects.js
addProject
function addProject(project) { var hub = generateUniqueHubId(); //TODO Also add name of project owner? Replace by projectJSON all over the file. var query = sharedProject.findOne({location: project}); return query.exec() .then(function(doc) { return doc ? Promise.resolve(doc) : sharedProject.create({location: project, hubid: hub}); }); }
javascript
function addProject(project) { var hub = generateUniqueHubId(); //TODO Also add name of project owner? Replace by projectJSON all over the file. var query = sharedProject.findOne({location: project}); return query.exec() .then(function(doc) { return doc ? Promise.resolve(doc) : sharedProject.create({location: project, hubid: hub}); }); }
[ "function", "addProject", "(", "project", ")", "{", "var", "hub", "=", "generateUniqueHubId", "(", ")", ";", "//TODO Also add name of project owner? Replace by projectJSON all over the file.", "var", "query", "=", "sharedProject", ".", "findOne", "(", "{", "location", ":", "project", "}", ")", ";", "return", "query", ".", "exec", "(", ")", ".", "then", "(", "function", "(", "doc", ")", "{", "return", "doc", "?", "Promise", ".", "resolve", "(", "doc", ")", ":", "sharedProject", ".", "create", "(", "{", "location", ":", "project", ",", "hubid", ":", "hub", "}", ")", ";", "}", ")", ";", "}" ]
Adds the project and a new hubID to the sharedProjects db document.
[ "Adds", "the", "project", "and", "a", "new", "hubID", "to", "the", "sharedProjects", "db", "document", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/shared/db/sharedProjects.js#L89-L97
14,195
eclipse/orion.client
modules/orionode/lib/shared/db/sharedProjects.js
removeProject
function removeProject(project) { return sharedProject.findOne({'location': project}).exec() .then(function(doc) { if (doc.users.length > 0) { return userProjectsCollection.removeProjectReferences(doc.users, project).exec(); } }) .then(function() { return sharedProject.remove({location: project}).exec(); }); }
javascript
function removeProject(project) { return sharedProject.findOne({'location': project}).exec() .then(function(doc) { if (doc.users.length > 0) { return userProjectsCollection.removeProjectReferences(doc.users, project).exec(); } }) .then(function() { return sharedProject.remove({location: project}).exec(); }); }
[ "function", "removeProject", "(", "project", ")", "{", "return", "sharedProject", ".", "findOne", "(", "{", "'location'", ":", "project", "}", ")", ".", "exec", "(", ")", ".", "then", "(", "function", "(", "doc", ")", "{", "if", "(", "doc", ".", "users", ".", "length", ">", "0", ")", "{", "return", "userProjectsCollection", ".", "removeProjectReferences", "(", "doc", ".", "users", ",", "project", ")", ".", "exec", "(", ")", ";", "}", "}", ")", ".", "then", "(", "function", "(", ")", "{", "return", "sharedProject", ".", "remove", "(", "{", "location", ":", "project", "}", ")", ".", "exec", "(", ")", ";", "}", ")", ";", "}" ]
Removes project from shared projects. Also removes all references from the other table.
[ "Removes", "project", "from", "shared", "projects", ".", "Also", "removes", "all", "references", "from", "the", "other", "table", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/shared/db/sharedProjects.js#L103-L113
14,196
eclipse/orion.client
modules/orionode/lib/shared/db/sharedProjects.js
generateUniqueHubId
function generateUniqueHubId() { //TODO ensure generated hub id is unique (not in db) // do { var length = 10; var letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV0123456789'; var s = ''; for (var i=0; i<length; i++) { s += letters.charAt(Math.floor(Math.random() * letters.length)); } // } while (s == 0); //TODO actually check in db for value existence return s; }
javascript
function generateUniqueHubId() { //TODO ensure generated hub id is unique (not in db) // do { var length = 10; var letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV0123456789'; var s = ''; for (var i=0; i<length; i++) { s += letters.charAt(Math.floor(Math.random() * letters.length)); } // } while (s == 0); //TODO actually check in db for value existence return s; }
[ "function", "generateUniqueHubId", "(", ")", "{", "//TODO ensure generated hub id is unique (not in db)", "// do {", "var", "length", "=", "10", ";", "var", "letters", "=", "'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV0123456789'", ";", "var", "s", "=", "''", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "s", "+=", "letters", ".", "charAt", "(", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "letters", ".", "length", ")", ")", ";", "}", "// } while (s == 0); //TODO actually check in db for value existence", "return", "s", ";", "}" ]
returns a unique hubID
[ "returns", "a", "unique", "hubID" ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/shared/db/sharedProjects.js#L126-L138
14,197
eclipse/orion.client
modules/orionode/lib/shared/db/sharedProjects.js
getUsersInProject
function getUsersInProject(project) { return sharedProject.findOne({'location': project}).exec() .then(function(doc) { return doc ? doc.users : undefined; }); }
javascript
function getUsersInProject(project) { return sharedProject.findOne({'location': project}).exec() .then(function(doc) { return doc ? doc.users : undefined; }); }
[ "function", "getUsersInProject", "(", "project", ")", "{", "return", "sharedProject", ".", "findOne", "(", "{", "'location'", ":", "project", "}", ")", ".", "exec", "(", ")", ".", "then", "(", "function", "(", "doc", ")", "{", "return", "doc", "?", "doc", ".", "users", ":", "undefined", ";", "}", ")", ";", "}" ]
Returns the list of users that the project is shared with.
[ "Returns", "the", "list", "of", "users", "that", "the", "project", "is", "shared", "with", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/shared/db/sharedProjects.js#L168-L173
14,198
eclipse/orion.client
modules/orionode/lib/shared/db/sharedProjects.js
addUserToProject
function addUserToProject(user, project) { return addProject(project) .then(function(doc) { if (doc.users.indexOf(user) === -1) { return sharedProject.findOneAndUpdate({'location': project}, {$addToSet: {'users': user} }, { safe: true, w: 'majority' }).exec(); } }); // return sharedProject.findOne({'location': project}).exec() // .then(function(doc) { // if (!doc) { // return addProject(project); // } else { // return Promise.resolve(doc); // } // }).then(function(doc) { // if (doc.users.indexOf(user) === -1) { // return sharedProject.findOneAndUpdate({'location': project}, {$addToSet: {'users': user} }, { // safe: true, // w: 'majority' // }).exec(); // } // }); }
javascript
function addUserToProject(user, project) { return addProject(project) .then(function(doc) { if (doc.users.indexOf(user) === -1) { return sharedProject.findOneAndUpdate({'location': project}, {$addToSet: {'users': user} }, { safe: true, w: 'majority' }).exec(); } }); // return sharedProject.findOne({'location': project}).exec() // .then(function(doc) { // if (!doc) { // return addProject(project); // } else { // return Promise.resolve(doc); // } // }).then(function(doc) { // if (doc.users.indexOf(user) === -1) { // return sharedProject.findOneAndUpdate({'location': project}, {$addToSet: {'users': user} }, { // safe: true, // w: 'majority' // }).exec(); // } // }); }
[ "function", "addUserToProject", "(", "user", ",", "project", ")", "{", "return", "addProject", "(", "project", ")", ".", "then", "(", "function", "(", "doc", ")", "{", "if", "(", "doc", ".", "users", ".", "indexOf", "(", "user", ")", "===", "-", "1", ")", "{", "return", "sharedProject", ".", "findOneAndUpdate", "(", "{", "'location'", ":", "project", "}", ",", "{", "$addToSet", ":", "{", "'users'", ":", "user", "}", "}", ",", "{", "safe", ":", "true", ",", "w", ":", "'majority'", "}", ")", ".", "exec", "(", ")", ";", "}", "}", ")", ";", "// return sharedProject.findOne({'location': project}).exec()", "// .then(function(doc) {", "// \tif (!doc) {", "// \t\treturn addProject(project);", "// \t} else {", "// \t\treturn Promise.resolve(doc);", "// \t}", "// }).then(function(doc) {", "// \tif (doc.users.indexOf(user) === -1) {", "// \t\treturn sharedProject.findOneAndUpdate({'location': project}, {$addToSet: {'users': user} }, {", "// \t\tsafe: true,", "// \t\tw: 'majority'", "// \t}).exec();", "// \t}", "// });", "}" ]
Adds user to project's user list.
[ "Adds", "user", "to", "project", "s", "user", "list", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/shared/db/sharedProjects.js#L178-L204
14,199
eclipse/orion.client
modules/orionode/lib/shared/db/sharedProjects.js
removeUserFromProject
function removeUserFromProject(user, project) { return sharedProject.findOne({'location': project}).exec() .then(function(doc) { return sharedProject.findOneAndUpdate({'location': project}, {$pull: {'users': { $in: [user]}} }, { safe: true, w: 'majority' }).exec(); }); }
javascript
function removeUserFromProject(user, project) { return sharedProject.findOne({'location': project}).exec() .then(function(doc) { return sharedProject.findOneAndUpdate({'location': project}, {$pull: {'users': { $in: [user]}} }, { safe: true, w: 'majority' }).exec(); }); }
[ "function", "removeUserFromProject", "(", "user", ",", "project", ")", "{", "return", "sharedProject", ".", "findOne", "(", "{", "'location'", ":", "project", "}", ")", ".", "exec", "(", ")", ".", "then", "(", "function", "(", "doc", ")", "{", "return", "sharedProject", ".", "findOneAndUpdate", "(", "{", "'location'", ":", "project", "}", ",", "{", "$pull", ":", "{", "'users'", ":", "{", "$in", ":", "[", "user", "]", "}", "}", "}", ",", "{", "safe", ":", "true", ",", "w", ":", "'majority'", "}", ")", ".", "exec", "(", ")", ";", "}", ")", ";", "}" ]
Remove user from project's user list.
[ "Remove", "user", "from", "project", "s", "user", "list", "." ]
eb2583100c662b5cfc1b461a978b31d3b8555ce1
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/shared/db/sharedProjects.js#L209-L217