repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
dcodeIO/PSON
src/PSON/ProgressivePair.js
function(dict, options) { Pair.call(this); this.encoder = new Encoder(dict, true, options); this.decoder = new Decoder(dict, true, options); }
javascript
function(dict, options) { Pair.call(this); this.encoder = new Encoder(dict, true, options); this.decoder = new Decoder(dict, true, options); }
[ "function", "(", "dict", ",", "options", ")", "{", "Pair", ".", "call", "(", "this", ")", ";", "this", ".", "encoder", "=", "new", "Encoder", "(", "dict", ",", "true", ",", "options", ")", ";", "this", ".", "decoder", "=", "new", "Decoder", "(", ...
Constructs a new progressive PSON encoder and decoder pair. @exports PSON.ProgressivePair @class A progressive PSON encoder and decoder pair. @param {Array.<string>=} dict Initial dictionary @param {Object.<string,*>=} options Options @constructor @extends PSON.Pair
[ "Constructs", "a", "new", "progressive", "PSON", "encoder", "and", "decoder", "pair", "." ]
be3bb7c10260c4bf7d57aec57e98937d950e938d
https://github.com/dcodeIO/PSON/blob/be3bb7c10260c4bf7d57aec57e98937d950e938d/src/PSON/ProgressivePair.js#L15-L20
train
dcodeIO/PSON
dist/PSON.js
function(dict, progressive, options) { /** * Dictionary hash. * @type {Object.<string,number>} */ this.dict = {}; /** * Next dictionary index. * @type {number} */ ...
javascript
function(dict, progressive, options) { /** * Dictionary hash. * @type {Object.<string,number>} */ this.dict = {}; /** * Next dictionary index. * @type {number} */ ...
[ "function", "(", "dict", ",", "progressive", ",", "options", ")", "{", "/**\n * Dictionary hash.\n * @type {Object.<string,number>}\n */", "this", ".", "dict", "=", "{", "}", ";", "/**\n * Next dictionary index.\n ...
Constructs a new PSON Encoder. @exports PSON.Encoder @class A PSON Encoder. @param {Array.<string>=} dict Initial dictionary @param {boolean} progressive Whether this is a progressive or a static encoder @param {Object.<string,*>=} options Options @constructor
[ "Constructs", "a", "new", "PSON", "Encoder", "." ]
be3bb7c10260c4bf7d57aec57e98937d950e938d
https://github.com/dcodeIO/PSON/blob/be3bb7c10260c4bf7d57aec57e98937d950e938d/dist/PSON.js#L103-L133
train
dcodeIO/PSON
dist/PSON.js
function(dict, progressive, options) { /** * Dictionary array. * @type {Array.<string>} */ this.dict = (dict && Array.isArray(dict)) ? dict : []; /** * Whether this is a progressive or a static decoder....
javascript
function(dict, progressive, options) { /** * Dictionary array. * @type {Array.<string>} */ this.dict = (dict && Array.isArray(dict)) ? dict : []; /** * Whether this is a progressive or a static decoder....
[ "function", "(", "dict", ",", "progressive", ",", "options", ")", "{", "/**\n * Dictionary array.\n * @type {Array.<string>}\n */", "this", ".", "dict", "=", "(", "dict", "&&", "Array", ".", "isArray", "(", "dict", ")", ")...
Constructs a new PSON Decoder. @exports PSON.Decoder @class A PSON Decoder. @param {Array.<string>} dict Initial dictionary values @param {boolean} progressive Whether this is a progressive or a static decoder @param {Object.<string,*>=} options Options @constructor
[ "Constructs", "a", "new", "PSON", "Decoder", "." ]
be3bb7c10260c4bf7d57aec57e98937d950e938d
https://github.com/dcodeIO/PSON/blob/be3bb7c10260c4bf7d57aec57e98937d950e938d/dist/PSON.js#L298-L317
train
kalabox/kalabox
docs/js/extra.js
determineSelectedBranch
function determineSelectedBranch() { var branch = 'stable', path = window.location.pathname; // path is like /en/<branch>/<lang>/build/ -> extract 'lang' // split[0] is an '' because the path starts with the separator branch = path.split('/')[2]; return branch; }
javascript
function determineSelectedBranch() { var branch = 'stable', path = window.location.pathname; // path is like /en/<branch>/<lang>/build/ -> extract 'lang' // split[0] is an '' because the path starts with the separator branch = path.split('/')[2]; return branch; }
[ "function", "determineSelectedBranch", "(", ")", "{", "var", "branch", "=", "'stable'", ",", "path", "=", "window", ".", "location", ".", "pathname", ";", "// path is like /en/<branch>/<lang>/build/ -> extract 'lang'", "// split[0] is an '' because the path starts with the sepa...
Analyzes the URL of the current page to find out what the selected GitHub branch is. It's usually part of the location path. The code needs to distinguish between running MkDocs standalone and docs served from RTD. If no valid branch could be determined 'dev' returned. @returns GitHub branch name
[ "Analyzes", "the", "URL", "of", "the", "current", "page", "to", "find", "out", "what", "the", "selected", "GitHub", "branch", "is", ".", "It", "s", "usually", "part", "of", "the", "location", "path", ".", "The", "code", "needs", "to", "distinguish", "bet...
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/docs/js/extra.js#L32-L38
train
kalabox/kalabox
lib/app/registry.js
appsAreEqual
function appsAreEqual(x, y) { function pp(o) { return JSON.stringify(o); } var xs = pp(x); var ys = pp(y); return xs === ys; }
javascript
function appsAreEqual(x, y) { function pp(o) { return JSON.stringify(o); } var xs = pp(x); var ys = pp(y); return xs === ys; }
[ "function", "appsAreEqual", "(", "x", ",", "y", ")", "{", "function", "pp", "(", "o", ")", "{", "return", "JSON", ".", "stringify", "(", "o", ")", ";", "}", "var", "xs", "=", "pp", "(", "x", ")", ";", "var", "ys", "=", "pp", "(", "y", ")", ...
Returns true if two apps are equal.
[ "Returns", "true", "if", "two", "apps", "are", "equal", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/app/registry.js#L31-L38
train
kalabox/kalabox
lib/app/registry.js
existsInCache
function existsInCache(x, cache) { var found = _.find(cache, function(y) { return appsAreEqual(x, y); }); return !!found; }
javascript
function existsInCache(x, cache) { var found = _.find(cache, function(y) { return appsAreEqual(x, y); }); return !!found; }
[ "function", "existsInCache", "(", "x", ",", "cache", ")", "{", "var", "found", "=", "_", ".", "find", "(", "cache", ",", "function", "(", "y", ")", "{", "return", "appsAreEqual", "(", "x", ",", "y", ")", ";", "}", ")", ";", "return", "!", "!", ...
Returns true if app already exists in cache.
[ "Returns", "true", "if", "app", "already", "exists", "in", "cache", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/app/registry.js#L41-L46
train
kalabox/kalabox
lib/app/registry.js
function(app) { if (!appCache.good) { appCache.good = []; } if (!existsInCache(app, appCache.good)) { appCache.good.push(app); } }
javascript
function(app) { if (!appCache.good) { appCache.good = []; } if (!existsInCache(app, appCache.good)) { appCache.good.push(app); } }
[ "function", "(", "app", ")", "{", "if", "(", "!", "appCache", ".", "good", ")", "{", "appCache", ".", "good", "=", "[", "]", ";", "}", "if", "(", "!", "existsInCache", "(", "app", ",", "appCache", ".", "good", ")", ")", "{", "appCache", ".", "g...
Cache an appDir by appName in data store.
[ "Cache", "an", "appDir", "by", "appName", "in", "data", "store", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/app/registry.js#L49-L56
train
kalabox/kalabox
lib/app/registry.js
function(app) { if (!appCache.bad) { appCache.bad = []; } if (!existsInCache(app, appCache.bad)) { appCache.bad.push(app); } }
javascript
function(app) { if (!appCache.bad) { appCache.bad = []; } if (!existsInCache(app, appCache.bad)) { appCache.bad.push(app); } }
[ "function", "(", "app", ")", "{", "if", "(", "!", "appCache", ".", "bad", ")", "{", "appCache", ".", "bad", "=", "[", "]", ";", "}", "if", "(", "!", "existsInCache", "(", "app", ",", "appCache", ".", "bad", ")", ")", "{", "appCache", ".", "bad"...
Cache an appDir by appName in bad app data store.
[ "Cache", "an", "appDir", "by", "appName", "in", "bad", "app", "data", "store", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/app/registry.js#L59-L66
train
kalabox/kalabox
lib/app/registry.js
function() { var globalConfig = getGlobalConfig(); // Read contents of app registry file. return Promise.fromNode(function(cb) { fs.readFile(globalConfig.appRegistry, {encoding: 'utf8'}, cb); }) // Parse contents and return app dirs. .then(function(data) { var json = JSON.parse(data); if (json)...
javascript
function() { var globalConfig = getGlobalConfig(); // Read contents of app registry file. return Promise.fromNode(function(cb) { fs.readFile(globalConfig.appRegistry, {encoding: 'utf8'}, cb); }) // Parse contents and return app dirs. .then(function(data) { var json = JSON.parse(data); if (json)...
[ "function", "(", ")", "{", "var", "globalConfig", "=", "getGlobalConfig", "(", ")", ";", "// Read contents of app registry file.", "return", "Promise", ".", "fromNode", "(", "function", "(", "cb", ")", "{", "fs", ".", "readFile", "(", "globalConfig", ".", "app...
Read from app registry file.
[ "Read", "from", "app", "registry", "file", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/app/registry.js#L79-L104
train
kalabox/kalabox
lib/app/registry.js
function(apps) { var filepath = getGlobalConfig().appRegistry; var tempFilepath = filepath + '.tmp'; // Write to temp file. return Promise.fromNode(function(cb) { fs.writeFile(tempFilepath, JSON.stringify(apps), cb); log.debug(format('Setting app registry with %j', apps)); }) // Rename temp file ...
javascript
function(apps) { var filepath = getGlobalConfig().appRegistry; var tempFilepath = filepath + '.tmp'; // Write to temp file. return Promise.fromNode(function(cb) { fs.writeFile(tempFilepath, JSON.stringify(apps), cb); log.debug(format('Setting app registry with %j', apps)); }) // Rename temp file ...
[ "function", "(", "apps", ")", "{", "var", "filepath", "=", "getGlobalConfig", "(", ")", ".", "appRegistry", ";", "var", "tempFilepath", "=", "filepath", "+", "'.tmp'", ";", "// Write to temp file.", "return", "Promise", ".", "fromNode", "(", "function", "(", ...
Rewrite the app registry file.
[ "Rewrite", "the", "app", "registry", "file", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/app/registry.js#L107-L125
train
kalabox/kalabox
lib/app/registry.js
function(app) { var filepath = path.join(app.dir, APP_CONFIG_FILENAME); // Read contents of file. return Promise.fromNode(function(cb) { fs.readFile(filepath, {encoding: 'utf8'}, cb); }) // Handle no entry error. .catch(function(err) { if (err.code === 'ENOENT') { cacheBadApp(app); } els...
javascript
function(app) { var filepath = path.join(app.dir, APP_CONFIG_FILENAME); // Read contents of file. return Promise.fromNode(function(cb) { fs.readFile(filepath, {encoding: 'utf8'}, cb); }) // Handle no entry error. .catch(function(err) { if (err.code === 'ENOENT') { cacheBadApp(app); } els...
[ "function", "(", "app", ")", "{", "var", "filepath", "=", "path", ".", "join", "(", "app", ".", "dir", ",", "APP_CONFIG_FILENAME", ")", ";", "// Read contents of file.", "return", "Promise", ".", "fromNode", "(", "function", "(", "cb", ")", "{", "fs", "....
Given an app, inspect it and return the appName.
[ "Given", "an", "app", "inspect", "it", "and", "return", "the", "appName", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/app/registry.js#L128-L167
train
kalabox/kalabox
lib/app/registry.js
function() { // Get list of dirs from app registry. return getAppRegistry() // Map app dirs to app names. .then(inspectDirs) .all() .tap(function(appRegistryApps) { log.debug(format('Apps in registry: %j', appRegistryApps)); }); }
javascript
function() { // Get list of dirs from app registry. return getAppRegistry() // Map app dirs to app names. .then(inspectDirs) .all() .tap(function(appRegistryApps) { log.debug(format('Apps in registry: %j', appRegistryApps)); }); }
[ "function", "(", ")", "{", "// Get list of dirs from app registry.", "return", "getAppRegistry", "(", ")", "// Map app dirs to app names.", ".", "then", "(", "inspectDirs", ")", ".", "all", "(", ")", ".", "tap", "(", "function", "(", "appRegistryApps", ")", "{", ...
Return list of app names from app registry dirs.
[ "Return", "list", "of", "app", "names", "from", "app", "registry", "dirs", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/app/registry.js#L177-L187
train
kalabox/kalabox
lib/app/registry.js
function(cache) { // Init a promise. return Promise.resolve() .then(function() { if (!_.isEmpty(appCache)) { // Return cached value. return appCache[cache] || []; } else { // Reload and cache app dirs, then get app dir from cache again. return list() .then(function() { ...
javascript
function(cache) { // Init a promise. return Promise.resolve() .then(function() { if (!_.isEmpty(appCache)) { // Return cached value. return appCache[cache] || []; } else { // Reload and cache app dirs, then get app dir from cache again. return list() .then(function() { ...
[ "function", "(", "cache", ")", "{", "// Init a promise.", "return", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "function", "(", ")", "{", "if", "(", "!", "_", ".", "isEmpty", "(", "appCache", ")", ")", "{", "// Return cached value.", "return"...
Get app helped
[ "Get", "app", "helped" ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/app/registry.js#L190-L207
train
kalabox/kalabox
src/modules/guiEngine/sites.js
function() { // Get app. return kbox.app.get(self.name) // Ignore errors. .catch(function() {}) .then(function(app) { if (app) { // Return app. return app; } else { // Take a short delay then try again. return $q...
javascript
function() { // Get app. return kbox.app.get(self.name) // Ignore errors. .catch(function() {}) .then(function(app) { if (app) { // Return app. return app; } else { // Take a short delay then try again. return $q...
[ "function", "(", ")", "{", "// Get app.", "return", "kbox", ".", "app", ".", "get", "(", "self", ".", "name", ")", "// Ignore errors.", ".", "catch", "(", "function", "(", ")", "{", "}", ")", ".", "then", "(", "function", "(", "app", ")", "{", "if"...
Recursive method to get app object.
[ "Recursive", "method", "to", "get", "app", "object", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/src/modules/guiEngine/sites.js#L40-L57
train
kalabox/kalabox
src/modules/dashboard/dashboard.js
reloadSites
function reloadSites() { function reload() { sites.get() .then(function(sites) { $scope.ui.sites = sites; }); } /* * Reload sites mutliple times, because sometimes updates to list of sites * aren't ready immediately. */ // Reload sites immediately. reload(); ...
javascript
function reloadSites() { function reload() { sites.get() .then(function(sites) { $scope.ui.sites = sites; }); } /* * Reload sites mutliple times, because sometimes updates to list of sites * aren't ready immediately. */ // Reload sites immediately. reload(); ...
[ "function", "reloadSites", "(", ")", "{", "function", "reload", "(", ")", "{", "sites", ".", "get", "(", ")", ".", "then", "(", "function", "(", "sites", ")", "{", "$scope", ".", "ui", ".", "sites", "=", "sites", ";", "}", ")", ";", "}", "/*\n ...
Helper function for reloading list of sites.
[ "Helper", "function", "for", "reloading", "list", "of", "sites", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/src/modules/dashboard/dashboard.js#L160-L177
train
kalabox/kalabox
lib/create.js
function(task, type) { // Make sure we are going to add a task with a real app if (!get(type)) { // todo: something useful besides silentfail // todo: never forget how funny this was/is/will always be throw new Error('F!'); } // Get the app plugin metadata var app = get(type); ...
javascript
function(task, type) { // Make sure we are going to add a task with a real app if (!get(type)) { // todo: something useful besides silentfail // todo: never forget how funny this was/is/will always be throw new Error('F!'); } // Get the app plugin metadata var app = get(type); ...
[ "function", "(", "task", ",", "type", ")", "{", "// Make sure we are going to add a task with a real app", "if", "(", "!", "get", "(", "type", ")", ")", "{", "// todo: something useful besides silentfail", "// todo: never forget how funny this was/is/will always be", "throw", ...
Assembles create.add metadata and builds a task to create a certain kind of app. @memberof create @static @method @arg {Object} task - A kbox task object. @arg {string} appName - The name of the kind of app to be created. @example // Task to create kalabox apps kbox.tasks.add(function(task) { kbox.create.buildTask(task...
[ "Assembles", "create", ".", "add", "metadata", "and", "builds", "a", "task", "to", "create", "a", "certain", "kind", "of", "app", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/create.js#L415-L476
train
kalabox/kalabox
lib/core/tasks.js
function(node, path) { // Validate. if (!isBranch(node)) { assert(false); } if (path.length === 0) { assert(false); } // Partition head and tail. var hd = path[0]; var tl = path.slice(1); // Find a child of node that matches path. var cursor = _.find(node.children,...
javascript
function(node, path) { // Validate. if (!isBranch(node)) { assert(false); } if (path.length === 0) { assert(false); } // Partition head and tail. var hd = path[0]; var tl = path.slice(1); // Find a child of node that matches path. var cursor = _.find(node.children,...
[ "function", "(", "node", ",", "path", ")", "{", "// Validate.", "if", "(", "!", "isBranch", "(", "node", ")", ")", "{", "assert", "(", "false", ")", ";", "}", "if", "(", "path", ".", "length", "===", "0", ")", "{", "assert", "(", "false", ")", ...
Recursive function for placing task in task tree.
[ "Recursive", "function", "for", "placing", "task", "in", "task", "tree", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/core/tasks.js#L221-L279
train
kalabox/kalabox
lib/core/tasks.js
function(node, payload) { if (payload.length === 0) { // Reached end of argv path, so return current node. node.argv = { payload: payload, options: argv.options, rawOptions: argv.rawOptions }; return node; } else if (isTask(node)) { // A task has been fo...
javascript
function(node, payload) { if (payload.length === 0) { // Reached end of argv path, so return current node. node.argv = { payload: payload, options: argv.options, rawOptions: argv.rawOptions }; return node; } else if (isTask(node)) { // A task has been fo...
[ "function", "(", "node", ",", "payload", ")", "{", "if", "(", "payload", ".", "length", "===", "0", ")", "{", "// Reached end of argv path, so return current node.", "node", ".", "argv", "=", "{", "payload", ":", "payload", ",", "options", ":", "argv", ".", ...
Recursive function for searching the task tree.
[ "Recursive", "function", "for", "searching", "the", "task", "tree", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/core/tasks.js#L659-L709
train
kalabox/kalabox
lib/core/tasks.js
function(node) { if (isTask(node)) { // This is a task so do nothing. return [node]; } else if (isBranch(node)) { // Concat map children with a recMap. node.children = _.flatten(_.map(node.children, recMap)); // Sort children. node.children.sort(compareBranchOrTask); ...
javascript
function(node) { if (isTask(node)) { // This is a task so do nothing. return [node]; } else if (isBranch(node)) { // Concat map children with a recMap. node.children = _.flatten(_.map(node.children, recMap)); // Sort children. node.children.sort(compareBranchOrTask); ...
[ "function", "(", "node", ")", "{", "if", "(", "isTask", "(", "node", ")", ")", "{", "// This is a task so do nothing.", "return", "[", "node", "]", ";", "}", "else", "if", "(", "isBranch", "(", "node", ")", ")", "{", "// Concat map children with a recMap.", ...
Recursively map branch to get the cli look we want.
[ "Recursively", "map", "branch", "to", "get", "the", "cli", "look", "we", "want", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/core/tasks.js#L911-L985
train
kalabox/kalabox
lib/core/tasks.js
function(node, lines, parentName, depth) { // Default depth. if (_.isUndefined(depth)) { depth = 0; } // Default parentName. if (_.isUndefined(parentName)) { parentName = 'root'; } if (isTask(node)) { // This is a task so add to lines and nothing further. lines.pu...
javascript
function(node, lines, parentName, depth) { // Default depth. if (_.isUndefined(depth)) { depth = 0; } // Default parentName. if (_.isUndefined(parentName)) { parentName = 'root'; } if (isTask(node)) { // This is a task so add to lines and nothing further. lines.pu...
[ "function", "(", "node", ",", "lines", ",", "parentName", ",", "depth", ")", "{", "// Default depth.", "if", "(", "_", ".", "isUndefined", "(", "depth", ")", ")", "{", "depth", "=", "0", ";", "}", "// Default parentName.", "if", "(", "_", ".", "isUndef...
Recursively build list of lines.
[ "Recursively", "build", "list", "of", "lines", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/core/tasks.js#L988-L1028
train
kalabox/kalabox
lib/util/shell.js
getEnvironment
function getEnvironment(opts) { if (opts.app) { // Merge app env over the process env and return. var processEnv = _.cloneDeep(process.env); var appEnv = opts.app.env.getEnv(); return _.merge(processEnv, appEnv); } else { // Just use process env. return process.env; } }
javascript
function getEnvironment(opts) { if (opts.app) { // Merge app env over the process env and return. var processEnv = _.cloneDeep(process.env); var appEnv = opts.app.env.getEnv(); return _.merge(processEnv, appEnv); } else { // Just use process env. return process.env; } }
[ "function", "getEnvironment", "(", "opts", ")", "{", "if", "(", "opts", ".", "app", ")", "{", "// Merge app env over the process env and return.", "var", "processEnv", "=", "_", ".", "cloneDeep", "(", "process", ".", "env", ")", ";", "var", "appEnv", "=", "o...
Get an env object to inject into child process.
[ "Get", "an", "env", "object", "to", "inject", "into", "child", "process", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/util/shell.js#L26-L36
train
kalabox/kalabox
lib/integrations.js
function(name, fn) { try { // Create options. var opts = createInternals(name, fn); // Create new integration instance. var newIntegration = new Integration(opts); // Get key to register with. var key = newIntegration.name; // Ensure this integration isn't already registere...
javascript
function(name, fn) { try { // Create options. var opts = createInternals(name, fn); // Create new integration instance. var newIntegration = new Integration(opts); // Get key to register with. var key = newIntegration.name; // Ensure this integration isn't already registere...
[ "function", "(", "name", ",", "fn", ")", "{", "try", "{", "// Create options.", "var", "opts", "=", "createInternals", "(", "name", ",", "fn", ")", ";", "// Create new integration instance.", "var", "newIntegration", "=", "new", "Integration", "(", "opts", ")"...
Create new integration class instance and register with singleton map. @memberof integrations
[ "Create", "new", "integration", "class", "instance", "and", "register", "with", "singleton", "map", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/integrations.js#L49-L69
train
kalabox/kalabox
lib/integrations.js
function(name) { if (name) { // Find integration by name. var result = integrations[name]; if (!result) { throw new Error('Integration does not exist: ' + name); } return result; } else { // Return entire singleton integration map. return integrations; } }
javascript
function(name) { if (name) { // Find integration by name. var result = integrations[name]; if (!result) { throw new Error('Integration does not exist: ' + name); } return result; } else { // Return entire singleton integration map. return integrations; } }
[ "function", "(", "name", ")", "{", "if", "(", "name", ")", "{", "// Find integration by name.", "var", "result", "=", "integrations", "[", "name", "]", ";", "if", "(", "!", "result", ")", "{", "throw", "new", "Error", "(", "'Integration does not exist: '", ...
Return list of integrations, or if a name is given, just return the integration registered under that name. @memberof integrations
[ "Return", "list", "of", "integrations", "or", "if", "a", "name", "is", "given", "just", "return", "the", "integration", "registered", "under", "that", "name", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/integrations.js#L76-L88
train
kalabox/kalabox
lib/app.js
rec
function rec(counter) { // Format next app name to check for. var name = counter ? util.format(opts.template, appName, counter) : appName; // Check if app name exists. return exists(name) .then(function(exists) { // App name already exists. if (exists) { // We've chec...
javascript
function rec(counter) { // Format next app name to check for. var name = counter ? util.format(opts.template, appName, counter) : appName; // Check if app name exists. return exists(name) .then(function(exists) { // App name already exists. if (exists) { // We've chec...
[ "function", "rec", "(", "counter", ")", "{", "// Format next app name to check for.", "var", "name", "=", "counter", "?", "util", ".", "format", "(", "opts", ".", "template", ",", "appName", ",", "counter", ")", ":", "appName", ";", "// Check if app name exists....
Recursive function for finding unique app name.
[ "Recursive", "function", "for", "finding", "unique", "app", "name", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/lib/app.js#L453-L479
train
kalabox/kalabox
src/modules/guiEngine/recloop.js
rec
function rec() { // Start a new promise. return Promise.fromNode(function(cb) { // Apply jitter to interval to get next timeout duration. var duration = applyJitter(opts.jitter, opts.interval); // Init a timeout. setTimeout(function() { // Run handler function. ...
javascript
function rec() { // Start a new promise. return Promise.fromNode(function(cb) { // Apply jitter to interval to get next timeout duration. var duration = applyJitter(opts.jitter, opts.interval); // Init a timeout. setTimeout(function() { // Run handler function. ...
[ "function", "rec", "(", ")", "{", "// Start a new promise.", "return", "Promise", ".", "fromNode", "(", "function", "(", "cb", ")", "{", "// Apply jitter to interval to get next timeout duration.", "var", "duration", "=", "applyJitter", "(", "opts", ".", "jitter", "...
Recursive function.
[ "Recursive", "function", "." ]
c8d3e66fe33645e5973b138f4b8403f96abe90e8
https://github.com/kalabox/kalabox/blob/c8d3e66fe33645e5973b138f4b8403f96abe90e8/src/modules/guiEngine/recloop.js#L39-L62
train
robwierzbowski/grunt-build-control
tasks/build_control.js
assignTokens
function assignTokens () { var sourceBranch = shelljs.exec('git rev-parse --abbrev-ref HEAD', {silent: true}); var sourceCommit = shelljs.exec('git rev-parse --short HEAD', {silent: true}); if (sourceBranch.code === 0) { tokens.branch = sourceBranch.output.replace(/\n/g, ''); } if...
javascript
function assignTokens () { var sourceBranch = shelljs.exec('git rev-parse --abbrev-ref HEAD', {silent: true}); var sourceCommit = shelljs.exec('git rev-parse --short HEAD', {silent: true}); if (sourceBranch.code === 0) { tokens.branch = sourceBranch.output.replace(/\n/g, ''); } if...
[ "function", "assignTokens", "(", ")", "{", "var", "sourceBranch", "=", "shelljs", ".", "exec", "(", "'git rev-parse --abbrev-ref HEAD'", ",", "{", "silent", ":", "true", "}", ")", ";", "var", "sourceCommit", "=", "shelljs", ".", "exec", "(", "'git rev-parse --...
Assign %token% values if available
[ "Assign", "%token%", "values", "if", "available" ]
cd0086e2ffc613c683ff628c24bbfd2cc0b4c560
https://github.com/robwierzbowski/grunt-build-control/blob/cd0086e2ffc613c683ff628c24bbfd2cc0b4c560/tasks/build_control.js#L152-L168
train
robwierzbowski/grunt-build-control
tasks/build_control.js
initGit
function initGit () { if (!fs.existsSync(path.join(gruntDir, options.dir, '.git'))) { log.subhead('Creating git repository in "' + options.dir + '".'); execWrap('git init'); } }
javascript
function initGit () { if (!fs.existsSync(path.join(gruntDir, options.dir, '.git'))) { log.subhead('Creating git repository in "' + options.dir + '".'); execWrap('git init'); } }
[ "function", "initGit", "(", ")", "{", "if", "(", "!", "fs", ".", "existsSync", "(", "path", ".", "join", "(", "gruntDir", ",", "options", ".", "dir", ",", "'.git'", ")", ")", ")", "{", "log", ".", "subhead", "(", "'Creating git repository in \"'", "+",...
Initialize git repo if one doesn't exist
[ "Initialize", "git", "repo", "if", "one", "doesn", "t", "exist" ]
cd0086e2ffc613c683ff628c24bbfd2cc0b4c560
https://github.com/robwierzbowski/grunt-build-control/blob/cd0086e2ffc613c683ff628c24bbfd2cc0b4c560/tasks/build_control.js#L180-L186
train
robwierzbowski/grunt-build-control
tasks/build_control.js
initRemote
function initRemote () { remoteName = "remote-" + crypto.createHash('md5').update(options.remote).digest('hex').substring(0, 6); if (shelljs.exec('git remote', {silent: true}).output.indexOf(remoteName) === -1) { log.subhead('Creating remote.'); execWrap('git remote add ' + remoteName + ' '...
javascript
function initRemote () { remoteName = "remote-" + crypto.createHash('md5').update(options.remote).digest('hex').substring(0, 6); if (shelljs.exec('git remote', {silent: true}).output.indexOf(remoteName) === -1) { log.subhead('Creating remote.'); execWrap('git remote add ' + remoteName + ' '...
[ "function", "initRemote", "(", ")", "{", "remoteName", "=", "\"remote-\"", "+", "crypto", ".", "createHash", "(", "'md5'", ")", ".", "update", "(", "options", ".", "remote", ")", ".", "digest", "(", "'hex'", ")", ".", "substring", "(", "0", ",", "6", ...
Create a named remote if one doesn't exist
[ "Create", "a", "named", "remote", "if", "one", "doesn", "t", "exist" ]
cd0086e2ffc613c683ff628c24bbfd2cc0b4c560
https://github.com/robwierzbowski/grunt-build-control/blob/cd0086e2ffc613c683ff628c24bbfd2cc0b4c560/tasks/build_control.js#L198-L205
train
robwierzbowski/grunt-build-control
tasks/build_control.js
gitFetch
function gitFetch (dest) { var branch = (options.remoteBranch || options.branch) + (dest ? ':' + options.branch : ''); log.subhead('Fetching "' + options.branch + '" ' + (options.shallowFetch ? 'files' : 'history') + ' from ' + options.remote + '.'); // `--update-head-ok` allows fetch on a branch wit...
javascript
function gitFetch (dest) { var branch = (options.remoteBranch || options.branch) + (dest ? ':' + options.branch : ''); log.subhead('Fetching "' + options.branch + '" ' + (options.shallowFetch ? 'files' : 'history') + ' from ' + options.remote + '.'); // `--update-head-ok` allows fetch on a branch wit...
[ "function", "gitFetch", "(", "dest", ")", "{", "var", "branch", "=", "(", "options", ".", "remoteBranch", "||", "options", ".", "branch", ")", "+", "(", "dest", "?", "':'", "+", "options", ".", "branch", ":", "''", ")", ";", "log", ".", "subhead", ...
Fetch remote refs to a specific branch, equivalent to a pull without checkout
[ "Fetch", "remote", "refs", "to", "a", "specific", "branch", "equivalent", "to", "a", "pull", "without", "checkout" ]
cd0086e2ffc613c683ff628c24bbfd2cc0b4c560
https://github.com/robwierzbowski/grunt-build-control/blob/cd0086e2ffc613c683ff628c24bbfd2cc0b4c560/tasks/build_control.js#L238-L244
train
robwierzbowski/grunt-build-control
tasks/build_control.js
gitTrack
function gitTrack () { var remoteBranch = options.remoteBranch || options.branch; if (shelljs.exec('git config branch.' + options.branch + '.remote', {silent: true}).output.replace(/\n/g, '') !== remoteName) { execWrap('git branch --set-upstream-to=' + remoteName + '/' + remoteBranch + ' ' + options...
javascript
function gitTrack () { var remoteBranch = options.remoteBranch || options.branch; if (shelljs.exec('git config branch.' + options.branch + '.remote', {silent: true}).output.replace(/\n/g, '') !== remoteName) { execWrap('git branch --set-upstream-to=' + remoteName + '/' + remoteBranch + ' ' + options...
[ "function", "gitTrack", "(", ")", "{", "var", "remoteBranch", "=", "options", ".", "remoteBranch", "||", "options", ".", "branch", ";", "if", "(", "shelljs", ".", "exec", "(", "'git config branch.'", "+", "options", ".", "branch", "+", "'.remote'", ",", "{...
Set branch to track remote
[ "Set", "branch", "to", "track", "remote" ]
cd0086e2ffc613c683ff628c24bbfd2cc0b4c560
https://github.com/robwierzbowski/grunt-build-control/blob/cd0086e2ffc613c683ff628c24bbfd2cc0b4c560/tasks/build_control.js#L257-L262
train
robwierzbowski/grunt-build-control
tasks/build_control.js
gitCommit
function gitCommit () { var message = options.message .replace(/%sourceName%/g, tokens.name) .replace(/%sourceCommit%/g, tokens.commit) .replace(/%sourceBranch%/g, tokens.branch); // If there are no changes, skip commit if (shelljs.exec('git status --porcelain', {silent: true}...
javascript
function gitCommit () { var message = options.message .replace(/%sourceName%/g, tokens.name) .replace(/%sourceCommit%/g, tokens.commit) .replace(/%sourceBranch%/g, tokens.branch); // If there are no changes, skip commit if (shelljs.exec('git status --porcelain', {silent: true}...
[ "function", "gitCommit", "(", ")", "{", "var", "message", "=", "options", ".", "message", ".", "replace", "(", "/", "%sourceName%", "/", "g", ",", "tokens", ".", "name", ")", ".", "replace", "(", "/", "%sourceCommit%", "/", "g", ",", "tokens", ".", "...
Stage and commit to a branch
[ "Stage", "and", "commit", "to", "a", "branch" ]
cd0086e2ffc613c683ff628c24bbfd2cc0b4c560
https://github.com/robwierzbowski/grunt-build-control/blob/cd0086e2ffc613c683ff628c24bbfd2cc0b4c560/tasks/build_control.js#L265-L287
train
robwierzbowski/grunt-build-control
tasks/build_control.js
gitTag
function gitTag () { // If the tag exists, skip tagging if (shelljs.exec('git ls-remote --tags --exit-code ' + remoteName + ' ' + options.tag, {silent: true}).code === 0) { log.subhead('The tag "' + options.tag + '" already exists on remote. Skipping tagging.'); return; } log.su...
javascript
function gitTag () { // If the tag exists, skip tagging if (shelljs.exec('git ls-remote --tags --exit-code ' + remoteName + ' ' + options.tag, {silent: true}).code === 0) { log.subhead('The tag "' + options.tag + '" already exists on remote. Skipping tagging.'); return; } log.su...
[ "function", "gitTag", "(", ")", "{", "// If the tag exists, skip tagging", "if", "(", "shelljs", ".", "exec", "(", "'git ls-remote --tags --exit-code '", "+", "remoteName", "+", "' '", "+", "options", ".", "tag", ",", "{", "silent", ":", "true", "}", ")", ".",...
Tag local branch
[ "Tag", "local", "branch" ]
cd0086e2ffc613c683ff628c24bbfd2cc0b4c560
https://github.com/robwierzbowski/grunt-build-control/blob/cd0086e2ffc613c683ff628c24bbfd2cc0b4c560/tasks/build_control.js#L290-L299
train
robwierzbowski/grunt-build-control
tasks/build_control.js
gitPush
function gitPush () { var branch = options.branch; var withForce = options.force ? ' --force ' : ''; if (options.remoteBranch) branch += ':' + options.remoteBranch; log.subhead('Pushing ' + options.branch + ' to ' + options.remote + withForce); execWrap('git push ' + withForce + remoteNa...
javascript
function gitPush () { var branch = options.branch; var withForce = options.force ? ' --force ' : ''; if (options.remoteBranch) branch += ':' + options.remoteBranch; log.subhead('Pushing ' + options.branch + ' to ' + options.remote + withForce); execWrap('git push ' + withForce + remoteNa...
[ "function", "gitPush", "(", ")", "{", "var", "branch", "=", "options", ".", "branch", ";", "var", "withForce", "=", "options", ".", "force", "?", "' --force '", ":", "''", ";", "if", "(", "options", ".", "remoteBranch", ")", "branch", "+=", "':'", "+",...
Push branch to remote
[ "Push", "branch", "to", "remote" ]
cd0086e2ffc613c683ff628c24bbfd2cc0b4c560
https://github.com/robwierzbowski/grunt-build-control/blob/cd0086e2ffc613c683ff628c24bbfd2cc0b4c560/tasks/build_control.js#L302-L314
train
ncuillery/angular-breadcrumb
release/angular-breadcrumb.js
function(state) { // Check if state has explicit parent OR we try guess parent from its name var parent = state.parent || (/^(.+)\.[^.]+$/.exec(state.name) || [])[1]; var isObjectParent = typeof parent === "object"; // if parent is a object reference, then extract the nam...
javascript
function(state) { // Check if state has explicit parent OR we try guess parent from its name var parent = state.parent || (/^(.+)\.[^.]+$/.exec(state.name) || [])[1]; var isObjectParent = typeof parent === "object"; // if parent is a object reference, then extract the nam...
[ "function", "(", "state", ")", "{", "// Check if state has explicit parent OR we try guess parent from its name", "var", "parent", "=", "state", ".", "parent", "||", "(", "/", "^(.+)\\.[^.]+$", "/", ".", "exec", "(", "state", ".", "name", ")", "||", "[", "]", ")...
Get the parent state
[ "Get", "the", "parent", "state" ]
301df6351f9272347ad3bd4b75f51a4d245dd2ef
https://github.com/ncuillery/angular-breadcrumb/blob/301df6351f9272347ad3bd4b75f51a4d245dd2ef/release/angular-breadcrumb.js#L61-L67
train
ncuillery/angular-breadcrumb
release/angular-breadcrumb.js
function(chain, stateRef) { var conf, parentParams, ref = parseStateRef(stateRef), force = false, skip = false; for(var i=0, l=chain.length; i<l; i+=1) { if (chain[i].name === ref.state) { return...
javascript
function(chain, stateRef) { var conf, parentParams, ref = parseStateRef(stateRef), force = false, skip = false; for(var i=0, l=chain.length; i<l; i+=1) { if (chain[i].name === ref.state) { return...
[ "function", "(", "chain", ",", "stateRef", ")", "{", "var", "conf", ",", "parentParams", ",", "ref", "=", "parseStateRef", "(", "stateRef", ")", ",", "force", "=", "false", ",", "skip", "=", "false", ";", "for", "(", "var", "i", "=", "0", ",", "l",...
Add the state in the chain if not already in and if not abstract
[ "Add", "the", "state", "in", "the", "chain", "if", "not", "already", "in", "and", "if", "not", "abstract" ]
301df6351f9272347ad3bd4b75f51a4d245dd2ef
https://github.com/ncuillery/angular-breadcrumb/blob/301df6351f9272347ad3bd4b75f51a4d245dd2ef/release/angular-breadcrumb.js#L70-L98
train
ncuillery/angular-breadcrumb
release/angular-breadcrumb.js
function(stateRef) { var ref = parseStateRef(stateRef), conf = $state.get(ref.state); if(conf.ncyBreadcrumb && conf.ncyBreadcrumb.parent) { // Handle the "parent" property of the breadcrumb, override the parent/child relation of the state var isFu...
javascript
function(stateRef) { var ref = parseStateRef(stateRef), conf = $state.get(ref.state); if(conf.ncyBreadcrumb && conf.ncyBreadcrumb.parent) { // Handle the "parent" property of the breadcrumb, override the parent/child relation of the state var isFu...
[ "function", "(", "stateRef", ")", "{", "var", "ref", "=", "parseStateRef", "(", "stateRef", ")", ",", "conf", "=", "$state", ".", "get", "(", "ref", ".", "state", ")", ";", "if", "(", "conf", ".", "ncyBreadcrumb", "&&", "conf", ".", "ncyBreadcrumb", ...
Get the state for the parent step in the breadcrumb
[ "Get", "the", "state", "for", "the", "parent", "step", "in", "the", "breadcrumb" ]
301df6351f9272347ad3bd4b75f51a4d245dd2ef
https://github.com/ncuillery/angular-breadcrumb/blob/301df6351f9272347ad3bd4b75f51a4d245dd2ef/release/angular-breadcrumb.js#L101-L115
train
MathieuLoutre/grunt-aws-s3
tasks/aws_s3.js
function (params) { return _.every(_.keys(params), function (key) { return _.contains(put_params, key); }); }
javascript
function (params) { return _.every(_.keys(params), function (key) { return _.contains(put_params, key); }); }
[ "function", "(", "params", ")", "{", "return", "_", ".", "every", "(", "_", ".", "keys", "(", "params", ")", ",", "function", "(", "key", ")", "{", "return", "_", ".", "contains", "(", "put_params", ",", "key", ")", ";", "}", ")", ";", "}" ]
Checks that all params are in put_params
[ "Checks", "that", "all", "params", "are", "in", "put_params" ]
7ebcdd6287da7c2cbee772d763d6648d259a62a1
https://github.com/MathieuLoutre/grunt-aws-s3/blob/7ebcdd6287da7c2cbee772d763d6648d259a62a1/tasks/aws_s3.js#L82-L87
train
MathieuLoutre/grunt-aws-s3
tasks/aws_s3.js
function (key, dest) { var path; if (_.last(dest) === '/') { // if the path string is a directory, remove it from the key path = key.replace(dest, ''); } else if (key.replace(dest, '') === '') { path = _.last(key.split('/')); } else { path = key; } return path; }
javascript
function (key, dest) { var path; if (_.last(dest) === '/') { // if the path string is a directory, remove it from the key path = key.replace(dest, ''); } else if (key.replace(dest, '') === '') { path = _.last(key.split('/')); } else { path = key; } return path; }
[ "function", "(", "key", ",", "dest", ")", "{", "var", "path", ";", "if", "(", "_", ".", "last", "(", "dest", ")", "===", "'/'", ")", "{", "// if the path string is a directory, remove it from the key", "path", "=", "key", ".", "replace", "(", "dest", ",", ...
Get the key URL relative to a path string
[ "Get", "the", "key", "URL", "relative", "to", "a", "path", "string" ]
7ebcdd6287da7c2cbee772d763d6648d259a62a1
https://github.com/MathieuLoutre/grunt-aws-s3/blob/7ebcdd6287da7c2cbee772d763d6648d259a62a1/tasks/aws_s3.js#L102-L118
train
MathieuLoutre/grunt-aws-s3
tasks/aws_s3.js
function (options, callback) { fs.stat(options.file_path, function (err, stats) { if (err) { callback(err); } else { var local_date = new Date(stats.mtime).getTime(); var server_date = new Date(options.server_date).getTime(); if (options.compare_date === 'newer') { callback(n...
javascript
function (options, callback) { fs.stat(options.file_path, function (err, stats) { if (err) { callback(err); } else { var local_date = new Date(stats.mtime).getTime(); var server_date = new Date(options.server_date).getTime(); if (options.compare_date === 'newer') { callback(n...
[ "function", "(", "options", ",", "callback", ")", "{", "fs", ".", "stat", "(", "options", ".", "file_path", ",", "function", "(", "err", ",", "stats", ")", "{", "if", "(", "err", ")", "{", "callback", "(", "err", ")", ";", "}", "else", "{", "var"...
Checks that local file is 'date_compare' than server file
[ "Checks", "that", "local", "file", "is", "date_compare", "than", "server", "file" ]
7ebcdd6287da7c2cbee772d763d6648d259a62a1
https://github.com/MathieuLoutre/grunt-aws-s3/blob/7ebcdd6287da7c2cbee772d763d6648d259a62a1/tasks/aws_s3.js#L146-L165
train
cytoscape/cytoscape.js-cose-bilkent
src/Layout/index.js
function() { if (options.fit) { options.cy.fit(options.eles.nodes(), options.padding); } if (!ready) { ready = true; self.cy.one('layoutready', options.ready); self.cy.trigger({type: 'layoutready', layout: self}); } }
javascript
function() { if (options.fit) { options.cy.fit(options.eles.nodes(), options.padding); } if (!ready) { ready = true; self.cy.one('layoutready', options.ready); self.cy.trigger({type: 'layoutready', layout: self}); } }
[ "function", "(", ")", "{", "if", "(", "options", ".", "fit", ")", "{", "options", ".", "cy", ".", "fit", "(", "options", ".", "eles", ".", "nodes", "(", ")", ",", "options", ".", "padding", ")", ";", "}", "if", "(", "!", "ready", ")", "{", "r...
Thigs to perform after nodes are repositioned on screen
[ "Thigs", "to", "perform", "after", "nodes", "are", "repositioned", "on", "screen" ]
8834b05101daf241ba75ea4a84b703fffec5cbc5
https://github.com/cytoscape/cytoscape.js-cose-bilkent/blob/8834b05101daf241ba75ea4a84b703fffec5cbc5/src/Layout/index.js#L186-L196
train
telehash/telehash-js
ext/stream.class.js
ChannelStream
function ChannelStream(chan, encoding){ if(!encoding) encoding = 'binary'; if(typeof chan != 'object' || !chan.isChannel) { log.warn('invalid channel passed to streamize'); return false; } var allowHalfOpen = (chan.type === "thtp") ? true : false; Duplex.call(this,{allowHalfOpen: allowHalfOpen, ob...
javascript
function ChannelStream(chan, encoding){ if(!encoding) encoding = 'binary'; if(typeof chan != 'object' || !chan.isChannel) { log.warn('invalid channel passed to streamize'); return false; } var allowHalfOpen = (chan.type === "thtp") ? true : false; Duplex.call(this,{allowHalfOpen: allowHalfOpen, ob...
[ "function", "ChannelStream", "(", "chan", ",", "encoding", ")", "{", "if", "(", "!", "encoding", ")", "encoding", "=", "'binary'", ";", "if", "(", "typeof", "chan", "!=", "'object'", "||", "!", "chan", ".", "isChannel", ")", "{", "log", ".", "warn", ...
ChannelStream impliments a Duplex stream API over Telehash channels. for Duplex stream usage, consult core node docs. for an idea of how you might expand upon streams within the Telehash ecosystem, see thtp @class ChannelStream @constructor @param {Channel} channel - a Telehash channel (generated by e3x) @param {string...
[ "ChannelStream", "impliments", "a", "Duplex", "stream", "API", "over", "Telehash", "channels", ".", "for", "Duplex", "stream", "usage", "consult", "core", "node", "docs", ".", "for", "an", "idea", "of", "how", "you", "might", "expand", "upon", "streams", "wi...
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/ext/stream.class.js#L17-L51
train
telehash/telehash-js
ext/chat.js
fail
function fail(err, cbErr) { if(!err) return; // only catch errors log.warn('chat fail',err); chat.err = err; // TODO error inbox/outbox if(typeof cbErr == 'function') cbErr(err); readyUp(err); }
javascript
function fail(err, cbErr) { if(!err) return; // only catch errors log.warn('chat fail',err); chat.err = err; // TODO error inbox/outbox if(typeof cbErr == 'function') cbErr(err); readyUp(err); }
[ "function", "fail", "(", "err", ",", "cbErr", ")", "{", "if", "(", "!", "err", ")", "return", ";", "// only catch errors", "log", ".", "warn", "(", "'chat fail'", ",", "err", ")", ";", "chat", ".", "err", "=", "err", ";", "// TODO error inbox/outbox", ...
internal fail handler
[ "internal", "fail", "handler" ]
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/ext/chat.js#L79-L87
train
telehash/telehash-js
ext/chat.js
stamp
function stamp() { if(!chat.seq) return fail('chat history overflow, please restart'); var id = lib.hashname.siphash(mesh.hashname, chat.secret); for(var i = 0; i < chat.seq; i++) id = lib.hashname.siphash(id.key,id); chat.seq--; return lib.base32.encode(id); }
javascript
function stamp() { if(!chat.seq) return fail('chat history overflow, please restart'); var id = lib.hashname.siphash(mesh.hashname, chat.secret); for(var i = 0; i < chat.seq; i++) id = lib.hashname.siphash(id.key,id); chat.seq--; return lib.base32.encode(id); }
[ "function", "stamp", "(", ")", "{", "if", "(", "!", "chat", ".", "seq", ")", "return", "fail", "(", "'chat history overflow, please restart'", ")", ";", "var", "id", "=", "lib", ".", "hashname", ".", "siphash", "(", "mesh", ".", "hashname", ",", "chat", ...
internal message id generator
[ "internal", "message", "id", "generator" ]
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/ext/chat.js#L90-L97
train
telehash/telehash-js
ext/chat.js
sync
function sync(id) { if(id == last.json.id) return; // bottoms up, send older first sync(lib.base32.encode(lib.hashname.siphash(mesh.hashname, lib.base32.decode(id)))); stream.write(chat.messages[id]); }
javascript
function sync(id) { if(id == last.json.id) return; // bottoms up, send older first sync(lib.base32.encode(lib.hashname.siphash(mesh.hashname, lib.base32.decode(id)))); stream.write(chat.messages[id]); }
[ "function", "sync", "(", "id", ")", "{", "if", "(", "id", "==", "last", ".", "json", ".", "id", ")", "return", ";", "// bottoms up, send older first", "sync", "(", "lib", ".", "base32", ".", "encode", "(", "lib", ".", "hashname", ".", "siphash", "(", ...
send any messages since the last they saw
[ "send", "any", "messages", "since", "the", "last", "they", "saw" ]
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/ext/chat.js#L169-L175
train
telehash/telehash-js
bin/chat.js
rlog
function rlog() { process.stdout.clearLine(); process.stdout.cursorTo(0); console.log.apply(console, arguments); rl.prompt(); }
javascript
function rlog() { process.stdout.clearLine(); process.stdout.cursorTo(0); console.log.apply(console, arguments); rl.prompt(); }
[ "function", "rlog", "(", ")", "{", "process", ".", "stdout", ".", "clearLine", "(", ")", ";", "process", ".", "stdout", ".", "cursorTo", "(", "0", ")", ";", "console", ".", "log", ".", "apply", "(", "console", ",", "arguments", ")", ";", "rl", ".",...
clear readline then log
[ "clear", "readline", "then", "log" ]
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/bin/chat.js#L49-L55
train
telehash/telehash-js
lib/util/json.js
loadMeshJSON
function loadMeshJSON(mesh,hashname, args){ // add/get json store var json = mesh.json_store[hashname]; if(!json) json = mesh.json_store[hashname] = {hashname:hashname,paths:[],keys:{}}; if(args.keys) json.keys = args.keys; // only know a single csid/key if(args.csid && args.key) { json.keys...
javascript
function loadMeshJSON(mesh,hashname, args){ // add/get json store var json = mesh.json_store[hashname]; if(!json) json = mesh.json_store[hashname] = {hashname:hashname,paths:[],keys:{}}; if(args.keys) json.keys = args.keys; // only know a single csid/key if(args.csid && args.key) { json.keys...
[ "function", "loadMeshJSON", "(", "mesh", ",", "hashname", ",", "args", ")", "{", "// add/get json store", "var", "json", "=", "mesh", ".", "json_store", "[", "hashname", "]", ";", "if", "(", "!", "json", ")", "json", "=", "mesh", ".", "json_store", "[", ...
load a hashname and other parameters into our json format @param {hashname} hn @param {object} args - a hash with key, keys, and csid params @return {object} json - the populated json
[ "load", "a", "hashname", "and", "other", "parameters", "into", "our", "json", "format" ]
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/lib/util/json.js#L15-L37
train
telehash/telehash-js
lib/mesh.class.js
ready
function ready(err, mesh) { // links can be passed in if(Array.isArray(args.links)) args.links.forEach(function forEachLinkArg(linkArg){ if(linkArg.hashname == mesh.hashname) return; // ignore ourselves, happens mesh.link(linkArg); }); cbMesh(err,mesh); }
javascript
function ready(err, mesh) { // links can be passed in if(Array.isArray(args.links)) args.links.forEach(function forEachLinkArg(linkArg){ if(linkArg.hashname == mesh.hashname) return; // ignore ourselves, happens mesh.link(linkArg); }); cbMesh(err,mesh); }
[ "function", "ready", "(", "err", ",", "mesh", ")", "{", "// links can be passed in", "if", "(", "Array", ".", "isArray", "(", "args", ".", "links", ")", ")", "args", ".", "links", ".", "forEach", "(", "function", "forEachLinkArg", "(", "linkArg", ")", "{...
after extensions have run, load any other arguments
[ "after", "extensions", "have", "run", "load", "any", "other", "arguments" ]
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/lib/mesh.class.js#L89-L99
train
telehash/telehash-js
index.js
loaded
function loaded(err) { if(err) { log.error(err); cbMesh(err); return false; } return telehash.mesh(args, function(err, mesh){ if(!mesh) return cbMesh(err); // sync links automatically to file whenever they change if(linksFile) mesh.linked(function(json, str){ ...
javascript
function loaded(err) { if(err) { log.error(err); cbMesh(err); return false; } return telehash.mesh(args, function(err, mesh){ if(!mesh) return cbMesh(err); // sync links automatically to file whenever they change if(linksFile) mesh.linked(function(json, str){ ...
[ "function", "loaded", "(", "err", ")", "{", "if", "(", "err", ")", "{", "log", ".", "error", "(", "err", ")", ";", "cbMesh", "(", "err", ")", ";", "return", "false", ";", "}", "return", "telehash", ".", "mesh", "(", "args", ",", "function", "(", ...
set up some node-specific things after the mesh is created
[ "set", "up", "some", "node", "-", "specific", "things", "after", "the", "mesh", "is", "created" ]
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/index.js#L23-L43
train
telehash/telehash-js
lib/util/handshake.js
handshake_collect
function handshake_collect(mesh, id, handshake, pipe, message) { handshake = handshake_bootstrap(handshake); if (!handshake) return false; var valid = handshake_validate(id,handshake, message, mesh); if (!valid) return false; // get all from cache w/ matching at, by type var types = handshake_type...
javascript
function handshake_collect(mesh, id, handshake, pipe, message) { handshake = handshake_bootstrap(handshake); if (!handshake) return false; var valid = handshake_validate(id,handshake, message, mesh); if (!valid) return false; // get all from cache w/ matching at, by type var types = handshake_type...
[ "function", "handshake_collect", "(", "mesh", ",", "id", ",", "handshake", ",", "pipe", ",", "message", ")", "{", "handshake", "=", "handshake_bootstrap", "(", "handshake", ")", ";", "if", "(", "!", "handshake", ")", "return", "false", ";", "var", "valid",...
collect incoming handshakes to accept them @param {object} id @param {handshake} handshake @param {pipe} pipe @param {Buffer} message
[ "collect", "incoming", "handshakes", "to", "accept", "them" ]
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/lib/util/handshake.js#L26-L65
train
telehash/telehash-js
lib/util/receive.js
bouncer
function bouncer(err) { if(!err) return; var json = {err:err}; json.c = inner.json.c; log.debug('bouncing open',json); link.x.send({json:json}); }
javascript
function bouncer(err) { if(!err) return; var json = {err:err}; json.c = inner.json.c; log.debug('bouncing open',json); link.x.send({json:json}); }
[ "function", "bouncer", "(", "err", ")", "{", "if", "(", "!", "err", ")", "return", ";", "var", "json", "=", "{", "err", ":", "err", "}", ";", "json", ".", "c", "=", "inner", ".", "json", ".", "c", ";", "log", ".", "debug", "(", "'bouncing open'...
error utility for any open handler problems
[ "error", "utility", "for", "any", "open", "handler", "problems" ]
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/lib/util/receive.js#L91-L98
train
telehash/telehash-js
ext/peer.js
peer_send
function peer_send(packet, link, cbSend) { var router = mesh.index[to]; if(!router) return cbSend('cannot peer to an unknown router: '+pipe.to); if(!router.x) return cbSend('cannot peer yet via this router: '+pipe.to); if(!link) return cbSend('requires link'); // no packet means try t...
javascript
function peer_send(packet, link, cbSend) { var router = mesh.index[to]; if(!router) return cbSend('cannot peer to an unknown router: '+pipe.to); if(!router.x) return cbSend('cannot peer yet via this router: '+pipe.to); if(!link) return cbSend('requires link'); // no packet means try t...
[ "function", "peer_send", "(", "packet", ",", "link", ",", "cbSend", ")", "{", "var", "router", "=", "mesh", ".", "index", "[", "to", "]", ";", "if", "(", "!", "router", ")", "return", "cbSend", "(", "'cannot peer to an unknown router: '", "+", "pipe", "....
handle any peer delivery through the router
[ "handle", "any", "peer", "delivery", "through", "the", "router" ]
a9c9fa2a909382c0dc57c190e682198e21d1c96a
https://github.com/telehash/telehash-js/blob/a9c9fa2a909382c0dc57c190e682198e21d1c96a/ext/peer.js#L28-L58
train
christopherthielen/ui-router-extras
release/modular/ct-ui-router-extras.sticky.js
mapInactives
function mapInactives() { var mappedStates = {}; angular.forEach(inactiveStates, function (state, name) { var stickyAncestors = getStickyStateStack(state); for (var i = 0; i < stickyAncestors.length; i++) { var parent = stickyAncestors[i].parent; mappedStates[...
javascript
function mapInactives() { var mappedStates = {}; angular.forEach(inactiveStates, function (state, name) { var stickyAncestors = getStickyStateStack(state); for (var i = 0; i < stickyAncestors.length; i++) { var parent = stickyAncestors[i].parent; mappedStates[...
[ "function", "mapInactives", "(", ")", "{", "var", "mappedStates", "=", "{", "}", ";", "angular", ".", "forEach", "(", "inactiveStates", ",", "function", "(", "state", ",", "name", ")", "{", "var", "stickyAncestors", "=", "getStickyStateStack", "(", "state", ...
Each inactive states is either a sticky state, or a child of a sticky state. This function finds the closest ancestor sticky state, then find that state's parent. Map all inactive states to their closest parent-to-sticky state.
[ "Each", "inactive", "states", "is", "either", "a", "sticky", "state", "or", "a", "child", "of", "a", "sticky", "state", ".", "This", "function", "finds", "the", "closest", "ancestor", "sticky", "state", "then", "find", "that", "state", "s", "parent", ".", ...
9ac225e8f137a4f5811595e817a39b58d1cd5625
https://github.com/christopherthielen/ui-router-extras/blob/9ac225e8f137a4f5811595e817a39b58d1cd5625/release/modular/ct-ui-router-extras.sticky.js#L47-L62
train
christopherthielen/ui-router-extras
release/modular/ct-ui-router-extras.sticky.js
getStickyStateStack
function getStickyStateStack(state) { var stack = []; if (!state) return stack; do { if (state.sticky) stack.push(state); state = state.parent; } while (state); stack.reverse(); return stack; }
javascript
function getStickyStateStack(state) { var stack = []; if (!state) return stack; do { if (state.sticky) stack.push(state); state = state.parent; } while (state); stack.reverse(); return stack; }
[ "function", "getStickyStateStack", "(", "state", ")", "{", "var", "stack", "=", "[", "]", ";", "if", "(", "!", "state", ")", "return", "stack", ";", "do", "{", "if", "(", "state", ".", "sticky", ")", "stack", ".", "push", "(", "state", ")", ";", ...
Given a state, returns all ancestor states which are sticky. Walks up the view's state's ancestry tree and locates each ancestor state which is marked as sticky. Returns an array populated with only those ancestor sticky states.
[ "Given", "a", "state", "returns", "all", "ancestor", "states", "which", "are", "sticky", ".", "Walks", "up", "the", "view", "s", "state", "s", "ancestry", "tree", "and", "locates", "each", "ancestor", "state", "which", "is", "marked", "as", "sticky", ".", ...
9ac225e8f137a4f5811595e817a39b58d1cd5625
https://github.com/christopherthielen/ui-router-extras/blob/9ac225e8f137a4f5811595e817a39b58d1cd5625/release/modular/ct-ui-router-extras.sticky.js#L79-L88
train
christopherthielen/ui-router-extras
release/modular/ct-ui-router-extras.sticky.js
function (state) { // Keep locals around. inactiveStates[state.self.name] = state; // Notify states they are being Inactivated (i.e., a different // sticky state tree is now active). state.self.status = 'inactive'; if (state.self.onInactivate) $inj...
javascript
function (state) { // Keep locals around. inactiveStates[state.self.name] = state; // Notify states they are being Inactivated (i.e., a different // sticky state tree is now active). state.self.status = 'inactive'; if (state.self.onInactivate) $inj...
[ "function", "(", "state", ")", "{", "// Keep locals around.", "inactiveStates", "[", "state", ".", "self", ".", "name", "]", "=", "state", ";", "// Notify states they are being Inactivated (i.e., a different", "// sticky state tree is now active).", "state", ".", "self", ...
Adds a state to the inactivated sticky state registry.
[ "Adds", "a", "state", "to", "the", "inactivated", "sticky", "state", "registry", "." ]
9ac225e8f137a4f5811595e817a39b58d1cd5625
https://github.com/christopherthielen/ui-router-extras/blob/9ac225e8f137a4f5811595e817a39b58d1cd5625/release/modular/ct-ui-router-extras.sticky.js#L302-L310
train
christopherthielen/ui-router-extras
release/modular/ct-ui-router-extras.sticky.js
function (exiting, exitQueue, onExit) { var exitingNames = {}; angular.forEach(exitQueue, function (state) { exitingNames[state.self.name] = true; }); angular.forEach(inactiveStates, function (inactiveExiting, name) { // TODO: Might need to run the inacti...
javascript
function (exiting, exitQueue, onExit) { var exitingNames = {}; angular.forEach(exitQueue, function (state) { exitingNames[state.self.name] = true; }); angular.forEach(inactiveStates, function (inactiveExiting, name) { // TODO: Might need to run the inacti...
[ "function", "(", "exiting", ",", "exitQueue", ",", "onExit", ")", "{", "var", "exitingNames", "=", "{", "}", ";", "angular", ".", "forEach", "(", "exitQueue", ",", "function", "(", "state", ")", "{", "exitingNames", "[", "state", ".", "self", ".", "nam...
Exits all inactivated descendant substates when the ancestor state is exited. When transitionTo is exiting a state, this function is called with the state being exited. It checks the registry of inactivated states for descendants of the exited state and also exits those descendants. It then removes the locals and de-...
[ "Exits", "all", "inactivated", "descendant", "substates", "when", "the", "ancestor", "state", "is", "exited", ".", "When", "transitionTo", "is", "exiting", "a", "state", "this", "function", "is", "called", "with", "the", "state", "being", "exited", ".", "It", ...
9ac225e8f137a4f5811595e817a39b58d1cd5625
https://github.com/christopherthielen/ui-router-extras/blob/9ac225e8f137a4f5811595e817a39b58d1cd5625/release/modular/ct-ui-router-extras.sticky.js#L327-L353
train
christopherthielen/ui-router-extras
release/modular/ct-ui-router-extras.sticky.js
function (entering, params, onEnter, updateParams) { var inactivatedState = getInactivatedState(entering); if (inactivatedState && (updateParams || !getInactivatedState(entering, params))) { var savedLocals = entering.locals; this.stateExiting(inactivatedState); e...
javascript
function (entering, params, onEnter, updateParams) { var inactivatedState = getInactivatedState(entering); if (inactivatedState && (updateParams || !getInactivatedState(entering, params))) { var savedLocals = entering.locals; this.stateExiting(inactivatedState); e...
[ "function", "(", "entering", ",", "params", ",", "onEnter", ",", "updateParams", ")", "{", "var", "inactivatedState", "=", "getInactivatedState", "(", "entering", ")", ";", "if", "(", "inactivatedState", "&&", "(", "updateParams", "||", "!", "getInactivatedState...
Removes a previously inactivated state from the inactive sticky state registry
[ "Removes", "a", "previously", "inactivated", "state", "from", "the", "inactive", "sticky", "state", "registry" ]
9ac225e8f137a4f5811595e817a39b58d1cd5625
https://github.com/christopherthielen/ui-router-extras/blob/9ac225e8f137a4f5811595e817a39b58d1cd5625/release/modular/ct-ui-router-extras.sticky.js#L356-L367
train
christopherthielen/ui-router-extras
release/modular/ct-ui-router-extras.sticky.js
SurrogateState
function SurrogateState(type) { return { resolve: { }, locals: { globals: root && root.locals && root.locals.globals }, views: { }, self: { }, params: { }, ownParams: ( versionHeuristics.hasParamSet ? { $$equals: function() { return true; } } : []), surrogateType: type }; }
javascript
function SurrogateState(type) { return { resolve: { }, locals: { globals: root && root.locals && root.locals.globals }, views: { }, self: { }, params: { }, ownParams: ( versionHeuristics.hasParamSet ? { $$equals: function() { return true; } } : []), surrogateType: type }; }
[ "function", "SurrogateState", "(", "type", ")", "{", "return", "{", "resolve", ":", "{", "}", ",", "locals", ":", "{", "globals", ":", "root", "&&", "root", ".", "locals", "&&", "root", ".", "locals", ".", "globals", "}", ",", "views", ":", "{", "}...
Creates a blank surrogate state
[ "Creates", "a", "blank", "surrogate", "state" ]
9ac225e8f137a4f5811595e817a39b58d1cd5625
https://github.com/christopherthielen/ui-router-extras/blob/9ac225e8f137a4f5811595e817a39b58d1cd5625/release/modular/ct-ui-router-extras.sticky.js#L460-L472
train
christopherthielen/ui-router-extras
release/modular/ct-ui-router-extras.core.js
protoKeys
function protoKeys(object, ignoreKeys) { var result = []; for (var key in object) { if (!ignoreKeys || ignoreKeys.indexOf(key) === -1) result.push(key); } return result; }
javascript
function protoKeys(object, ignoreKeys) { var result = []; for (var key in object) { if (!ignoreKeys || ignoreKeys.indexOf(key) === -1) result.push(key); } return result; }
[ "function", "protoKeys", "(", "object", ",", "ignoreKeys", ")", "{", "var", "result", "=", "[", "]", ";", "for", "(", "var", "key", "in", "object", ")", "{", "if", "(", "!", "ignoreKeys", "||", "ignoreKeys", ".", "indexOf", "(", "key", ")", "===", ...
like objectKeys, but includes keys from prototype chain. @param object the object whose prototypal keys will be returned @param ignoreKeys an array of keys to ignore Duplicates code in UI-Router common.js
[ "like", "objectKeys", "but", "includes", "keys", "from", "prototype", "chain", "." ]
9ac225e8f137a4f5811595e817a39b58d1cd5625
https://github.com/christopherthielen/ui-router-extras/blob/9ac225e8f137a4f5811595e817a39b58d1cd5625/release/modular/ct-ui-router-extras.core.js#L103-L110
train
stealjs/steal-cordova
lib/steal-cordova.js
function(opts){ var buildPath = (opts && opts.path) || this.options.path; assert(!!buildPath, "Path needs to be provided"); var p = path.resolve(buildPath); var stealCordova = this; return new Promise(function(resolve, reject){ fse.exists(p, function(doesExist){ if(doesExist) { resolve(); } ...
javascript
function(opts){ var buildPath = (opts && opts.path) || this.options.path; assert(!!buildPath, "Path needs to be provided"); var p = path.resolve(buildPath); var stealCordova = this; return new Promise(function(resolve, reject){ fse.exists(p, function(doesExist){ if(doesExist) { resolve(); } ...
[ "function", "(", "opts", ")", "{", "var", "buildPath", "=", "(", "opts", "&&", "opts", ".", "path", ")", "||", "this", ".", "options", ".", "path", ";", "assert", "(", "!", "!", "buildPath", ",", "\"Path needs to be provided\"", ")", ";", "var", "p", ...
Only initialize if it hasn't already been.
[ "Only", "initialize", "if", "it", "hasn", "t", "already", "been", "." ]
f4e704eead4133afa0585ea2ecad439d089086ee
https://github.com/stealjs/steal-cordova/blob/f4e704eead4133afa0585ea2ecad439d089086ee/lib/steal-cordova.js#L38-L58
train
synacor/preact-context-provider
src/index.js
assign
function assign(obj, props) { for (let i in props) { if (props.hasOwnProperty(i)) { obj[i] = props[i]; } } return obj; }
javascript
function assign(obj, props) { for (let i in props) { if (props.hasOwnProperty(i)) { obj[i] = props[i]; } } return obj; }
[ "function", "assign", "(", "obj", ",", "props", ")", "{", "for", "(", "let", "i", "in", "props", ")", "{", "if", "(", "props", ".", "hasOwnProperty", "(", "i", ")", ")", "{", "obj", "[", "i", "]", "=", "props", "[", "i", "]", ";", "}", "}", ...
A simpler Object.assign @private
[ "A", "simpler", "Object", ".", "assign" ]
fb0677932c7126f5095ce5eb19c96136ac131f9f
https://github.com/synacor/preact-context-provider/blob/fb0677932c7126f5095ce5eb19c96136ac131f9f/src/index.js#L50-L57
train
synacor/preact-context-provider
src/index.js
deepAssign
function deepAssign(target, source) { //if they aren't both objects, use target if it is defined (null/0/false/etc. are OK), otherwise use source if (!(target && source && typeof target==='object' && typeof source==='object')) { return typeof target !== 'undefined' ? target : source; } let out = assign({}, targe...
javascript
function deepAssign(target, source) { //if they aren't both objects, use target if it is defined (null/0/false/etc. are OK), otherwise use source if (!(target && source && typeof target==='object' && typeof source==='object')) { return typeof target !== 'undefined' ? target : source; } let out = assign({}, targe...
[ "function", "deepAssign", "(", "target", ",", "source", ")", "{", "//if they aren't both objects, use target if it is defined (null/0/false/etc. are OK), otherwise use source", "if", "(", "!", "(", "target", "&&", "source", "&&", "typeof", "target", "===", "'object'", "&&",...
Recursively copy keys from `source` to `target`, skipping truthy values already in `target` so parent values can block child values @private
[ "Recursively", "copy", "keys", "from", "source", "to", "target", "skipping", "truthy", "values", "already", "in", "target", "so", "parent", "values", "can", "block", "child", "values" ]
fb0677932c7126f5095ce5eb19c96136ac131f9f
https://github.com/synacor/preact-context-provider/blob/fb0677932c7126f5095ce5eb19c96136ac131f9f/src/index.js#L63-L76
train
jonashartmann/webcam-directive
app/scripts/webcam.js
onSuccess
function onSuccess(stream) { videoStream = stream; if (window.hasModernUserMedia) { videoElem.srcObject = stream; } else if (navigator.mozGetUserMedia) { // Firefox supports a src object videoElem.mozSrcObject = stream; } else { va...
javascript
function onSuccess(stream) { videoStream = stream; if (window.hasModernUserMedia) { videoElem.srcObject = stream; } else if (navigator.mozGetUserMedia) { // Firefox supports a src object videoElem.mozSrcObject = stream; } else { va...
[ "function", "onSuccess", "(", "stream", ")", "{", "videoStream", "=", "stream", ";", "if", "(", "window", ".", "hasModernUserMedia", ")", "{", "videoElem", ".", "srcObject", "=", "stream", ";", "}", "else", "if", "(", "navigator", ".", "mozGetUserMedia", "...
called when camera stream is loaded
[ "called", "when", "camera", "stream", "is", "loaded" ]
46988cdd0ce74b8bd624984c22c591a2388ef00e
https://github.com/jonashartmann/webcam-directive/blob/46988cdd0ce74b8bd624984c22c591a2388ef00e/app/scripts/webcam.js#L87-L108
train
jonashartmann/webcam-directive
app/scripts/webcam.js
onFailure
function onFailure(err) { _removeDOMElement(placeholder); if (console && console.debug) { console.debug('The following error occured: ', err); } /* Call custom callback */ if ($scope.onError) { $scope.onError({err:err}); } r...
javascript
function onFailure(err) { _removeDOMElement(placeholder); if (console && console.debug) { console.debug('The following error occured: ', err); } /* Call custom callback */ if ($scope.onError) { $scope.onError({err:err}); } r...
[ "function", "onFailure", "(", "err", ")", "{", "_removeDOMElement", "(", "placeholder", ")", ";", "if", "(", "console", "&&", "console", ".", "debug", ")", "{", "console", ".", "debug", "(", "'The following error occured: '", ",", "err", ")", ";", "}", "/*...
called when any error happens
[ "called", "when", "any", "error", "happens" ]
46988cdd0ce74b8bd624984c22c591a2388ef00e
https://github.com/jonashartmann/webcam-directive/blob/46988cdd0ce74b8bd624984c22c591a2388ef00e/app/scripts/webcam.js#L111-L123
train
compact/angular-bootstrap-lightbox
dist/angular-bootstrap-lightbox.js
function (dimensions, fullScreenMode) { var w = dimensions.width; var h = dimensions.height; var minW = dimensions.minWidth; var minH = dimensions.minHeight; var maxW = dimensions.maxWidth; var maxH = dimensions.maxHeight; var displayW = w; var displayH = h; if (!fullScreenMode) { ...
javascript
function (dimensions, fullScreenMode) { var w = dimensions.width; var h = dimensions.height; var minW = dimensions.minWidth; var minH = dimensions.minHeight; var maxW = dimensions.maxWidth; var maxH = dimensions.maxHeight; var displayW = w; var displayH = h; if (!fullScreenMode) { ...
[ "function", "(", "dimensions", ",", "fullScreenMode", ")", "{", "var", "w", "=", "dimensions", ".", "width", ";", "var", "h", "=", "dimensions", ".", "height", ";", "var", "minW", "=", "dimensions", ".", "minWidth", ";", "var", "minH", "=", "dimensions",...
Calculate the dimensions to display the image. The max dimensions override the min dimensions if they conflict.
[ "Calculate", "the", "dimensions", "to", "display", "the", "image", ".", "The", "max", "dimensions", "override", "the", "min", "dimensions", "if", "they", "conflict", "." ]
1d194e2c79d9d2667ef2ff5ba299f60d7d63d0eb
https://github.com/compact/angular-bootstrap-lightbox/blob/1d194e2c79d9d2667ef2ff5ba299f60d7d63d0eb/dist/angular-bootstrap-lightbox.js#L534-L602
train
compact/angular-bootstrap-lightbox
dist/angular-bootstrap-lightbox.js
function () { // get the window dimensions var windowWidth = $window.innerWidth; var windowHeight = $window.innerHeight; // calculate the max/min dimensions for the image var imageDimensionLimits = Lightbox.calculateImageDimensionLimits({ 'windowWidth': windowWidth, ...
javascript
function () { // get the window dimensions var windowWidth = $window.innerWidth; var windowHeight = $window.innerHeight; // calculate the max/min dimensions for the image var imageDimensionLimits = Lightbox.calculateImageDimensionLimits({ 'windowWidth': windowWidth, ...
[ "function", "(", ")", "{", "// get the window dimensions", "var", "windowWidth", "=", "$window", ".", "innerWidth", ";", "var", "windowHeight", "=", "$window", ".", "innerHeight", ";", "// calculate the max/min dimensions for the image", "var", "imageDimensionLimits", "="...
resize the img element and the containing modal
[ "resize", "the", "img", "element", "and", "the", "containing", "modal" ]
1d194e2c79d9d2667ef2ff5ba299f60d7d63d0eb
https://github.com/compact/angular-bootstrap-lightbox/blob/1d194e2c79d9d2667ef2ff5ba299f60d7d63d0eb/dist/angular-bootstrap-lightbox.js#L616-L672
train
box/viewer.js
src/js/components/layout-vertical.js
function () { var state = this.state, currentPage = state.pages[state.currentPage - 1], rowIndex = currentPage.rowIndex, nextRow = state.rows[rowIndex + 1]; return nextRow && nextRow[0] + 1 || state.currentPage; }
javascript
function () { var state = this.state, currentPage = state.pages[state.currentPage - 1], rowIndex = currentPage.rowIndex, nextRow = state.rows[rowIndex + 1]; return nextRow && nextRow[0] + 1 || state.currentPage; }
[ "function", "(", ")", "{", "var", "state", "=", "this", ".", "state", ",", "currentPage", "=", "state", ".", "pages", "[", "state", ".", "currentPage", "-", "1", "]", ",", "rowIndex", "=", "currentPage", ".", "rowIndex", ",", "nextRow", "=", "state", ...
Calculates the next page @returns {int} The next page number
[ "Calculates", "the", "next", "page" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/src/js/components/layout-vertical.js#L80-L86
train
box/viewer.js
src/js/components/layout-vertical.js
function () { var state = this.state, currentPage = state.pages[state.currentPage - 1], rowIndex = currentPage.rowIndex, prevRow = state.rows[rowIndex - 1]; return prevRow && prevRow[0] + 1 || state.currentPage; }
javascript
function () { var state = this.state, currentPage = state.pages[state.currentPage - 1], rowIndex = currentPage.rowIndex, prevRow = state.rows[rowIndex - 1]; return prevRow && prevRow[0] + 1 || state.currentPage; }
[ "function", "(", ")", "{", "var", "state", "=", "this", ".", "state", ",", "currentPage", "=", "state", ".", "pages", "[", "state", ".", "currentPage", "-", "1", "]", ",", "rowIndex", "=", "currentPage", ".", "rowIndex", ",", "prevRow", "=", "state", ...
Calculates the previous page @returns {int} The previous page number
[ "Calculates", "the", "previous", "page" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/src/js/components/layout-vertical.js#L92-L98
train
box/viewer.js
dist/crocodoc.viewer.js
findCircularDependencies
function findCircularDependencies(componentName, dependencies, path) { var i; path = path || componentName; for (i = 0; i < dependencies.length; ++i) { if (componentName === dependencies[i]) { throw new Error('Circular dependency detected: ' + path + '->' + dependenci...
javascript
function findCircularDependencies(componentName, dependencies, path) { var i; path = path || componentName; for (i = 0; i < dependencies.length; ++i) { if (componentName === dependencies[i]) { throw new Error('Circular dependency detected: ' + path + '->' + dependenci...
[ "function", "findCircularDependencies", "(", "componentName", ",", "dependencies", ",", "path", ")", "{", "var", "i", ";", "path", "=", "path", "||", "componentName", ";", "for", "(", "i", "=", "0", ";", "i", "<", "dependencies", ".", "length", ";", "++"...
Find circular dependencies in component mixins @param {string} componentName The component name that is being added @param {Array} dependencies Array of component mixin dependencies @param {void} path String used to keep track of depencency graph @returns {void}
[ "Find", "circular", "dependencies", "in", "component", "mixins" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L230-L240
train
box/viewer.js
dist/crocodoc.viewer.js
function (name, mixins, creator) { if (mixins instanceof Function) { creator = mixins; mixins = []; } // make sure this component won't cause a circular mixin dependency findCircularDependencies(name, mixins); components[name] =...
javascript
function (name, mixins, creator) { if (mixins instanceof Function) { creator = mixins; mixins = []; } // make sure this component won't cause a circular mixin dependency findCircularDependencies(name, mixins); components[name] =...
[ "function", "(", "name", ",", "mixins", ",", "creator", ")", "{", "if", "(", "mixins", "instanceof", "Function", ")", "{", "creator", "=", "mixins", ";", "mixins", "=", "[", "]", ";", "}", "// make sure this component won't cause a circular mixin dependency", "f...
Register a new component @param {string} name The (unique) name of the component @param {Array} mixins Array of component names to instantiate and pass as mixinable objects to the creator method @param {Function} creator Factory function used to create an instance of the component @returns {void}
[ "Register", "a", "new", "component" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L298-L309
train
box/viewer.js
dist/crocodoc.viewer.js
function (name, scope) { var component = components[name]; if (component) { var args = []; for (var i = 0; i < component.mixins.length; ++i) { args.push(this.createComponent(component.mixins[i], scope)); } args....
javascript
function (name, scope) { var component = components[name]; if (component) { var args = []; for (var i = 0; i < component.mixins.length; ++i) { args.push(this.createComponent(component.mixins[i], scope)); } args....
[ "function", "(", "name", ",", "scope", ")", "{", "var", "component", "=", "components", "[", "name", "]", ";", "if", "(", "component", ")", "{", "var", "args", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "component", "....
Create and return an instance of the named component @param {string} name The name of the component to create @param {Crocodoc.Scope} scope The scope object to create the component on @returns {?Object} The component instance or null if the component doesn't exist
[ "Create", "and", "return", "an", "instance", "of", "the", "named", "component" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L317-L330
train
box/viewer.js
dist/crocodoc.viewer.js
function (name) { var utility = utilities[name]; if (utility) { if (!utility.instance) { utility.instance = utility.creator(this); } return utility.instance; } return null; }
javascript
function (name) { var utility = utilities[name]; if (utility) { if (!utility.instance) { utility.instance = utility.creator(this); } return utility.instance; } return null; }
[ "function", "(", "name", ")", "{", "var", "utility", "=", "utilities", "[", "name", "]", ";", "if", "(", "utility", ")", "{", "if", "(", "!", "utility", ".", "instance", ")", "{", "utility", ".", "instance", "=", "utility", ".", "creator", "(", "th...
Retrieve the named utility @param {string} name The name of the utility to retrieve @returns {?Object} The utility or null if the utility doesn't exist
[ "Retrieve", "the", "named", "utility" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L369-L381
train
box/viewer.js
dist/crocodoc.viewer.js
broadcast
function broadcast(messageName, data) { var i, len, instance, messages; for (i = 0, len = instances.length; i < len; ++i) { instance = instances[i]; if (!instance) { continue; } messages = instance.messages || []...
javascript
function broadcast(messageName, data) { var i, len, instance, messages; for (i = 0, len = instances.length; i < len; ++i) { instance = instances[i]; if (!instance) { continue; } messages = instance.messages || []...
[ "function", "broadcast", "(", "messageName", ",", "data", ")", "{", "var", "i", ",", "len", ",", "instance", ",", "messages", ";", "for", "(", "i", "=", "0", ",", "len", "=", "instances", ".", "length", ";", "i", "<", "len", ";", "++", "i", ")", ...
Broadcast a message to all components in this scope that have registered a listener for the named message type @param {string} messageName The message name @param {any} data The message data @returns {void} @private
[ "Broadcast", "a", "message", "to", "all", "components", "in", "this", "scope", "that", "have", "registered", "a", "listener", "for", "the", "named", "message", "type" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L414-L429
train
box/viewer.js
dist/crocodoc.viewer.js
destroyComponent
function destroyComponent(instance) { if (util.isFn(instance.destroy) && !instance._destroyed) { instance.destroy(); instance._destroyed = true; } }
javascript
function destroyComponent(instance) { if (util.isFn(instance.destroy) && !instance._destroyed) { instance.destroy(); instance._destroyed = true; } }
[ "function", "destroyComponent", "(", "instance", ")", "{", "if", "(", "util", ".", "isFn", "(", "instance", ".", "destroy", ")", "&&", "!", "instance", ".", "_destroyed", ")", "{", "instance", ".", "destroy", "(", ")", ";", "instance", ".", "_destroyed",...
Call the destroy method on a component instance if it exists and the instance has not already been destroyed @param {Object} instance The component instance @returns {void}
[ "Call", "the", "destroy", "method", "on", "a", "component", "instance", "if", "it", "exists", "and", "the", "instance", "has", "not", "already", "been", "destroyed" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L452-L457
train
box/viewer.js
dist/crocodoc.viewer.js
buildEventObject
function buildEventObject(type, data) { var isDefaultPrevented = false; return { type: type, data: data, /** * Prevent the default action for this event * @returns {void} */ preventDefault: function () { ...
javascript
function buildEventObject(type, data) { var isDefaultPrevented = false; return { type: type, data: data, /** * Prevent the default action for this event * @returns {void} */ preventDefault: function () { ...
[ "function", "buildEventObject", "(", "type", ",", "data", ")", "{", "var", "isDefaultPrevented", "=", "false", ";", "return", "{", "type", ":", "type", ",", "data", ":", "data", ",", "/**\n * Prevent the default action for this event\n * @returns...
Build an event object for the given type and data @param {string} type The event type @param {Object} data The event data @returns {Object} The event object
[ "Build", "an", "event", "object", "for", "the", "given", "type", "and", "data" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L602-L624
train
box/viewer.js
dist/crocodoc.viewer.js
function(type, handler) { var handlers = this._handlers[type], i, len; if (handlers instanceof Array) { if (!handler) { handlers.length = 0; return; } for (i = 0, len = handle...
javascript
function(type, handler) { var handlers = this._handlers[type], i, len; if (handlers instanceof Array) { if (!handler) { handlers.length = 0; return; } for (i = 0, len = handle...
[ "function", "(", "type", ",", "handler", ")", "{", "var", "handlers", "=", "this", ".", "_handlers", "[", "type", "]", ",", "i", ",", "len", ";", "if", "(", "handlers", "instanceof", "Array", ")", "{", "if", "(", "!", "handler", ")", "{", "handlers...
Removes an event handler from a given event. If the handler is not provided, remove all handlers of the given type. @param {string} type The name of the event to remove from. @param {Function} handler The function to remove as a handler. @returns {void}
[ "Removes", "an", "event", "handler", "from", "a", "given", "event", ".", "If", "the", "handler", "is", "not", "provided", "remove", "all", "handlers", "of", "the", "given", "type", "." ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L712-L729
train
box/viewer.js
dist/crocodoc.viewer.js
function(type, handler) { var self = this, proxy = function (event) { self.off(type, proxy); handler.call(self, event); }; proxy.handler = handler; this.on(type, proxy); }
javascript
function(type, handler) { var self = this, proxy = function (event) { self.off(type, proxy); handler.call(self, event); }; proxy.handler = handler; this.on(type, proxy); }
[ "function", "(", "type", ",", "handler", ")", "{", "var", "self", "=", "this", ",", "proxy", "=", "function", "(", "event", ")", "{", "self", ".", "off", "(", "type", ",", "proxy", ")", ";", "handler", ".", "call", "(", "self", ",", "event", ")",...
Adds a new event handler that should be removed after it's been triggered once. @param {string} type The name of the event to listen for. @param {Function} handler The function to call when the event occurs. @returns {void}
[ "Adds", "a", "new", "event", "handler", "that", "should", "be", "removed", "after", "it", "s", "been", "triggered", "once", "." ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L738-L746
train
box/viewer.js
dist/crocodoc.viewer.js
function() { var url = this.getURL(), $promise = ajax.fetch(url, Crocodoc.ASSET_REQUEST_RETRIES); // @NOTE: promise.then() creates a new promise, which does not copy // custom properties, so we need to create a futher promise and add // an object with the...
javascript
function() { var url = this.getURL(), $promise = ajax.fetch(url, Crocodoc.ASSET_REQUEST_RETRIES); // @NOTE: promise.then() creates a new promise, which does not copy // custom properties, so we need to create a futher promise and add // an object with the...
[ "function", "(", ")", "{", "var", "url", "=", "this", ".", "getURL", "(", ")", ",", "$promise", "=", "ajax", ".", "fetch", "(", "url", ",", "Crocodoc", ".", "ASSET_REQUEST_RETRIES", ")", ";", "// @NOTE: promise.then() creates a new promise, which does not copy", ...
Retrieve the info.json asset from the server @returns {$.Promise} A promise with an additional abort() method that will abort the XHR request.
[ "Retrieve", "the", "info", ".", "json", "asset", "from", "the", "server" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1065-L1075
train
box/viewer.js
dist/crocodoc.viewer.js
function(objectType, pageNum) { var img = this.getImage(), retries = Crocodoc.ASSET_REQUEST_RETRIES, loaded = false, url = this.getURL(pageNum), $deferred = $.Deferred(); function loadImage() { img.setAttribute('src...
javascript
function(objectType, pageNum) { var img = this.getImage(), retries = Crocodoc.ASSET_REQUEST_RETRIES, loaded = false, url = this.getURL(pageNum), $deferred = $.Deferred(); function loadImage() { img.setAttribute('src...
[ "function", "(", "objectType", ",", "pageNum", ")", "{", "var", "img", "=", "this", ".", "getImage", "(", ")", ",", "retries", "=", "Crocodoc", ".", "ASSET_REQUEST_RETRIES", ",", "loaded", "=", "false", ",", "url", "=", "this", ".", "getURL", "(", "pag...
Retrieve the page image asset from the server @param {string} objectType The type of data being requested @param {number} pageNum The page number for which to request the page image @returns {$.Promise} A promise with an additional abort() method that will abort the img request.
[ "Retrieve", "the", "page", "image", "asset", "from", "the", "server" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1105-L1154
train
box/viewer.js
dist/crocodoc.viewer.js
function (pageNum) { var imgPath = util.template(config.template.img, { page: pageNum }); return config.url + imgPath + config.queryString; }
javascript
function (pageNum) { var imgPath = util.template(config.template.img, { page: pageNum }); return config.url + imgPath + config.queryString; }
[ "function", "(", "pageNum", ")", "{", "var", "imgPath", "=", "util", ".", "template", "(", "config", ".", "template", ".", "img", ",", "{", "page", ":", "pageNum", "}", ")", ";", "return", "config", ".", "url", "+", "imgPath", "+", "config", ".", "...
Build and return the URL to the PNG asset for the specified page @param {number} pageNum The page number @returns {string} The URL
[ "Build", "and", "return", "the", "URL", "to", "the", "PNG", "asset", "for", "the", "specified", "page" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1161-L1164
train
box/viewer.js
dist/crocodoc.viewer.js
interpolateCSSText
function interpolateCSSText(text, cssText) { // CSS text var stylesheetHTML = '<style>' + cssText + '</style>'; // If using Firefox with no subpx support, add "text-rendering" CSS. // @NOTE(plai): We are not adding this to Chrome because Chrome supports "textLength" // on tspans...
javascript
function interpolateCSSText(text, cssText) { // CSS text var stylesheetHTML = '<style>' + cssText + '</style>'; // If using Firefox with no subpx support, add "text-rendering" CSS. // @NOTE(plai): We are not adding this to Chrome because Chrome supports "textLength" // on tspans...
[ "function", "interpolateCSSText", "(", "text", ",", "cssText", ")", "{", "// CSS text", "var", "stylesheetHTML", "=", "'<style>'", "+", "cssText", "+", "'</style>'", ";", "// If using Firefox with no subpx support, add \"text-rendering\" CSS.", "// @NOTE(plai): We are not addin...
Interpolate CSS text into the SVG text @param {string} text The SVG text @param {string} cssText The CSS text @returns {string} The full SVG text
[ "Interpolate", "CSS", "text", "into", "the", "SVG", "text" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1198-L1215
train
box/viewer.js
dist/crocodoc.viewer.js
processSVGContent
function processSVGContent(text) { if (destroyed) { return; } var query = config.queryString.replace('&', '&#38;'), dataUrlCount; dataUrlCount = util.countInStr(text, 'xlink:href="data:image'); // remove data:urls from the SVG content if the number excee...
javascript
function processSVGContent(text) { if (destroyed) { return; } var query = config.queryString.replace('&', '&#38;'), dataUrlCount; dataUrlCount = util.countInStr(text, 'xlink:href="data:image'); // remove data:urls from the SVG content if the number excee...
[ "function", "processSVGContent", "(", "text", ")", "{", "if", "(", "destroyed", ")", "{", "return", ";", "}", "var", "query", "=", "config", ".", "queryString", ".", "replace", "(", "'&'", ",", "'&#38;'", ")", ",", "dataUrlCount", ";", "dataUrlCount", "=...
Process SVG text and return the embeddable result @param {string} text The original SVG text @returns {string} The processed SVG text @private
[ "Process", "SVG", "text", "and", "return", "the", "embeddable", "result" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1223-L1247
train
box/viewer.js
dist/crocodoc.viewer.js
function (pageNum) { var svgPath = util.template(config.template.svg, { page: pageNum }); return config.url + svgPath + config.queryString; }
javascript
function (pageNum) { var svgPath = util.template(config.template.svg, { page: pageNum }); return config.url + svgPath + config.queryString; }
[ "function", "(", "pageNum", ")", "{", "var", "svgPath", "=", "util", ".", "template", "(", "config", ".", "template", ".", "svg", ",", "{", "page", ":", "pageNum", "}", ")", ";", "return", "config", ".", "url", "+", "svgPath", "+", "config", ".", "...
Build and return the URL to the SVG asset for the specified page @param {number} pageNum The page number @returns {string} The URL
[ "Build", "and", "return", "the", "URL", "to", "the", "SVG", "asset", "for", "the", "specified", "page" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1289-L1292
train
box/viewer.js
dist/crocodoc.viewer.js
processTextContent
function processTextContent(text) { if (destroyed) { return; } // in the text layer, divs are only used for text boxes, so // they should provide an accurate count var numTextBoxes = util.countInStr(text, '<div'); // too many textboxes... don't load this page...
javascript
function processTextContent(text) { if (destroyed) { return; } // in the text layer, divs are only used for text boxes, so // they should provide an accurate count var numTextBoxes = util.countInStr(text, '<div'); // too many textboxes... don't load this page...
[ "function", "processTextContent", "(", "text", ")", "{", "if", "(", "destroyed", ")", "{", "return", ";", "}", "// in the text layer, divs are only used for text boxes, so", "// they should provide an accurate count", "var", "numTextBoxes", "=", "util", ".", "countInStr", ...
Process HTML text and return the embeddable result @param {string} text The original HTML text @returns {string} The processed HTML text @private
[ "Process", "HTML", "text", "and", "return", "the", "embeddable", "result" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1322-L1339
train
box/viewer.js
dist/crocodoc.viewer.js
function(objectType, pageNum) { var url = this.getURL(pageNum), $promise; if (cache[pageNum]) { return cache[pageNum]; } $promise = ajax.fetch(url, Crocodoc.ASSET_REQUEST_RETRIES); // @NOTE: promise.then() creates a new promi...
javascript
function(objectType, pageNum) { var url = this.getURL(pageNum), $promise; if (cache[pageNum]) { return cache[pageNum]; } $promise = ajax.fetch(url, Crocodoc.ASSET_REQUEST_RETRIES); // @NOTE: promise.then() creates a new promi...
[ "function", "(", "objectType", ",", "pageNum", ")", "{", "var", "url", "=", "this", ".", "getURL", "(", "pageNum", ")", ",", "$promise", ";", "if", "(", "cache", "[", "pageNum", "]", ")", "{", "return", "cache", "[", "pageNum", "]", ";", "}", "$pro...
Retrieve a text asset from the server @param {string} objectType The type of data being requested @param {number} pageNum The page number for which to request the text HTML @returns {$.Promise} A promise with an additional abort() method that will abort the XHR request.
[ "Retrieve", "a", "text", "asset", "from", "the", "server" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1352-L1374
train
box/viewer.js
dist/crocodoc.viewer.js
function (pageNum) { var textPath = util.template(config.template.html, { page: pageNum }); return config.url + textPath + config.queryString; }
javascript
function (pageNum) { var textPath = util.template(config.template.html, { page: pageNum }); return config.url + textPath + config.queryString; }
[ "function", "(", "pageNum", ")", "{", "var", "textPath", "=", "util", ".", "template", "(", "config", ".", "template", ".", "html", ",", "{", "page", ":", "pageNum", "}", ")", ";", "return", "config", ".", "url", "+", "textPath", "+", "config", ".", ...
Build and return the URL to the HTML asset for the specified page @param {number} pageNum The page number @returns {string} The URL
[ "Build", "and", "return", "the", "URL", "to", "the", "HTML", "asset", "for", "the", "specified", "page" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1381-L1384
train
box/viewer.js
dist/crocodoc.viewer.js
processStylesheetContent
function processStylesheetContent(text) { // @NOTE: There is a bug in IE that causes the text layer to // not render the font when loaded for a second time (i.e., // destroy and recreate a viewer for the same document), so // namespace the font-family so there is no collision if ...
javascript
function processStylesheetContent(text) { // @NOTE: There is a bug in IE that causes the text layer to // not render the font when loaded for a second time (i.e., // destroy and recreate a viewer for the same document), so // namespace the font-family so there is no collision if ...
[ "function", "processStylesheetContent", "(", "text", ")", "{", "// @NOTE: There is a bug in IE that causes the text layer to", "// not render the font when loaded for a second time (i.e.,", "// destroy and recreate a viewer for the same document), so", "// namespace the font-family so there is no ...
Process stylesheet text and return the embeddable result @param {string} text The original CSS text @returns {string} The processed CSS text @private
[ "Process", "stylesheet", "text", "and", "return", "the", "embeddable", "result" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1411-L1422
train
box/viewer.js
dist/crocodoc.viewer.js
function() { if ($cachedPromise) { return $cachedPromise; } var $promise = ajax.fetch(this.getURL(), Crocodoc.ASSET_REQUEST_RETRIES); // @NOTE: promise.then() creates a new promise, which does not copy // custom properties, so we need to crea...
javascript
function() { if ($cachedPromise) { return $cachedPromise; } var $promise = ajax.fetch(this.getURL(), Crocodoc.ASSET_REQUEST_RETRIES); // @NOTE: promise.then() creates a new promise, which does not copy // custom properties, so we need to crea...
[ "function", "(", ")", "{", "if", "(", "$cachedPromise", ")", "{", "return", "$cachedPromise", ";", "}", "var", "$promise", "=", "ajax", ".", "fetch", "(", "this", ".", "getURL", "(", ")", ",", "Crocodoc", ".", "ASSET_REQUEST_RETRIES", ")", ";", "// @NOTE...
Retrieve the stylesheet.css asset from the server @returns {$.Promise} A promise with an additional abort() method that will abort the XHR request.
[ "Retrieve", "the", "stylesheet", ".", "css", "asset", "from", "the", "server" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1433-L1450
train
box/viewer.js
dist/crocodoc.viewer.js
parseOptions
function parseOptions(options) { options = util.extend(true, {}, options || {}); options.method = options.method || 'GET'; options.headers = options.headers || []; options.data = options.data || ''; options.withCredentials = !!options.withCredentials; if (typeof options....
javascript
function parseOptions(options) { options = util.extend(true, {}, options || {}); options.method = options.method || 'GET'; options.headers = options.headers || []; options.data = options.data || ''; options.withCredentials = !!options.withCredentials; if (typeof options....
[ "function", "parseOptions", "(", "options", ")", "{", "options", "=", "util", ".", "extend", "(", "true", ",", "{", "}", ",", "options", "||", "{", "}", ")", ";", "options", ".", "method", "=", "options", ".", "method", "||", "'GET'", ";", "options",...
Parse AJAX options @param {Object} options The options @returns {Object} The parsed options
[ "Parse", "AJAX", "options" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1530-L1545
train
box/viewer.js
dist/crocodoc.viewer.js
setHeaders
function setHeaders(req, headers) { var i; for (i = 0; i < headers.length; ++i) { req.setRequestHeader(headers[i][0], headers[i][1]); } }
javascript
function setHeaders(req, headers) { var i; for (i = 0; i < headers.length; ++i) { req.setRequestHeader(headers[i][0], headers[i][1]); } }
[ "function", "setHeaders", "(", "req", ",", "headers", ")", "{", "var", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "headers", ".", "length", ";", "++", "i", ")", "{", "req", ".", "setRequestHeader", "(", "headers", "[", "i", "]", "[", "...
Set XHR headers @param {XMLHttpRequest} req The request object @param {Array} headers Array of headers to set
[ "Set", "XHR", "headers" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1552-L1557
train
box/viewer.js
dist/crocodoc.viewer.js
doXHR
function doXHR(url, method, data, headers, withCredentials, success, fail) { var req = support.getXHR(); req.open(method, url, true); req.onreadystatechange = function () { var status; if (req.readyState === 4) { // DONE // remove the onreadystatechange ha...
javascript
function doXHR(url, method, data, headers, withCredentials, success, fail) { var req = support.getXHR(); req.open(method, url, true); req.onreadystatechange = function () { var status; if (req.readyState === 4) { // DONE // remove the onreadystatechange ha...
[ "function", "doXHR", "(", "url", ",", "method", ",", "data", ",", "headers", ",", "withCredentials", ",", "success", ",", "fail", ")", "{", "var", "req", "=", "support", ".", "getXHR", "(", ")", ";", "req", ".", "open", "(", "method", ",", "url", "...
Make an XHR request @param {string} url request URL @param {string} method request method @param {*} data request data to send @param {Array} headers request headers @param {boolean} withCredentials request withCredentials option @param {Function} ...
[ "Make", "an", "XHR", "request" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1571-L1611
train
box/viewer.js
dist/crocodoc.viewer.js
doXDR
function doXDR(url, method, data, success, fail) { var req = support.getXDR(); try { req.open(method, url); req.onload = function () { success(req); }; // NOTE: IE (8/9) requires onerror, ontimeout, and onprogress // to be defined when making XDR to https ...
javascript
function doXDR(url, method, data, success, fail) { var req = support.getXDR(); try { req.open(method, url); req.onload = function () { success(req); }; // NOTE: IE (8/9) requires onerror, ontimeout, and onprogress // to be defined when making XDR to https ...
[ "function", "doXDR", "(", "url", ",", "method", ",", "data", ",", "success", ",", "fail", ")", "{", "var", "req", "=", "support", ".", "getXDR", "(", ")", ";", "try", "{", "req", ".", "open", "(", "method", ",", "url", ")", ";", "req", ".", "on...
Make an XDR request @param {string} url request URL @param {string} method request method @param {*} data request data to send @param {Function} success success callback function @param {Function} fail fail callback function @returns {XDomainRequest} Request object @private
[ "Make", "an", "XDR", "request" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1623-L1641
train
box/viewer.js
dist/crocodoc.viewer.js
function (url, options) { var opt = parseOptions(options), method = opt.method, data = opt.data, headers = opt.headers, withCredentials = opt.withCredentials; if (method === 'GET' && data) { url = urlUtil.appendQuer...
javascript
function (url, options) { var opt = parseOptions(options), method = opt.method, data = opt.data, headers = opt.headers, withCredentials = opt.withCredentials; if (method === 'GET' && data) { url = urlUtil.appendQuer...
[ "function", "(", "url", ",", "options", ")", "{", "var", "opt", "=", "parseOptions", "(", "options", ")", ",", "method", "=", "opt", ".", "method", ",", "data", "=", "opt", ".", "data", ",", "headers", "=", "opt", ".", "headers", ",", "withCredential...
Make a raw AJAX request @param {string} url request URL @param {Object} [options] AJAX request options @param {string} [options.method] request method, eg. 'GET', 'POST' (defaults to 'GET') @param {Array} [options.headers] request headers (defaults to []) @param {*} ...
[ "Make", "a", "raw", "AJAX", "request" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1655-L1707
train
box/viewer.js
dist/crocodoc.viewer.js
ajaxSuccess
function ajaxSuccess(req) { if (util.isFn(opt.success)) { opt.success.call(createRequestWrapper(req)); } return req; }
javascript
function ajaxSuccess(req) { if (util.isFn(opt.success)) { opt.success.call(createRequestWrapper(req)); } return req; }
[ "function", "ajaxSuccess", "(", "req", ")", "{", "if", "(", "util", ".", "isFn", "(", "opt", ".", "success", ")", ")", "{", "opt", ".", "success", ".", "call", "(", "createRequestWrapper", "(", "req", ")", ")", ";", "}", "return", "req", ";", "}" ]
Function to call on successful AJAX request @returns {void} @private
[ "Function", "to", "call", "on", "successful", "AJAX", "request" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1672-L1677
train
box/viewer.js
dist/crocodoc.viewer.js
ajaxFail
function ajaxFail(req) { if (util.isFn(opt.fail)) { opt.fail.call(createRequestWrapper(req)); } return req; }
javascript
function ajaxFail(req) { if (util.isFn(opt.fail)) { opt.fail.call(createRequestWrapper(req)); } return req; }
[ "function", "ajaxFail", "(", "req", ")", "{", "if", "(", "util", ".", "isFn", "(", "opt", ".", "fail", ")", ")", "{", "opt", ".", "fail", ".", "call", "(", "createRequestWrapper", "(", "req", ")", ")", ";", "}", "return", "req", ";", "}" ]
Function to call on failed AJAX request @returns {void} @private
[ "Function", "to", "call", "on", "failed", "AJAX", "request" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1684-L1689
train
box/viewer.js
dist/crocodoc.viewer.js
function (url, retries) { var req, aborted = false, ajax = this, $deferred = $.Deferred(); /** * If there are retries remaining, make another attempt, otherwise * give up and reject the deferred * @param {O...
javascript
function (url, retries) { var req, aborted = false, ajax = this, $deferred = $.Deferred(); /** * If there are retries remaining, make another attempt, otherwise * give up and reject the deferred * @param {O...
[ "function", "(", "url", ",", "retries", ")", "{", "var", "req", ",", "aborted", "=", "false", ",", "ajax", "=", "this", ",", "$deferred", "=", "$", ".", "Deferred", "(", ")", ";", "/**\n * If there are retries remaining, make another attempt, otherwise...
Fetch an asset, retrying if necessary @param {string} url A url for the desired asset @param {number} retries The number of times to retry if the request fails @returns {$.Promise} A promise with an additional abort() method that will abort the XHR request.
[ "Fetch", "an", "asset", "retrying", "if", "necessary" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1715-L1793
train
box/viewer.js
dist/crocodoc.viewer.js
request
function request() { return ajax.request(url, { success: function () { var retryAfter, req; if (!aborted) { req = this.rawRequest; // check status code...
javascript
function request() { return ajax.request(url, { success: function () { var retryAfter, req; if (!aborted) { req = this.rawRequest; // check status code...
[ "function", "request", "(", ")", "{", "return", "ajax", ".", "request", "(", "url", ",", "{", "success", ":", "function", "(", ")", "{", "var", "retryAfter", ",", "req", ";", "if", "(", "!", "aborted", ")", "{", "req", "=", "this", ".", "rawRequest...
Make an AJAX request for the asset @returns {XMLHttpRequest|XDomainRequest} Request object @private
[ "Make", "an", "AJAX", "request", "for", "the", "asset" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1744-L1784
train
box/viewer.js
dist/crocodoc.viewer.js
function (list, x, prop) { var val, mid, low = 0, high = list.length; while (low < high) { mid = Math.floor((low + high) / 2); val = prop ? list[mid][prop] : list[mid]; if (val < x) { low = mid + 1; } else { ...
javascript
function (list, x, prop) { var val, mid, low = 0, high = list.length; while (low < high) { mid = Math.floor((low + high) / 2); val = prop ? list[mid][prop] : list[mid]; if (val < x) { low = mid + 1; } else { ...
[ "function", "(", "list", ",", "x", ",", "prop", ")", "{", "var", "val", ",", "mid", ",", "low", "=", "0", ",", "high", "=", "list", ".", "length", ";", "while", "(", "low", "<", "high", ")", "{", "mid", "=", "Math", ".", "floor", "(", "(", ...
Left bistect of list, optionally of property of objects in list @param {Array} list List of items to bisect @param {number} x The number to bisect against @param {string} [prop] Optional property to check on list items instead of using the item itself @returns {int} The index of the bisection
[ "Left", "bistect", "of", "list", "optionally", "of", "property", "of", "objects", "in", "list" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L1873-L1885
train
box/viewer.js
dist/crocodoc.viewer.js
function (wait, fn) { var context, args, timeout, result, previous = 0; function later () { previous = util.now(); timeout = null; result = fn.apply(context, args); } ...
javascript
function (wait, fn) { var context, args, timeout, result, previous = 0; function later () { previous = util.now(); timeout = null; result = fn.apply(context, args); } ...
[ "function", "(", "wait", ",", "fn", ")", "{", "var", "context", ",", "args", ",", "timeout", ",", "result", ",", "previous", "=", "0", ";", "function", "later", "(", ")", "{", "previous", "=", "util", ".", "now", "(", ")", ";", "timeout", "=", "n...
Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, will only actually call the original function at most once per every wait milliseconds @param {int} wait Time to wait between calls in ms @param {Function} fn The function to throttle @returns {Function} ...
[ "Creates", "and", "returns", "a", "new", "throttled", "version", "of", "the", "passed", "function", "that", "when", "invoked", "repeatedly", "will", "only", "actually", "call", "the", "original", "function", "at", "most", "once", "per", "every", "wait", "milli...
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L2004-L2032
train
box/viewer.js
dist/crocodoc.viewer.js
function (wait, fn) { var context, args, timeout, timestamp, result; function later() { var last = util.now() - timestamp; if (last < wait) { timeout = setTimeout(later, wait - la...
javascript
function (wait, fn) { var context, args, timeout, timestamp, result; function later() { var last = util.now() - timestamp; if (last < wait) { timeout = setTimeout(later, wait - la...
[ "function", "(", "wait", ",", "fn", ")", "{", "var", "context", ",", "args", ",", "timeout", ",", "timestamp", ",", "result", ";", "function", "later", "(", ")", "{", "var", "last", "=", "util", ".", "now", "(", ")", "-", "timestamp", ";", "if", ...
Creates and returns a new debounced version of the passed function which will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked. @param {int} wait Time to wait between calls in ms @param {Function} fn The function to debounced @returns {Function} The de...
[ "Creates", "and", "returns", "a", "new", "debounced", "version", "of", "the", "passed", "function", "which", "will", "postpone", "its", "execution", "until", "after", "wait", "milliseconds", "have", "elapsed", "since", "the", "last", "time", "it", "was", "invo...
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L2042-L2069
train
box/viewer.js
dist/crocodoc.viewer.js
function (css) { var styleEl = document.createElement('style'), cssTextNode = document.createTextNode(css); try { styleEl.setAttribute('type', 'text/css'); styleEl.appendChild(cssTextNode); } catch (err) { // uhhh IE < 9...
javascript
function (css) { var styleEl = document.createElement('style'), cssTextNode = document.createTextNode(css); try { styleEl.setAttribute('type', 'text/css'); styleEl.appendChild(cssTextNode); } catch (err) { // uhhh IE < 9...
[ "function", "(", "css", ")", "{", "var", "styleEl", "=", "document", ".", "createElement", "(", "'style'", ")", ",", "cssTextNode", "=", "document", ".", "createTextNode", "(", "css", ")", ";", "try", "{", "styleEl", ".", "setAttribute", "(", "'type'", "...
Insert the given CSS string into the DOM and return the resulting DOMElement @param {string} css The CSS string to insert @returns {Element} The <style> element that was created and inserted
[ "Insert", "the", "given", "CSS", "string", "into", "the", "DOM", "and", "return", "the", "resulting", "DOMElement" ]
7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17
https://github.com/box/viewer.js/blob/7d11f2e4b01ef418aeb76efe2c2e5f08950f7c17/dist/crocodoc.viewer.js#L2076-L2087
train