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
dtao/autodoc
autodoc.js
Autodoc
function Autodoc(options) { options = Lazy(options || {}) .defaults(Autodoc.options) .toObject(); this.codeParser = wrapParser(options.codeParser); this.commentParser = wrapParser(options.commentParser); this.markdownParser = wrapParser(options.markdownParser, Autodoc.processInte...
javascript
function Autodoc(options) { options = Lazy(options || {}) .defaults(Autodoc.options) .toObject(); this.codeParser = wrapParser(options.codeParser); this.commentParser = wrapParser(options.commentParser); this.markdownParser = wrapParser(options.markdownParser, Autodoc.processInte...
[ "function", "Autodoc", "(", "options", ")", "{", "options", "=", "Lazy", "(", "options", "||", "{", "}", ")", ".", "defaults", "(", "Autodoc", ".", "options", ")", ".", "toObject", "(", ")", ";", "this", ".", "codeParser", "=", "wrapParser", "(", "op...
All of the options Autodoc supports. @typedef {Object} AutodocOptions @property {Parser|function(string):*} codeParser @property {Parser|function(string):*} commentParser @property {Parser|function(string):*} markdownParser @property {Array.<string>} namespaces @property {Array.<string>} tags @property {string} grep @...
[ "All", "of", "the", "options", "Autodoc", "supports", "." ]
6742cf126f2ba4b35126e5984074ce7a89c6826b
https://github.com/dtao/autodoc/blob/6742cf126f2ba4b35126e5984074ce7a89c6826b/autodoc.js#L64-L89
train
dtao/autodoc
autodoc.js
splitCamelCase
function splitCamelCase(string) { var matcher = /[^A-Z]([A-Z])|([A-Z])[^A-Z]/g, tokens = [], position = 0, index, match; string || (string = ''); while (match = matcher.exec(string)) { index = typeof match[1] === 'string' ? match.index + 1 : match.index; if (position...
javascript
function splitCamelCase(string) { var matcher = /[^A-Z]([A-Z])|([A-Z])[^A-Z]/g, tokens = [], position = 0, index, match; string || (string = ''); while (match = matcher.exec(string)) { index = typeof match[1] === 'string' ? match.index + 1 : match.index; if (position...
[ "function", "splitCamelCase", "(", "string", ")", "{", "var", "matcher", "=", "/", "[^A-Z]([A-Z])|([A-Z])[^A-Z]", "/", "g", ",", "tokens", "=", "[", "]", ",", "position", "=", "0", ",", "index", ",", "match", ";", "string", "||", "(", "string", "=", "'...
Splits apart a camelCased string. @private @param {string} string The string to split. @returns {Array.<string>} An array containing the parts of the string. @examples splitCamelCase('fooBarBaz'); // => ['foo', 'bar', 'baz'] splitCamelCase('Foo123Bar'); // => ['foo123', 'bar'] splitCamelCase('XMLHttpRequest...
[ "Splits", "apart", "a", "camelCased", "string", "." ]
6742cf126f2ba4b35126e5984074ce7a89c6826b
https://github.com/dtao/autodoc/blob/6742cf126f2ba4b35126e5984074ce7a89c6826b/autodoc.js#L1660-L1680
train
dtao/autodoc
autodoc.js
divide
function divide(string, divider) { var seam = string.indexOf(divider); if (seam === -1) { return [string]; } return [string.substring(0, seam), string.substring(seam + divider.length)]; }
javascript
function divide(string, divider) { var seam = string.indexOf(divider); if (seam === -1) { return [string]; } return [string.substring(0, seam), string.substring(seam + divider.length)]; }
[ "function", "divide", "(", "string", ",", "divider", ")", "{", "var", "seam", "=", "string", ".", "indexOf", "(", "divider", ")", ";", "if", "(", "seam", "===", "-", "1", ")", "{", "return", "[", "string", "]", ";", "}", "return", "[", "string", ...
Splits a string into two parts on either side of a specified divider. @private @param {string} string The string to divide into two parts. @param {string} divider The string used as the pivot point. @returns {Array.<string>} The parts of the string before and after the first occurrence of `divider`, or a 1-element arr...
[ "Splits", "a", "string", "into", "two", "parts", "on", "either", "side", "of", "a", "specified", "divider", "." ]
6742cf126f2ba4b35126e5984074ce7a89c6826b
https://github.com/dtao/autodoc/blob/6742cf126f2ba4b35126e5984074ce7a89c6826b/autodoc.js#L1733-L1740
train
dtao/autodoc
autodoc.js
unindent
function unindent(string, skipFirstLine) { var lines = string.split('\n'), skipFirst = typeof skipFirstLine !== 'undefined' ? skipFirstLine : true, start = skipFirst ? 1 : 0; var indentation, smallestIndentation = Infinity; for (var i = start, len = lines.length; i < len; ++i) { ...
javascript
function unindent(string, skipFirstLine) { var lines = string.split('\n'), skipFirst = typeof skipFirstLine !== 'undefined' ? skipFirstLine : true, start = skipFirst ? 1 : 0; var indentation, smallestIndentation = Infinity; for (var i = start, len = lines.length; i < len; ++i) { ...
[ "function", "unindent", "(", "string", ",", "skipFirstLine", ")", "{", "var", "lines", "=", "string", ".", "split", "(", "'\\n'", ")", ",", "skipFirst", "=", "typeof", "skipFirstLine", "!==", "'undefined'", "?", "skipFirstLine", ":", "true", ",", "start", ...
Unindents a multiline string based on the indentation level of the least- indented line. @private @param {string} string The string to unindent. @param {boolean} skipFirstLine Whether or not to skip the first line for the purpose of determining proper indentation (defaults to `true`). @returns {string} A new string th...
[ "Unindents", "a", "multiline", "string", "based", "on", "the", "indentation", "level", "of", "the", "least", "-", "indented", "line", "." ]
6742cf126f2ba4b35126e5984074ce7a89c6826b
https://github.com/dtao/autodoc/blob/6742cf126f2ba4b35126e5984074ce7a89c6826b/autodoc.js#L1758-L1784
train
dtao/autodoc
autodoc.js
firstLine
function firstLine(string) { var lineBreak = string.indexOf('\n'); if (lineBreak === -1) { return string; } return string.substring(0, lineBreak) + ' (...)'; }
javascript
function firstLine(string) { var lineBreak = string.indexOf('\n'); if (lineBreak === -1) { return string; } return string.substring(0, lineBreak) + ' (...)'; }
[ "function", "firstLine", "(", "string", ")", "{", "var", "lineBreak", "=", "string", ".", "indexOf", "(", "'\\n'", ")", ";", "if", "(", "lineBreak", "===", "-", "1", ")", "{", "return", "string", ";", "}", "return", "string", ".", "substring", "(", "...
Takes the first line of a string and, if there's more, appends '...' to indicate as much. @private @param {string} string The string whose first line you want to get. @returns {string} The first line of the string. @examples firstLine('foo'); // => 'foo' firstLine('foo\nbar'); // => 'foo (...)'
[ "Takes", "the", "first", "line", "of", "a", "string", "and", "if", "there", "s", "more", "appends", "...", "to", "indicate", "as", "much", "." ]
6742cf126f2ba4b35126e5984074ce7a89c6826b
https://github.com/dtao/autodoc/blob/6742cf126f2ba4b35126e5984074ce7a89c6826b/autodoc.js#L1869-L1877
train
dtao/autodoc
autodoc.js
exampleHandlers
function exampleHandlers(customHandlers) { return (customHandlers || []).concat([ { pattern: /^(\w[\w\.\(\)\[\]'"]*)\s*===?\s*(.*)$/, template: 'equality', data: function(match) { return { left: match[1], right: match[2] }; } },...
javascript
function exampleHandlers(customHandlers) { return (customHandlers || []).concat([ { pattern: /^(\w[\w\.\(\)\[\]'"]*)\s*===?\s*(.*)$/, template: 'equality', data: function(match) { return { left: match[1], right: match[2] }; } },...
[ "function", "exampleHandlers", "(", "customHandlers", ")", "{", "return", "(", "customHandlers", "||", "[", "]", ")", ".", "concat", "(", "[", "{", "pattern", ":", "/", "^(\\w[\\w\\.\\(\\)\\[\\]'\"]*)\\s*===?\\s*(.*)$", "/", ",", "template", ":", "'equality'", "...
The default handlers defined for examples.
[ "The", "default", "handlers", "defined", "for", "examples", "." ]
6742cf126f2ba4b35126e5984074ce7a89c6826b
https://github.com/dtao/autodoc/blob/6742cf126f2ba4b35126e5984074ce7a89c6826b/autodoc.js#L1993-L2100
train
dtao/autodoc
example/redundant.js
function(string, delimiter) { var start = 0, parts = [], index = string.indexOf(delimiter); if (delimiter === '') { while (index < string.length) { parts.push(string.charAt(index++)); } return parts; } while (index !== -1 & index < string.length) { parts...
javascript
function(string, delimiter) { var start = 0, parts = [], index = string.indexOf(delimiter); if (delimiter === '') { while (index < string.length) { parts.push(string.charAt(index++)); } return parts; } while (index !== -1 & index < string.length) { parts...
[ "function", "(", "string", ",", "delimiter", ")", "{", "var", "start", "=", "0", ",", "parts", "=", "[", "]", ",", "index", "=", "string", ".", "indexOf", "(", "delimiter", ")", ";", "if", "(", "delimiter", "===", "''", ")", "{", "while", "(", "i...
Splits a string by a given delimiter. This duplicates `String.prototype.split`. @memberOf R.strings @param {string} string The string to split. @param {string} delimiter The delimiter used to split the string. @returns {Array.<string>} An array of the parts separated by the given delimiter. @examples R.strings.split(...
[ "Splits", "a", "string", "by", "a", "given", "delimiter", ".", "This", "duplicates", "String", ".", "prototype", ".", "split", "." ]
6742cf126f2ba4b35126e5984074ce7a89c6826b
https://github.com/dtao/autodoc/blob/6742cf126f2ba4b35126e5984074ce7a89c6826b/example/redundant.js#L251-L274
train
dtao/autodoc
example/redundant.js
function(string) { var chars = new Array(string.length); var charCode; for (var i = 0, len = chars.length; i < len; ++i) { charCode = string.charCodeAt(i); if (charCode > 96 && charCode < 123) { charCode -= 32; } chars[i] = String.fromCharCode(charCode); } return c...
javascript
function(string) { var chars = new Array(string.length); var charCode; for (var i = 0, len = chars.length; i < len; ++i) { charCode = string.charCodeAt(i); if (charCode > 96 && charCode < 123) { charCode -= 32; } chars[i] = String.fromCharCode(charCode); } return c...
[ "function", "(", "string", ")", "{", "var", "chars", "=", "new", "Array", "(", "string", ".", "length", ")", ";", "var", "charCode", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "chars", ".", "length", ";", "i", "<", "len", ";", "++"...
Converts all of a string's characters to uppercase. This duplicates `String.prototype.toUpperCase`. @memberOf R.strings @param {string} string The string to upcase. @returns {string} The string w/ characters capitalized. @examples R.strings.toUpperCase('foo') // => 'FOO' R.strings.toUpperCase(' foo ') // =~ /FOO/
[ "Converts", "all", "of", "a", "string", "s", "characters", "to", "uppercase", ".", "This", "duplicates", "String", ".", "prototype", ".", "toUpperCase", "." ]
6742cf126f2ba4b35126e5984074ce7a89c6826b
https://github.com/dtao/autodoc/blob/6742cf126f2ba4b35126e5984074ce7a89c6826b/example/redundant.js#L288-L302
train
dtao/autodoc
example/nodeTypes.js
printEvens
function printEvens(N) { try { var i = -1; beginning: do { if (++i < N) { if (i % 2 !== 0) { continue beginning; } printNumber(i); } break; } while (true); } catch (e) { debugger; } }
javascript
function printEvens(N) { try { var i = -1; beginning: do { if (++i < N) { if (i % 2 !== 0) { continue beginning; } printNumber(i); } break; } while (true); } catch (e) { debugger; } }
[ "function", "printEvens", "(", "N", ")", "{", "try", "{", "var", "i", "=", "-", "1", ";", "beginning", ":", "do", "{", "if", "(", "++", "i", "<", "N", ")", "{", "if", "(", "i", "%", "2", "!==", "0", ")", "{", "continue", "beginning", ";", "...
Prints the even numbers up to N. @global @param {number} N
[ "Prints", "the", "even", "numbers", "up", "to", "N", "." ]
6742cf126f2ba4b35126e5984074ce7a89c6826b
https://github.com/dtao/autodoc/blob/6742cf126f2ba4b35126e5984074ce7a89c6826b/example/nodeTypes.js#L12-L33
train
af/envalid
src/envalidWithoutDotenv.js
validateVar
function validateVar({ spec = {}, name, rawValue }) { if (typeof spec._parse !== 'function') { throw new EnvError(`Invalid spec for "${name}"`) } const value = spec._parse(rawValue) if (spec.choices) { if (!Array.isArray(spec.choices)) { throw new TypeError(`"choices" must b...
javascript
function validateVar({ spec = {}, name, rawValue }) { if (typeof spec._parse !== 'function') { throw new EnvError(`Invalid spec for "${name}"`) } const value = spec._parse(rawValue) if (spec.choices) { if (!Array.isArray(spec.choices)) { throw new TypeError(`"choices" must b...
[ "function", "validateVar", "(", "{", "spec", "=", "{", "}", ",", "name", ",", "rawValue", "}", ")", "{", "if", "(", "typeof", "spec", ".", "_parse", "!==", "'function'", ")", "{", "throw", "new", "EnvError", "(", "`", "${", "name", "}", "`", ")", ...
Validate a single env var, given a spec object @throws EnvError - If validation is unsuccessful @return - The cleaned value
[ "Validate", "a", "single", "env", "var", "given", "a", "spec", "object" ]
1e34b5f5ee06634ee526d58431373157a38324c7
https://github.com/af/envalid/blob/1e34b5f5ee06634ee526d58431373157a38324c7/src/envalidWithoutDotenv.js#L24-L39
train
af/envalid
src/envalidWithoutDotenv.js
formatSpecDescription
function formatSpecDescription(spec) { const egText = spec.example ? ` (eg. "${spec.example}")` : '' const docsText = spec.docs ? `. See ${spec.docs}` : '' return `${spec.desc}${egText}${docsText}` || '' }
javascript
function formatSpecDescription(spec) { const egText = spec.example ? ` (eg. "${spec.example}")` : '' const docsText = spec.docs ? `. See ${spec.docs}` : '' return `${spec.desc}${egText}${docsText}` || '' }
[ "function", "formatSpecDescription", "(", "spec", ")", "{", "const", "egText", "=", "spec", ".", "example", "?", "`", "${", "spec", ".", "example", "}", "`", ":", "''", "const", "docsText", "=", "spec", ".", "docs", "?", "`", "${", "spec", ".", "docs...
Format a string error message for when a required env var is missing
[ "Format", "a", "string", "error", "message", "for", "when", "a", "required", "env", "var", "is", "missing" ]
1e34b5f5ee06634ee526d58431373157a38324c7
https://github.com/af/envalid/blob/1e34b5f5ee06634ee526d58431373157a38324c7/src/envalidWithoutDotenv.js#L42-L46
train
af/envalid
src/envalid.js
extendWithDotEnv
function extendWithDotEnv(inputEnv, dotEnvPath = '.env') { let dotEnvBuffer = null try { dotEnvBuffer = fs.readFileSync(dotEnvPath) } catch (err) { if (err.code === 'ENOENT') return inputEnv throw err } const parsed = dotenv.parse(dotEnvBuffer) return extend(parsed, input...
javascript
function extendWithDotEnv(inputEnv, dotEnvPath = '.env') { let dotEnvBuffer = null try { dotEnvBuffer = fs.readFileSync(dotEnvPath) } catch (err) { if (err.code === 'ENOENT') return inputEnv throw err } const parsed = dotenv.parse(dotEnvBuffer) return extend(parsed, input...
[ "function", "extendWithDotEnv", "(", "inputEnv", ",", "dotEnvPath", "=", "'.env'", ")", "{", "let", "dotEnvBuffer", "=", "null", "try", "{", "dotEnvBuffer", "=", "fs", ".", "readFileSync", "(", "dotEnvPath", ")", "}", "catch", "(", "err", ")", "{", "if", ...
Extend an env var object with the values parsed from a ".env" file, whose path is given by the second argument.
[ "Extend", "an", "env", "var", "object", "with", "the", "values", "parsed", "from", "a", ".", "env", "file", "whose", "path", "is", "given", "by", "the", "second", "argument", "." ]
1e34b5f5ee06634ee526d58431373157a38324c7
https://github.com/af/envalid/blob/1e34b5f5ee06634ee526d58431373157a38324c7/src/envalid.js#L8-L18
train
prettier/plugin-php
src/util.js
useSingleQuote
function useSingleQuote(node, options) { return ( !node.isDoubleQuote || (options.singleQuote && !node.raw.match(/\\n|\\t|\\r|\\t|\\v|\\e|\\f/) && !node.value.match( /["'$\n]|\\[0-7]{1,3}|\\x[0-9A-Fa-f]{1,2}|\\u{[0-9A-Fa-f]+}/ )) ); }
javascript
function useSingleQuote(node, options) { return ( !node.isDoubleQuote || (options.singleQuote && !node.raw.match(/\\n|\\t|\\r|\\t|\\v|\\e|\\f/) && !node.value.match( /["'$\n]|\\[0-7]{1,3}|\\x[0-9A-Fa-f]{1,2}|\\u{[0-9A-Fa-f]+}/ )) ); }
[ "function", "useSingleQuote", "(", "node", ",", "options", ")", "{", "return", "(", "!", "node", ".", "isDoubleQuote", "||", "(", "options", ".", "singleQuote", "&&", "!", "node", ".", "raw", ".", "match", "(", "/", "\\\\n|\\\\t|\\\\r|\\\\t|\\\\v|\\\\e|\\\\f",...
Check if string can safely be converted from double to single quotes, i.e. - no embedded variables ("foo $bar") - no linebreaks - no special characters like \n, \t, ... - no octal/hex/unicode characters See http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double
[ "Check", "if", "string", "can", "safely", "be", "converted", "from", "double", "to", "single", "quotes", "i", ".", "e", "." ]
249651b8bf3f66d0c1cf63823b1a173a7f31e86a
https://github.com/prettier/plugin-php/blob/249651b8bf3f66d0c1cf63823b1a173a7f31e86a/src/util.js#L592-L601
train
aaronshaf/dynamodb-admin
lib/util.js
doSearch
function doSearch(docClient, tableName, scanParams, limit, startKey, progress, readOperation = 'scan') { limit = limit !== undefined ? limit : null startKey = startKey !== undefined ? startKey : null let params = { TableName: tableName, } if (scanParams !== undefined && scanParams) { ...
javascript
function doSearch(docClient, tableName, scanParams, limit, startKey, progress, readOperation = 'scan') { limit = limit !== undefined ? limit : null startKey = startKey !== undefined ? startKey : null let params = { TableName: tableName, } if (scanParams !== undefined && scanParams) { ...
[ "function", "doSearch", "(", "docClient", ",", "tableName", ",", "scanParams", ",", "limit", ",", "startKey", ",", "progress", ",", "readOperation", "=", "'scan'", ")", "{", "limit", "=", "limit", "!==", "undefined", "?", "limit", ":", "null", "startKey", ...
Invokes a database scan @param {Object} docClient The AWS DynamoDB client @param {String} tableName The table name @param {Object} scanParams Extra params for the query @param {Number} limit The of items to request per chunked query. NOT a limit of items that should be returned. @param {Object?} startKey The key to st...
[ "Invokes", "a", "database", "scan" ]
c7726afa1a80f55e78502b6de7209f3639e7ff4a
https://github.com/aaronshaf/dynamodb-admin/blob/c7726afa1a80f55e78502b6de7209f3639e7ff4a/lib/util.js#L51-L111
train
aaronshaf/dynamodb-admin
lib/backend.js
loadDynamoConfig
function loadDynamoConfig(env, AWS) { const dynamoConfig = { endpoint: 'http://localhost:8000', sslEnabled: false, region: 'us-east-1', accessKeyId: 'key', secretAccessKey: env.AWS_SECRET_ACCESS_KEY || 'secret' } loadDynamoEndpoint(env, dynamoConfig) if (AWS.config) { if (AWS.config.re...
javascript
function loadDynamoConfig(env, AWS) { const dynamoConfig = { endpoint: 'http://localhost:8000', sslEnabled: false, region: 'us-east-1', accessKeyId: 'key', secretAccessKey: env.AWS_SECRET_ACCESS_KEY || 'secret' } loadDynamoEndpoint(env, dynamoConfig) if (AWS.config) { if (AWS.config.re...
[ "function", "loadDynamoConfig", "(", "env", ",", "AWS", ")", "{", "const", "dynamoConfig", "=", "{", "endpoint", ":", "'http://localhost:8000'", ",", "sslEnabled", ":", "false", ",", "region", ":", "'us-east-1'", ",", "accessKeyId", ":", "'key'", ",", "secretA...
Create the configuration for the local dynamodb instance. Region and AccessKeyId are determined as follows: 1) Look at local aws configuration in ~/.aws/credentials 2) Look at env variables env.AWS_REGION and env.AWS_ACCESS_KEY_ID 3) Use default values 'us-east-1' and 'key' @param env - the process environment @param...
[ "Create", "the", "configuration", "for", "the", "local", "dynamodb", "instance", "." ]
c7726afa1a80f55e78502b6de7209f3639e7ff4a
https://github.com/aaronshaf/dynamodb-admin/blob/c7726afa1a80f55e78502b6de7209f3639e7ff4a/lib/backend.js#L47-L79
train
Jam3/layout-bmfont-text
demo/index.js
metrics
function metrics(context) { //x-height context.fillStyle = 'blue' context.fillRect(0, -layout.height + layout.baseline, 15, -layout.xHeight) //ascender context.fillStyle = 'pink' context.fillRect(27, -layout.height, 36, layout.ascender) //cap height context.fillStyle = 'yellow' context.fillRect(110,...
javascript
function metrics(context) { //x-height context.fillStyle = 'blue' context.fillRect(0, -layout.height + layout.baseline, 15, -layout.xHeight) //ascender context.fillStyle = 'pink' context.fillRect(27, -layout.height, 36, layout.ascender) //cap height context.fillStyle = 'yellow' context.fillRect(110,...
[ "function", "metrics", "(", "context", ")", "{", "//x-height", "context", ".", "fillStyle", "=", "'blue'", "context", ".", "fillRect", "(", "0", ",", "-", "layout", ".", "height", "+", "layout", ".", "baseline", ",", "15", ",", "-", "layout", ".", "xHe...
draw our metrics squares
[ "draw", "our", "metrics", "squares" ]
5efcf3d8179e5ed95c268f76a87975979f845db6
https://github.com/Jam3/layout-bmfont-text/blob/5efcf3d8179e5ed95c268f76a87975979f845db6/demo/index.js#L66-L93
train
JetBrains/ring-ui
packages/docs/webpack-docs-plugin.setup.js
createNav
function createNav(sources) { const defaultCategory = 'Uncategorized'; const sourcesByCategories = sources. // get category names reduce((categories, source) => categories. concat(source.attrs.category || defaultCategory), []). // remove duplicates filter((value, i, self) => self.indexOf(val...
javascript
function createNav(sources) { const defaultCategory = 'Uncategorized'; const sourcesByCategories = sources. // get category names reduce((categories, source) => categories. concat(source.attrs.category || defaultCategory), []). // remove duplicates filter((value, i, self) => self.indexOf(val...
[ "function", "createNav", "(", "sources", ")", "{", "const", "defaultCategory", "=", "'Uncategorized'", ";", "const", "sourcesByCategories", "=", "sources", ".", "// get category names", "reduce", "(", "(", "categories", ",", "source", ")", "=>", "categories", ".",...
Creates navigation object. @param {Array<Source>} sources @returns {Array<Object>}
[ "Creates", "navigation", "object", "." ]
fa7c39f47a91bb4b75d642834cad5409715a8402
https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/packages/docs/webpack-docs-plugin.setup.js#L123-L148
train
JetBrains/ring-ui
components/dialog-ng/dialog-ng.js
focusFirst
function focusFirst() { const controls = node.queryAll('input,select,button,textarea,*[contentEditable=true]'). filter(inputNode => getStyles(inputNode).display !== 'none'); if (controls.length) { controls[0].focus(); } }
javascript
function focusFirst() { const controls = node.queryAll('input,select,button,textarea,*[contentEditable=true]'). filter(inputNode => getStyles(inputNode).display !== 'none'); if (controls.length) { controls[0].focus(); } }
[ "function", "focusFirst", "(", ")", "{", "const", "controls", "=", "node", ".", "queryAll", "(", "'input,select,button,textarea,*[contentEditable=true]'", ")", ".", "filter", "(", "inputNode", "=>", "getStyles", "(", "inputNode", ")", ".", "display", "!==", "'none...
Focus first input
[ "Focus", "first", "input" ]
fa7c39f47a91bb4b75d642834cad5409715a8402
https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/dialog-ng/dialog-ng.js#L405-L411
train
JetBrains/ring-ui
components/docked-panel-ng/docked-panel-ng.js
dock
function dock() { onBeforeDock(); panel.classList.add(DOCKED_CSS_CLASS_NAME); if (dockedPanelClass) { panel.classList.add(dockedPanelClass); } isDocked = true; }
javascript
function dock() { onBeforeDock(); panel.classList.add(DOCKED_CSS_CLASS_NAME); if (dockedPanelClass) { panel.classList.add(dockedPanelClass); } isDocked = true; }
[ "function", "dock", "(", ")", "{", "onBeforeDock", "(", ")", ";", "panel", ".", "classList", ".", "add", "(", "DOCKED_CSS_CLASS_NAME", ")", ";", "if", "(", "dockedPanelClass", ")", "{", "panel", ".", "classList", ".", "add", "(", "dockedPanelClass", ")", ...
Docks the panel to the bottom of the page
[ "Docks", "the", "panel", "to", "the", "bottom", "of", "the", "page" ]
fa7c39f47a91bb4b75d642834cad5409715a8402
https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/docked-panel-ng/docked-panel-ng.js#L119-L127
train
JetBrains/ring-ui
components/docked-panel-ng/docked-panel-ng.js
checkPanelPosition
function checkPanelPosition() { const currentPanelRect = panel.getBoundingClientRect(); if (currentPanelRect.top + currentPanelRect.height > getScrollContainerHeight() && !isDocked) { dock(); } else if ( isDocked && currentPanelRect.top + currentPanelRect...
javascript
function checkPanelPosition() { const currentPanelRect = panel.getBoundingClientRect(); if (currentPanelRect.top + currentPanelRect.height > getScrollContainerHeight() && !isDocked) { dock(); } else if ( isDocked && currentPanelRect.top + currentPanelRect...
[ "function", "checkPanelPosition", "(", ")", "{", "const", "currentPanelRect", "=", "panel", ".", "getBoundingClientRect", "(", ")", ";", "if", "(", "currentPanelRect", ".", "top", "+", "currentPanelRect", ".", "height", ">", "getScrollContainerHeight", "(", ")", ...
Check panel position
[ "Check", "panel", "position" ]
fa7c39f47a91bb4b75d642834cad5409715a8402
https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/docked-panel-ng/docked-panel-ng.js#L150-L163
train
JetBrains/ring-ui
components/old-browsers-message/old-browsers-message.js
startOldBrowsersDetector
function startOldBrowsersDetector(onOldBrowserDetected) { previousWindowErrorHandler = window.onerror; window.onerror = function oldBrowsersMessageShower(errorMsg, url, lineNumber) { if (onOldBrowserDetected) { onOldBrowserDetected(); } if (previousWindowErrorHandler) { return previousWind...
javascript
function startOldBrowsersDetector(onOldBrowserDetected) { previousWindowErrorHandler = window.onerror; window.onerror = function oldBrowsersMessageShower(errorMsg, url, lineNumber) { if (onOldBrowserDetected) { onOldBrowserDetected(); } if (previousWindowErrorHandler) { return previousWind...
[ "function", "startOldBrowsersDetector", "(", "onOldBrowserDetected", ")", "{", "previousWindowErrorHandler", "=", "window", ".", "onerror", ";", "window", ".", "onerror", "=", "function", "oldBrowsersMessageShower", "(", "errorMsg", ",", "url", ",", "lineNumber", ")",...
Listens to unhandled errors and displays passed node
[ "Listens", "to", "unhandled", "errors", "and", "displays", "passed", "node" ]
fa7c39f47a91bb4b75d642834cad5409715a8402
https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/old-browsers-message/old-browsers-message.js#L98-L112
train
JetBrains/ring-ui
components/autofocus-ng/autofocus-ng.js
focusOnElement
function focusOnElement(element) { if (!element) { return; } if (element.hasAttribute(RING_SELECT) || element.tagName.toLowerCase() === RING_SELECT) { focusOnElement(element.querySelector(RING_SELECT_SELECTOR)); return; } if (element.matches(FOCUSABLE_ELEMENTS) && element.focus) ...
javascript
function focusOnElement(element) { if (!element) { return; } if (element.hasAttribute(RING_SELECT) || element.tagName.toLowerCase() === RING_SELECT) { focusOnElement(element.querySelector(RING_SELECT_SELECTOR)); return; } if (element.matches(FOCUSABLE_ELEMENTS) && element.focus) ...
[ "function", "focusOnElement", "(", "element", ")", "{", "if", "(", "!", "element", ")", "{", "return", ";", "}", "if", "(", "element", ".", "hasAttribute", "(", "RING_SELECT", ")", "||", "element", ".", "tagName", ".", "toLowerCase", "(", ")", "===", "...
Focuses on element itself if it has "focus" method. Searches and focuses on select's button or input if element is rg-select @param element
[ "Focuses", "on", "element", "itself", "if", "it", "has", "focus", "method", ".", "Searches", "and", "focuses", "on", "select", "s", "button", "or", "input", "if", "element", "is", "rg", "-", "select" ]
fa7c39f47a91bb4b75d642834cad5409715a8402
https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/autofocus-ng/autofocus-ng.js#L23-L43
train
JetBrains/ring-ui
components/date-picker/months.js
scrollSpeed
function scrollSpeed(date) { const monthStart = moment(date).startOf('month'); const monthEnd = moment(date).endOf('month'); return (monthEnd - monthStart) / monthHeight(monthStart); }
javascript
function scrollSpeed(date) { const monthStart = moment(date).startOf('month'); const monthEnd = moment(date).endOf('month'); return (monthEnd - monthStart) / monthHeight(monthStart); }
[ "function", "scrollSpeed", "(", "date", ")", "{", "const", "monthStart", "=", "moment", "(", "date", ")", ".", "startOf", "(", "'month'", ")", ";", "const", "monthEnd", "=", "moment", "(", "date", ")", ".", "endOf", "(", "'month'", ")", ";", "return", ...
in milliseconds per pixel
[ "in", "milliseconds", "per", "pixel" ]
fa7c39f47a91bb4b75d642834cad5409715a8402
https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/date-picker/months.js#L32-L36
train
JetBrains/ring-ui
components/grid/row.js
getModifierClassNames
function getModifierClassNames(props) { return modifierKeys.reduce((result, key) => { if (props[key]) { return result.concat(styles[`${key}-${props[key]}`]); } return result; }, []); }
javascript
function getModifierClassNames(props) { return modifierKeys.reduce((result, key) => { if (props[key]) { return result.concat(styles[`${key}-${props[key]}`]); } return result; }, []); }
[ "function", "getModifierClassNames", "(", "props", ")", "{", "return", "modifierKeys", ".", "reduce", "(", "(", "result", ",", "key", ")", "=>", "{", "if", "(", "props", "[", "key", "]", ")", "{", "return", "result", ".", "concat", "(", "styles", "[", ...
Converts xs="middle" to class "middle-xs" @param {Object} props incoming props @returns {Array} result modifier classes
[ "Converts", "xs", "=", "middle", "to", "class", "middle", "-", "xs" ]
fa7c39f47a91bb4b75d642834cad5409715a8402
https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/grid/row.js#L20-L27
train
mattdesl/budo
lib/budo.js
watch
function watch (glob, watchOpt) { if (!started) { deferredWatch = emitter.watch.bind(null, glob, watchOpt) } else { // destroy previous if (fileWatcher) fileWatcher.close() glob = glob && glob.length > 0 ? glob : defaultWatchGlob glob = Array.isArray(glob) ? glob : [ glob ] w...
javascript
function watch (glob, watchOpt) { if (!started) { deferredWatch = emitter.watch.bind(null, glob, watchOpt) } else { // destroy previous if (fileWatcher) fileWatcher.close() glob = glob && glob.length > 0 ? glob : defaultWatchGlob glob = Array.isArray(glob) ? glob : [ glob ] w...
[ "function", "watch", "(", "glob", ",", "watchOpt", ")", "{", "if", "(", "!", "started", ")", "{", "deferredWatch", "=", "emitter", ".", "watch", ".", "bind", "(", "null", ",", "glob", ",", "watchOpt", ")", "}", "else", "{", "// destroy previous", "if",...
enable file watch capabilities
[ "enable", "file", "watch", "capabilities" ]
6800de2b083ba390a0936fce3f72c448d4b1ae3a
https://github.com/mattdesl/budo/blob/6800de2b083ba390a0936fce3f72c448d4b1ae3a/lib/budo.js#L199-L213
train
mattdesl/budo
lib/budo.js
live
function live (liveOpts) { if (!started) { deferredLive = emitter.live.bind(null, liveOpts) } else { // destroy previous if (reloader) reloader.close() // pass some options for the server middleware server.setLiveOptions(xtend(liveOpts)) // create a web socket server for li...
javascript
function live (liveOpts) { if (!started) { deferredLive = emitter.live.bind(null, liveOpts) } else { // destroy previous if (reloader) reloader.close() // pass some options for the server middleware server.setLiveOptions(xtend(liveOpts)) // create a web socket server for li...
[ "function", "live", "(", "liveOpts", ")", "{", "if", "(", "!", "started", ")", "{", "deferredLive", "=", "emitter", ".", "live", ".", "bind", "(", "null", ",", "liveOpts", ")", "}", "else", "{", "// destroy previous", "if", "(", "reloader", ")", "reloa...
enables LiveReload capabilities
[ "enables", "LiveReload", "capabilities" ]
6800de2b083ba390a0936fce3f72c448d4b1ae3a
https://github.com/mattdesl/budo/blob/6800de2b083ba390a0936fce3f72c448d4b1ae3a/lib/budo.js#L216-L230
train
mattdesl/budo
lib/error-handler.js
parseError
function parseError (err) { var filePath, lineNum, splitLines var result = {} // For root files that syntax-error doesn't pick up: var parseFilePrefix = 'Parsing file ' if (err.indexOf(parseFilePrefix) === 0) { var pathWithErr = err.substring(parseFilePrefix.length) filePath = getFilePa...
javascript
function parseError (err) { var filePath, lineNum, splitLines var result = {} // For root files that syntax-error doesn't pick up: var parseFilePrefix = 'Parsing file ' if (err.indexOf(parseFilePrefix) === 0) { var pathWithErr = err.substring(parseFilePrefix.length) filePath = getFilePa...
[ "function", "parseError", "(", "err", ")", "{", "var", "filePath", ",", "lineNum", ",", "splitLines", "var", "result", "=", "{", "}", "// For root files that syntax-error doesn't pick up:", "var", "parseFilePrefix", "=", "'Parsing file '", "if", "(", "err", ".", "...
parse an error message into pieces
[ "parse", "an", "error", "message", "into", "pieces" ]
6800de2b083ba390a0936fce3f72c448d4b1ae3a
https://github.com/mattdesl/budo/blob/6800de2b083ba390a0936fce3f72c448d4b1ae3a/lib/error-handler.js#L149-L221
train
mattdesl/budo
lib/error-handler.js
getFilePath
function getFilePath (str) { var hasRoot = /^[a-z]:/i.exec(str) var colonLeftIndex = 0 if (hasRoot) { colonLeftIndex = hasRoot[0].length } var pathEnd = str.split('\n')[0].indexOf(':', colonLeftIndex) if (pathEnd === -1) { // invalid string, return non-formattable result return...
javascript
function getFilePath (str) { var hasRoot = /^[a-z]:/i.exec(str) var colonLeftIndex = 0 if (hasRoot) { colonLeftIndex = hasRoot[0].length } var pathEnd = str.split('\n')[0].indexOf(':', colonLeftIndex) if (pathEnd === -1) { // invalid string, return non-formattable result return...
[ "function", "getFilePath", "(", "str", ")", "{", "var", "hasRoot", "=", "/", "^[a-z]:", "/", "i", ".", "exec", "(", "str", ")", "var", "colonLeftIndex", "=", "0", "if", "(", "hasRoot", ")", "{", "colonLeftIndex", "=", "hasRoot", "[", "0", "]", ".", ...
get a file path from the error message
[ "get", "a", "file", "path", "from", "the", "error", "message" ]
6800de2b083ba390a0936fce3f72c448d4b1ae3a
https://github.com/mattdesl/budo/blob/6800de2b083ba390a0936fce3f72c448d4b1ae3a/lib/error-handler.js#L224-L236
train
thysultan/stylis.js
docs/assets/javascript/editor.js
update
function update (e) { // tab indent if (e.keyCode === 9) { e.preventDefault(); var selection = window.getSelection(); var range = selection.getRangeAt(0); var text = document.createTextNode('\t'); range.deleteContents(); range.insertNode(text); range.setSta...
javascript
function update (e) { // tab indent if (e.keyCode === 9) { e.preventDefault(); var selection = window.getSelection(); var range = selection.getRangeAt(0); var text = document.createTextNode('\t'); range.deleteContents(); range.insertNode(text); range.setSta...
[ "function", "update", "(", "e", ")", "{", "// tab indent", "if", "(", "e", ".", "keyCode", "===", "9", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "var", "selection", "=", "window", ".", "getSelection", "(", ")", ";", "var", "range", "=", ...
update output preview
[ "update", "output", "preview" ]
4561e9bc830fccf1cb0e9e9838488b4d1d5cebf5
https://github.com/thysultan/stylis.js/blob/4561e9bc830fccf1cb0e9e9838488b4d1d5cebf5/docs/assets/javascript/editor.js#L28-L66
train
Automattic/cli-table
lib/utils.js
options
function options(defaults, opts) { for (var p in opts) { if (opts[p] && opts[p].constructor && opts[p].constructor === Object) { defaults[p] = defaults[p] || {}; options(defaults[p], opts[p]); } else { defaults[p] = opts[p]; } } return defaults; }
javascript
function options(defaults, opts) { for (var p in opts) { if (opts[p] && opts[p].constructor && opts[p].constructor === Object) { defaults[p] = defaults[p] || {}; options(defaults[p], opts[p]); } else { defaults[p] = opts[p]; } } return defaults; }
[ "function", "options", "(", "defaults", ",", "opts", ")", "{", "for", "(", "var", "p", "in", "opts", ")", "{", "if", "(", "opts", "[", "p", "]", "&&", "opts", "[", "p", "]", ".", "constructor", "&&", "opts", "[", "p", "]", ".", "constructor", "...
Copies and merges options with defaults. @param {Object} defaults @param {Object} supplied options @return {Object} new (merged) object
[ "Copies", "and", "merges", "options", "with", "defaults", "." ]
7b14232ba779929e1859b267bf753c150d90a618
https://github.com/Automattic/cli-table/blob/7b14232ba779929e1859b267bf753c150d90a618/lib/utils.js#L60-L70
train
Automattic/cli-table
lib/index.js
line
function line (line, left, right, intersection){ var width = 0 , line = left + repeat(line, totalWidth - 2) + right; colWidths.forEach(function (w, i){ if (i == colWidths.length - 1) return; width += w + 1; line = line.substr(0, width) + intersection + line.sub...
javascript
function line (line, left, right, intersection){ var width = 0 , line = left + repeat(line, totalWidth - 2) + right; colWidths.forEach(function (w, i){ if (i == colWidths.length - 1) return; width += w + 1; line = line.substr(0, width) + intersection + line.sub...
[ "function", "line", "(", "line", ",", "left", ",", "right", ",", "intersection", ")", "{", "var", "width", "=", "0", ",", "line", "=", "left", "+", "repeat", "(", "line", ",", "totalWidth", "-", "2", ")", "+", "right", ";", "colWidths", ".", "forEa...
draws a line
[ "draws", "a", "line" ]
7b14232ba779929e1859b267bf753c150d90a618
https://github.com/Automattic/cli-table/blob/7b14232ba779929e1859b267bf753c150d90a618/lib/index.js#L137-L151
train
Automattic/cli-table
lib/index.js
lineTop
function lineTop (){ var l = line(chars.top , chars['top-left'] || chars.top , chars['top-right'] || chars.top , chars['top-mid']); if (l) ret += l + "\n"; }
javascript
function lineTop (){ var l = line(chars.top , chars['top-left'] || chars.top , chars['top-right'] || chars.top , chars['top-mid']); if (l) ret += l + "\n"; }
[ "function", "lineTop", "(", ")", "{", "var", "l", "=", "line", "(", "chars", ".", "top", ",", "chars", "[", "'top-left'", "]", "||", "chars", ".", "top", ",", "chars", "[", "'top-right'", "]", "||", "chars", ".", "top", ",", "chars", "[", "'top-mid...
draws the top line
[ "draws", "the", "top", "line" ]
7b14232ba779929e1859b267bf753c150d90a618
https://github.com/Automattic/cli-table/blob/7b14232ba779929e1859b267bf753c150d90a618/lib/index.js#L154-L161
train
Automattic/cli-table
lib/index.js
string
function string (str, index){ var str = String(typeof str == 'object' && str.text ? str.text : str) , length = utils.strlen(str) , width = colWidths[index] - (style['padding-left'] || 0) - (style['padding-right'] || 0) , align = options.colAligns[index] || 'left'; return r...
javascript
function string (str, index){ var str = String(typeof str == 'object' && str.text ? str.text : str) , length = utils.strlen(str) , width = colWidths[index] - (style['padding-left'] || 0) - (style['padding-right'] || 0) , align = options.colAligns[index] || 'left'; return r...
[ "function", "string", "(", "str", ",", "index", ")", "{", "var", "str", "=", "String", "(", "typeof", "str", "==", "'object'", "&&", "str", ".", "text", "?", "str", ".", "text", ":", "str", ")", ",", "length", "=", "utils", ".", "strlen", "(", "s...
renders a string, by padding it or truncating it
[ "renders", "a", "string", "by", "padding", "it", "or", "truncating", "it" ]
7b14232ba779929e1859b267bf753c150d90a618
https://github.com/Automattic/cli-table/blob/7b14232ba779929e1859b267bf753c150d90a618/lib/index.js#L236-L252
train
jshttp/mime-types
index.js
charset
function charset (type) { if (!type || typeof type !== 'string') { return false } // TODO: use media-typer var match = EXTRACT_TYPE_REGEXP.exec(type) var mime = match && db[match[1].toLowerCase()] if (mime && mime.charset) { return mime.charset } // default text/* to utf-8 if (match && TEXT...
javascript
function charset (type) { if (!type || typeof type !== 'string') { return false } // TODO: use media-typer var match = EXTRACT_TYPE_REGEXP.exec(type) var mime = match && db[match[1].toLowerCase()] if (mime && mime.charset) { return mime.charset } // default text/* to utf-8 if (match && TEXT...
[ "function", "charset", "(", "type", ")", "{", "if", "(", "!", "type", "||", "typeof", "type", "!==", "'string'", ")", "{", "return", "false", "}", "// TODO: use media-typer", "var", "match", "=", "EXTRACT_TYPE_REGEXP", ".", "exec", "(", "type", ")", "var",...
Get the default charset for a MIME type. @param {string} type @return {boolean|string}
[ "Get", "the", "default", "charset", "for", "a", "MIME", "type", "." ]
e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0
https://github.com/jshttp/mime-types/blob/e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0/index.js#L49-L68
train
jshttp/mime-types
index.js
contentType
function contentType (str) { // TODO: should this even be in this module? if (!str || typeof str !== 'string') { return false } var mime = str.indexOf('/') === -1 ? exports.lookup(str) : str if (!mime) { return false } // TODO: use content-type or other module if (mime.indexOf('charse...
javascript
function contentType (str) { // TODO: should this even be in this module? if (!str || typeof str !== 'string') { return false } var mime = str.indexOf('/') === -1 ? exports.lookup(str) : str if (!mime) { return false } // TODO: use content-type or other module if (mime.indexOf('charse...
[ "function", "contentType", "(", "str", ")", "{", "// TODO: should this even be in this module?", "if", "(", "!", "str", "||", "typeof", "str", "!==", "'string'", ")", "{", "return", "false", "}", "var", "mime", "=", "str", ".", "indexOf", "(", "'/'", ")", ...
Create a full Content-Type header given a MIME type or extension. @param {string} str @return {boolean|string}
[ "Create", "a", "full", "Content", "-", "Type", "header", "given", "a", "MIME", "type", "or", "extension", "." ]
e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0
https://github.com/jshttp/mime-types/blob/e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0/index.js#L77-L98
train
jshttp/mime-types
index.js
extension
function extension (type) { if (!type || typeof type !== 'string') { return false } // TODO: use media-typer var match = EXTRACT_TYPE_REGEXP.exec(type) // get extensions var exts = match && exports.extensions[match[1].toLowerCase()] if (!exts || !exts.length) { return false } return exts[0...
javascript
function extension (type) { if (!type || typeof type !== 'string') { return false } // TODO: use media-typer var match = EXTRACT_TYPE_REGEXP.exec(type) // get extensions var exts = match && exports.extensions[match[1].toLowerCase()] if (!exts || !exts.length) { return false } return exts[0...
[ "function", "extension", "(", "type", ")", "{", "if", "(", "!", "type", "||", "typeof", "type", "!==", "'string'", ")", "{", "return", "false", "}", "// TODO: use media-typer", "var", "match", "=", "EXTRACT_TYPE_REGEXP", ".", "exec", "(", "type", ")", "// ...
Get the default extension for a MIME type. @param {string} type @return {boolean|string}
[ "Get", "the", "default", "extension", "for", "a", "MIME", "type", "." ]
e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0
https://github.com/jshttp/mime-types/blob/e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0/index.js#L107-L123
train
jshttp/mime-types
index.js
populateMaps
function populateMaps (extensions, types) { // source preference (least -> most) var preference = ['nginx', 'apache', undefined, 'iana'] Object.keys(db).forEach(function forEachMimeType (type) { var mime = db[type] var exts = mime.extensions if (!exts || !exts.length) { return } // mi...
javascript
function populateMaps (extensions, types) { // source preference (least -> most) var preference = ['nginx', 'apache', undefined, 'iana'] Object.keys(db).forEach(function forEachMimeType (type) { var mime = db[type] var exts = mime.extensions if (!exts || !exts.length) { return } // mi...
[ "function", "populateMaps", "(", "extensions", ",", "types", ")", "{", "// source preference (least -> most)", "var", "preference", "=", "[", "'nginx'", ",", "'apache'", ",", "undefined", ",", "'iana'", "]", "Object", ".", "keys", "(", "db", ")", ".", "forEach...
Populate the extensions and types maps. @private
[ "Populate", "the", "extensions", "and", "types", "maps", "." ]
e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0
https://github.com/jshttp/mime-types/blob/e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0/index.js#L154-L188
train
observing/pre-commit
install.js
getGitFolderPath
function getGitFolderPath(currentPath) { var git = path.resolve(currentPath, '.git') if (!exists(git) || !fs.lstatSync(git).isDirectory()) { console.log('pre-commit:'); console.log('pre-commit: Not found .git folder in', git); var newPath = path.resolve(currentPath, '..'); // Stop if we on to...
javascript
function getGitFolderPath(currentPath) { var git = path.resolve(currentPath, '.git') if (!exists(git) || !fs.lstatSync(git).isDirectory()) { console.log('pre-commit:'); console.log('pre-commit: Not found .git folder in', git); var newPath = path.resolve(currentPath, '..'); // Stop if we on to...
[ "function", "getGitFolderPath", "(", "currentPath", ")", "{", "var", "git", "=", "path", ".", "resolve", "(", "currentPath", ",", "'.git'", ")", "if", "(", "!", "exists", "(", "git", ")", "||", "!", "fs", ".", "lstatSync", "(", "git", ")", ".", "isDi...
Function to recursively finding .git folder
[ "Function", "to", "recursively", "finding", ".", "git", "folder" ]
84aa9eac11634d8fe6053fa7946dee5b77f09581
https://github.com/observing/pre-commit/blob/84aa9eac11634d8fe6053fa7946dee5b77f09581/install.js#L23-L43
train
observing/pre-commit
index.js
Hook
function Hook(fn, options) { if (!this) return new Hook(fn, options); options = options || {}; this.options = options; // Used for testing only. Ignore this. Don't touch. this.config = {}; // pre-commit configuration from the `package.json`. this.json = {}; // Actual content of the ...
javascript
function Hook(fn, options) { if (!this) return new Hook(fn, options); options = options || {}; this.options = options; // Used for testing only. Ignore this. Don't touch. this.config = {}; // pre-commit configuration from the `package.json`. this.json = {}; // Actual content of the ...
[ "function", "Hook", "(", "fn", ",", "options", ")", "{", "if", "(", "!", "this", ")", "return", "new", "Hook", "(", "fn", ",", "options", ")", ";", "options", "=", "options", "||", "{", "}", ";", "this", ".", "options", "=", "options", ";", "// U...
Representation of a hook runner. @constructor @param {Function} fn Function to be called when we want to exit @param {Object} options Optional configuration, primarily used for testing. @api public
[ "Representation", "of", "a", "hook", "runner", "." ]
84aa9eac11634d8fe6053fa7946dee5b77f09581
https://github.com/observing/pre-commit/blob/84aa9eac11634d8fe6053fa7946dee5b77f09581/index.js#L17-L31
train
davidyack/Xrm.Tools.CRMWebAPI
JS/Examples/SinglePage/app/scripts/app.js
loadView
function loadView(view) { $errorMessage.empty(); var ctrl = loadCtrl(view); if (!ctrl) return; // Check if View Requires Authentication if (ctrl.requireADLogin && !authContext.getCachedUser()) { authContext.config.redirectUri = window.location.href; ...
javascript
function loadView(view) { $errorMessage.empty(); var ctrl = loadCtrl(view); if (!ctrl) return; // Check if View Requires Authentication if (ctrl.requireADLogin && !authContext.getCachedUser()) { authContext.config.redirectUri = window.location.href; ...
[ "function", "loadView", "(", "view", ")", "{", "$errorMessage", ".", "empty", "(", ")", ";", "var", "ctrl", "=", "loadCtrl", "(", "view", ")", ";", "if", "(", "!", "ctrl", ")", "return", ";", "// Check if View Requires Authentication", "if", "(", "ctrl", ...
Show a View
[ "Show", "a", "View" ]
c5569bb668e34d87fe4cba0f4089973943ab0ca0
https://github.com/davidyack/Xrm.Tools.CRMWebAPI/blob/c5569bb668e34d87fe4cba0f4089973943ab0ca0/JS/Examples/SinglePage/app/scripts/app.js#L79-L112
train
benwiley4000/cassette
packages/core/src/utils/getSourceList.js
getSourceList
function getSourceList(playlist) { return (playlist || []).map((_, i) => getTrackSources(playlist, i)[0].src); }
javascript
function getSourceList(playlist) { return (playlist || []).map((_, i) => getTrackSources(playlist, i)[0].src); }
[ "function", "getSourceList", "(", "playlist", ")", "{", "return", "(", "playlist", "||", "[", "]", ")", ".", "map", "(", "(", "_", ",", "i", ")", "=>", "getTrackSources", "(", "playlist", ",", "i", ")", "[", "0", "]", ".", "src", ")", ";", "}" ]
collapses playlist into flat list containing the first source url for each track
[ "collapses", "playlist", "into", "flat", "list", "containing", "the", "first", "source", "url", "for", "each", "track" ]
2f6e15a911addb27fdf0d876e92c29c94779c1ca
https://github.com/benwiley4000/cassette/blob/2f6e15a911addb27fdf0d876e92c29c94779c1ca/packages/core/src/utils/getSourceList.js#L5-L7
train
benwiley4000/cassette
packages/core/src/PlayerContextProvider.js
getGoToTrackState
function getGoToTrackState({ prevState, index, track, shouldPlay = true, shouldForceLoad = false }) { const isNewTrack = prevState.activeTrackIndex !== index; const shouldLoadAsNew = Boolean(isNewTrack || shouldForceLoad); const currentTime = track.startingTime || 0; return { duration: getInitialD...
javascript
function getGoToTrackState({ prevState, index, track, shouldPlay = true, shouldForceLoad = false }) { const isNewTrack = prevState.activeTrackIndex !== index; const shouldLoadAsNew = Boolean(isNewTrack || shouldForceLoad); const currentTime = track.startingTime || 0; return { duration: getInitialD...
[ "function", "getGoToTrackState", "(", "{", "prevState", ",", "index", ",", "track", ",", "shouldPlay", "=", "true", ",", "shouldForceLoad", "=", "false", "}", ")", "{", "const", "isNewTrack", "=", "prevState", ".", "activeTrackIndex", "!==", "index", ";", "c...
assumes playlist is valid
[ "assumes", "playlist", "is", "valid" ]
2f6e15a911addb27fdf0d876e92c29c94779c1ca
https://github.com/benwiley4000/cassette/blob/2f6e15a911addb27fdf0d876e92c29c94779c1ca/packages/core/src/PlayerContextProvider.js#L83-L105
train
morajabi/styled-media-query
src/convertors.js
pxToEmOrRem
function pxToEmOrRem(breakpoints, ratio = 16, unit) { const newBreakpoints = {}; for (let key in breakpoints) { const point = breakpoints[key]; if (String(point).includes('px')) { newBreakpoints[key] = +(parseInt(point) / ratio) + unit; continue; } newBreakpoints[key] = point; } ...
javascript
function pxToEmOrRem(breakpoints, ratio = 16, unit) { const newBreakpoints = {}; for (let key in breakpoints) { const point = breakpoints[key]; if (String(point).includes('px')) { newBreakpoints[key] = +(parseInt(point) / ratio) + unit; continue; } newBreakpoints[key] = point; } ...
[ "function", "pxToEmOrRem", "(", "breakpoints", ",", "ratio", "=", "16", ",", "unit", ")", "{", "const", "newBreakpoints", "=", "{", "}", ";", "for", "(", "let", "key", "in", "breakpoints", ")", "{", "const", "point", "=", "breakpoints", "[", "key", "]"...
Converts breakpoint units in px to rem or em @param {Object} breakpoints - an object containing breakpoint names as keys and the width as value @param {number} ratio [16] - size of 1 rem in px. What is your main font-size in px? @param {'rem' | 'em'} unit
[ "Converts", "breakpoint", "units", "in", "px", "to", "rem", "or", "em" ]
687a2089dbf46924783a8b157f4d3ebcdead7b3b
https://github.com/morajabi/styled-media-query/blob/687a2089dbf46924783a8b157f4d3ebcdead7b3b/src/convertors.js#L7-L22
train
Automattic/monk
lib/manager.js
Manager
function Manager (uri, opts, fn) { if (!uri) { throw Error('No connection URI provided.') } if (!(this instanceof Manager)) { return new Manager(uri, opts, fn) } if (typeof opts === 'function') { fn = opts opts = {} } opts = opts || {} this._collectionOptions = objectAssign({}, DEFAU...
javascript
function Manager (uri, opts, fn) { if (!uri) { throw Error('No connection URI provided.') } if (!(this instanceof Manager)) { return new Manager(uri, opts, fn) } if (typeof opts === 'function') { fn = opts opts = {} } opts = opts || {} this._collectionOptions = objectAssign({}, DEFAU...
[ "function", "Manager", "(", "uri", ",", "opts", ",", "fn", ")", "{", "if", "(", "!", "uri", ")", "{", "throw", "Error", "(", "'No connection URI provided.'", ")", "}", "if", "(", "!", "(", "this", "instanceof", "Manager", ")", ")", "{", "return", "ne...
Monk constructor. @param {Array|String} uri replica sets can be an array or comma-separated @param {Object|Function} opts or connect callback @param {Function} fn connect callback @return {Promise} resolve when the connection is opened
[ "Monk", "constructor", "." ]
39228eacd4d649de884b096624a55472cf20c40a
https://github.com/Automattic/monk/blob/39228eacd4d649de884b096624a55472cf20c40a/lib/manager.js#L47-L116
train
flickr/yakbak
index.js
tapename
function tapename(req, body) { var hash = opts.hash || messageHash.sync; return hash(req, Buffer.concat(body)) + '.js'; }
javascript
function tapename(req, body) { var hash = opts.hash || messageHash.sync; return hash(req, Buffer.concat(body)) + '.js'; }
[ "function", "tapename", "(", "req", ",", "body", ")", "{", "var", "hash", "=", "opts", ".", "hash", "||", "messageHash", ".", "sync", ";", "return", "hash", "(", "req", ",", "Buffer", ".", "concat", "(", "body", ")", ")", "+", "'.js'", ";", "}" ]
Returns the tape name for `req`. @param {http.IncomingMessage} req @param {Array.<Buffer>} body @returns {String}
[ "Returns", "the", "tape", "name", "for", "req", "." ]
0047013893066a3b3b0a9d3143042c5430e4db75
https://github.com/flickr/yakbak/blob/0047013893066a3b3b0a9d3143042c5430e4db75/index.js#L70-L74
train
flickr/yakbak
lib/record.js
write
function write(filename, data) { return Promise.fromCallback(function (done) { debug('write', filename); fs.writeFile(filename, data, done); }); }
javascript
function write(filename, data) { return Promise.fromCallback(function (done) { debug('write', filename); fs.writeFile(filename, data, done); }); }
[ "function", "write", "(", "filename", ",", "data", ")", "{", "return", "Promise", ".", "fromCallback", "(", "function", "(", "done", ")", "{", "debug", "(", "'write'", ",", "filename", ")", ";", "fs", ".", "writeFile", "(", "filename", ",", "data", ","...
Write `data` to `filename`. Seems overkill to "promisify" this. @param {String} filename @param {String} data @returns {Promise}
[ "Write", "data", "to", "filename", ".", "Seems", "overkill", "to", "promisify", "this", "." ]
0047013893066a3b3b0a9d3143042c5430e4db75
https://github.com/flickr/yakbak/blob/0047013893066a3b3b0a9d3143042c5430e4db75/lib/record.js#L46-L51
train
fluencelabs/fluence
fluence-js/src/examples/todo-list/index.js
createNewTask
function createNewTask(task) { console.log("Creating task..."); //set up the new list item const listItem = document.createElement("li"); const checkBox = document.createElement("input"); const label = document.createElement("label"); //pull the inputed text into label...
javascript
function createNewTask(task) { console.log("Creating task..."); //set up the new list item const listItem = document.createElement("li"); const checkBox = document.createElement("input"); const label = document.createElement("label"); //pull the inputed text into label...
[ "function", "createNewTask", "(", "task", ")", "{", "console", ".", "log", "(", "\"Creating task...\"", ")", ";", "//set up the new list item", "const", "listItem", "=", "document", ".", "createElement", "(", "\"li\"", ")", ";", "const", "checkBox", "=", "docume...
create functions creating the actual task list item
[ "create", "functions", "creating", "the", "actual", "task", "list", "item" ]
2877526629d7efd8aa61e0e250d3498b2837dfb8
https://github.com/fluencelabs/fluence/blob/2877526629d7efd8aa61e0e250d3498b2837dfb8/fluence-js/src/examples/todo-list/index.js#L130-L150
train
fluencelabs/fluence
fluence-js/src/examples/todo-list/index.js
addTask
function addTask() { const task = newTask.value.trim(); console.log("Adding task: " + task); // ***** // *** we need to add a task to the fluence cluster after we pressed the `Add task` button // ***** addTaskToFluence(task); updateTaskList(task) }
javascript
function addTask() { const task = newTask.value.trim(); console.log("Adding task: " + task); // ***** // *** we need to add a task to the fluence cluster after we pressed the `Add task` button // ***** addTaskToFluence(task); updateTaskList(task) }
[ "function", "addTask", "(", ")", "{", "const", "task", "=", "newTask", ".", "value", ".", "trim", "(", ")", ";", "console", ".", "log", "(", "\"Adding task: \"", "+", "task", ")", ";", "// *****", "// *** we need to add a task to the fluence cluster after we press...
do the new task into actual incomplete list
[ "do", "the", "new", "task", "into", "actual", "incomplete", "list" ]
2877526629d7efd8aa61e0e250d3498b2837dfb8
https://github.com/fluencelabs/fluence/blob/2877526629d7efd8aa61e0e250d3498b2837dfb8/fluence-js/src/examples/todo-list/index.js#L187-L198
train
fluencelabs/fluence
fluence-js/src/examples/todo-list/index.js
deleteTask
function deleteTask() { console.log("Deleting task..."); const listItem = this.parentNode; const ul = listItem.parentNode; const task = listItem.getElementsByTagName('label')[0].innerText; // ***** // *** delete a task from the cluster when we press `Delete` button on ...
javascript
function deleteTask() { console.log("Deleting task..."); const listItem = this.parentNode; const ul = listItem.parentNode; const task = listItem.getElementsByTagName('label')[0].innerText; // ***** // *** delete a task from the cluster when we press `Delete` button on ...
[ "function", "deleteTask", "(", ")", "{", "console", ".", "log", "(", "\"Deleting task...\"", ")", ";", "const", "listItem", "=", "this", ".", "parentNode", ";", "const", "ul", "=", "listItem", ".", "parentNode", ";", "const", "task", "=", "listItem", ".", ...
delete task functions
[ "delete", "task", "functions" ]
2877526629d7efd8aa61e0e250d3498b2837dfb8
https://github.com/fluencelabs/fluence/blob/2877526629d7efd8aa61e0e250d3498b2837dfb8/fluence-js/src/examples/todo-list/index.js#L242-L257
train
xtuc/webassemblyjs
packages/dce/src/used-exports.js
onLocalModuleBinding
function onLocalModuleBinding(ident, ast, acc) { traverse(ast, { CallExpression({ node: callExpression }) { // left must be a member expression if (t.isMemberExpression(callExpression.callee) === false) { return; } const memberExpression = callExpression.callee; /** ...
javascript
function onLocalModuleBinding(ident, ast, acc) { traverse(ast, { CallExpression({ node: callExpression }) { // left must be a member expression if (t.isMemberExpression(callExpression.callee) === false) { return; } const memberExpression = callExpression.callee; /** ...
[ "function", "onLocalModuleBinding", "(", "ident", ",", "ast", ",", "acc", ")", "{", "traverse", "(", "ast", ",", "{", "CallExpression", "(", "{", "node", ":", "callExpression", "}", ")", "{", "// left must be a member expression", "if", "(", "t", ".", "isMem...
We found a local binding from the wasm binary. `import x from 'module.wasm'` ^
[ "We", "found", "a", "local", "binding", "from", "the", "wasm", "binary", "." ]
32996b42072073f270adc178ce542da1ae9e9704
https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/packages/dce/src/used-exports.js#L23-L51
train
xtuc/webassemblyjs
packages/dce/src/used-exports.js
onInstanceThenFn
function onInstanceThenFn(fn, acc) { if (t.isArrowFunctionExpression(fn) === false) { throw new Error("Unsupported function type: " + fn.type); } let [localIdent] = fn.params; /** * `then(({exports}) => ...)` * * We need to resolve the identifier (binding) from the ObjectPattern. * * TODO(s...
javascript
function onInstanceThenFn(fn, acc) { if (t.isArrowFunctionExpression(fn) === false) { throw new Error("Unsupported function type: " + fn.type); } let [localIdent] = fn.params; /** * `then(({exports}) => ...)` * * We need to resolve the identifier (binding) from the ObjectPattern. * * TODO(s...
[ "function", "onInstanceThenFn", "(", "fn", ",", "acc", ")", "{", "if", "(", "t", ".", "isArrowFunctionExpression", "(", "fn", ")", "===", "false", ")", "{", "throw", "new", "Error", "(", "\"Unsupported function type: \"", "+", "fn", ".", "type", ")", ";", ...
We found the function handling the module instance `makeX().then(...)`
[ "We", "found", "the", "function", "handling", "the", "module", "instance" ]
32996b42072073f270adc178ce542da1ae9e9704
https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/packages/dce/src/used-exports.js#L58-L112
train
xtuc/webassemblyjs
website/static/js/repl.js
configureMonaco
function configureMonaco() { monaco.languages.register({ id: "wast" }); monaco.languages.setMonarchTokensProvider("wast", { tokenizer: { root: [ [REGEXP_KEYWORD, "keyword"], [REGEXP_KEYWORD_ASSERTS, "keyword"], [REGEXP_NUMBER, "number"], [/\$([a-zA-Z0-9_`\+\-\*\/\\\^~=<>!\...
javascript
function configureMonaco() { monaco.languages.register({ id: "wast" }); monaco.languages.setMonarchTokensProvider("wast", { tokenizer: { root: [ [REGEXP_KEYWORD, "keyword"], [REGEXP_KEYWORD_ASSERTS, "keyword"], [REGEXP_NUMBER, "number"], [/\$([a-zA-Z0-9_`\+\-\*\/\\\^~=<>!\...
[ "function", "configureMonaco", "(", ")", "{", "monaco", ".", "languages", ".", "register", "(", "{", "id", ":", "\"wast\"", "}", ")", ";", "monaco", ".", "languages", ".", "setMonarchTokensProvider", "(", "\"wast\"", ",", "{", "tokenizer", ":", "{", "root"...
Monaco wast def
[ "Monaco", "wast", "def" ]
32996b42072073f270adc178ce542da1ae9e9704
https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/website/static/js/repl.js#L16-L40
train
xtuc/webassemblyjs
packages/leb128/src/leb.js
encodeBufferCommon
function encodeBufferCommon(buffer, signed) { let signBit; let bitCount; if (signed) { signBit = bits.getSign(buffer); bitCount = signedBitCount(buffer); } else { signBit = 0; bitCount = unsignedBitCount(buffer); } const byteCount = Math.ceil(bitCount / 7); const result = bufs.alloc(byte...
javascript
function encodeBufferCommon(buffer, signed) { let signBit; let bitCount; if (signed) { signBit = bits.getSign(buffer); bitCount = signedBitCount(buffer); } else { signBit = 0; bitCount = unsignedBitCount(buffer); } const byteCount = Math.ceil(bitCount / 7); const result = bufs.alloc(byte...
[ "function", "encodeBufferCommon", "(", "buffer", ",", "signed", ")", "{", "let", "signBit", ";", "let", "bitCount", ";", "if", "(", "signed", ")", "{", "signBit", "=", "bits", ".", "getSign", "(", "buffer", ")", ";", "bitCount", "=", "signedBitCount", "(...
Common encoder for both signed and unsigned ints. This takes a bigint-ish buffer, returning an LEB128-encoded buffer.
[ "Common", "encoder", "for", "both", "signed", "and", "unsigned", "ints", ".", "This", "takes", "a", "bigint", "-", "ish", "buffer", "returning", "an", "LEB128", "-", "encoded", "buffer", "." ]
32996b42072073f270adc178ce542da1ae9e9704
https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/packages/leb128/src/leb.js#L95-L119
train
xtuc/webassemblyjs
packages/leb128/src/leb.js
encodedLength
function encodedLength(encodedBuffer, index) { let result = 0; while (encodedBuffer[index + result] >= 0x80) { result++; } result++; // to account for the last byte if (index + result > encodedBuffer.length) { // FIXME(sven): seems to cause false positives // throw new Error("integer representa...
javascript
function encodedLength(encodedBuffer, index) { let result = 0; while (encodedBuffer[index + result] >= 0x80) { result++; } result++; // to account for the last byte if (index + result > encodedBuffer.length) { // FIXME(sven): seems to cause false positives // throw new Error("integer representa...
[ "function", "encodedLength", "(", "encodedBuffer", ",", "index", ")", "{", "let", "result", "=", "0", ";", "while", "(", "encodedBuffer", "[", "index", "+", "result", "]", ">=", "0x80", ")", "{", "result", "++", ";", "}", "result", "++", ";", "// to ac...
Gets the byte-length of the value encoded in the given buffer at the given index.
[ "Gets", "the", "byte", "-", "length", "of", "the", "value", "encoded", "in", "the", "given", "buffer", "at", "the", "given", "index", "." ]
32996b42072073f270adc178ce542da1ae9e9704
https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/packages/leb128/src/leb.js#L125-L140
train
xtuc/webassemblyjs
packages/leb128/src/leb.js
decodeBufferCommon
function decodeBufferCommon(encodedBuffer, index, signed) { index = index === undefined ? 0 : index; let length = encodedLength(encodedBuffer, index); const bitLength = length * 7; let byteLength = Math.ceil(bitLength / 8); let result = bufs.alloc(byteLength); let outIndex = 0; while (length > 0) { ...
javascript
function decodeBufferCommon(encodedBuffer, index, signed) { index = index === undefined ? 0 : index; let length = encodedLength(encodedBuffer, index); const bitLength = length * 7; let byteLength = Math.ceil(bitLength / 8); let result = bufs.alloc(byteLength); let outIndex = 0; while (length > 0) { ...
[ "function", "decodeBufferCommon", "(", "encodedBuffer", ",", "index", ",", "signed", ")", "{", "index", "=", "index", "===", "undefined", "?", "0", ":", "index", ";", "let", "length", "=", "encodedLength", "(", "encodedBuffer", ",", "index", ")", ";", "con...
Common decoder for both signed and unsigned ints. This takes an LEB128-encoded buffer, returning a bigint-ish buffer.
[ "Common", "decoder", "for", "both", "signed", "and", "unsigned", "ints", ".", "This", "takes", "an", "LEB128", "-", "encoded", "buffer", "returning", "a", "bigint", "-", "ish", "buffer", "." ]
32996b42072073f270adc178ce542da1ae9e9704
https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/packages/leb128/src/leb.js#L146-L192
train
expressjs/vhost
index.js
vhost
function vhost (hostname, handle) { if (!hostname) { throw new TypeError('argument hostname is required') } if (!handle) { throw new TypeError('argument handle is required') } if (typeof handle !== 'function') { throw new TypeError('argument handle must be a function') } // create regular e...
javascript
function vhost (hostname, handle) { if (!hostname) { throw new TypeError('argument hostname is required') } if (!handle) { throw new TypeError('argument handle is required') } if (typeof handle !== 'function') { throw new TypeError('argument handle must be a function') } // create regular e...
[ "function", "vhost", "(", "hostname", ",", "handle", ")", "{", "if", "(", "!", "hostname", ")", "{", "throw", "new", "TypeError", "(", "'argument hostname is required'", ")", "}", "if", "(", "!", "handle", ")", "{", "throw", "new", "TypeError", "(", "'ar...
Create a vhost middleware. @param {string|RegExp} hostname @param {function} handle @return {Function} @public
[ "Create", "a", "vhost", "middleware", "." ]
1ba557c2e1772ba4b0afe2b7355ff0ec050eff80
https://github.com/expressjs/vhost/blob/1ba557c2e1772ba4b0afe2b7355ff0ec050eff80/index.js#L37-L66
train
expressjs/vhost
index.js
hostnameof
function hostnameof (req) { var host = req.headers.host if (!host) { return } var offset = host[0] === '[' ? host.indexOf(']') + 1 : 0 var index = host.indexOf(':', offset) return index !== -1 ? host.substring(0, index) : host }
javascript
function hostnameof (req) { var host = req.headers.host if (!host) { return } var offset = host[0] === '[' ? host.indexOf(']') + 1 : 0 var index = host.indexOf(':', offset) return index !== -1 ? host.substring(0, index) : host }
[ "function", "hostnameof", "(", "req", ")", "{", "var", "host", "=", "req", ".", "headers", ".", "host", "if", "(", "!", "host", ")", "{", "return", "}", "var", "offset", "=", "host", "[", "0", "]", "===", "'['", "?", "host", ".", "indexOf", "(", ...
Get hostname of request. @param (object} req @return {string} @private
[ "Get", "hostname", "of", "request", "." ]
1ba557c2e1772ba4b0afe2b7355ff0ec050eff80
https://github.com/expressjs/vhost/blob/1ba557c2e1772ba4b0afe2b7355ff0ec050eff80/index.js#L76-L91
train
expressjs/vhost
index.js
hostregexp
function hostregexp (val) { var source = !isregexp(val) ? String(val).replace(ESCAPE_REGEXP, ESCAPE_REPLACE).replace(ASTERISK_REGEXP, ASTERISK_REPLACE) : val.source // force leading anchor matching if (source[0] !== '^') { source = '^' + source } // force trailing anchor matching if (!END_ANCH...
javascript
function hostregexp (val) { var source = !isregexp(val) ? String(val).replace(ESCAPE_REGEXP, ESCAPE_REPLACE).replace(ASTERISK_REGEXP, ASTERISK_REPLACE) : val.source // force leading anchor matching if (source[0] !== '^') { source = '^' + source } // force trailing anchor matching if (!END_ANCH...
[ "function", "hostregexp", "(", "val", ")", "{", "var", "source", "=", "!", "isregexp", "(", "val", ")", "?", "String", "(", "val", ")", ".", "replace", "(", "ESCAPE_REGEXP", ",", "ESCAPE_REPLACE", ")", ".", "replace", "(", "ASTERISK_REGEXP", ",", "ASTERI...
Generate RegExp for given hostname value. @param (string|RegExp} val @private
[ "Generate", "RegExp", "for", "given", "hostname", "value", "." ]
1ba557c2e1772ba4b0afe2b7355ff0ec050eff80
https://github.com/expressjs/vhost/blob/1ba557c2e1772ba4b0afe2b7355ff0ec050eff80/index.js#L112-L128
train
expressjs/vhost
index.js
vhostof
function vhostof (req, regexp) { var host = req.headers.host var hostname = hostnameof(req) if (!hostname) { return } var match = regexp.exec(hostname) if (!match) { return } var obj = Object.create(null) obj.host = host obj.hostname = hostname obj.length = match.length - 1 for (va...
javascript
function vhostof (req, regexp) { var host = req.headers.host var hostname = hostnameof(req) if (!hostname) { return } var match = regexp.exec(hostname) if (!match) { return } var obj = Object.create(null) obj.host = host obj.hostname = hostname obj.length = match.length - 1 for (va...
[ "function", "vhostof", "(", "req", ",", "regexp", ")", "{", "var", "host", "=", "req", ".", "headers", ".", "host", "var", "hostname", "=", "hostnameof", "(", "req", ")", "if", "(", "!", "hostname", ")", "{", "return", "}", "var", "match", "=", "re...
Get the vhost data of the request for RegExp @param (object} req @param (RegExp} regexp @return {object} @private
[ "Get", "the", "vhost", "data", "of", "the", "request", "for", "RegExp" ]
1ba557c2e1772ba4b0afe2b7355ff0ec050eff80
https://github.com/expressjs/vhost/blob/1ba557c2e1772ba4b0afe2b7355ff0ec050eff80/index.js#L139-L164
train
sheerun/graphqlviz
index.js
analyzeField
function analyzeField (field) { var obj = {} var namedType = field.type obj.name = field.name obj.isDeprecated = field.isDeprecated obj.deprecationReason = field.deprecationReason obj.defaultValue = field.defaultValue if (namedType.kind === 'NON_NULL') { obj.isRequired = true namedType = namedType...
javascript
function analyzeField (field) { var obj = {} var namedType = field.type obj.name = field.name obj.isDeprecated = field.isDeprecated obj.deprecationReason = field.deprecationReason obj.defaultValue = field.defaultValue if (namedType.kind === 'NON_NULL') { obj.isRequired = true namedType = namedType...
[ "function", "analyzeField", "(", "field", ")", "{", "var", "obj", "=", "{", "}", "var", "namedType", "=", "field", ".", "type", "obj", ".", "name", "=", "field", ".", "name", "obj", ".", "isDeprecated", "=", "field", ".", "isDeprecated", "obj", ".", ...
analyzes a field and returns a simplified object
[ "analyzes", "a", "field", "and", "returns", "a", "simplified", "object" ]
976d12bc3965e487a91892f278194599e51974d8
https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L70-L102
train
sheerun/graphqlviz
index.js
processType
function processType (item, entities, types) { var type = _.find(types, { name: item }) var additionalTypes = [] // get the type names of the union or interface's possible types, given its type name var addPossibleTypes = typeName => { var union = _.find(types, { name: typeName }) var possibleTypes = _...
javascript
function processType (item, entities, types) { var type = _.find(types, { name: item }) var additionalTypes = [] // get the type names of the union or interface's possible types, given its type name var addPossibleTypes = typeName => { var union = _.find(types, { name: typeName }) var possibleTypes = _...
[ "function", "processType", "(", "item", ",", "entities", ",", "types", ")", "{", "var", "type", "=", "_", ".", "find", "(", "types", ",", "{", "name", ":", "item", "}", ")", "var", "additionalTypes", "=", "[", "]", "// get the type names of the union or in...
process a graphql type object returns simplified version of the type
[ "process", "a", "graphql", "type", "object", "returns", "simplified", "version", "of", "the", "type" ]
976d12bc3965e487a91892f278194599e51974d8
https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L106-L156
train
sheerun/graphqlviz
index.js
walkBFS
function walkBFS (obj, iter) { var q = _.map(_.keys(obj), k => { return { key: k, path: '["' + k + '"]' } }) var current var currentNode var retval var push = (v, k) => { q.push({ key: k, path: current.path + '["' + k + '"]' }) } while (q.length) { current = q.shift() currentNode = _.ge...
javascript
function walkBFS (obj, iter) { var q = _.map(_.keys(obj), k => { return { key: k, path: '["' + k + '"]' } }) var current var currentNode var retval var push = (v, k) => { q.push({ key: k, path: current.path + '["' + k + '"]' }) } while (q.length) { current = q.shift() currentNode = _.ge...
[ "function", "walkBFS", "(", "obj", ",", "iter", ")", "{", "var", "q", "=", "_", ".", "map", "(", "_", ".", "keys", "(", "obj", ")", ",", "k", "=>", "{", "return", "{", "key", ":", "k", ",", "path", ":", "'[\"'", "+", "k", "+", "'\"]'", "}",...
walks the object in level-order invokes iter at each node if iter returns truthy, breaks & returns the value assumes no cycles
[ "walks", "the", "object", "in", "level", "-", "order", "invokes", "iter", "at", "each", "node", "if", "iter", "returns", "truthy", "breaks", "&", "returns", "the", "value", "assumes", "no", "cycles" ]
976d12bc3965e487a91892f278194599e51974d8
https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L188-L211
train
sheerun/graphqlviz
index.js
isEnabled
function isEnabled (obj) { var enabled = false if (obj.isEnumType) { enabled = !this.theme.enums.hide } else if (obj.isInputType) { enabled = !this.theme.inputs.hide } else if (obj.isInterfaceType) { enabled = !this.theme.interfaces.hide } else if (obj.isUnionType) { enabled = !this.theme.unio...
javascript
function isEnabled (obj) { var enabled = false if (obj.isEnumType) { enabled = !this.theme.enums.hide } else if (obj.isInputType) { enabled = !this.theme.inputs.hide } else if (obj.isInterfaceType) { enabled = !this.theme.interfaces.hide } else if (obj.isUnionType) { enabled = !this.theme.unio...
[ "function", "isEnabled", "(", "obj", ")", "{", "var", "enabled", "=", "false", "if", "(", "obj", ".", "isEnumType", ")", "{", "enabled", "=", "!", "this", ".", "theme", ".", "enums", ".", "hide", "}", "else", "if", "(", "obj", ".", "isInputType", "...
get if the object type is enabled
[ "get", "if", "the", "object", "type", "is", "enabled" ]
976d12bc3965e487a91892f278194599e51974d8
https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L263-L277
train
sheerun/graphqlviz
index.js
getColor
function getColor (obj) { var color = this.theme.types.color if (obj.isEnumType && !this.theme.enums.hide) { color = this.theme.enums.color } else if (obj.isInputType && !this.theme.inputs.hide) { color = this.theme.inputs.color } else if (obj.isInterfaceType && !this.theme.interfaces.hide) { color ...
javascript
function getColor (obj) { var color = this.theme.types.color if (obj.isEnumType && !this.theme.enums.hide) { color = this.theme.enums.color } else if (obj.isInputType && !this.theme.inputs.hide) { color = this.theme.inputs.color } else if (obj.isInterfaceType && !this.theme.interfaces.hide) { color ...
[ "function", "getColor", "(", "obj", ")", "{", "var", "color", "=", "this", ".", "theme", ".", "types", ".", "color", "if", "(", "obj", ".", "isEnumType", "&&", "!", "this", ".", "theme", ".", "enums", ".", "hide", ")", "{", "color", "=", "this", ...
get the color for the given field
[ "get", "the", "color", "for", "the", "given", "field" ]
976d12bc3965e487a91892f278194599e51974d8
https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L280-L292
train
sheerun/graphqlviz
index.js
createTable
function createTable (context) { var result = '"' + context.typeName + '" ' result += '[label=<<TABLE COLOR="' + context.color + '" BORDER="0" CELLBORDER="1" CELLSPACING="0">' result += '<TR><TD PORT="__title"' + (this.theme.header.invert ? ' BGCOLOR="' + context.color + '"' : '') + '><FON...
javascript
function createTable (context) { var result = '"' + context.typeName + '" ' result += '[label=<<TABLE COLOR="' + context.color + '" BORDER="0" CELLBORDER="1" CELLSPACING="0">' result += '<TR><TD PORT="__title"' + (this.theme.header.invert ? ' BGCOLOR="' + context.color + '"' : '') + '><FON...
[ "function", "createTable", "(", "context", ")", "{", "var", "result", "=", "'\"'", "+", "context", ".", "typeName", "+", "'\" '", "result", "+=", "'[label=<<TABLE COLOR=\"'", "+", "context", ".", "color", "+", "'\" BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\">'", ...
For the given context, creates a table for the class with the typeName as the header, and rows as the fields
[ "For", "the", "given", "context", "creates", "a", "table", "for", "the", "class", "with", "the", "typeName", "as", "the", "header", "and", "rows", "as", "the", "fields" ]
976d12bc3965e487a91892f278194599e51974d8
https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L381-L425
train
sheerun/graphqlviz
index.js
graph
function graph (processedTypes, typeTheme) { var result = '' if (typeTheme.group) { result += 'subgraph cluster_' + groupId++ + ' {' if (typeTheme.color) { result += 'color=' + typeTheme.color + ';' } if (typeTheme.groupLabel) { result += 'label="' + typeTheme.groupLabel + '";' } ...
javascript
function graph (processedTypes, typeTheme) { var result = '' if (typeTheme.group) { result += 'subgraph cluster_' + groupId++ + ' {' if (typeTheme.color) { result += 'color=' + typeTheme.color + ';' } if (typeTheme.groupLabel) { result += 'label="' + typeTheme.groupLabel + '";' } ...
[ "function", "graph", "(", "processedTypes", ",", "typeTheme", ")", "{", "var", "result", "=", "''", "if", "(", "typeTheme", ".", "group", ")", "{", "result", "+=", "'subgraph cluster_'", "+", "groupId", "++", "+", "' {'", "if", "(", "typeTheme", ".", "co...
For the provided simplified types, creates all the tables to represent them. Optionally groups the supplied types in a subgraph.
[ "For", "the", "provided", "simplified", "types", "creates", "all", "the", "tables", "to", "represent", "them", ".", "Optionally", "groups", "the", "supplied", "types", "in", "a", "subgraph", "." ]
976d12bc3965e487a91892f278194599e51974d8
https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L431-L471
train
sheerun/graphqlviz
cli.js
fatal
function fatal (e, text) { console.error('ERROR processing input. Use --verbose flag to see output.') console.error(e.message) if (cli.flags.verbose) { console.error(text) } process.exit(1) }
javascript
function fatal (e, text) { console.error('ERROR processing input. Use --verbose flag to see output.') console.error(e.message) if (cli.flags.verbose) { console.error(text) } process.exit(1) }
[ "function", "fatal", "(", "e", ",", "text", ")", "{", "console", ".", "error", "(", "'ERROR processing input. Use --verbose flag to see output.'", ")", "console", ".", "error", "(", "e", ".", "message", ")", "if", "(", "cli", ".", "flags", ".", "verbose", ")...
logs the error and exits
[ "logs", "the", "error", "and", "exits" ]
976d12bc3965e487a91892f278194599e51974d8
https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/cli.js#L69-L78
train
sheerun/graphqlviz
cli.js
introspect
function introspect (text) { return new Promise(function (resolve, reject) { try { var astDocument = parse(text) var schema = buildASTSchema(astDocument) graphql(schema, graphqlviz.query) .then(function (data) { resolve(data) }) .catch(function (e) { r...
javascript
function introspect (text) { return new Promise(function (resolve, reject) { try { var astDocument = parse(text) var schema = buildASTSchema(astDocument) graphql(schema, graphqlviz.query) .then(function (data) { resolve(data) }) .catch(function (e) { r...
[ "function", "introspect", "(", "text", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "try", "{", "var", "astDocument", "=", "parse", "(", "text", ")", "var", "schema", "=", "buildASTSchema", "(", "astDocu...
given a "GraphQL schema language" text file, converts into introspection JSON
[ "given", "a", "GraphQL", "schema", "language", "text", "file", "converts", "into", "introspection", "JSON" ]
976d12bc3965e487a91892f278194599e51974d8
https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/cli.js#L81-L99
train
pillarjs/multiparty
index.js
function (done) { if (called) return; called = true; // wait for req events to fire process.nextTick(function() { if (waitend && req.readable) { // dump rest of request req.resume(); req.once('end', done); return; } done(); ...
javascript
function (done) { if (called) return; called = true; // wait for req events to fire process.nextTick(function() { if (waitend && req.readable) { // dump rest of request req.resume(); req.once('end', done); return; } done(); ...
[ "function", "(", "done", ")", "{", "if", "(", "called", ")", "return", ";", "called", "=", "true", ";", "// wait for req events to fire", "process", ".", "nextTick", "(", "function", "(", ")", "{", "if", "(", "waitend", "&&", "req", ".", "readable", ")",...
wait for request to end before calling cb
[ "wait", "for", "request", "to", "end", "before", "calling", "cb" ]
7034ca123d9db53827bc8c4a058d79db513d0d3d
https://github.com/pillarjs/multiparty/blob/7034ca123d9db53827bc8c4a058d79db513d0d3d/index.js#L101-L117
train
observing/thor
metrics.js
Metrics
function Metrics(requests) { this.requests = requests; // The total amount of requests send this.connections = 0; // Connections established this.disconnects = 0; // Closed connections this.failures = 0; // Connections that received an error thi...
javascript
function Metrics(requests) { this.requests = requests; // The total amount of requests send this.connections = 0; // Connections established this.disconnects = 0; // Closed connections this.failures = 0; // Connections that received an error thi...
[ "function", "Metrics", "(", "requests", ")", "{", "this", ".", "requests", "=", "requests", ";", "// The total amount of requests send", "this", ".", "connections", "=", "0", ";", "// Connections established", "this", ".", "disconnects", "=", "0", ";", "// Closed ...
Metrics collection and generation. @constructor @param {Number} requests The total amount of requests scheduled to be send
[ "Metrics", "collection", "and", "generation", "." ]
20c51d6c5dcc57a1927ae0c6e77f21836d71f9de
https://github.com/observing/thor/blob/20c51d6c5dcc57a1927ae0c6e77f21836d71f9de/metrics.js#L14-L32
train
observing/thor
mjolnir.js
write
function write(socket, task, id, fn) { session[binary ? 'binary' : 'utf8'](task.size, function message(err, data) { var start = socket.last = Date.now(); socket.send(data, { binary: binary, mask: masked }, function sending(err) { if (err) { process.send({ type: 'error', message:...
javascript
function write(socket, task, id, fn) { session[binary ? 'binary' : 'utf8'](task.size, function message(err, data) { var start = socket.last = Date.now(); socket.send(data, { binary: binary, mask: masked }, function sending(err) { if (err) { process.send({ type: 'error', message:...
[ "function", "write", "(", "socket", ",", "task", ",", "id", ",", "fn", ")", "{", "session", "[", "binary", "?", "'binary'", ":", "'utf8'", "]", "(", "task", ".", "size", ",", "function", "message", "(", "err", ",", "data", ")", "{", "var", "start",...
Helper function from writing messages to the socket. @param {WebSocket} socket WebSocket connection we should write to @param {Object} task The given task @param {String} id @param {Function} fn The callback @api private
[ "Helper", "function", "from", "writing", "messages", "to", "the", "socket", "." ]
20c51d6c5dcc57a1927ae0c6e77f21836d71f9de
https://github.com/observing/thor/blob/20c51d6c5dcc57a1927ae0c6e77f21836d71f9de/mjolnir.js#L102-L120
train
takuyaa/kuromoji.js
gulpfile.js
toBuffer
function toBuffer (typed) { var ab = typed.buffer; var buffer = new Buffer(ab.byteLength); var view = new Uint8Array(ab); for (var i = 0; i < buffer.length; ++i) { buffer[i] = view[i]; } return buffer; }
javascript
function toBuffer (typed) { var ab = typed.buffer; var buffer = new Buffer(ab.byteLength); var view = new Uint8Array(ab); for (var i = 0; i < buffer.length; ++i) { buffer[i] = view[i]; } return buffer; }
[ "function", "toBuffer", "(", "typed", ")", "{", "var", "ab", "=", "typed", ".", "buffer", ";", "var", "buffer", "=", "new", "Buffer", "(", "ab", ".", "byteLength", ")", ";", "var", "view", "=", "new", "Uint8Array", "(", "ab", ")", ";", "for", "(", ...
To node.js Buffer
[ "To", "node", ".", "js", "Buffer" ]
71ea8473bd119546977f22c61e4d52da28ac30a6
https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/gulpfile.js#L58-L66
train
takuyaa/kuromoji.js
src/util/ByteBuffer.js
ByteBuffer
function ByteBuffer(arg) { var initial_size; if (arg == null) { initial_size = 1024 * 1024; } else if (typeof arg === "number") { initial_size = arg; } else if (arg instanceof Uint8Array) { this.buffer = arg; this.position = 0; // Overwrite return; } else { ...
javascript
function ByteBuffer(arg) { var initial_size; if (arg == null) { initial_size = 1024 * 1024; } else if (typeof arg === "number") { initial_size = arg; } else if (arg instanceof Uint8Array) { this.buffer = arg; this.position = 0; // Overwrite return; } else { ...
[ "function", "ByteBuffer", "(", "arg", ")", "{", "var", "initial_size", ";", "if", "(", "arg", "==", "null", ")", "{", "initial_size", "=", "1024", "*", "1024", ";", "}", "else", "if", "(", "typeof", "arg", "===", "\"number\"", ")", "{", "initial_size",...
Utilities to manipulate byte sequence @param {(number|Uint8Array)} arg Initial size of this buffer (number), or buffer to set (Uint8Array) @constructor
[ "Utilities", "to", "manipulate", "byte", "sequence" ]
71ea8473bd119546977f22c61e4d52da28ac30a6
https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/util/ByteBuffer.js#L140-L157
train
takuyaa/kuromoji.js
src/loader/DictionaryLoader.js
function (callback) { async.map([ "tid.dat.gz", "tid_pos.dat.gz", "tid_map.dat.gz" ], function (filename, _callback) { loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) { if(err) { return _callback(err); } ...
javascript
function (callback) { async.map([ "tid.dat.gz", "tid_pos.dat.gz", "tid_map.dat.gz" ], function (filename, _callback) { loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) { if(err) { return _callback(err); } ...
[ "function", "(", "callback", ")", "{", "async", ".", "map", "(", "[", "\"tid.dat.gz\"", ",", "\"tid_pos.dat.gz\"", ",", "\"tid_map.dat.gz\"", "]", ",", "function", "(", "filename", ",", "_callback", ")", "{", "loadArrayBuffer", "(", "path", ".", "join", "(",...
Token info dictionaries
[ "Token", "info", "dictionaries" ]
71ea8473bd119546977f22c61e4d52da28ac30a6
https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/loader/DictionaryLoader.js#L69-L88
train
takuyaa/kuromoji.js
src/loader/DictionaryLoader.js
function (callback) { loadArrayBuffer(path.join(dic_path, "cc.dat.gz"), function (err, buffer) { if(err) { return callback(err); } var cc_buffer = new Int16Array(buffer); dic.loadConnectionCosts(cc_buffer); c...
javascript
function (callback) { loadArrayBuffer(path.join(dic_path, "cc.dat.gz"), function (err, buffer) { if(err) { return callback(err); } var cc_buffer = new Int16Array(buffer); dic.loadConnectionCosts(cc_buffer); c...
[ "function", "(", "callback", ")", "{", "loadArrayBuffer", "(", "path", ".", "join", "(", "dic_path", ",", "\"cc.dat.gz\"", ")", ",", "function", "(", "err", ",", "buffer", ")", "{", "if", "(", "err", ")", "{", "return", "callback", "(", "err", ")", "...
Connection cost matrix
[ "Connection", "cost", "matrix" ]
71ea8473bd119546977f22c61e4d52da28ac30a6
https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/loader/DictionaryLoader.js#L90-L99
train
takuyaa/kuromoji.js
src/dict/DynamicDictionaries.js
DynamicDictionaries
function DynamicDictionaries(trie, token_info_dictionary, connection_costs, unknown_dictionary) { if (trie != null) { this.trie = trie; } else { this.trie = doublearray.builder(0).build([ {k: "", v: 1} ]); } if (token_info_dictionary != null) { this.token_info...
javascript
function DynamicDictionaries(trie, token_info_dictionary, connection_costs, unknown_dictionary) { if (trie != null) { this.trie = trie; } else { this.trie = doublearray.builder(0).build([ {k: "", v: 1} ]); } if (token_info_dictionary != null) { this.token_info...
[ "function", "DynamicDictionaries", "(", "trie", ",", "token_info_dictionary", ",", "connection_costs", ",", "unknown_dictionary", ")", "{", "if", "(", "trie", "!=", "null", ")", "{", "this", ".", "trie", "=", "trie", ";", "}", "else", "{", "this", ".", "tr...
Dictionaries container for Tokenizer @param {DoubleArray} trie @param {TokenInfoDictionary} token_info_dictionary @param {ConnectionCosts} connection_costs @param {UnknownDictionary} unknown_dictionary @constructor
[ "Dictionaries", "container", "for", "Tokenizer" ]
71ea8473bd119546977f22c61e4d52da28ac30a6
https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/dict/DynamicDictionaries.js#L33-L57
train
takuyaa/kuromoji.js
src/viterbi/ViterbiNode.js
ViterbiNode
function ViterbiNode(node_name, node_cost, start_pos, length, type, left_id, right_id, surface_form) { this.name = node_name; this.cost = node_cost; this.start_pos = start_pos; this.length = length; this.left_id = left_id; this.right_id = right_id; this.prev = null; this.surface_form = s...
javascript
function ViterbiNode(node_name, node_cost, start_pos, length, type, left_id, right_id, surface_form) { this.name = node_name; this.cost = node_cost; this.start_pos = start_pos; this.length = length; this.left_id = left_id; this.right_id = right_id; this.prev = null; this.surface_form = s...
[ "function", "ViterbiNode", "(", "node_name", ",", "node_cost", ",", "start_pos", ",", "length", ",", "type", ",", "left_id", ",", "right_id", ",", "surface_form", ")", "{", "this", ".", "name", "=", "node_name", ";", "this", ".", "cost", "=", "node_cost", ...
ViterbiNode is a node of ViterbiLattice @param {number} node_name Word ID @param {number} node_cost Word cost to generate @param {number} start_pos Start position from 1 @param {number} length Word length @param {string} type Node type (KNOWN, UNKNOWN, BOS, EOS, ...) @param {number} left_id Left context ID @param {numb...
[ "ViterbiNode", "is", "a", "node", "of", "ViterbiLattice" ]
71ea8473bd119546977f22c61e4d52da28ac30a6
https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/viterbi/ViterbiNode.js#L32-L47
train
fgnass/domino
lib/Document.js
MultiId
function MultiId(node) { this.nodes = Object.create(null); this.nodes[node._nid] = node; this.length = 1; this.firstNode = undefined; }
javascript
function MultiId(node) { this.nodes = Object.create(null); this.nodes[node._nid] = node; this.length = 1; this.firstNode = undefined; }
[ "function", "MultiId", "(", "node", ")", "{", "this", ".", "nodes", "=", "Object", ".", "create", "(", "null", ")", ";", "this", ".", "nodes", "[", "node", ".", "_nid", "]", "=", "node", ";", "this", ".", "length", "=", "1", ";", "this", ".", "...
A class for storing multiple nodes with the same ID
[ "A", "class", "for", "storing", "multiple", "nodes", "with", "the", "same", "ID" ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/Document.js#L833-L838
train
fgnass/domino
lib/HTMLParser.js
isA
function isA(elt, set) { if (typeof set === 'string') { // convenience case for testing a particular HTML element return elt.namespaceURI === NAMESPACE.HTML && elt.localName === set; } var tagnames = set[elt.namespaceURI]; return tagnames && tagnames[elt.localName]; }
javascript
function isA(elt, set) { if (typeof set === 'string') { // convenience case for testing a particular HTML element return elt.namespaceURI === NAMESPACE.HTML && elt.localName === set; } var tagnames = set[elt.namespaceURI]; return tagnames && tagnames[elt.localName]; }
[ "function", "isA", "(", "elt", ",", "set", ")", "{", "if", "(", "typeof", "set", "===", "'string'", ")", "{", "// convenience case for testing a particular HTML element", "return", "elt", ".", "namespaceURI", "===", "NAMESPACE", ".", "HTML", "&&", "elt", ".", ...
Determine whether the element is a member of the set. The set is an object that maps namespaces to objects. The objects then map local tagnames to the value true if that tag is part of the set
[ "Determine", "whether", "the", "element", "is", "a", "member", "of", "the", "set", ".", "The", "set", "is", "an", "object", "that", "maps", "namespaces", "to", "objects", ".", "The", "objects", "then", "map", "local", "tagnames", "to", "the", "value", "t...
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L1568-L1576
train
fgnass/domino
lib/HTMLParser.js
equal
function equal(newelt, oldelt, oldattrs) { if (newelt.localName !== oldelt.localName) return false; if (newelt._numattrs !== oldattrs.length) return false; for(var i = 0, n = oldattrs.length; i < n; i++) { var oldname = oldattrs[i][0]; var oldval = oldattrs[i][1]; if (!newelt.hasAttribute(...
javascript
function equal(newelt, oldelt, oldattrs) { if (newelt.localName !== oldelt.localName) return false; if (newelt._numattrs !== oldattrs.length) return false; for(var i = 0, n = oldattrs.length; i < n; i++) { var oldname = oldattrs[i][0]; var oldval = oldattrs[i][1]; if (!newelt.hasAttribute(...
[ "function", "equal", "(", "newelt", ",", "oldelt", ",", "oldattrs", ")", "{", "if", "(", "newelt", ".", "localName", "!==", "oldelt", ".", "localName", ")", "return", "false", ";", "if", "(", "newelt", ".", "_numattrs", "!==", "oldattrs", ".", "length", ...
This function defines equality of two elements for the purposes of the AFE list. Note that it compares the new elements attributes to the saved array of attributes associated with the old element because a script could have changed the old element's set of attributes
[ "This", "function", "defines", "equality", "of", "two", "elements", "for", "the", "purposes", "of", "the", "AFE", "list", ".", "Note", "that", "it", "compares", "the", "new", "elements", "attributes", "to", "the", "saved", "array", "of", "attributes", "assoc...
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L1858-L1868
train
fgnass/domino
lib/HTMLParser.js
function() { var frag = doc.createDocumentFragment(); var root = doc.firstChild; while(root.hasChildNodes()) { frag.appendChild(root.firstChild); } return frag; }
javascript
function() { var frag = doc.createDocumentFragment(); var root = doc.firstChild; while(root.hasChildNodes()) { frag.appendChild(root.firstChild); } return frag; }
[ "function", "(", ")", "{", "var", "frag", "=", "doc", ".", "createDocumentFragment", "(", ")", ";", "var", "root", "=", "doc", ".", "firstChild", ";", "while", "(", "root", ".", "hasChildNodes", "(", ")", ")", "{", "frag", ".", "appendChild", "(", "r...
Convenience function for internal use. Can only be called once, as it removes the nodes from `doc` to add them to fragment.
[ "Convenience", "function", "for", "internal", "use", ".", "Can", "only", "be", "called", "once", "as", "it", "removes", "the", "nodes", "from", "doc", "to", "add", "them", "to", "fragment", "." ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2008-L2015
train
fgnass/domino
lib/HTMLParser.js
handleSimpleAttribute
function handleSimpleAttribute() { SIMPLEATTR.lastIndex = nextchar-1; var matched = SIMPLEATTR.exec(chars); if (!matched) throw new Error("should never happen"); var name = matched[1]; if (!name) return false; var value = matched[2]; var len = value.length; switch(value[0]) { case '"...
javascript
function handleSimpleAttribute() { SIMPLEATTR.lastIndex = nextchar-1; var matched = SIMPLEATTR.exec(chars); if (!matched) throw new Error("should never happen"); var name = matched[1]; if (!name) return false; var value = matched[2]; var len = value.length; switch(value[0]) { case '"...
[ "function", "handleSimpleAttribute", "(", ")", "{", "SIMPLEATTR", ".", "lastIndex", "=", "nextchar", "-", "1", ";", "var", "matched", "=", "SIMPLEATTR", ".", "exec", "(", "chars", ")", ";", "if", "(", "!", "matched", ")", "throw", "new", "Error", "(", ...
Shortcut for simple attributes
[ "Shortcut", "for", "simple", "attributes" ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2337-L2367
train
fgnass/domino
lib/HTMLParser.js
getMatchingChars
function getMatchingChars(pattern) { pattern.lastIndex = nextchar - 1; var match = pattern.exec(chars); if (match && match.index === nextchar - 1) { match = match[0]; nextchar += match.length - 1; /* Careful! Make sure we haven't matched the EOF character! */ if (input_complete && n...
javascript
function getMatchingChars(pattern) { pattern.lastIndex = nextchar - 1; var match = pattern.exec(chars); if (match && match.index === nextchar - 1) { match = match[0]; nextchar += match.length - 1; /* Careful! Make sure we haven't matched the EOF character! */ if (input_complete && n...
[ "function", "getMatchingChars", "(", "pattern", ")", "{", "pattern", ".", "lastIndex", "=", "nextchar", "-", "1", ";", "var", "match", "=", "pattern", ".", "exec", "(", "chars", ")", ";", "if", "(", "match", "&&", "match", ".", "index", "===", "nextcha...
Consume chars matched by the pattern and return them as a string. Starts matching at the current position, so users should drop the current char otherwise.
[ "Consume", "chars", "matched", "by", "the", "pattern", "and", "return", "them", "as", "a", "string", ".", "Starts", "matching", "at", "the", "current", "position", "so", "users", "should", "drop", "the", "current", "char", "otherwise", "." ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2423-L2439
train
fgnass/domino
lib/HTMLParser.js
emitCharsWhile
function emitCharsWhile(pattern) { pattern.lastIndex = nextchar-1; var match = pattern.exec(chars)[0]; if (!match) return false; emitCharString(match); nextchar += match.length - 1; return true; }
javascript
function emitCharsWhile(pattern) { pattern.lastIndex = nextchar-1; var match = pattern.exec(chars)[0]; if (!match) return false; emitCharString(match); nextchar += match.length - 1; return true; }
[ "function", "emitCharsWhile", "(", "pattern", ")", "{", "pattern", ".", "lastIndex", "=", "nextchar", "-", "1", ";", "var", "match", "=", "pattern", ".", "exec", "(", "chars", ")", "[", "0", "]", ";", "if", "(", "!", "match", ")", "return", "false", ...
emit a string of chars that match a regexp Returns false if no chars matched.
[ "emit", "a", "string", "of", "chars", "that", "match", "a", "regexp", "Returns", "false", "if", "no", "chars", "matched", "." ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2443-L2450
train
fgnass/domino
lib/HTMLParser.js
emitCharString
function emitCharString(s) { if (textrun.length > 0) flushText(); if (ignore_linefeed) { ignore_linefeed = false; if (s[0] === "\n") s = s.substring(1); if (s.length === 0) return; } insertToken(TEXT, s); }
javascript
function emitCharString(s) { if (textrun.length > 0) flushText(); if (ignore_linefeed) { ignore_linefeed = false; if (s[0] === "\n") s = s.substring(1); if (s.length === 0) return; } insertToken(TEXT, s); }
[ "function", "emitCharString", "(", "s", ")", "{", "if", "(", "textrun", ".", "length", ">", "0", ")", "flushText", "(", ")", ";", "if", "(", "ignore_linefeed", ")", "{", "ignore_linefeed", "=", "false", ";", "if", "(", "s", "[", "0", "]", "===", "\...
This is used by CDATA sections
[ "This", "is", "used", "by", "CDATA", "sections" ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2453-L2463
train
fgnass/domino
lib/HTMLParser.js
insertElement
function insertElement(eltFunc) { var elt; if (foster_parent_mode && isA(stack.top, tablesectionrowSet)) { elt = fosterParent(eltFunc); } else if (stack.top instanceof impl.HTMLTemplateElement) { // "If the adjusted insertion location is inside a template element, // let it instead be ...
javascript
function insertElement(eltFunc) { var elt; if (foster_parent_mode && isA(stack.top, tablesectionrowSet)) { elt = fosterParent(eltFunc); } else if (stack.top instanceof impl.HTMLTemplateElement) { // "If the adjusted insertion location is inside a template element, // let it instead be ...
[ "function", "insertElement", "(", "eltFunc", ")", "{", "var", "elt", ";", "if", "(", "foster_parent_mode", "&&", "isA", "(", "stack", ".", "top", ",", "tablesectionrowSet", ")", ")", "{", "elt", "=", "fosterParent", "(", "eltFunc", ")", ";", "}", "else",...
Insert the element into the open element or foster parent it
[ "Insert", "the", "element", "into", "the", "open", "element", "or", "foster", "parent", "it" ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2640-L2657
train
fgnass/domino
lib/HTMLParser.js
after_attribute_name_state
function after_attribute_name_state(c) { switch(c) { case 0x0009: // CHARACTER TABULATION (tab) case 0x000A: // LINE FEED (LF) case 0x000C: // FORM FEED (FF) case 0x0020: // SPACE /* Ignore the character. */ break; case 0x002F: // SOLIDUS // Keep in sync with before_attribute_n...
javascript
function after_attribute_name_state(c) { switch(c) { case 0x0009: // CHARACTER TABULATION (tab) case 0x000A: // LINE FEED (LF) case 0x000C: // FORM FEED (FF) case 0x0020: // SPACE /* Ignore the character. */ break; case 0x002F: // SOLIDUS // Keep in sync with before_attribute_n...
[ "function", "after_attribute_name_state", "(", "c", ")", "{", "switch", "(", "c", ")", "{", "case", "0x0009", ":", "// CHARACTER TABULATION (tab)", "case", "0x000A", ":", "// LINE FEED (LF)", "case", "0x000C", ":", "// FORM FEED (FF)", "case", "0x0020", ":", "// S...
There is an active attribute in attrnamebuf, but not yet in attrvaluebuf.
[ "There", "is", "an", "active", "attribute", "in", "attrnamebuf", "but", "not", "yet", "in", "attrvaluebuf", "." ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L4179-L4212
train
fgnass/domino
lib/HTMLParser.js
before_html_mode
function before_html_mode(t,value,arg3,arg4) { var elt; switch(t) { case 1: // TEXT value = value.replace(LEADINGWS, ""); // Ignore spaces if (value.length === 0) return; // Are we done? break; // Handle anything non-space text below case 5: // DOCTYPE /* ignore the token */ ...
javascript
function before_html_mode(t,value,arg3,arg4) { var elt; switch(t) { case 1: // TEXT value = value.replace(LEADINGWS, ""); // Ignore spaces if (value.length === 0) return; // Are we done? break; // Handle anything non-space text below case 5: // DOCTYPE /* ignore the token */ ...
[ "function", "before_html_mode", "(", "t", ",", "value", ",", "arg3", ",", "arg4", ")", "{", "var", "elt", ";", "switch", "(", "t", ")", "{", "case", "1", ":", "// TEXT", "value", "=", "value", ".", "replace", "(", "LEADINGWS", ",", "\"\"", ")", ";"...
11.2.5.4.2 The "before html" insertion mode
[ "11", ".", "2", ".", "5", ".", "4", ".", "2", "The", "before", "html", "insertion", "mode" ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L5332-L5374
train
fgnass/domino
lib/HTMLParser.js
before_head_mode
function before_head_mode(t,value,arg3,arg4) { switch(t) { case 1: // TEXT value = value.replace(LEADINGWS, ""); // Ignore spaces if (value.length === 0) return; // Are we done? break; // Handle anything non-space text below case 5: // DOCTYPE /* ignore the token */ return; ...
javascript
function before_head_mode(t,value,arg3,arg4) { switch(t) { case 1: // TEXT value = value.replace(LEADINGWS, ""); // Ignore spaces if (value.length === 0) return; // Are we done? break; // Handle anything non-space text below case 5: // DOCTYPE /* ignore the token */ return; ...
[ "function", "before_head_mode", "(", "t", ",", "value", ",", "arg3", ",", "arg4", ")", "{", "switch", "(", "t", ")", "{", "case", "1", ":", "// TEXT", "value", "=", "value", ".", "replace", "(", "LEADINGWS", ",", "\"\"", ")", ";", "// Ignore spaces", ...
11.2.5.4.3 The "before head" insertion mode
[ "11", ".", "2", ".", "5", ".", "4", ".", "3", "The", "before", "head", "insertion", "mode" ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L5377-L5416
train
fgnass/domino
lib/HTMLParser.js
in_head_noscript_mode
function in_head_noscript_mode(t, value, arg3, arg4) { switch(t) { case 5: // DOCTYPE return; case 4: // COMMENT in_head_mode(t, value); return; case 1: // TEXT var ws = value.match(LEADINGWS); if (ws) { in_head_mode(t, ws[0]); value = value.substring(ws[0]....
javascript
function in_head_noscript_mode(t, value, arg3, arg4) { switch(t) { case 5: // DOCTYPE return; case 4: // COMMENT in_head_mode(t, value); return; case 1: // TEXT var ws = value.match(LEADINGWS); if (ws) { in_head_mode(t, ws[0]); value = value.substring(ws[0]....
[ "function", "in_head_noscript_mode", "(", "t", ",", "value", ",", "arg3", ",", "arg4", ")", "{", "switch", "(", "t", ")", "{", "case", "5", ":", "// DOCTYPE", "return", ";", "case", "4", ":", "// COMMENT", "in_head_mode", "(", "t", ",", "value", ")", ...
13.2.5.4.5 The "in head noscript" insertion mode
[ "13", ".", "2", ".", "5", ".", "4", ".", "5", "The", "in", "head", "noscript", "insertion", "mode" ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L5521-L5571
train
fgnass/domino
lib/EventTarget.js
function(event) { return (this._armed !== null && event.type === 'mouseup' && event.isTrusted && event.button === 0 && event.timeStamp - this._armed.t < 1000 && Math.abs(event.clientX - this._armed.x) < 10 && Math.abs(event.clientY - this._armed.Y) < 10); }
javascript
function(event) { return (this._armed !== null && event.type === 'mouseup' && event.isTrusted && event.button === 0 && event.timeStamp - this._armed.t < 1000 && Math.abs(event.clientX - this._armed.x) < 10 && Math.abs(event.clientY - this._armed.Y) < 10); }
[ "function", "(", "event", ")", "{", "return", "(", "this", ".", "_armed", "!==", "null", "&&", "event", ".", "type", "===", "'mouseup'", "&&", "event", ".", "isTrusted", "&&", "event", ".", "button", "===", "0", "&&", "event", ".", "timeStamp", "-", ...
Determine whether a click occurred XXX We don't support double clicks for now
[ "Determine", "whether", "a", "click", "occurred", "XXX", "We", "don", "t", "support", "double", "clicks", "for", "now" ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/EventTarget.js#L222-L230
train
fgnass/domino
lib/cssparser.js
function(filter){ var buffer = "", c = this.read(); while(c !== null && filter(c)){ buffer += c; c = this.read(); } return buffer; }
javascript
function(filter){ var buffer = "", c = this.read(); while(c !== null && filter(c)){ buffer += c; c = this.read(); } return buffer; }
[ "function", "(", "filter", ")", "{", "var", "buffer", "=", "\"\"", ",", "c", "=", "this", ".", "read", "(", ")", ";", "while", "(", "c", "!==", "null", "&&", "filter", "(", "c", ")", ")", "{", "buffer", "+=", "c", ";", "c", "=", "this", ".", ...
Reads characters while each character causes the given filter function to return true. The function is passed in each character and either returns true to continue reading or false to stop. @param {Function} filter The function to read on each character. @return {String} The string made up of all characters that passed...
[ "Reads", "characters", "while", "each", "character", "causes", "the", "given", "filter", "function", "to", "return", "true", ".", "The", "function", "is", "passed", "in", "each", "character", "and", "either", "returns", "true", "to", "continue", "reading", "or...
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/cssparser.js#L320-L332
train
fgnass/domino
lib/cssparser.js
function(matcher){ var source = this._input.substring(this._cursor), value = null; //if it's a string, just do a straight match if (typeof matcher === "string"){ if (source.indexOf(matcher) === 0){ value = this.readCount(matcher.length); } ...
javascript
function(matcher){ var source = this._input.substring(this._cursor), value = null; //if it's a string, just do a straight match if (typeof matcher === "string"){ if (source.indexOf(matcher) === 0){ value = this.readCount(matcher.length); } ...
[ "function", "(", "matcher", ")", "{", "var", "source", "=", "this", ".", "_input", ".", "substring", "(", "this", ".", "_cursor", ")", ",", "value", "=", "null", ";", "//if it's a string, just do a straight match", "if", "(", "typeof", "matcher", "===", "\"s...
Reads characters that match either text or a regular expression and returns those characters. If a match is found, the row and column are adjusted; if no match is found, the reader's state is unchanged. reading or false to stop. @param {String|RegExp} matchter If a string, then the literal string value is searched for....
[ "Reads", "characters", "that", "match", "either", "text", "or", "a", "regular", "expression", "and", "returns", "those", "characters", ".", "If", "a", "match", "is", "found", "the", "row", "and", "column", "are", "adjusted", ";", "if", "no", "match", "is",...
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/cssparser.js#L346-L363
train
fgnass/domino
lib/cssparser.js
TokenStreamBase
function TokenStreamBase(input, tokenData){ /** * The string reader for easy access to the text. * @type StringReader * @property _reader * @private */ this._reader = input ? new StringReader(input.toString()) : null; /** * Token object for the last consumed token. * @ty...
javascript
function TokenStreamBase(input, tokenData){ /** * The string reader for easy access to the text. * @type StringReader * @property _reader * @private */ this._reader = input ? new StringReader(input.toString()) : null; /** * Token object for the last consumed token. * @ty...
[ "function", "TokenStreamBase", "(", "input", ",", "tokenData", ")", "{", "/**\n * The string reader for easy access to the text.\n * @type StringReader\n * @property _reader\n * @private\n */", "this", ".", "_reader", "=", "input", "?", "new", "StringReader", "(...
Generic TokenStream providing base functionality. @class TokenStreamBase @namespace parserlib.util @constructor @param {String|StringReader} input The text to tokenize or a reader from which to read the input.
[ "Generic", "TokenStream", "providing", "base", "functionality", "." ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/cssparser.js#L510-L553
train
fgnass/domino
lib/Element.js
Attr
function Attr(elt, lname, prefix, namespace, value) { // localName and namespace are constant for any attr object. // But value may change. And so can prefix, and so, therefore can name. this.localName = lname; this.prefix = (prefix===null || prefix==='') ? null : ('' + prefix); this.namespaceURI = (namespac...
javascript
function Attr(elt, lname, prefix, namespace, value) { // localName and namespace are constant for any attr object. // But value may change. And so can prefix, and so, therefore can name. this.localName = lname; this.prefix = (prefix===null || prefix==='') ? null : ('' + prefix); this.namespaceURI = (namespac...
[ "function", "Attr", "(", "elt", ",", "lname", ",", "prefix", ",", "namespace", ",", "value", ")", "{", "// localName and namespace are constant for any attr object.", "// But value may change. And so can prefix, and so, therefore can name.", "this", ".", "localName", "=", "l...
The Attr class represents a single attribute. The values in _attrsByQName and _attrsByLName are instances of this class.
[ "The", "Attr", "class", "represents", "a", "single", "attribute", ".", "The", "values", "in", "_attrsByQName", "and", "_attrsByLName", "are", "instances", "of", "this", "class", "." ]
2fc67e349e5a9ff978330d2247a546682e04753d
https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/Element.js#L964-L973
train
wbyoung/avn
lib/hooks.js
function(version) { var result; /** local */ var ensure = function(key) { return function(r) { if (r && !r[key]) { throw new Error('result missing ' + key); } return r; }; }; return plugins.first(function(plugin) { return Promise.resolve() .then(function() { return plugin.match(ver...
javascript
function(version) { var result; /** local */ var ensure = function(key) { return function(r) { if (r && !r[key]) { throw new Error('result missing ' + key); } return r; }; }; return plugins.first(function(plugin) { return Promise.resolve() .then(function() { return plugin.match(ver...
[ "function", "(", "version", ")", "{", "var", "result", ";", "/** local */", "var", "ensure", "=", "function", "(", "key", ")", "{", "return", "function", "(", "r", ")", "{", "if", "(", "r", "&&", "!", "r", "[", "key", "]", ")", "{", "throw", "new...
Find the first plugin that can activate the requested version. @private @function hooks.~match @param {String} version The semver version to activate. @return {Promise} A promise that resolves with both `version` and `command` properties.
[ "Find", "the", "first", "plugin", "that", "can", "activate", "the", "requested", "version", "." ]
30884a077977181a5851025c9a309e196943b591
https://github.com/wbyoung/avn/blob/30884a077977181a5851025c9a309e196943b591/lib/hooks.js#L20-L39
train
wbyoung/avn
lib/fmt.js
function(error) { return util.format(' %s: %s', chalk.magenta(error.plugin.name), error.message); }
javascript
function(error) { return util.format(' %s: %s', chalk.magenta(error.plugin.name), error.message); }
[ "function", "(", "error", ")", "{", "return", "util", ".", "format", "(", "' %s: %s'", ",", "chalk", ".", "magenta", "(", "error", ".", "plugin", ".", "name", ")", ",", "error", ".", "message", ")", ";", "}" ]
Build a detailed error string for displaying to the user. @private @function fmt.~errorDetail @param {Error} error The error for which to build a string. @return {String}
[ "Build", "a", "detailed", "error", "string", "for", "displaying", "to", "the", "user", "." ]
30884a077977181a5851025c9a309e196943b591
https://github.com/wbyoung/avn/blob/30884a077977181a5851025c9a309e196943b591/lib/fmt.js#L34-L38
train
wbyoung/avn
lib/setup/plugins.js
function() { return Promise.resolve() .then(function() { return npm.loadAsync(); }) .then(function(npm) { npm.config.set('spin', false); npm.config.set('global', true); npm.config.set('depth', 0); return Promise.promisify(npm.commands.list)([], true); }) .then(function(data) { return data; });...
javascript
function() { return Promise.resolve() .then(function() { return npm.loadAsync(); }) .then(function(npm) { npm.config.set('spin', false); npm.config.set('global', true); npm.config.set('depth', 0); return Promise.promisify(npm.commands.list)([], true); }) .then(function(data) { return data; });...
[ "function", "(", ")", "{", "return", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "function", "(", ")", "{", "return", "npm", ".", "loadAsync", "(", ")", ";", "}", ")", ".", "then", "(", "function", "(", "npm", ")", "{", "npm", ".", "...
Get a list of all global npm modules. @private @function setup.plugins.~modules @return {Promise}
[ "Get", "a", "list", "of", "all", "global", "npm", "modules", "." ]
30884a077977181a5851025c9a309e196943b591
https://github.com/wbyoung/avn/blob/30884a077977181a5851025c9a309e196943b591/lib/setup/plugins.js#L15-L25
train
pouchdb/pouchdb-server
examples/todos/public/scripts/app.js
addTodo
function addTodo(text) { var todo = { _id: new Date().toISOString(), title: text, completed: false }; db.put(todo, function callback (err, result) { if (!err) { console.log('Successfully posted a todo!'); } }); }
javascript
function addTodo(text) { var todo = { _id: new Date().toISOString(), title: text, completed: false }; db.put(todo, function callback (err, result) { if (!err) { console.log('Successfully posted a todo!'); } }); }
[ "function", "addTodo", "(", "text", ")", "{", "var", "todo", "=", "{", "_id", ":", "new", "Date", "(", ")", ".", "toISOString", "(", ")", ",", "title", ":", "text", ",", "completed", ":", "false", "}", ";", "db", ".", "put", "(", "todo", ",", "...
We have to create a new todo document and enter it in the database
[ "We", "have", "to", "create", "a", "new", "todo", "document", "and", "enter", "it", "in", "the", "database" ]
89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5
https://github.com/pouchdb/pouchdb-server/blob/89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5/examples/todos/public/scripts/app.js#L23-L34
train
pouchdb/pouchdb-server
examples/todos/public/scripts/app.js
showTodos
function showTodos() { db.allDocs({ include_docs: true, descending: true }, function(err, doc) { redrawTodosUI(doc.rows); }); }
javascript
function showTodos() { db.allDocs({ include_docs: true, descending: true }, function(err, doc) { redrawTodosUI(doc.rows); }); }
[ "function", "showTodos", "(", ")", "{", "db", ".", "allDocs", "(", "{", "include_docs", ":", "true", ",", "descending", ":", "true", "}", ",", "function", "(", "err", ",", "doc", ")", "{", "redrawTodosUI", "(", "doc", ".", "rows", ")", ";", "}", ")...
Show the current list of todos by reading them from the database
[ "Show", "the", "current", "list", "of", "todos", "by", "reading", "them", "from", "the", "database" ]
89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5
https://github.com/pouchdb/pouchdb-server/blob/89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5/examples/todos/public/scripts/app.js#L37-L44
train