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
graphql/graphiql
src/utility/fillLeafs.js
getIndentation
function getIndentation(str, index) { let indentStart = index; let indentEnd = index; while (indentStart) { const c = str.charCodeAt(indentStart - 1); // line break if (c === 10 || c === 13 || c === 0x2028 || c === 0x2029) { break; } indentStart--; // not white space if (c !== 9 ...
javascript
function getIndentation(str, index) { let indentStart = index; let indentEnd = index; while (indentStart) { const c = str.charCodeAt(indentStart - 1); // line break if (c === 10 || c === 13 || c === 0x2028 || c === 0x2029) { break; } indentStart--; // not white space if (c !== 9 ...
[ "function", "getIndentation", "(", "str", ",", "index", ")", "{", "let", "indentStart", "=", "index", ";", "let", "indentEnd", "=", "index", ";", "while", "(", "indentStart", ")", "{", "const", "c", "=", "str", ".", "charCodeAt", "(", "indentStart", "-",...
Given a string and an index, look backwards to find the string of whitespace following the next previous line break.
[ "Given", "a", "string", "and", "an", "index", "look", "backwards", "to", "find", "the", "string", "of", "whitespace", "following", "the", "next", "previous", "line", "break", "." ]
5d0f31d6059edc5f816edba3962c3b57fdabd478
https://github.com/graphql/graphiql/blob/5d0f31d6059edc5f816edba3962c3b57fdabd478/src/utility/fillLeafs.js#L161-L177
train
PrismJS/prism
gulpfile.js
guessTitle
function guessTitle(id) { if (!id) { return id; } return (id.substring(0, 1).toUpperCase() + id.substring(1)).replace(/s(?=cript)/, 'S'); }
javascript
function guessTitle(id) { if (!id) { return id; } return (id.substring(0, 1).toUpperCase() + id.substring(1)).replace(/s(?=cript)/, 'S'); }
[ "function", "guessTitle", "(", "id", ")", "{", "if", "(", "!", "id", ")", "{", "return", "id", ";", "}", "return", "(", "id", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "id", ".", "substring", "(", "1", ")", ...
Tries to guess the name of a language given its id. From `prism-show-language.js`. @param {string} id The language id. @returns {string}
[ "Tries", "to", "guess", "the", "name", "of", "a", "language", "given", "its", "id", "." ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/gulpfile.js#L109-L114
train
PrismJS/prism
plugins/line-highlight/prism-line-highlight.js
highlightLines
function highlightLines(pre, lines, classes) { lines = typeof lines === 'string' ? lines : pre.getAttribute('data-line'); var ranges = lines.replace(/\s+/g, '').split(','); var offset = +pre.getAttribute('data-line-offset') || 0; var parseMethod = isLineHeightRounded() ? parseInt : parseFloat; var lineHeigh...
javascript
function highlightLines(pre, lines, classes) { lines = typeof lines === 'string' ? lines : pre.getAttribute('data-line'); var ranges = lines.replace(/\s+/g, '').split(','); var offset = +pre.getAttribute('data-line-offset') || 0; var parseMethod = isLineHeightRounded() ? parseInt : parseFloat; var lineHeigh...
[ "function", "highlightLines", "(", "pre", ",", "lines", ",", "classes", ")", "{", "lines", "=", "typeof", "lines", "===", "'string'", "?", "lines", ":", "pre", ".", "getAttribute", "(", "'data-line'", ")", ";", "var", "ranges", "=", "lines", ".", "replac...
Highlights the lines of the given pre. This function is split into a DOM measuring and mutate phase to improve performance. The returned function mutates the DOM when called. @param {HTMLElement} pre @param {string} [lines] @param {string} [classes=''] @returns {() => void}
[ "Highlights", "the", "lines", "of", "the", "given", "pre", "." ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/plugins/line-highlight/prism-line-highlight.js#L53-L121
train
PrismJS/prism
components/prism-asciidoc.js
copyFromAsciiDoc
function copyFromAsciiDoc(keys) { keys = keys.split(' '); var o = {}; for (var i = 0, l = keys.length; i < l; i++) { o[keys[i]] = asciidoc[keys[i]]; } return o; }
javascript
function copyFromAsciiDoc(keys) { keys = keys.split(' '); var o = {}; for (var i = 0, l = keys.length; i < l; i++) { o[keys[i]] = asciidoc[keys[i]]; } return o; }
[ "function", "copyFromAsciiDoc", "(", "keys", ")", "{", "keys", "=", "keys", ".", "split", "(", "' '", ")", ";", "var", "o", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ",", "l", "=", "keys", ".", "length", ";", "i", "<", "l", ";", ...
Allow some nesting. There is no recursion though, so cloning should not be needed.
[ "Allow", "some", "nesting", ".", "There", "is", "no", "recursion", "though", "so", "cloning", "should", "not", "be", "needed", "." ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/components/prism-asciidoc.js#L203-L211
train
PrismJS/prism
plugins/custom-class/prism-custom-class.js
map
function map(classMap) { if (typeof classMap === 'function') { options.classMap = classMap; } else { options.classMap = function (className) { return classMap[className] || className; }; } }
javascript
function map(classMap) { if (typeof classMap === 'function') { options.classMap = classMap; } else { options.classMap = function (className) { return classMap[className] || className; }; } }
[ "function", "map", "(", "classMap", ")", "{", "if", "(", "typeof", "classMap", "===", "'function'", ")", "{", "options", ".", "classMap", "=", "classMap", ";", "}", "else", "{", "options", ".", "classMap", "=", "function", "(", "className", ")", "{", "...
Maps all class names using the given object or map function. This does not affect the prefix. @param {Object<string, string> | ClassMapper} classMap
[ "Maps", "all", "class", "names", "using", "the", "given", "object", "or", "map", "function", "." ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/plugins/custom-class/prism-custom-class.js#L39-L47
train
PrismJS/prism
components/prism-jsx.js
function (token) { if (!token) { return ''; } if (typeof token === 'string') { return token; } if (typeof token.content === 'string') { return token.content; } return token.content.map(stringifyToken).join(''); }
javascript
function (token) { if (!token) { return ''; } if (typeof token === 'string') { return token; } if (typeof token.content === 'string') { return token.content; } return token.content.map(stringifyToken).join(''); }
[ "function", "(", "token", ")", "{", "if", "(", "!", "token", ")", "{", "return", "''", ";", "}", "if", "(", "typeof", "token", "===", "'string'", ")", "{", "return", "token", ";", "}", "if", "(", "typeof", "token", ".", "content", "===", "'string'"...
The following will handle plain text inside tags
[ "The", "following", "will", "handle", "plain", "text", "inside", "tags" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/components/prism-jsx.js#L38-L49
train
PrismJS/prism
scripts/utopia.js
function(obj, func, context) { if(!_.type(func) == 'function') { throw Error('The second argument in Utopia.each() must be a function'); }; context = context || obj; for (var i in obj) { if(obj.hasOwnProperty && obj.hasOwnProperty(i)) { var ret = func.call(context, obj[i], i); if(!!ret || ret =...
javascript
function(obj, func, context) { if(!_.type(func) == 'function') { throw Error('The second argument in Utopia.each() must be a function'); }; context = context || obj; for (var i in obj) { if(obj.hasOwnProperty && obj.hasOwnProperty(i)) { var ret = func.call(context, obj[i], i); if(!!ret || ret =...
[ "function", "(", "obj", ",", "func", ",", "context", ")", "{", "if", "(", "!", "_", ".", "type", "(", "func", ")", "==", "'function'", ")", "{", "throw", "Error", "(", "'The second argument in Utopia.each() must be a function'", ")", ";", "}", ";", "contex...
Iterate over the properties of an object. Checks whether the properties actually belong to it. Can be stopped if the function explicitly returns a value that isn't null, undefined or NaN. @param obj {Object} The object to iterate over @param func {Function} The function used in the iteration. Can accept 2 parameters: ...
[ "Iterate", "over", "the", "properties", "of", "an", "object", ".", "Checks", "whether", "the", "properties", "actually", "belong", "to", "it", ".", "Can", "be", "stopped", "if", "the", "function", "explicitly", "returns", "a", "value", "that", "isn", "t", ...
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L86-L104
train
PrismJS/prism
scripts/utopia.js
function(objects) { var ret = {}; for(var i=0; i<arguments.length; i++) { var o = arguments[i]; for(var j in o) { ret[j] = o[j]; } } return ret; }
javascript
function(objects) { var ret = {}; for(var i=0; i<arguments.length; i++) { var o = arguments[i]; for(var j in o) { ret[j] = o[j]; } } return ret; }
[ "function", "(", "objects", ")", "{", "var", "ret", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "arguments", ".", "length", ";", "i", "++", ")", "{", "var", "o", "=", "arguments", "[", "i", "]", ";", "for", "(", "va...
Copies the properties of one object onto another. When there is a collision, the later one wins @return {Object} destination object
[ "Copies", "the", "properties", "of", "one", "object", "onto", "another", ".", "When", "there", "is", "a", "collision", "the", "later", "one", "wins" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L112-L124
train
PrismJS/prism
scripts/utopia.js
function(object, objects) { for(var i=0; i<arguments.length; i++) { var o = arguments[i]; for(var j in o) { if(!(j in object)) { object[j] = o[j]; } } } return object; }
javascript
function(object, objects) { for(var i=0; i<arguments.length; i++) { var o = arguments[i]; for(var j in o) { if(!(j in object)) { object[j] = o[j]; } } } return object; }
[ "function", "(", "object", ",", "objects", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "arguments", ".", "length", ";", "i", "++", ")", "{", "var", "o", "=", "arguments", "[", "i", "]", ";", "for", "(", "var", "j", "in", "o", ...
Copies the properties of one or more objects onto the first one When there is a collision, the first object wins
[ "Copies", "the", "properties", "of", "one", "or", "more", "objects", "onto", "the", "first", "one", "When", "there", "is", "a", "collision", "the", "first", "object", "wins" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L130-L142
train
PrismJS/prism
scripts/utopia.js
function() { var options; if(_.type(arguments[0]) === 'string') { if(_.type(arguments[1]) === 'object') { // Utopia.element.create('div', { ... }); options = arguments[1]; options.tag = arguments[0]; } else { // Utopia.element.create('div', ...); options = { tag: argume...
javascript
function() { var options; if(_.type(arguments[0]) === 'string') { if(_.type(arguments[1]) === 'object') { // Utopia.element.create('div', { ... }); options = arguments[1]; options.tag = arguments[0]; } else { // Utopia.element.create('div', ...); options = { tag: argume...
[ "function", "(", ")", "{", "var", "options", ";", "if", "(", "_", ".", "type", "(", "arguments", "[", "0", "]", ")", "===", "'string'", ")", "{", "if", "(", "_", ".", "type", "(", "arguments", "[", "1", "]", ")", "===", "'object'", ")", "{", ...
Creates a new DOM element @param options {Object} A set of key/value pairs for attributes, properties, contents, placement in the DOM etc @return The new DOM element
[ "Creates", "a", "new", "DOM", "element" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L150-L220
train
PrismJS/prism
scripts/utopia.js
function(target, event, callback, traditional) { if(_.type(target) === 'string' || _.type(target) === 'array') { var elements = _.type(target) === 'string'? $$(target) : target; elements.forEach(function(element) { _.event.bind(element, event, callback, traditional); }); } else if(_.type(...
javascript
function(target, event, callback, traditional) { if(_.type(target) === 'string' || _.type(target) === 'array') { var elements = _.type(target) === 'string'? $$(target) : target; elements.forEach(function(element) { _.event.bind(element, event, callback, traditional); }); } else if(_.type(...
[ "function", "(", "target", ",", "event", ",", "callback", ",", "traditional", ")", "{", "if", "(", "_", ".", "type", "(", "target", ")", "===", "'string'", "||", "_", ".", "type", "(", "target", ")", "===", "'array'", ")", "{", "var", "elements", "...
Binds one or more events to one or more elements
[ "Binds", "one", "or", "more", "events", "to", "one", "or", "more", "elements" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L310-L336
train
PrismJS/prism
scripts/utopia.js
function(target, type, properties) { if(_.type(target) === 'string' || _.type(target) === 'array') { var elements = _.type(target) === 'string'? $$(target) : target; elements.forEach(function(element) { _.event.fire(element, type, properties); }); } else if (document.createEvent) { va...
javascript
function(target, type, properties) { if(_.type(target) === 'string' || _.type(target) === 'array') { var elements = _.type(target) === 'string'? $$(target) : target; elements.forEach(function(element) { _.event.fire(element, type, properties); }); } else if (document.createEvent) { va...
[ "function", "(", "target", ",", "type", ",", "properties", ")", "{", "if", "(", "_", ".", "type", "(", "target", ")", "===", "'string'", "||", "_", ".", "type", "(", "target", ")", "===", "'array'", ")", "{", "var", "elements", "=", "_", ".", "ty...
Fire a custom event
[ "Fire", "a", "custom", "event" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L341-L361
train
PrismJS/prism
scripts/utopia.js
function(o) { document.body.setAttribute('data-loading', ''); var xhr = new XMLHttpRequest(), method = o.method || 'GET', data = o.data || ''; xhr.open(method, o.url + (method === 'GET' && data? '?' + data : ''), true); o.headers = o.headers || {}; if(method !== 'GET' && !o.headers['Content-...
javascript
function(o) { document.body.setAttribute('data-loading', ''); var xhr = new XMLHttpRequest(), method = o.method || 'GET', data = o.data || ''; xhr.open(method, o.url + (method === 'GET' && data? '?' + data : ''), true); o.headers = o.headers || {}; if(method !== 'GET' && !o.headers['Content-...
[ "function", "(", "o", ")", "{", "document", ".", "body", ".", "setAttribute", "(", "'data-loading'", ",", "''", ")", ";", "var", "xhr", "=", "new", "XMLHttpRequest", "(", ")", ",", "method", "=", "o", ".", "method", "||", "'GET'", ",", "data", "=", ...
Helper for XHR requests
[ "Helper", "for", "XHR", "requests" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L367-L398
train
PrismJS/prism
plugins/show-invisibles/prism-show-invisibles.js
handleToken
function handleToken(tokens, name) { var value = tokens[name]; var type = Prism.util.type(value); switch (type) { case 'RegExp': var inside = {}; tokens[name] = { pattern: value, inside: inside }; addInvisibles(inside); break; case 'Array': for (var i = 0, l = value.lengt...
javascript
function handleToken(tokens, name) { var value = tokens[name]; var type = Prism.util.type(value); switch (type) { case 'RegExp': var inside = {}; tokens[name] = { pattern: value, inside: inside }; addInvisibles(inside); break; case 'Array': for (var i = 0, l = value.lengt...
[ "function", "handleToken", "(", "tokens", ",", "name", ")", "{", "var", "value", "=", "tokens", "[", "name", "]", ";", "var", "type", "=", "Prism", ".", "util", ".", "type", "(", "value", ")", ";", "switch", "(", "type", ")", "{", "case", "'RegExp'...
Handles the recursive calling of `addInvisibles` for one token. @param {Object|Array} tokens The grammar or array which contains the token. @param {string|number} name The name or index of the token in `tokens`.
[ "Handles", "the", "recursive", "calling", "of", "addInvisibles", "for", "one", "token", "." ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/plugins/show-invisibles/prism-show-invisibles.js#L26-L51
train
PrismJS/prism
plugins/previewers/prism-previewers.js
function(prefix, func, values) { // Default value for angle var angle = '180deg'; if (/^(?:-?\d*\.?\d+(?:deg|rad)|to\b|top|right|bottom|left)/.test(values[0])) { angle = values.shift(); if (angle.indexOf('to ') < 0) { // Angle uses old keywords // W3C syntax uses "to" + opposit...
javascript
function(prefix, func, values) { // Default value for angle var angle = '180deg'; if (/^(?:-?\d*\.?\d+(?:deg|rad)|to\b|top|right|bottom|left)/.test(values[0])) { angle = values.shift(); if (angle.indexOf('to ') < 0) { // Angle uses old keywords // W3C syntax uses "to" + opposit...
[ "function", "(", "prefix", ",", "func", ",", "values", ")", "{", "// Default value for angle", "var", "angle", "=", "'180deg'", ";", "if", "(", "/", "^(?:-?\\d*\\.?\\d+(?:deg|rad)|to\\b|top|right|bottom|left)", "/", ".", "test", "(", "values", "[", "0", "]", ")"...
Returns a W3C-valid linear gradient @param {string} prefix Vendor prefix if any ("-moz-", "-webkit-", etc.) @param {string} func Gradient function name ("linear-gradient") @param {string[]} values Array of the gradient function parameters (["0deg", "red 0%", "blue 100%"])
[ "Returns", "a", "W3C", "-", "valid", "linear", "gradient" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/plugins/previewers/prism-previewers.js#L25-L66
train
PrismJS/prism
plugins/previewers/prism-previewers.js
function(prefix, func, values) { if (values[0].indexOf('at') < 0) { // Looks like old syntax // Default values var position = 'center'; var shape = 'ellipse'; var size = 'farthest-corner'; if (/\bcenter|top|right|bottom|left\b|^\d+/.test(values[0])) { // Found a positio...
javascript
function(prefix, func, values) { if (values[0].indexOf('at') < 0) { // Looks like old syntax // Default values var position = 'center'; var shape = 'ellipse'; var size = 'farthest-corner'; if (/\bcenter|top|right|bottom|left\b|^\d+/.test(values[0])) { // Found a positio...
[ "function", "(", "prefix", ",", "func", ",", "values", ")", "{", "if", "(", "values", "[", "0", "]", ".", "indexOf", "(", "'at'", ")", "<", "0", ")", "{", "// Looks like old syntax", "// Default values", "var", "position", "=", "'center'", ";", "var", ...
Returns a W3C-valid radial gradient @param {string} prefix Vendor prefix if any ("-moz-", "-webkit-", etc.) @param {string} func Gradient function name ("linear-gradient") @param {string[]} values Array of the gradient function parameters (["0deg", "red 0%", "blue 100%"])
[ "Returns", "a", "W3C", "-", "valid", "radial", "gradient" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/plugins/previewers/prism-previewers.js#L74-L109
train
PrismJS/prism
components/prism-javadoclike.js
docCommentSupport
function docCommentSupport(lang, callback) { var tokenName = 'doc-comment'; var grammar = Prism.languages[lang]; if (!grammar) { return; } var token = grammar[tokenName]; if (!token) { // add doc comment: /** */ var definition = {}; definition[tokenName] = { pattern: /(^|[^\\])\/\*\*[^/][\...
javascript
function docCommentSupport(lang, callback) { var tokenName = 'doc-comment'; var grammar = Prism.languages[lang]; if (!grammar) { return; } var token = grammar[tokenName]; if (!token) { // add doc comment: /** */ var definition = {}; definition[tokenName] = { pattern: /(^|[^\\])\/\*\*[^/][\...
[ "function", "docCommentSupport", "(", "lang", ",", "callback", ")", "{", "var", "tokenName", "=", "'doc-comment'", ";", "var", "grammar", "=", "Prism", ".", "languages", "[", "lang", "]", ";", "if", "(", "!", "grammar", ")", "{", "return", ";", "}", "v...
Adds doc comment support to the given language and calls a given callback on each doc comment pattern. @param {string} lang the language add doc comment support to. @param {(pattern: {inside: {rest: undefined}}) => void} callback the function called with each doc comment pattern as argument.
[ "Adds", "doc", "comment", "support", "to", "the", "given", "language", "and", "calls", "a", "given", "callback", "on", "each", "doc", "comment", "pattern", "." ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/components/prism-javadoclike.js#L24-L59
train
PrismJS/prism
components/prism-javadoclike.js
addSupport
function addSupport(languages, docLanguage) { if (typeof languages === 'string') { languages = [languages]; } languages.forEach(function (lang) { docCommentSupport(lang, function (pattern) { if (!pattern.inside) { pattern.inside = {}; } pattern.inside.rest = docLanguage; }); }); }
javascript
function addSupport(languages, docLanguage) { if (typeof languages === 'string') { languages = [languages]; } languages.forEach(function (lang) { docCommentSupport(lang, function (pattern) { if (!pattern.inside) { pattern.inside = {}; } pattern.inside.rest = docLanguage; }); }); }
[ "function", "addSupport", "(", "languages", ",", "docLanguage", ")", "{", "if", "(", "typeof", "languages", "===", "'string'", ")", "{", "languages", "=", "[", "languages", "]", ";", "}", "languages", ".", "forEach", "(", "function", "(", "lang", ")", "{...
Adds doc-comment support to the given languages for the given documentation language. @param {string[]|string} languages @param {Object} docLanguage
[ "Adds", "doc", "-", "comment", "support", "to", "the", "given", "languages", "for", "the", "given", "documentation", "language", "." ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/components/prism-javadoclike.js#L67-L80
train
PrismJS/prism
plugins/line-numbers/prism-line-numbers.js
function (element) { if (!element) { return null; } return window.getComputedStyle ? getComputedStyle(element) : (element.currentStyle || null); }
javascript
function (element) { if (!element) { return null; } return window.getComputedStyle ? getComputedStyle(element) : (element.currentStyle || null); }
[ "function", "(", "element", ")", "{", "if", "(", "!", "element", ")", "{", "return", "null", ";", "}", "return", "window", ".", "getComputedStyle", "?", "getComputedStyle", "(", "element", ")", ":", "(", "element", ".", "currentStyle", "||", "null", ")",...
Returns style declarations for the element @param {Element} element
[ "Returns", "style", "declarations", "for", "the", "element" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/plugins/line-numbers/prism-line-numbers.js#L57-L63
train
PrismJS/prism
plugins/line-numbers/prism-line-numbers.js
function (element, number) { if (element.tagName !== 'PRE' || !element.classList.contains(PLUGIN_NAME)) { return; } var lineNumberRows = element.querySelector('.line-numbers-rows'); var lineNumberStart = parseInt(element.getAttribute('data-start'), 10) || 1; var lineNumberEnd = lineNumberStart + (li...
javascript
function (element, number) { if (element.tagName !== 'PRE' || !element.classList.contains(PLUGIN_NAME)) { return; } var lineNumberRows = element.querySelector('.line-numbers-rows'); var lineNumberStart = parseInt(element.getAttribute('data-start'), 10) || 1; var lineNumberEnd = lineNumberStart + (li...
[ "function", "(", "element", ",", "number", ")", "{", "if", "(", "element", ".", "tagName", "!==", "'PRE'", "||", "!", "element", ".", "classList", ".", "contains", "(", "PLUGIN_NAME", ")", ")", "{", "return", ";", "}", "var", "lineNumberRows", "=", "el...
Get node for provided line number @param {Element} element pre element @param {Number} number line number @return {Element|undefined}
[ "Get", "node", "for", "provided", "line", "number" ]
acceb3b56f0e8362a7ef274dbd85b17611df2ec4
https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/plugins/line-numbers/prism-line-numbers.js#L146-L165
train
fengyuanchen/cropper
dist/cropper.common.js
forEach
function forEach(data, callback) { if (data && isFunction(callback)) { if (Array.isArray(data) || isNumber(data.length) /* array-like */) { var length = data.length; var i = void 0; for (i = 0; i < length; i += 1) { if (callback.call(data, data[i], i, data) === false) { ...
javascript
function forEach(data, callback) { if (data && isFunction(callback)) { if (Array.isArray(data) || isNumber(data.length) /* array-like */) { var length = data.length; var i = void 0; for (i = 0; i < length; i += 1) { if (callback.call(data, data[i], i, data) === false) { ...
[ "function", "forEach", "(", "data", ",", "callback", ")", "{", "if", "(", "data", "&&", "isFunction", "(", "callback", ")", ")", "{", "if", "(", "Array", ".", "isArray", "(", "data", ")", "||", "isNumber", "(", "data", ".", "length", ")", "/* array-l...
Iterate the given data. @param {*} data - The data to iterate. @param {Function} callback - The process function for each element. @returns {*} The original data.
[ "Iterate", "the", "given", "data", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L283-L303
train
fengyuanchen/cropper
dist/cropper.common.js
setStyle
function setStyle(element, styles) { var style = element.style; forEach(styles, function (value, property) { if (REGEXP_SUFFIX.test(property) && isNumber(value)) { value += 'px'; } style[property] = value; }); }
javascript
function setStyle(element, styles) { var style = element.style; forEach(styles, function (value, property) { if (REGEXP_SUFFIX.test(property) && isNumber(value)) { value += 'px'; } style[property] = value; }); }
[ "function", "setStyle", "(", "element", ",", "styles", ")", "{", "var", "style", "=", "element", ".", "style", ";", "forEach", "(", "styles", ",", "function", "(", "value", ",", "property", ")", "{", "if", "(", "REGEXP_SUFFIX", ".", "test", "(", "prope...
Apply styles to the given element. @param {Element} element - The target element. @param {Object} styles - The styles for applying.
[ "Apply", "styles", "to", "the", "given", "element", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L351-L362
train
fengyuanchen/cropper
dist/cropper.common.js
getData
function getData(element, name) { if (isObject(element[name])) { return element[name]; } else if (element.dataset) { return element.dataset[name]; } return element.getAttribute('data-' + hyphenate(name)); }
javascript
function getData(element, name) { if (isObject(element[name])) { return element[name]; } else if (element.dataset) { return element.dataset[name]; } return element.getAttribute('data-' + hyphenate(name)); }
[ "function", "getData", "(", "element", ",", "name", ")", "{", "if", "(", "isObject", "(", "element", "[", "name", "]", ")", ")", "{", "return", "element", "[", "name", "]", ";", "}", "else", "if", "(", "element", ".", "dataset", ")", "{", "return",...
Get data from the given element. @param {Element} element - The target element. @param {string} name - The data key to get. @returns {string} The data value.
[ "Get", "data", "from", "the", "given", "element", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L475-L483
train
fengyuanchen/cropper
dist/cropper.common.js
setData
function setData(element, name, data) { if (isObject(data)) { element[name] = data; } else if (element.dataset) { element.dataset[name] = data; } else { element.setAttribute('data-' + hyphenate(name), data); } }
javascript
function setData(element, name, data) { if (isObject(data)) { element[name] = data; } else if (element.dataset) { element.dataset[name] = data; } else { element.setAttribute('data-' + hyphenate(name), data); } }
[ "function", "setData", "(", "element", ",", "name", ",", "data", ")", "{", "if", "(", "isObject", "(", "data", ")", ")", "{", "element", "[", "name", "]", "=", "data", ";", "}", "else", "if", "(", "element", ".", "dataset", ")", "{", "element", "...
Set data to the given element. @param {Element} element - The target element. @param {string} name - The data key to set. @param {string} data - The data value.
[ "Set", "data", "to", "the", "given", "element", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L491-L499
train
fengyuanchen/cropper
dist/cropper.common.js
removeData
function removeData(element, name) { if (isObject(element[name])) { try { delete element[name]; } catch (e) { element[name] = undefined; } } else if (element.dataset) { // #128 Safari not allows to delete dataset property try { delete element.dataset[name]; } catch (e) { ...
javascript
function removeData(element, name) { if (isObject(element[name])) { try { delete element[name]; } catch (e) { element[name] = undefined; } } else if (element.dataset) { // #128 Safari not allows to delete dataset property try { delete element.dataset[name]; } catch (e) { ...
[ "function", "removeData", "(", "element", ",", "name", ")", "{", "if", "(", "isObject", "(", "element", "[", "name", "]", ")", ")", "{", "try", "{", "delete", "element", "[", "name", "]", ";", "}", "catch", "(", "e", ")", "{", "element", "[", "na...
Remove data from the given element. @param {Element} element - The target element. @param {string} name - The data key to remove.
[ "Remove", "data", "from", "the", "given", "element", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L506-L523
train
fengyuanchen/cropper
dist/cropper.common.js
isCrossOriginURL
function isCrossOriginURL(url) { var parts = url.match(REGEXP_ORIGINS); return parts && (parts[1] !== location.protocol || parts[2] !== location.hostname || parts[3] !== location.port); }
javascript
function isCrossOriginURL(url) { var parts = url.match(REGEXP_ORIGINS); return parts && (parts[1] !== location.protocol || parts[2] !== location.hostname || parts[3] !== location.port); }
[ "function", "isCrossOriginURL", "(", "url", ")", "{", "var", "parts", "=", "url", ".", "match", "(", "REGEXP_ORIGINS", ")", ";", "return", "parts", "&&", "(", "parts", "[", "1", "]", "!==", "location", ".", "protocol", "||", "parts", "[", "2", "]", "...
Check if the given URL is a cross origin URL. @param {string} url - The target URL. @returns {boolean} Returns `true` if the given URL is a cross origin URL, else `false`.
[ "Check", "if", "the", "given", "URL", "is", "a", "cross", "origin", "URL", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L683-L687
train
fengyuanchen/cropper
dist/cropper.common.js
getAdjustedSizes
function getAdjustedSizes(_ref4) // or 'cover' { var aspectRatio = _ref4.aspectRatio, height = _ref4.height, width = _ref4.width; var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'contain'; var isValidNumber = function isValidNumber(value) { return isFinite(value) &&...
javascript
function getAdjustedSizes(_ref4) // or 'cover' { var aspectRatio = _ref4.aspectRatio, height = _ref4.height, width = _ref4.width; var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'contain'; var isValidNumber = function isValidNumber(value) { return isFinite(value) &&...
[ "function", "getAdjustedSizes", "(", "_ref4", ")", "// or 'cover'", "{", "var", "aspectRatio", "=", "_ref4", ".", "aspectRatio", ",", "height", "=", "_ref4", ".", "height", ",", "width", "=", "_ref4", ".", "width", ";", "var", "type", "=", "arguments", "."...
Get the max sizes in a rectangle under the given aspect ratio. @param {Object} data - The original sizes. @param {string} [type='contain'] - The adjust type. @returns {Object} The result sizes.
[ "Get", "the", "max", "sizes", "in", "a", "rectangle", "under", "the", "given", "aspect", "ratio", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L836-L865
train
fengyuanchen/cropper
dist/cropper.common.js
arrayBufferToDataURL
function arrayBufferToDataURL(arrayBuffer, mimeType) { var uint8 = new Uint8Array(arrayBuffer); var data = ''; // TypedArray.prototype.forEach is not supported in some browsers. forEach(uint8, function (value) { data += fromCharCode(value); }); return 'data:' + mimeType + ';base64,' + btoa(data); }
javascript
function arrayBufferToDataURL(arrayBuffer, mimeType) { var uint8 = new Uint8Array(arrayBuffer); var data = ''; // TypedArray.prototype.forEach is not supported in some browsers. forEach(uint8, function (value) { data += fromCharCode(value); }); return 'data:' + mimeType + ';base64,' + btoa(data); }
[ "function", "arrayBufferToDataURL", "(", "arrayBuffer", ",", "mimeType", ")", "{", "var", "uint8", "=", "new", "Uint8Array", "(", "arrayBuffer", ")", ";", "var", "data", "=", "''", ";", "// TypedArray.prototype.forEach is not supported in some browsers.", "forEach", "...
Transform array buffer to Data URL. @param {ArrayBuffer} arrayBuffer - The array buffer to transform. @param {string} mimeType - The mime type of the Data URL. @returns {string} The result Data URL.
[ "Transform", "array", "buffer", "to", "Data", "URL", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L1034-L1044
train
fengyuanchen/cropper
dist/cropper.common.js
destroy
function destroy() { var element = this.element; if (!getData(element, NAMESPACE)) { return this; } if (this.isImg && this.replaced) { element.src = this.originalUrl; } this.uncreate(); removeData(element, NAMESPACE); return this; }
javascript
function destroy() { var element = this.element; if (!getData(element, NAMESPACE)) { return this; } if (this.isImg && this.replaced) { element.src = this.originalUrl; } this.uncreate(); removeData(element, NAMESPACE); return this; }
[ "function", "destroy", "(", ")", "{", "var", "element", "=", "this", ".", "element", ";", "if", "(", "!", "getData", "(", "element", ",", "NAMESPACE", ")", ")", "{", "return", "this", ";", "}", "if", "(", "this", ".", "isImg", "&&", "this", ".", ...
Destroy the cropper and remove the instance from the image @returns {Cropper} this
[ "Destroy", "the", "cropper", "and", "remove", "the", "instance", "from", "the", "image" ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L2559-L2575
train
fengyuanchen/cropper
dist/cropper.common.js
zoomTo
function zoomTo(ratio, pivot, _originalEvent) { var options = this.options, canvasData = this.canvasData; var width = canvasData.width, height = canvasData.height, naturalWidth = canvasData.naturalWidth, naturalHeight = canvasData.naturalHeight; ratio = Number(ratio); ...
javascript
function zoomTo(ratio, pivot, _originalEvent) { var options = this.options, canvasData = this.canvasData; var width = canvasData.width, height = canvasData.height, naturalWidth = canvasData.naturalWidth, naturalHeight = canvasData.naturalHeight; ratio = Number(ratio); ...
[ "function", "zoomTo", "(", "ratio", ",", "pivot", ",", "_originalEvent", ")", "{", "var", "options", "=", "this", ".", "options", ",", "canvasData", "=", "this", ".", "canvasData", ";", "var", "width", "=", "canvasData", ".", "width", ",", "height", "=",...
Zoom the canvas to an absolute ratio @param {number} ratio - The target ratio. @param {Object} pivot - The zoom pivot point coordinate. @param {Event} _originalEvent - The original event if any. @returns {Cropper} this
[ "Zoom", "the", "canvas", "to", "an", "absolute", "ratio" ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L2659-L2709
train
fengyuanchen/cropper
dist/cropper.common.js
setData$$1
function setData$$1(data) { var options = this.options, imageData = this.imageData, canvasData = this.canvasData; var cropBoxData = {}; if (this.ready && !this.disabled && isPlainObject(data)) { var transformed = false; if (options.rotatable) { if (isNumber(data.rotate...
javascript
function setData$$1(data) { var options = this.options, imageData = this.imageData, canvasData = this.canvasData; var cropBoxData = {}; if (this.ready && !this.disabled && isPlainObject(data)) { var transformed = false; if (options.rotatable) { if (isNumber(data.rotate...
[ "function", "setData$$1", "(", "data", ")", "{", "var", "options", "=", "this", ".", "options", ",", "imageData", "=", "this", ".", "imageData", ",", "canvasData", "=", "this", ".", "canvasData", ";", "var", "cropBoxData", "=", "{", "}", ";", "if", "("...
Set the cropped area position and size with new data @param {Object} data - The new data. @returns {Cropper} this
[ "Set", "the", "cropped", "area", "position", "and", "size", "with", "new", "data" ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L2855-L2910
train
fengyuanchen/cropper
dist/cropper.common.js
getCropBoxData
function getCropBoxData() { var cropBoxData = this.cropBoxData; var data = void 0; if (this.ready && this.cropped) { data = { left: cropBoxData.left, top: cropBoxData.top, width: cropBoxData.width, height: cropBoxData.height }; } return data || {}; }
javascript
function getCropBoxData() { var cropBoxData = this.cropBoxData; var data = void 0; if (this.ready && this.cropped) { data = { left: cropBoxData.left, top: cropBoxData.top, width: cropBoxData.width, height: cropBoxData.height }; } return data || {}; }
[ "function", "getCropBoxData", "(", ")", "{", "var", "cropBoxData", "=", "this", ".", "cropBoxData", ";", "var", "data", "=", "void", "0", ";", "if", "(", "this", ".", "ready", "&&", "this", ".", "cropped", ")", "{", "data", "=", "{", "left", ":", "...
Get the crop box position and size data. @returns {Object} The result crop box data.
[ "Get", "the", "crop", "box", "position", "and", "size", "data", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L2988-L3003
train
fengyuanchen/cropper
dist/cropper.common.js
setCropBoxData
function setCropBoxData(data) { var cropBoxData = this.cropBoxData; var aspectRatio = this.options.aspectRatio; var widthChanged = void 0; var heightChanged = void 0; if (this.ready && this.cropped && !this.disabled && isPlainObject(data)) { if (isNumber(data.left)) { cropBoxData.lef...
javascript
function setCropBoxData(data) { var cropBoxData = this.cropBoxData; var aspectRatio = this.options.aspectRatio; var widthChanged = void 0; var heightChanged = void 0; if (this.ready && this.cropped && !this.disabled && isPlainObject(data)) { if (isNumber(data.left)) { cropBoxData.lef...
[ "function", "setCropBoxData", "(", "data", ")", "{", "var", "cropBoxData", "=", "this", ".", "cropBoxData", ";", "var", "aspectRatio", "=", "this", ".", "options", ".", "aspectRatio", ";", "var", "widthChanged", "=", "void", "0", ";", "var", "heightChanged",...
Set the crop box position and size with new data. @param {Object} data - The new crop box data. @returns {Cropper} this
[ "Set", "the", "crop", "box", "position", "and", "size", "with", "new", "data", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L3011-L3049
train
fengyuanchen/cropper
dist/cropper.common.js
Cropper
function Cropper(element) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; classCallCheck(this, Cropper); if (!element || !REGEXP_TAG_NAME.test(element.tagName)) { throw new Error('The first argument is required and must be an <img> or <canvas> element.'); }...
javascript
function Cropper(element) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; classCallCheck(this, Cropper); if (!element || !REGEXP_TAG_NAME.test(element.tagName)) { throw new Error('The first argument is required and must be an <img> or <canvas> element.'); }...
[ "function", "Cropper", "(", "element", ")", "{", "var", "options", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "{", "}", ";", "classCallCheck", "(", "this", ",...
Create a new Cropper. @param {Element} element - The target element for cropping. @param {Object} [options={}] - The configuration options.
[ "Create", "a", "new", "Cropper", "." ]
6677332a6a375b647f58808dfc24ea09f5804041
https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L3266-L3285
train
grpc/grpc-node
packages/grpc-native-core/src/client.js
ClientWritableStream
function ClientWritableStream(call) { Writable.call(this, {objectMode: true}); this.call = call; var self = this; this.on('finish', function() { self.call.halfClose(); }); }
javascript
function ClientWritableStream(call) { Writable.call(this, {objectMode: true}); this.call = call; var self = this; this.on('finish', function() { self.call.halfClose(); }); }
[ "function", "ClientWritableStream", "(", "call", ")", "{", "Writable", ".", "call", "(", "this", ",", "{", "objectMode", ":", "true", "}", ")", ";", "this", ".", "call", "=", "call", ";", "var", "self", "=", "this", ";", "this", ".", "on", "(", "'f...
A stream that the client can write to. Used for calls that are streaming from the client side. @constructor grpc~ClientWritableStream @extends external:Writable @borrows grpc~ClientUnaryCall#cancel as grpc~ClientWritableStream#cancel @borrows grpc~ClientUnaryCall#getPeer as grpc~ClientWritableStream#getPeer @borrows gr...
[ "A", "stream", "that", "the", "client", "can", "write", "to", ".", "Used", "for", "calls", "that", "are", "streaming", "from", "the", "client", "side", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client.js#L97-L104
train
grpc/grpc-node
packages/grpc-native-core/src/client.js
_write
function _write(chunk, encoding, callback) { /* jshint validthis: true */ var self = this; if (this.writeFailed) { /* Once a write fails, just call the callback immediately to let the caller flush any pending writes. */ setImmediate(callback); return; } var outerCallback = function(err, eve...
javascript
function _write(chunk, encoding, callback) { /* jshint validthis: true */ var self = this; if (this.writeFailed) { /* Once a write fails, just call the callback immediately to let the caller flush any pending writes. */ setImmediate(callback); return; } var outerCallback = function(err, eve...
[ "function", "_write", "(", "chunk", ",", "encoding", ",", "callback", ")", "{", "/* jshint validthis: true */", "var", "self", "=", "this", ";", "if", "(", "this", ".", "writeFailed", ")", "{", "/* Once a write fails, just call the callback immediately to let the caller...
Write a message to the request stream. If serializing the argument fails, the call will be cancelled and the stream will end with an error. @name grpc~ClientWritableStream#write @kind function @override @param {*} message The message to write. Must be a valid argument to the serialize function of the corresponding meth...
[ "Write", "a", "message", "to", "the", "request", "stream", ".", "If", "serializing", "the", "argument", "fails", "the", "call", "will", "be", "cancelled", "and", "the", "stream", "will", "end", "with", "an", "error", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client.js#L127-L150
train
grpc/grpc-node
packages/grpc-native-core/src/client.js
ClientReadableStream
function ClientReadableStream(call) { Readable.call(this, {objectMode: true}); this.call = call; this.finished = false; this.reading = false; /* Status generated from reading messages from the server. Overrides the * status from the server if not OK */ this.read_status = null; /* Status received from t...
javascript
function ClientReadableStream(call) { Readable.call(this, {objectMode: true}); this.call = call; this.finished = false; this.reading = false; /* Status generated from reading messages from the server. Overrides the * status from the server if not OK */ this.read_status = null; /* Status received from t...
[ "function", "ClientReadableStream", "(", "call", ")", "{", "Readable", ".", "call", "(", "this", ",", "{", "objectMode", ":", "true", "}", ")", ";", "this", ".", "call", "=", "call", ";", "this", ".", "finished", "=", "false", ";", "this", ".", "read...
A stream that the client can read from. Used for calls that are streaming from the server side. @constructor grpc~ClientReadableStream @extends external:Readable @borrows grpc~ClientUnaryCall#cancel as grpc~ClientReadableStream#cancel @borrows grpc~ClientUnaryCall#getPeer as grpc~ClientReadableStream#getPeer @borrows g...
[ "A", "stream", "that", "the", "client", "can", "read", "from", ".", "Used", "for", "calls", "that", "are", "streaming", "from", "the", "server", "side", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client.js#L170-L180
train
grpc/grpc-node
packages/grpc-native-core/src/client.js
_readsDone
function _readsDone(status) { /* jshint validthis: true */ if (!status) { status = {code: constants.status.OK, details: 'OK'}; } if (status.code !== constants.status.OK) { this.call.cancelWithStatus(status.code, status.details); } this.finished = true; this.read_status = status; this._emitStatus...
javascript
function _readsDone(status) { /* jshint validthis: true */ if (!status) { status = {code: constants.status.OK, details: 'OK'}; } if (status.code !== constants.status.OK) { this.call.cancelWithStatus(status.code, status.details); } this.finished = true; this.read_status = status; this._emitStatus...
[ "function", "_readsDone", "(", "status", ")", "{", "/* jshint validthis: true */", "if", "(", "!", "status", ")", "{", "status", "=", "{", "code", ":", "constants", ".", "status", ".", "OK", ",", "details", ":", "'OK'", "}", ";", "}", "if", "(", "statu...
Called when all messages from the server have been processed. The status parameter indicates that the call should end with that status. status defaults to OK if not provided. @param {Object!} status The status that the call should end with @private
[ "Called", "when", "all", "messages", "from", "the", "server", "have", "been", "processed", ".", "The", "status", "parameter", "indicates", "that", "the", "call", "should", "end", "with", "that", "status", ".", "status", "defaults", "to", "OK", "if", "not", ...
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client.js#L189-L200
train
grpc/grpc-node
packages/grpc-native-core/src/client.js
_emitStatusIfDone
function _emitStatusIfDone() { /* jshint validthis: true */ var status; if (this.read_status && this.received_status) { if (this.read_status.code !== constants.status.OK) { status = this.read_status; } else { status = this.received_status; } if (status.code === constants.status.OK) { ...
javascript
function _emitStatusIfDone() { /* jshint validthis: true */ var status; if (this.read_status && this.received_status) { if (this.read_status.code !== constants.status.OK) { status = this.read_status; } else { status = this.received_status; } if (status.code === constants.status.OK) { ...
[ "function", "_emitStatusIfDone", "(", ")", "{", "/* jshint validthis: true */", "var", "status", ";", "if", "(", "this", ".", "read_status", "&&", "this", ".", "received_status", ")", "{", "if", "(", "this", ".", "read_status", ".", "code", "!==", "constants",...
If we have both processed all incoming messages and received the status from the server, emit the status. Otherwise, do nothing. @private
[ "If", "we", "have", "both", "processed", "all", "incoming", "messages", "and", "received", "the", "status", "from", "the", "server", "emit", "the", "status", ".", "Otherwise", "do", "nothing", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client.js#L221-L238
train
grpc/grpc-node
packages/grpc-native-core/src/client.js
_read
function _read(size) { /* jshint validthis: true */ if (this.finished) { this.push(null); } else { if (!this.reading) { this.reading = true; var context = { stream: this }; this.call.recvMessageWithContext(context); } } }
javascript
function _read(size) { /* jshint validthis: true */ if (this.finished) { this.push(null); } else { if (!this.reading) { this.reading = true; var context = { stream: this }; this.call.recvMessageWithContext(context); } } }
[ "function", "_read", "(", "size", ")", "{", "/* jshint validthis: true */", "if", "(", "this", ".", "finished", ")", "{", "this", ".", "push", "(", "null", ")", ";", "}", "else", "{", "if", "(", "!", "this", ".", "reading", ")", "{", "this", ".", "...
Read the next object from the stream. @private @param {*} size Ignored because we use objectMode=true
[ "Read", "the", "next", "object", "from", "the", "stream", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client.js#L247-L260
train
grpc/grpc-node
packages/grpc-native-core/src/client.js
ClientDuplexStream
function ClientDuplexStream(call) { Duplex.call(this, {objectMode: true}); this.call = call; /* Status generated from reading messages from the server. Overrides the * status from the server if not OK */ this.read_status = null; /* Status received from the server. */ this.received_status = null; var se...
javascript
function ClientDuplexStream(call) { Duplex.call(this, {objectMode: true}); this.call = call; /* Status generated from reading messages from the server. Overrides the * status from the server if not OK */ this.read_status = null; /* Status received from the server. */ this.received_status = null; var se...
[ "function", "ClientDuplexStream", "(", "call", ")", "{", "Duplex", ".", "call", "(", "this", ",", "{", "objectMode", ":", "true", "}", ")", ";", "this", ".", "call", "=", "call", ";", "/* Status generated from reading messages from the server. Overrides the\n * st...
A stream that the client can read from or write to. Used for calls with duplex streaming. @constructor grpc~ClientDuplexStream @extends external:Duplex @borrows grpc~ClientUnaryCall#cancel as grpc~ClientDuplexStream#cancel @borrows grpc~ClientUnaryCall#getPeer as grpc~ClientDuplexStream#getPeer @borrows grpc~ClientWrit...
[ "A", "stream", "that", "the", "client", "can", "read", "from", "or", "write", "to", ".", "Used", "for", "calls", "with", "duplex", "streaming", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client.js#L281-L293
train
grpc/grpc-node
packages/grpc-native-core/src/client.js
Client
function Client(address, credentials, options) { var self = this; if (!options) { options = {}; } // Resolve interceptor options and assign interceptors to each method if (Array.isArray(options.interceptor_providers) && Array.isArray(options.interceptors)) { throw new client_interceptors.InterceptorC...
javascript
function Client(address, credentials, options) { var self = this; if (!options) { options = {}; } // Resolve interceptor options and assign interceptors to each method if (Array.isArray(options.interceptor_providers) && Array.isArray(options.interceptors)) { throw new client_interceptors.InterceptorC...
[ "function", "Client", "(", "address", ",", "credentials", ",", "options", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "options", ")", "{", "options", "=", "{", "}", ";", "}", "// Resolve interceptor options and assign interceptors to each method",...
Options that can be set on a call. @typedef {Object} grpc.Client~CallOptions @property {grpc~Deadline} deadline The deadline for the entire call to complete. @property {string} host Server hostname to set on the call. Only meaningful if different from the server address used to construct the client. @property {grpc.Cli...
[ "Options", "that", "can", "be", "set", "on", "a", "call", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client.js#L365-L415
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
function(providers, method_definition) { if (!Array.isArray(providers)) { return null; } var interceptors = []; for (var i = 0; i < providers.length; i++) { var provider = providers[i]; var interceptor = provider(method_definition); if (interceptor) { interceptors.push(interceptor); } ...
javascript
function(providers, method_definition) { if (!Array.isArray(providers)) { return null; } var interceptors = []; for (var i = 0; i < providers.length; i++) { var provider = providers[i]; var interceptor = provider(method_definition); if (interceptor) { interceptors.push(interceptor); } ...
[ "function", "(", "providers", ",", "method_definition", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "providers", ")", ")", "{", "return", "null", ";", "}", "var", "interceptors", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";"...
Transforms a list of interceptor providers into interceptors. @param {InterceptorProvider[]} providers @param {grpc~MethodDefinition} method_definition @return {null|Interceptor[]}
[ "Transforms", "a", "list", "of", "interceptor", "providers", "into", "interceptors", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L354-L367
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
function(metadata, current_listener) { // If there is a next call in the chain, run it. Otherwise do nothing. if (self.next_call) { // Wire together any listener provided with the next listener var listener = _getInterceptingListener(current_listener, next_listener); self.next_call.start(metad...
javascript
function(metadata, current_listener) { // If there is a next call in the chain, run it. Otherwise do nothing. if (self.next_call) { // Wire together any listener provided with the next listener var listener = _getInterceptingListener(current_listener, next_listener); self.next_call.start(metad...
[ "function", "(", "metadata", ",", "current_listener", ")", "{", "// If there is a next call in the chain, run it. Otherwise do nothing.", "if", "(", "self", ".", "next_call", ")", "{", "// Wire together any listener provided with the next listener", "var", "listener", "=", "_ge...
Build the next method in the interceptor chain
[ "Build", "the", "next", "method", "in", "the", "interceptor", "chain" ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L448-L455
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
getCall
function getCall(channel, path, options) { var deadline; var host; var parent; var propagate_flags; var credentials; if (options) { deadline = options.deadline; host = options.host; parent = options.parent ? options.parent.call : undefined; propagate_flags = options.propagate_flags; cred...
javascript
function getCall(channel, path, options) { var deadline; var host; var parent; var propagate_flags; var credentials; if (options) { deadline = options.deadline; host = options.host; parent = options.parent ? options.parent.call : undefined; propagate_flags = options.propagate_flags; cred...
[ "function", "getCall", "(", "channel", ",", "path", ",", "options", ")", "{", "var", "deadline", ";", "var", "host", ";", "var", "parent", ";", "var", "propagate_flags", ";", "var", "credentials", ";", "if", "(", "options", ")", "{", "deadline", "=", "...
Get a call object built with the provided options. @param {grpc.Channel} channel @param {string} path @param {grpc.Client~CallOptions=} options Options object.
[ "Get", "a", "call", "object", "built", "with", "the", "provided", "options", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L639-L661
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
_getStreamReadCallback
function _getStreamReadCallback(emitter, call, get_listener, deserialize) { return function (err, response) { if (err) { // Something has gone wrong. Stop reading and wait for status emitter.finished = true; emitter._readsDone(); return; } var data = response.read; var deserial...
javascript
function _getStreamReadCallback(emitter, call, get_listener, deserialize) { return function (err, response) { if (err) { // Something has gone wrong. Stop reading and wait for status emitter.finished = true; emitter._readsDone(); return; } var data = response.read; var deserial...
[ "function", "_getStreamReadCallback", "(", "emitter", ",", "call", ",", "get_listener", ",", "deserialize", ")", "{", "return", "function", "(", "err", ",", "response", ")", "{", "if", "(", "err", ")", "{", "// Something has gone wrong. Stop reading and wait for sta...
Produces a callback triggered by streaming response messages. @private @param {EventEmitter} emitter @param {grpc.internal~Call} call @param {function} get_listener Returns a grpc~Listener. @param {grpc~deserialize} deserialize @return {Function}
[ "Produces", "a", "callback", "triggered", "by", "streaming", "response", "messages", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L678-L708
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
_areBatchRequirementsMet
function _areBatchRequirementsMet(batch_ops, completed_ops) { var dependencies = common.flatMap(batch_ops, function(op) { return OP_DEPENDENCIES[op] || []; }); for (var i = 0; i < dependencies.length; i++) { var required_dep = dependencies[i]; if (batch_ops.indexOf(required_dep) === -1 && comp...
javascript
function _areBatchRequirementsMet(batch_ops, completed_ops) { var dependencies = common.flatMap(batch_ops, function(op) { return OP_DEPENDENCIES[op] || []; }); for (var i = 0; i < dependencies.length; i++) { var required_dep = dependencies[i]; if (batch_ops.indexOf(required_dep) === -1 && comp...
[ "function", "_areBatchRequirementsMet", "(", "batch_ops", ",", "completed_ops", ")", "{", "var", "dependencies", "=", "common", ".", "flatMap", "(", "batch_ops", ",", "function", "(", "op", ")", "{", "return", "OP_DEPENDENCIES", "[", "op", "]", "||", "[", "]...
Tests whether a batch can be started. @private @param {number[]} batch_ops The operations in the batch we are checking. @param {number[]} completed_ops Previously completed operations. @return {boolean}
[ "Tests", "whether", "a", "batch", "can", "be", "started", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L717-L729
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
_startBatchIfReady
function _startBatchIfReady(call, batch, batch_state, callback) { var completed_ops = batch_state.completed_ops; var deferred_batches = batch_state.deferred_batches; var batch_ops = Object.keys(batch).map(Number); if (_areBatchRequirementsMet(batch_ops, completed_ops)) { // Dependencies are met, start the b...
javascript
function _startBatchIfReady(call, batch, batch_state, callback) { var completed_ops = batch_state.completed_ops; var deferred_batches = batch_state.deferred_batches; var batch_ops = Object.keys(batch).map(Number); if (_areBatchRequirementsMet(batch_ops, completed_ops)) { // Dependencies are met, start the b...
[ "function", "_startBatchIfReady", "(", "call", ",", "batch", ",", "batch_state", ",", "callback", ")", "{", "var", "completed_ops", "=", "batch_state", ".", "completed_ops", ";", "var", "deferred_batches", "=", "batch_state", ".", "deferred_batches", ";", "var", ...
Enforces the order of operations for synchronous requests. If a batch's operations cannot be started because required operations have not started yet, the batch is deferred until requirements are met. @private @param {grpc.Client~Call} call @param {object} batch @param {object} batch_state @param {number[]} [batch_stat...
[ "Enforces", "the", "order", "of", "operations", "for", "synchronous", "requests", ".", "If", "a", "batch", "s", "operations", "cannot", "be", "started", "because", "required", "operations", "have", "not", "started", "yet", "the", "batch", "is", "deferred", "un...
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L745-L773
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
_getUnaryInterceptor
function _getUnaryInterceptor(method_definition, channel, emitter, callback) { var serialize = method_definition.requestSerialize; var deserialize = method_definition.responseDeserialize; return function (options) { var call = getCall(channel, method_definition.path, options); var first_listener; var ...
javascript
function _getUnaryInterceptor(method_definition, channel, emitter, callback) { var serialize = method_definition.requestSerialize; var deserialize = method_definition.responseDeserialize; return function (options) { var call = getCall(channel, method_definition.path, options); var first_listener; var ...
[ "function", "_getUnaryInterceptor", "(", "method_definition", ",", "channel", ",", "emitter", ",", "callback", ")", "{", "var", "serialize", "=", "method_definition", ".", "requestSerialize", ";", "var", "deserialize", "=", "method_definition", ".", "responseDeseriali...
Produces an interceptor which will start gRPC batches for unary calls. @private @param {grpc~MethodDefinition} method_definition @param {grpc.Channel} channel @param {EventEmitter} emitter @param {function} callback @return {Interceptor}
[ "Produces", "an", "interceptor", "which", "will", "start", "gRPC", "batches", "for", "unary", "calls", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L784-L860
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
_getServerStreamingInterceptor
function _getServerStreamingInterceptor(method_definition, channel, emitter) { var deserialize = common.wrapIgnoreNull( method_definition.responseDeserialize); var serialize = method_definition.requestSerialize; return function (options) { var batch_state = { completed_ops: [], deferred_batche...
javascript
function _getServerStreamingInterceptor(method_definition, channel, emitter) { var deserialize = common.wrapIgnoreNull( method_definition.responseDeserialize); var serialize = method_definition.requestSerialize; return function (options) { var batch_state = { completed_ops: [], deferred_batche...
[ "function", "_getServerStreamingInterceptor", "(", "method_definition", ",", "channel", ",", "emitter", ")", "{", "var", "deserialize", "=", "common", ".", "wrapIgnoreNull", "(", "method_definition", ".", "responseDeserialize", ")", ";", "var", "serialize", "=", "me...
Produces an interceptor which will start gRPC batches for server streaming calls. @private @param {grpc~MethodDefinition} method_definition @param {grpc.Channel} channel @param {EventEmitter} emitter @return {Interceptor}
[ "Produces", "an", "interceptor", "which", "will", "start", "gRPC", "batches", "for", "server", "streaming", "calls", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L986-L1074
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
_getUnaryListener
function _getUnaryListener(method_definition, emitter, callback) { var resultMessage; return { onReceiveMetadata: function (metadata) { emitter.emit('metadata', metadata); }, onReceiveMessage: function (message) { resultMessage = message; }, onReceiveStatus: function (status) { ...
javascript
function _getUnaryListener(method_definition, emitter, callback) { var resultMessage; return { onReceiveMetadata: function (metadata) { emitter.emit('metadata', metadata); }, onReceiveMessage: function (message) { resultMessage = message; }, onReceiveStatus: function (status) { ...
[ "function", "_getUnaryListener", "(", "method_definition", ",", "emitter", ",", "callback", ")", "{", "var", "resultMessage", ";", "return", "{", "onReceiveMetadata", ":", "function", "(", "metadata", ")", "{", "emitter", ".", "emit", "(", "'metadata'", ",", "...
Produces a listener for responding to callers of unary RPCs. @private @param {grpc~MethodDefinition} method_definition @param {EventEmitter} emitter @param {function} callback @return {grpc~Listener}
[ "Produces", "a", "listener", "for", "responding", "to", "callers", "of", "unary", "RPCs", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L1193-L1212
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
_getBidiStreamingListener
function _getBidiStreamingListener(method_definition, emitter) { var deserialize = common.wrapIgnoreNull( method_definition.responseDeserialize); return { onReceiveMetadata: function (metadata) { emitter.emit('metadata', metadata); }, onReceiveMessage: function(message, next, context) { ...
javascript
function _getBidiStreamingListener(method_definition, emitter) { var deserialize = common.wrapIgnoreNull( method_definition.responseDeserialize); return { onReceiveMetadata: function (metadata) { emitter.emit('metadata', metadata); }, onReceiveMessage: function(message, next, context) { ...
[ "function", "_getBidiStreamingListener", "(", "method_definition", ",", "emitter", ")", "{", "var", "deserialize", "=", "common", ".", "wrapIgnoreNull", "(", "method_definition", ".", "responseDeserialize", ")", ";", "return", "{", "onReceiveMetadata", ":", "function"...
Produces a listener for responding to callers of bi-directional RPCs. @private @param {grpc~MethodDefinition} method_definition @param {EventEmitter} emitter @return {grpc~Listener}
[ "Produces", "a", "listener", "for", "responding", "to", "callers", "of", "bi", "-", "directional", "RPCs", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L1284-L1309
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
getLastListener
function getLastListener(method_definition, emitter, callback) { if (emitter instanceof Function) { callback = emitter; callback = function() {}; } if (!(callback instanceof Function)) { callback = function() {}; } if (!((emitter instanceof EventEmitter) && (callback instanceof Function))) ...
javascript
function getLastListener(method_definition, emitter, callback) { if (emitter instanceof Function) { callback = emitter; callback = function() {}; } if (!(callback instanceof Function)) { callback = function() {}; } if (!((emitter instanceof EventEmitter) && (callback instanceof Function))) ...
[ "function", "getLastListener", "(", "method_definition", ",", "emitter", ",", "callback", ")", "{", "if", "(", "emitter", "instanceof", "Function", ")", "{", "callback", "=", "emitter", ";", "callback", "=", "function", "(", ")", "{", "}", ";", "}", "if", ...
Creates the last listener in an interceptor stack. @param {grpc~MethodDefinition} method_definition @param {EventEmitter} emitter @param {function=} callback @return {grpc~Listener}
[ "Creates", "the", "last", "listener", "in", "an", "interceptor", "stack", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L1332-L1347
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
_getLastInterceptor
function _getLastInterceptor(method_definition, channel, responder) { var callback = (responder instanceof Function) ? responder : function() {}; var emitter = (responder instanceof EventEmitter) ? responder : new EventEmitter(); var method_type = common.getMe...
javascript
function _getLastInterceptor(method_definition, channel, responder) { var callback = (responder instanceof Function) ? responder : function() {}; var emitter = (responder instanceof EventEmitter) ? responder : new EventEmitter(); var method_type = common.getMe...
[ "function", "_getLastInterceptor", "(", "method_definition", ",", "channel", ",", "responder", ")", "{", "var", "callback", "=", "(", "responder", "instanceof", "Function", ")", "?", "responder", ":", "function", "(", ")", "{", "}", ";", "var", "emitter", "=...
Creates the last interceptor in an interceptor stack. @private @param {grpc~MethodDefinition} method_definition @param {grpc.Channel} channel @param {function|EventEmitter} responder @return {Interceptor}
[ "Creates", "the", "last", "interceptor", "in", "an", "interceptor", "stack", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L1373-L1380
train
grpc/grpc-node
packages/grpc-native-core/src/client_interceptors.js
_buildChain
function _buildChain(interceptors, options) { var next = function(interceptors) { if (interceptors.length === 0) { return function (options) {}; } var head_interceptor = interceptors[0]; var rest_interceptors = interceptors.slice(1); return function (options) { return head_interceptor(...
javascript
function _buildChain(interceptors, options) { var next = function(interceptors) { if (interceptors.length === 0) { return function (options) {}; } var head_interceptor = interceptors[0]; var rest_interceptors = interceptors.slice(1); return function (options) { return head_interceptor(...
[ "function", "_buildChain", "(", "interceptors", ",", "options", ")", "{", "var", "next", "=", "function", "(", "interceptors", ")", "{", "if", "(", "interceptors", ".", "length", "===", "0", ")", "{", "return", "function", "(", "options", ")", "{", "}", ...
Chain a list of interceptors together and return the first InterceptingCall. @private @param {Interceptor[]} interceptors An interceptor stack. @param {grpc.Client~CallOptions} options Call options. @return {InterceptingCall}
[ "Chain", "a", "list", "of", "interceptors", "together", "and", "return", "the", "first", "InterceptingCall", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L1389-L1402
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
handleError
function handleError(call, error) { var statusMetadata = new Metadata(); var status = { code: constants.status.UNKNOWN, details: 'Unknown Error' }; if (error.hasOwnProperty('message')) { status.details = error.message; } if (error.hasOwnProperty('code') && Number.isInteger(error.code)) { sta...
javascript
function handleError(call, error) { var statusMetadata = new Metadata(); var status = { code: constants.status.UNKNOWN, details: 'Unknown Error' }; if (error.hasOwnProperty('message')) { status.details = error.message; } if (error.hasOwnProperty('code') && Number.isInteger(error.code)) { sta...
[ "function", "handleError", "(", "call", ",", "error", ")", "{", "var", "statusMetadata", "=", "new", "Metadata", "(", ")", ";", "var", "status", "=", "{", "code", ":", "constants", ".", "status", ".", "UNKNOWN", ",", "details", ":", "'Unknown Error'", "}...
Handle an error on a call by sending it as a status @private @param {grpc.internal~Call} call The call to send the error on @param {(Object|Error)} error The error object
[ "Handle", "an", "error", "on", "a", "call", "by", "sending", "it", "as", "a", "status" ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L44-L70
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
sendUnaryResponse
function sendUnaryResponse(call, value, serialize, metadata, flags) { var end_batch = {}; var statusMetadata = new Metadata(); var status = { code: constants.status.OK, details: 'OK' }; if (metadata) { statusMetadata = metadata; } var message; try { message = serialize(value); } catch ...
javascript
function sendUnaryResponse(call, value, serialize, metadata, flags) { var end_batch = {}; var statusMetadata = new Metadata(); var status = { code: constants.status.OK, details: 'OK' }; if (metadata) { statusMetadata = metadata; } var message; try { message = serialize(value); } catch ...
[ "function", "sendUnaryResponse", "(", "call", ",", "value", ",", "serialize", ",", "metadata", ",", "flags", ")", "{", "var", "end_batch", "=", "{", "}", ";", "var", "statusMetadata", "=", "new", "Metadata", "(", ")", ";", "var", "status", "=", "{", "c...
Send a response to a unary or client streaming call. @private @param {grpc.Call} call The call to respond on @param {*} value The value to respond with @param {grpc~serialize} serialize Serialization function for the response @param {grpc.Metadata=} metadata Optional trailing metadata to send with status @param {number...
[ "Send", "a", "response", "to", "a", "unary", "or", "client", "streaming", "call", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L83-L111
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
setUpWritable
function setUpWritable(stream, serialize) { stream.finished = false; stream.status = { code : constants.status.OK, details : 'OK', metadata : new Metadata() }; stream.serialize = common.wrapIgnoreNull(serialize); function sendStatus() { var batch = {}; if (!stream.call.metadataSent) { ...
javascript
function setUpWritable(stream, serialize) { stream.finished = false; stream.status = { code : constants.status.OK, details : 'OK', metadata : new Metadata() }; stream.serialize = common.wrapIgnoreNull(serialize); function sendStatus() { var batch = {}; if (!stream.call.metadataSent) { ...
[ "function", "setUpWritable", "(", "stream", ",", "serialize", ")", "{", "stream", ".", "finished", "=", "false", ";", "stream", ".", "status", "=", "{", "code", ":", "constants", ".", "status", ".", "OK", ",", "details", ":", "'OK'", ",", "metadata", "...
Initialize a writable stream. This is used for both the writable and duplex stream constructors. @private @param {Writable} stream The stream to set up @param {function(*):Buffer=} Serialization function for responses
[ "Initialize", "a", "writable", "stream", ".", "This", "is", "used", "for", "both", "the", "writable", "and", "duplex", "stream", "constructors", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L120-L190
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
setStatus
function setStatus(err) { var code = constants.status.UNKNOWN; var details = 'Unknown Error'; var metadata = new Metadata(); if (err.hasOwnProperty('message')) { details = err.message; } if (err.hasOwnProperty('code')) { code = err.code; if (err.hasOwnProperty('details')) { ...
javascript
function setStatus(err) { var code = constants.status.UNKNOWN; var details = 'Unknown Error'; var metadata = new Metadata(); if (err.hasOwnProperty('message')) { details = err.message; } if (err.hasOwnProperty('code')) { code = err.code; if (err.hasOwnProperty('details')) { ...
[ "function", "setStatus", "(", "err", ")", "{", "var", "code", "=", "constants", ".", "status", ".", "UNKNOWN", ";", "var", "details", "=", "'Unknown Error'", ";", "var", "metadata", "=", "new", "Metadata", "(", ")", ";", "if", "(", "err", ".", "hasOwnP...
Set the pending status to a given error status. If the error does not have code or details properties, the code will be set to grpc.status.UNKNOWN and the details will be set to 'Unknown Error'. @param {Error} err The error object
[ "Set", "the", "pending", "status", "to", "a", "given", "error", "status", ".", "If", "the", "error", "does", "not", "have", "code", "or", "details", "properties", "the", "code", "will", "be", "set", "to", "grpc", ".", "status", ".", "UNKNOWN", "and", "...
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L149-L166
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
setUpReadable
function setUpReadable(stream, deserialize) { stream.deserialize = common.wrapIgnoreNull(deserialize); stream.finished = false; stream.reading = false; stream.terminate = function() { stream.finished = true; stream.on('data', function() {}); }; stream.on('cancelled', function() { stream.termin...
javascript
function setUpReadable(stream, deserialize) { stream.deserialize = common.wrapIgnoreNull(deserialize); stream.finished = false; stream.reading = false; stream.terminate = function() { stream.finished = true; stream.on('data', function() {}); }; stream.on('cancelled', function() { stream.termin...
[ "function", "setUpReadable", "(", "stream", ",", "deserialize", ")", "{", "stream", ".", "deserialize", "=", "common", ".", "wrapIgnoreNull", "(", "deserialize", ")", ";", "stream", ".", "finished", "=", "false", ";", "stream", ".", "reading", "=", "false", ...
Initialize a readable stream. This is used for both the readable and duplex stream constructors. @private @param {Readable} stream The stream to initialize @param {grpc~deserialize} deserialize Deserialization function for incoming data.
[ "Initialize", "a", "readable", "stream", ".", "This", "is", "used", "for", "both", "the", "readable", "and", "duplex", "stream", "constructors", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L200-L213
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
ServerUnaryCall
function ServerUnaryCall(call, metadata) { EventEmitter.call(this); this.call = call; /** * Indicates if the call has been cancelled * @member {boolean} grpc~ServerUnaryCall#cancelled */ this.cancelled = false; /** * The request metadata from the client * @member {grpc.Metadata} grpc~ServerUnar...
javascript
function ServerUnaryCall(call, metadata) { EventEmitter.call(this); this.call = call; /** * Indicates if the call has been cancelled * @member {boolean} grpc~ServerUnaryCall#cancelled */ this.cancelled = false; /** * The request metadata from the client * @member {grpc.Metadata} grpc~ServerUnar...
[ "function", "ServerUnaryCall", "(", "call", ",", "metadata", ")", "{", "EventEmitter", ".", "call", "(", "this", ")", ";", "this", ".", "call", "=", "call", ";", "/**\n * Indicates if the call has been cancelled\n * @member {boolean} grpc~ServerUnaryCall#cancelled\n *...
An EventEmitter. Used for unary calls. @constructor grpc~ServerUnaryCall @extends external:EventEmitter @param {grpc.internal~Call} call The call object associated with the request @param {grpc.Metadata} metadata The request metadata from the client
[ "An", "EventEmitter", ".", "Used", "for", "unary", "calls", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L230-L248
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
ServerWritableStream
function ServerWritableStream(call, metadata, serialize) { Writable.call(this, {objectMode: true}); this.call = call; this.finished = false; setUpWritable(this, serialize); /** * Indicates if the call has been cancelled * @member {boolean} grpc~ServerWritableStream#cancelled */ this.cancelled = fa...
javascript
function ServerWritableStream(call, metadata, serialize) { Writable.call(this, {objectMode: true}); this.call = call; this.finished = false; setUpWritable(this, serialize); /** * Indicates if the call has been cancelled * @member {boolean} grpc~ServerWritableStream#cancelled */ this.cancelled = fa...
[ "function", "ServerWritableStream", "(", "call", ",", "metadata", ",", "serialize", ")", "{", "Writable", ".", "call", "(", "this", ",", "{", "objectMode", ":", "true", "}", ")", ";", "this", ".", "call", "=", "call", ";", "this", ".", "finished", "=",...
A stream that the server can write to. Used for calls that are streaming from the server side. @constructor grpc~ServerWritableStream @extends external:Writable @borrows grpc~ServerUnaryCall#sendMetadata as grpc~ServerWritableStream#sendMetadata @borrows grpc~ServerUnaryCall#getPeer as grpc~ServerWritableStream#getPeer...
[ "A", "stream", "that", "the", "server", "can", "write", "to", ".", "Used", "for", "calls", "that", "are", "streaming", "from", "the", "server", "side", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L270-L291
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
_write
function _write(chunk, encoding, callback) { /* jshint validthis: true */ var batch = {}; var self = this; var message; try { message = this.serialize(chunk); } catch (e) { e.code = constants.status.INTERNAL; callback(e); return; } if (!this.call.metadataSent) { batch[grpc.opType.SEN...
javascript
function _write(chunk, encoding, callback) { /* jshint validthis: true */ var batch = {}; var self = this; var message; try { message = this.serialize(chunk); } catch (e) { e.code = constants.status.INTERNAL; callback(e); return; } if (!this.call.metadataSent) { batch[grpc.opType.SEN...
[ "function", "_write", "(", "chunk", ",", "encoding", ",", "callback", ")", "{", "/* jshint validthis: true */", "var", "batch", "=", "{", "}", ";", "var", "self", "=", "this", ";", "var", "message", ";", "try", "{", "message", "=", "this", ".", "serializ...
Start writing a chunk of data. This is an implementation of a method required for implementing stream.Writable. @private @param {Buffer} chunk The chunk of data to write @param {string} encoding Used to pass write flags @param {function(Error=)} callback Callback to indicate that the write is complete
[ "Start", "writing", "a", "chunk", "of", "data", ".", "This", "is", "an", "implementation", "of", "a", "method", "required", "for", "implementing", "stream", ".", "Writable", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L302-L332
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
ServerReadableStream
function ServerReadableStream(call, metadata, deserialize) { Readable.call(this, {objectMode: true}); this.call = call; setUpReadable(this, deserialize); /** * Indicates if the call has been cancelled * @member {boolean} grpc~ServerReadableStream#cancelled */ this.cancelled = false; /** * The re...
javascript
function ServerReadableStream(call, metadata, deserialize) { Readable.call(this, {objectMode: true}); this.call = call; setUpReadable(this, deserialize); /** * Indicates if the call has been cancelled * @member {boolean} grpc~ServerReadableStream#cancelled */ this.cancelled = false; /** * The re...
[ "function", "ServerReadableStream", "(", "call", ",", "metadata", ",", "deserialize", ")", "{", "Readable", ".", "call", "(", "this", ",", "{", "objectMode", ":", "true", "}", ")", ";", "this", ".", "call", "=", "call", ";", "setUpReadable", "(", "this",...
A stream that the server can read from. Used for calls that are streaming from the client side. @constructor grpc~ServerReadableStream @extends external:Readable @borrows grpc~ServerUnaryCall#sendMetadata as grpc~ServerReadableStream#sendMetadata @borrows grpc~ServerUnaryCall#getPeer as grpc~ServerReadableStream#getPee...
[ "A", "stream", "that", "the", "server", "can", "read", "from", ".", "Used", "for", "calls", "that", "are", "streaming", "from", "the", "client", "side", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L356-L370
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
_read
function _read(size) { /* jshint validthis: true */ var self = this; /** * Callback to be called when a READ event is received. Pushes the data onto * the read queue and starts reading again if applicable * @param {grpc.Event} event READ event object */ function readCallback(err, event) { if (er...
javascript
function _read(size) { /* jshint validthis: true */ var self = this; /** * Callback to be called when a READ event is received. Pushes the data onto * the read queue and starts reading again if applicable * @param {grpc.Event} event READ event object */ function readCallback(err, event) { if (er...
[ "function", "_read", "(", "size", ")", "{", "/* jshint validthis: true */", "var", "self", "=", "this", ";", "/**\n * Callback to be called when a READ event is received. Pushes the data onto\n * the read queue and starts reading again if applicable\n * @param {grpc.Event} event READ e...
Start reading from the gRPC data source. This is an implementation of a method required for implementing stream.Readable @access private @param {number} size Ignored
[ "Start", "reading", "from", "the", "gRPC", "data", "source", ".", "This", "is", "an", "implementation", "of", "a", "method", "required", "for", "implementing", "stream", ".", "Readable" ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L378-L422
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
readCallback
function readCallback(err, event) { if (err) { self.terminate(); return; } if (self.finished) { self.push(null); return; } var data = event.read; var deserialized; try { deserialized = self.deserialize(data); } catch (e) { e.code = constants.status.INT...
javascript
function readCallback(err, event) { if (err) { self.terminate(); return; } if (self.finished) { self.push(null); return; } var data = event.read; var deserialized; try { deserialized = self.deserialize(data); } catch (e) { e.code = constants.status.INT...
[ "function", "readCallback", "(", "err", ",", "event", ")", "{", "if", "(", "err", ")", "{", "self", ".", "terminate", "(", ")", ";", "return", ";", "}", "if", "(", "self", ".", "finished", ")", "{", "self", ".", "push", "(", "null", ")", ";", "...
Callback to be called when a READ event is received. Pushes the data onto the read queue and starts reading again if applicable @param {grpc.Event} event READ event object
[ "Callback", "to", "be", "called", "when", "a", "READ", "event", "is", "received", ".", "Pushes", "the", "data", "onto", "the", "read", "queue", "and", "starts", "reading", "again", "if", "applicable" ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L386-L411
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
ServerDuplexStream
function ServerDuplexStream(call, metadata, serialize, deserialize) { Duplex.call(this, {objectMode: true}); this.call = call; setUpWritable(this, serialize); setUpReadable(this, deserialize); /** * Indicates if the call has been cancelled * @member {boolean} grpc~ServerReadableStream#cancelled */ ...
javascript
function ServerDuplexStream(call, metadata, serialize, deserialize) { Duplex.call(this, {objectMode: true}); this.call = call; setUpWritable(this, serialize); setUpReadable(this, deserialize); /** * Indicates if the call has been cancelled * @member {boolean} grpc~ServerReadableStream#cancelled */ ...
[ "function", "ServerDuplexStream", "(", "call", ",", "metadata", ",", "serialize", ",", "deserialize", ")", "{", "Duplex", ".", "call", "(", "this", ",", "{", "objectMode", ":", "true", "}", ")", ";", "this", ".", "call", "=", "call", ";", "setUpWritable"...
A stream that the server can read from or write to. Used for calls with duplex streaming. @constructor grpc~ServerDuplexStream @extends external:Duplex @borrows grpc~ServerUnaryCall#sendMetadata as grpc~ServerDuplexStream#sendMetadata @borrows grpc~ServerUnaryCall#getPeer as grpc~ServerDuplexStream#getPeer @param {grpc...
[ "A", "stream", "that", "the", "server", "can", "read", "from", "or", "write", "to", ".", "Used", "for", "calls", "with", "duplex", "streaming", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L448-L463
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
sendMetadata
function sendMetadata(responseMetadata) { /* jshint validthis: true */ var self = this; if (!this.call.metadataSent) { this.call.metadataSent = true; var batch = {}; batch[grpc.opType.SEND_INITIAL_METADATA] = responseMetadata._getCoreRepresentation(); this.call.startBatch(batch, function(e...
javascript
function sendMetadata(responseMetadata) { /* jshint validthis: true */ var self = this; if (!this.call.metadataSent) { this.call.metadataSent = true; var batch = {}; batch[grpc.opType.SEND_INITIAL_METADATA] = responseMetadata._getCoreRepresentation(); this.call.startBatch(batch, function(e...
[ "function", "sendMetadata", "(", "responseMetadata", ")", "{", "/* jshint validthis: true */", "var", "self", "=", "this", ";", "if", "(", "!", "this", ".", "call", ".", "metadataSent", ")", "{", "this", ".", "call", ".", "metadataSent", "=", "true", ";", ...
Send the initial metadata for a writable stream. @alias grpc~ServerUnaryCall#sendMetadata @param {grpc.Metadata} responseMetadata Metadata to send
[ "Send", "the", "initial", "metadata", "for", "a", "writable", "stream", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L473-L488
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
waitForCancel
function waitForCancel() { /* jshint validthis: true */ var self = this; var cancel_batch = {}; cancel_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true; self.call.startBatch(cancel_batch, function(err, result) { if (err) { self.emit('error', err); } if (result.cancelled) { self.cancelled...
javascript
function waitForCancel() { /* jshint validthis: true */ var self = this; var cancel_batch = {}; cancel_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true; self.call.startBatch(cancel_batch, function(err, result) { if (err) { self.emit('error', err); } if (result.cancelled) { self.cancelled...
[ "function", "waitForCancel", "(", ")", "{", "/* jshint validthis: true */", "var", "self", "=", "this", ";", "var", "cancel_batch", "=", "{", "}", ";", "cancel_batch", "[", "grpc", ".", "opType", ".", "RECV_CLOSE_ON_SERVER", "]", "=", "true", ";", "self", "....
Wait for the client to close, then emit a cancelled event if the client cancelled. @private
[ "Wait", "for", "the", "client", "to", "close", "then", "emit", "a", "cancelled", "event", "if", "the", "client", "cancelled", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L515-L529
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
handleUnary
function handleUnary(call, handler, metadata) { var emitter = new ServerUnaryCall(call, metadata); emitter.on('error', function(error) { handleError(call, error); }); emitter.waitForCancel(); var batch = {}; batch[grpc.opType.RECV_MESSAGE] = true; call.startBatch(batch, function(err, result) { if ...
javascript
function handleUnary(call, handler, metadata) { var emitter = new ServerUnaryCall(call, metadata); emitter.on('error', function(error) { handleError(call, error); }); emitter.waitForCancel(); var batch = {}; batch[grpc.opType.RECV_MESSAGE] = true; call.startBatch(batch, function(err, result) { if ...
[ "function", "handleUnary", "(", "call", ",", "handler", ",", "metadata", ")", "{", "var", "emitter", "=", "new", "ServerUnaryCall", "(", "call", ",", "metadata", ")", ";", "emitter", ".", "on", "(", "'error'", ",", "function", "(", "error", ")", "{", "...
User-provided method to handle unary requests on a server @callback grpc.Server~handleUnaryCall @param {grpc~ServerUnaryCall} call The call object @param {grpc.Server~sendUnaryData} callback The callback to call to respond to the request Fully handle a unary call @private @param {grpc.internal~Call} call The call to ...
[ "User", "-", "provided", "method", "to", "handle", "unary", "requests", "on", "a", "server" ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L567-L601
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
handleServerStreaming
function handleServerStreaming(call, handler, metadata) { var stream = new ServerWritableStream(call, metadata, handler.serialize); stream.waitForCancel(); var batch = {}; batch[grpc.opType.RECV_MESSAGE] = true; call.startBatch(batch, function(err, result) { if (err) { stream.emit('error', err); ...
javascript
function handleServerStreaming(call, handler, metadata) { var stream = new ServerWritableStream(call, metadata, handler.serialize); stream.waitForCancel(); var batch = {}; batch[grpc.opType.RECV_MESSAGE] = true; call.startBatch(batch, function(err, result) { if (err) { stream.emit('error', err); ...
[ "function", "handleServerStreaming", "(", "call", ",", "handler", ",", "metadata", ")", "{", "var", "stream", "=", "new", "ServerWritableStream", "(", "call", ",", "metadata", ",", "handler", ".", "serialize", ")", ";", "stream", ".", "waitForCancel", "(", "...
User provided method to handle server streaming methods on the server. @callback grpc.Server~handleServerStreamingCall @param {grpc~ServerWritableStream} call The call object Fully handle a server streaming call @private @param {grpc.internal~Call} call The call to handle @param {Object} handler Request handler objec...
[ "User", "provided", "method", "to", "handle", "server", "streaming", "methods", "on", "the", "server", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L622-L641
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
handleClientStreaming
function handleClientStreaming(call, handler, metadata) { var stream = new ServerReadableStream(call, metadata, handler.deserialize); stream.on('error', function(error) { handleError(call, error); }); stream.waitForCancel(); handler.func(stream, function(err, value, trailer, flags) { stream.terminate(...
javascript
function handleClientStreaming(call, handler, metadata) { var stream = new ServerReadableStream(call, metadata, handler.deserialize); stream.on('error', function(error) { handleError(call, error); }); stream.waitForCancel(); handler.func(stream, function(err, value, trailer, flags) { stream.terminate(...
[ "function", "handleClientStreaming", "(", "call", ",", "handler", ",", "metadata", ")", "{", "var", "stream", "=", "new", "ServerReadableStream", "(", "call", ",", "metadata", ",", "handler", ".", "deserialize", ")", ";", "stream", ".", "on", "(", "'error'",...
User provided method to handle client streaming methods on the server. @callback grpc.Server~handleClientStreamingCall @param {grpc~ServerReadableStream} call The call object @param {grpc.Server~sendUnaryData} callback The callback to call to respond to the request Fully handle a client streaming call @access private...
[ "User", "provided", "method", "to", "handle", "client", "streaming", "methods", "on", "the", "server", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L664-L681
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
handleBidiStreaming
function handleBidiStreaming(call, handler, metadata) { var stream = new ServerDuplexStream(call, metadata, handler.serialize, handler.deserialize); stream.waitForCancel(); handler.func(stream); }
javascript
function handleBidiStreaming(call, handler, metadata) { var stream = new ServerDuplexStream(call, metadata, handler.serialize, handler.deserialize); stream.waitForCancel(); handler.func(stream); }
[ "function", "handleBidiStreaming", "(", "call", ",", "handler", ",", "metadata", ")", "{", "var", "stream", "=", "new", "ServerDuplexStream", "(", "call", ",", "metadata", ",", "handler", ".", "serialize", ",", "handler", ".", "deserialize", ")", ";", "strea...
User provided method to handle bidirectional streaming calls on the server. @callback grpc.Server~handleBidiStreamingCall @param {grpc~ServerDuplexStream} call The call object Fully handle a bidirectional streaming call @private @param {grpc.internal~Call} call The call to handle @param {Object} handler Request handl...
[ "User", "provided", "method", "to", "handle", "bidirectional", "streaming", "calls", "on", "the", "server", "." ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L702-L707
train
grpc/grpc-node
packages/grpc-native-core/src/server.js
Server
function Server(options) { this.handlers = {}; var server = new grpc.Server(options); this._server = server; this.started = false; }
javascript
function Server(options) { this.handlers = {}; var server = new grpc.Server(options); this._server = server; this.started = false; }
[ "function", "Server", "(", "options", ")", "{", "this", ".", "handlers", "=", "{", "}", ";", "var", "server", "=", "new", "grpc", ".", "Server", "(", "options", ")", ";", "this", ".", "_server", "=", "server", ";", "this", ".", "started", "=", "fal...
Constructs a server object that stores request handlers and delegates incoming requests to those handlers @memberof grpc @constructor @param {Object=} options Options that should be passed to the internal server implementation @example var server = new grpc.Server(); server.addProtoService(protobuf_service_descriptor, ...
[ "Constructs", "a", "server", "object", "that", "stores", "request", "handlers", "and", "delegates", "incoming", "requests", "to", "those", "handlers" ]
b36b285f4cdb334bbd48f74c12c13bec69961488
https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L729-L734
train
angular/material
src/components/colors/colors.spec.js
checkColorMode
function checkColorMode() { if (angular.isUndefined(usesRGBA)) { var testerElement = compile('<div md-colors="{background: \'red\'}" >'); usesRGBA = testerElement[0].style.background.indexOf('rgba') === 0; } }
javascript
function checkColorMode() { if (angular.isUndefined(usesRGBA)) { var testerElement = compile('<div md-colors="{background: \'red\'}" >'); usesRGBA = testerElement[0].style.background.indexOf('rgba') === 0; } }
[ "function", "checkColorMode", "(", ")", "{", "if", "(", "angular", ".", "isUndefined", "(", "usesRGBA", ")", ")", "{", "var", "testerElement", "=", "compile", "(", "'<div md-colors=\"{background: \\'red\\'}\" >'", ")", ";", "usesRGBA", "=", "testerElement", "[", ...
Checks whether the current browser uses RGB or RGBA colors. This is necessary, because IE and Edge automatically convert RGB colors to RGBA.
[ "Checks", "whether", "the", "current", "browser", "uses", "RGB", "or", "RGBA", "colors", ".", "This", "is", "necessary", "because", "IE", "and", "Edge", "automatically", "convert", "RGB", "colors", "to", "RGBA", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/colors/colors.spec.js#L49-L54
train
angular/material
src/core/services/registry/componentRegistry.js
function(handle) { if (!isValidID(handle)) return null; var i, j, instance; for (i = 0, j = instances.length; i < j; i++) { instance = instances[i]; if (instance.$$mdHandle === handle) { return instance; } } return null; }
javascript
function(handle) { if (!isValidID(handle)) return null; var i, j, instance; for (i = 0, j = instances.length; i < j; i++) { instance = instances[i]; if (instance.$$mdHandle === handle) { return instance; } } return null; }
[ "function", "(", "handle", ")", "{", "if", "(", "!", "isValidID", "(", "handle", ")", ")", "return", "null", ";", "var", "i", ",", "j", ",", "instance", ";", "for", "(", "i", "=", "0", ",", "j", "=", "instances", ".", "length", ";", "i", "<", ...
Get a registered instance. @param handle the String handle to look up for a registered instance.
[ "Get", "a", "registered", "instance", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/registry/componentRegistry.js#L43-L54
train
angular/material
src/core/services/registry/componentRegistry.js
function(instance, handle) { if (!handle) return angular.noop; instance.$$mdHandle = handle; instances.push(instance); resolveWhen(); return deregister; /** * Remove registration for an instance */ function deregister() { var index =...
javascript
function(instance, handle) { if (!handle) return angular.noop; instance.$$mdHandle = handle; instances.push(instance); resolveWhen(); return deregister; /** * Remove registration for an instance */ function deregister() { var index =...
[ "function", "(", "instance", ",", "handle", ")", "{", "if", "(", "!", "handle", ")", "return", "angular", ".", "noop", ";", "instance", ".", "$$mdHandle", "=", "handle", ";", "instances", ".", "push", "(", "instance", ")", ";", "resolveWhen", "(", ")",...
Register an instance. @param instance the instance to register @param handle the handle to identify the instance under.
[ "Register", "an", "instance", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/registry/componentRegistry.js#L61-L92
train
angular/material
src/core/services/registry/componentRegistry.js
resolveWhen
function resolveWhen() { var dfd = pendings[handle]; if (dfd) { dfd.forEach(function (promise) { promise.resolve(instance); }); delete pendings[handle]; } }
javascript
function resolveWhen() { var dfd = pendings[handle]; if (dfd) { dfd.forEach(function (promise) { promise.resolve(instance); }); delete pendings[handle]; } }
[ "function", "resolveWhen", "(", ")", "{", "var", "dfd", "=", "pendings", "[", "handle", "]", ";", "if", "(", "dfd", ")", "{", "dfd", ".", "forEach", "(", "function", "(", "promise", ")", "{", "promise", ".", "resolve", "(", "instance", ")", ";", "}...
Resolve any pending promises for this instance
[ "Resolve", "any", "pending", "promises", "for", "this", "instance" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/registry/componentRegistry.js#L83-L91
train
angular/material
src/core/services/registry/componentRegistry.js
function(handle) { if (isValidID(handle)) { var deferred = $q.defer(); var instance = self.get(handle); if (instance) { deferred.resolve(instance); } else { if (pendings[handle] === undefined) { pendings[handle] = []; } ...
javascript
function(handle) { if (isValidID(handle)) { var deferred = $q.defer(); var instance = self.get(handle); if (instance) { deferred.resolve(instance); } else { if (pendings[handle] === undefined) { pendings[handle] = []; } ...
[ "function", "(", "handle", ")", "{", "if", "(", "isValidID", "(", "handle", ")", ")", "{", "var", "deferred", "=", "$q", ".", "defer", "(", ")", ";", "var", "instance", "=", "self", ".", "get", "(", "handle", ")", ";", "if", "(", "instance", ")",...
Async accessor to registered component instance If not available then a promise is created to notify all listeners when the instance is registered.
[ "Async", "accessor", "to", "registered", "component", "instance", "If", "not", "available", "then", "a", "promise", "is", "created", "to", "notify", "all", "listeners", "when", "the", "instance", "is", "registered", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/registry/componentRegistry.js#L99-L116
train
angular/material
src/components/chips/demoCustomInputs/script.js
querySearch
function querySearch (query) { var results = query ? self.vegetables.filter(createFilterFor(query)) : []; return results; }
javascript
function querySearch (query) { var results = query ? self.vegetables.filter(createFilterFor(query)) : []; return results; }
[ "function", "querySearch", "(", "query", ")", "{", "var", "results", "=", "query", "?", "self", ".", "vegetables", ".", "filter", "(", "createFilterFor", "(", "query", ")", ")", ":", "[", "]", ";", "return", "results", ";", "}" ]
Search for vegetables.
[ "Search", "for", "vegetables", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/chips/demoCustomInputs/script.js#L38-L41
train
angular/material
src/components/icon/icon.spec.js
clean
function clean(style) { return style .replace(/ng-scope|ng-isolate-scope|md-default-theme/gi,'') .replace(/\s\s+/g,' ') .replace(/\s+"/g,'"') .trim(); }
javascript
function clean(style) { return style .replace(/ng-scope|ng-isolate-scope|md-default-theme/gi,'') .replace(/\s\s+/g,' ') .replace(/\s+"/g,'"') .trim(); }
[ "function", "clean", "(", "style", ")", "{", "return", "style", ".", "replace", "(", "/", "ng-scope|ng-isolate-scope|md-default-theme", "/", "gi", ",", "''", ")", ".", "replace", "(", "/", "\\s\\s+", "/", "g", ",", "' '", ")", ".", "replace", "(", "/", ...
Utility to remove extra attributes to the specs are easy to compare
[ "Utility", "to", "remove", "extra", "attributes", "to", "the", "specs", "are", "easy", "to", "compare" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/icon/icon.spec.js#L384-L390
train
angular/material
docs/app/js/codepen.js
Codepen
function Codepen($demoAngularScripts, $document, codepenDataAdapter) { // The following URL used to be HTTP and not HTTPS to allow us to do localhost testing // It's no longer working, for more info: // https://blog.codepen.io/2017/03/31/codepen-going-https/ var CODEPEN_API = 'https://codepen.io/pen/de...
javascript
function Codepen($demoAngularScripts, $document, codepenDataAdapter) { // The following URL used to be HTTP and not HTTPS to allow us to do localhost testing // It's no longer working, for more info: // https://blog.codepen.io/2017/03/31/codepen-going-https/ var CODEPEN_API = 'https://codepen.io/pen/de...
[ "function", "Codepen", "(", "$demoAngularScripts", ",", "$document", ",", "codepenDataAdapter", ")", "{", "// The following URL used to be HTTP and not HTTPS to allow us to do localhost testing", "// It's no longer working, for more info:", "// https://blog.codepen.io/2017/03/31/codepen-goin...
Provides a service to open a code example in codepen.
[ "Provides", "a", "service", "to", "open", "a", "code", "example", "in", "codepen", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/codepen.js#L7-L57
train
angular/material
docs/app/js/codepen.js
buildForm
function buildForm(data) { var form = angular.element( '<form style="display: none;" method="post" target="_blank" action="' + CODEPEN_API + '"></form>' ); var input = '<input type="hidden" name="data" value="' + escapeJsonQuotes(data) + '" />'; form.append(input); ...
javascript
function buildForm(data) { var form = angular.element( '<form style="display: none;" method="post" target="_blank" action="' + CODEPEN_API + '"></form>' ); var input = '<input type="hidden" name="data" value="' + escapeJsonQuotes(data) + '" />'; form.append(input); ...
[ "function", "buildForm", "(", "data", ")", "{", "var", "form", "=", "angular", ".", "element", "(", "'<form style=\"display: none;\" method=\"post\" target=\"_blank\" action=\"'", "+", "CODEPEN_API", "+", "'\"></form>'", ")", ";", "var", "input", "=", "'<input type=\"hi...
Builds a hidden form with data necessary to create a codepen.
[ "Builds", "a", "hidden", "form", "with", "data", "necessary", "to", "create", "a", "codepen", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/codepen.js#L32-L41
train
angular/material
docs/app/js/codepen.js
processHtml
function processHtml(demo) { var allContent = demo.files.index.contents; var processors = [ applyAngularAttributesToParentElement, insertTemplatesAsScriptTags, htmlEscapeAmpersand ]; processors.forEach(function(processor) { allContent = processor(allContent, de...
javascript
function processHtml(demo) { var allContent = demo.files.index.contents; var processors = [ applyAngularAttributesToParentElement, insertTemplatesAsScriptTags, htmlEscapeAmpersand ]; processors.forEach(function(processor) { allContent = processor(allContent, de...
[ "function", "processHtml", "(", "demo", ")", "{", "var", "allContent", "=", "demo", ".", "files", ".", "index", ".", "contents", ";", "var", "processors", "=", "[", "applyAngularAttributesToParentElement", ",", "insertTemplatesAsScriptTags", ",", "htmlEscapeAmpersan...
Modifies index.html with necessary changes in order to display correctly in codepen See each processor to determine how each modifies the html
[ "Modifies", "index", ".", "html", "with", "necessary", "changes", "in", "order", "to", "display", "correctly", "in", "codepen", "See", "each", "processor", "to", "determine", "how", "each", "modifies", "the", "html" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/codepen.js#L98-L113
train
angular/material
docs/app/js/codepen.js
processJs
function processJs(jsFiles) { var mergedJs = mergeFiles(jsFiles).join(' '); var script = replaceDemoModuleWithCodepenModule(mergedJs); return script; }
javascript
function processJs(jsFiles) { var mergedJs = mergeFiles(jsFiles).join(' '); var script = replaceDemoModuleWithCodepenModule(mergedJs); return script; }
[ "function", "processJs", "(", "jsFiles", ")", "{", "var", "mergedJs", "=", "mergeFiles", "(", "jsFiles", ")", ".", "join", "(", "' '", ")", ";", "var", "script", "=", "replaceDemoModuleWithCodepenModule", "(", "mergedJs", ")", ";", "return", "script", ";", ...
Applies modifications the javascript prior to sending to codepen. Currently merges js files and replaces the module with the Codepen module. See documentation for replaceDemoModuleWithCodepenModule.
[ "Applies", "modifications", "the", "javascript", "prior", "to", "sending", "to", "codepen", ".", "Currently", "merges", "js", "files", "and", "replaces", "the", "module", "with", "the", "Codepen", "module", ".", "See", "documentation", "for", "replaceDemoModuleWit...
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/codepen.js#L148-L152
train
angular/material
docs/app/js/codepen.js
applyAngularAttributesToParentElement
function applyAngularAttributesToParentElement(html, demo) { var tmp; // Grab only the DIV for the demo... angular.forEach(angular.element(html), function(it,key){ if ((it.nodeName != "SCRIPT") && (it.nodeName != "#text")) { tmp = angular.element(it); } }); tmp....
javascript
function applyAngularAttributesToParentElement(html, demo) { var tmp; // Grab only the DIV for the demo... angular.forEach(angular.element(html), function(it,key){ if ((it.nodeName != "SCRIPT") && (it.nodeName != "#text")) { tmp = angular.element(it); } }); tmp....
[ "function", "applyAngularAttributesToParentElement", "(", "html", ",", "demo", ")", "{", "var", "tmp", ";", "// Grab only the DIV for the demo...", "angular", ".", "forEach", "(", "angular", ".", "element", "(", "html", ")", ",", "function", "(", "it", ",", "key...
Adds class to parent element so that styles are applied correctly Adds ng-app attribute. This is the same module name provided in the asset-cache.js
[ "Adds", "class", "to", "parent", "element", "so", "that", "styles", "are", "applied", "correctly", "Adds", "ng", "-", "app", "attribute", ".", "This", "is", "the", "same", "module", "name", "provided", "in", "the", "asset", "-", "cache", ".", "js" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/codepen.js#L163-L176
train
angular/material
docs/app/js/codepen.js
insertTemplatesAsScriptTags
function insertTemplatesAsScriptTags(indexHtml, demo) { if (demo.files.html.length) { var tmp = angular.element(indexHtml); angular.forEach(demo.files.html, function(template) { tmp.append("<script type='text/ng-template' id='" + template.name + "'>" + ...
javascript
function insertTemplatesAsScriptTags(indexHtml, demo) { if (demo.files.html.length) { var tmp = angular.element(indexHtml); angular.forEach(demo.files.html, function(template) { tmp.append("<script type='text/ng-template' id='" + template.name + "'>" + ...
[ "function", "insertTemplatesAsScriptTags", "(", "indexHtml", ",", "demo", ")", "{", "if", "(", "demo", ".", "files", ".", "html", ".", "length", ")", "{", "var", "tmp", "=", "angular", ".", "element", "(", "indexHtml", ")", ";", "angular", ".", "forEach"...
Adds templates inline in the html, so that templates are cached in the example
[ "Adds", "templates", "inline", "in", "the", "html", "so", "that", "templates", "are", "cached", "in", "the", "example" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/codepen.js#L179-L191
train
angular/material
src/components/colors/colors.js
parseColor
function parseColor(color, contrast) { contrast = contrast || false; var rgbValues = $mdTheming.PALETTES[color.palette][color.hue]; rgbValues = contrast ? rgbValues.contrast : rgbValues.value; return $mdUtil.supplant('rgba({0}, {1}, {2}, {3})', [rgbValues[0], rgbValues[1], rgbValues[2]...
javascript
function parseColor(color, contrast) { contrast = contrast || false; var rgbValues = $mdTheming.PALETTES[color.palette][color.hue]; rgbValues = contrast ? rgbValues.contrast : rgbValues.value; return $mdUtil.supplant('rgba({0}, {1}, {2}, {3})', [rgbValues[0], rgbValues[1], rgbValues[2]...
[ "function", "parseColor", "(", "color", ",", "contrast", ")", "{", "contrast", "=", "contrast", "||", "false", ";", "var", "rgbValues", "=", "$mdTheming", ".", "PALETTES", "[", "color", ".", "palette", "]", "[", "color", ".", "hue", "]", ";", "rgbValues"...
Return the parsed color @param {{hue: *, theme: any, palette: *, opacity: (*|string|number)}} color hash map of color definitions @param {boolean=} contrast whether use contrast color for foreground. Defaults to false. @returns {string} rgba color string
[ "Return", "the", "parsed", "color" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/colors/colors.js#L120-L129
train
angular/material
src/components/colors/colors.js
extractColorOptions
function extractColorOptions(expression) { var parts = expression.split('-'); var hasTheme = angular.isDefined($mdTheming.THEMES[parts[0]]); var theme = hasTheme ? parts.splice(0, 1)[0] : $mdTheming.defaultTheme(); return { theme: theme, palette: extractPalette(parts, theme), ...
javascript
function extractColorOptions(expression) { var parts = expression.split('-'); var hasTheme = angular.isDefined($mdTheming.THEMES[parts[0]]); var theme = hasTheme ? parts.splice(0, 1)[0] : $mdTheming.defaultTheme(); return { theme: theme, palette: extractPalette(parts, theme), ...
[ "function", "extractColorOptions", "(", "expression", ")", "{", "var", "parts", "=", "expression", ".", "split", "(", "'-'", ")", ";", "var", "hasTheme", "=", "angular", ".", "isDefined", "(", "$mdTheming", ".", "THEMES", "[", "parts", "[", "0", "]", "]"...
For the evaluated expression, extract the color parts into a hash map @param {string} expression color expression like 'red-800', 'red-A200-0.3', 'myTheme-primary', or 'myTheme-primary-400' @returns {{hue: *, theme: any, palette: *, opacity: (*|string|number)}}
[ "For", "the", "evaluated", "expression", "extract", "the", "color", "parts", "into", "a", "hash", "map" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/colors/colors.js#L175-L186
train
angular/material
src/components/colors/colors.js
extractPalette
function extractPalette(parts, theme) { // If the next section is one of the palettes we assume it's a two word palette // Two word palette can be also written in camelCase, forming camelCase to dash-case var isTwoWord = parts.length > 1 && colorPalettes.indexOf(parts[1]) !== -1; var palette = ...
javascript
function extractPalette(parts, theme) { // If the next section is one of the palettes we assume it's a two word palette // Two word palette can be also written in camelCase, forming camelCase to dash-case var isTwoWord = parts.length > 1 && colorPalettes.indexOf(parts[1]) !== -1; var palette = ...
[ "function", "extractPalette", "(", "parts", ",", "theme", ")", "{", "// If the next section is one of the palettes we assume it's a two word palette", "// Two word palette can be also written in camelCase, forming camelCase to dash-case", "var", "isTwoWord", "=", "parts", ".", "length"...
Calculate the theme palette name @param {Array} parts @param {string} theme name @return {string}
[ "Calculate", "the", "theme", "palette", "name" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/colors/colors.js#L194-L215
train
angular/material
src/components/tabs/js/tabsController.js
compileTemplate
function compileTemplate () { var template = $attrs.$mdTabsTemplate, element = angular.element($element[0].querySelector('md-tab-data')); element.html(template); $compile(element.contents())(ctrl.parent); delete $attrs.$mdTabsTemplate; }
javascript
function compileTemplate () { var template = $attrs.$mdTabsTemplate, element = angular.element($element[0].querySelector('md-tab-data')); element.html(template); $compile(element.contents())(ctrl.parent); delete $attrs.$mdTabsTemplate; }
[ "function", "compileTemplate", "(", ")", "{", "var", "template", "=", "$attrs", ".", "$mdTabsTemplate", ",", "element", "=", "angular", ".", "element", "(", "$element", "[", "0", "]", ".", "querySelector", "(", "'md-tab-data'", ")", ")", ";", "element", "....
Compiles the template provided by the user. This is passed as an attribute from the tabs directive's template function.
[ "Compiles", "the", "template", "provided", "by", "the", "user", ".", "This", "is", "passed", "as", "an", "attribute", "from", "the", "tabs", "directive", "s", "template", "function", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L110-L117
train
angular/material
src/components/tabs/js/tabsController.js
defineOneWayBinding
function defineOneWayBinding (key, handler) { var attr = $attrs.$normalize('md-' + key); if (handler) defineProperty(key, handler); $attrs.$observe(attr, function (newValue) { ctrl[ key ] = newValue; }); }
javascript
function defineOneWayBinding (key, handler) { var attr = $attrs.$normalize('md-' + key); if (handler) defineProperty(key, handler); $attrs.$observe(attr, function (newValue) { ctrl[ key ] = newValue; }); }
[ "function", "defineOneWayBinding", "(", "key", ",", "handler", ")", "{", "var", "attr", "=", "$attrs", ".", "$normalize", "(", "'md-'", "+", "key", ")", ";", "if", "(", "handler", ")", "defineProperty", "(", "key", ",", "handler", ")", ";", "$attrs", "...
Creates a one-way binding manually rather than relying on AngularJS's isolated scope @param key @param handler
[ "Creates", "a", "one", "-", "way", "binding", "manually", "rather", "than", "relying", "on", "AngularJS", "s", "isolated", "scope" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L139-L143
train
angular/material
src/components/tabs/js/tabsController.js
defineBooleanAttribute
function defineBooleanAttribute (key, handler) { var attr = $attrs.$normalize('md-' + key); if (handler) defineProperty(key, handler); if ($attrs.hasOwnProperty(attr)) updateValue($attrs[attr]); $attrs.$observe(attr, updateValue); function updateValue (newValue) { ctrl[ key ] = newValue !== 'f...
javascript
function defineBooleanAttribute (key, handler) { var attr = $attrs.$normalize('md-' + key); if (handler) defineProperty(key, handler); if ($attrs.hasOwnProperty(attr)) updateValue($attrs[attr]); $attrs.$observe(attr, updateValue); function updateValue (newValue) { ctrl[ key ] = newValue !== 'f...
[ "function", "defineBooleanAttribute", "(", "key", ",", "handler", ")", "{", "var", "attr", "=", "$attrs", ".", "$normalize", "(", "'md-'", "+", "key", ")", ";", "if", "(", "handler", ")", "defineProperty", "(", "key", ",", "handler", ")", ";", "if", "(...
Defines boolean attributes with default value set to true. I.e. md-stretch-tabs with no value will be treated as being truthy. @param {string} key @param {Function} handler
[ "Defines", "boolean", "attributes", "with", "default", "value", "set", "to", "true", ".", "I", ".", "e", ".", "md", "-", "stretch", "-", "tabs", "with", "no", "value", "will", "be", "treated", "as", "being", "truthy", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L151-L159
train
angular/material
src/components/tabs/js/tabsController.js
handleFocusIndexChange
function handleFocusIndexChange (newIndex, oldIndex) { if (newIndex === oldIndex) return; if (!getElements().tabs[ newIndex ]) return; adjustOffset(); redirectFocus(); }
javascript
function handleFocusIndexChange (newIndex, oldIndex) { if (newIndex === oldIndex) return; if (!getElements().tabs[ newIndex ]) return; adjustOffset(); redirectFocus(); }
[ "function", "handleFocusIndexChange", "(", "newIndex", ",", "oldIndex", ")", "{", "if", "(", "newIndex", "===", "oldIndex", ")", "return", ";", "if", "(", "!", "getElements", "(", ")", ".", "tabs", "[", "newIndex", "]", ")", "return", ";", "adjustOffset", ...
Update the UI whenever `ctrl.focusIndex` is updated @param {number} newIndex @param {number} oldIndex
[ "Update", "the", "UI", "whenever", "ctrl", ".", "focusIndex", "is", "updated" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L248-L253
train
angular/material
src/components/tabs/js/tabsController.js
handleResizeWhenVisible
function handleResizeWhenVisible () { // if there is already a watcher waiting for resize, do nothing if (handleResizeWhenVisible.watcher) return; // otherwise, we will abuse the $watch function to check for visible handleResizeWhenVisible.watcher = $scope.$watch(function () { // since we are chec...
javascript
function handleResizeWhenVisible () { // if there is already a watcher waiting for resize, do nothing if (handleResizeWhenVisible.watcher) return; // otherwise, we will abuse the $watch function to check for visible handleResizeWhenVisible.watcher = $scope.$watch(function () { // since we are chec...
[ "function", "handleResizeWhenVisible", "(", ")", "{", "// if there is already a watcher waiting for resize, do nothing", "if", "(", "handleResizeWhenVisible", ".", "watcher", ")", "return", ";", "// otherwise, we will abuse the $watch function to check for visible", "handleResizeWhenVi...
Queues up a call to `handleWindowResize` when a resize occurs while the tabs component is hidden.
[ "Queues", "up", "a", "call", "to", "handleWindowResize", "when", "a", "resize", "occurs", "while", "the", "tabs", "component", "is", "hidden", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L282-L300
train
angular/material
src/components/tabs/js/tabsController.js
select
function select (index, canSkipClick) { if (!locked) ctrl.focusIndex = ctrl.selectedIndex = index; // skip the click event if noSelectClick is enabled if (canSkipClick && ctrl.noSelectClick) return; // nextTick is required to prevent errors in user-defined click events $mdUtil.nextTick(function () {...
javascript
function select (index, canSkipClick) { if (!locked) ctrl.focusIndex = ctrl.selectedIndex = index; // skip the click event if noSelectClick is enabled if (canSkipClick && ctrl.noSelectClick) return; // nextTick is required to prevent errors in user-defined click events $mdUtil.nextTick(function () {...
[ "function", "select", "(", "index", ",", "canSkipClick", ")", "{", "if", "(", "!", "locked", ")", "ctrl", ".", "focusIndex", "=", "ctrl", ".", "selectedIndex", "=", "index", ";", "// skip the click event if noSelectClick is enabled", "if", "(", "canSkipClick", "...
Update the selected index. Triggers a click event on the original `md-tab` element in order to fire user-added click events if canSkipClick or `md-no-select-click` are false. @param index @param canSkipClick Optionally allow not firing the click event if `md-no-select-click` is also true.
[ "Update", "the", "selected", "index", ".", "Triggers", "a", "click", "event", "on", "the", "original", "md", "-", "tab", "element", "in", "order", "to", "fire", "user", "-", "added", "click", "events", "if", "canSkipClick", "or", "md", "-", "no", "-", ...
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L339-L347
train
angular/material
src/components/tabs/js/tabsController.js
scroll
function scroll (event) { if (!ctrl.shouldPaginate) return; event.preventDefault(); if (event.deltaY) { ctrl.offsetLeft = fixOffset(ctrl.offsetLeft + event.deltaY); } else if (event.deltaX) { ctrl.offsetLeft = fixOffset(ctrl.offsetLeft + event.deltaX); } }
javascript
function scroll (event) { if (!ctrl.shouldPaginate) return; event.preventDefault(); if (event.deltaY) { ctrl.offsetLeft = fixOffset(ctrl.offsetLeft + event.deltaY); } else if (event.deltaX) { ctrl.offsetLeft = fixOffset(ctrl.offsetLeft + event.deltaX); } }
[ "function", "scroll", "(", "event", ")", "{", "if", "(", "!", "ctrl", ".", "shouldPaginate", ")", "return", ";", "event", ".", "preventDefault", "(", ")", ";", "if", "(", "event", ".", "deltaY", ")", "{", "ctrl", ".", "offsetLeft", "=", "fixOffset", ...
When pagination is on, this makes sure the selected index is in view. @param {WheelEvent} event
[ "When", "pagination", "is", "on", "this", "makes", "sure", "the", "selected", "index", "is", "in", "view", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L353-L361
train
angular/material
src/components/tabs/js/tabsController.js
nextPage
function nextPage () { if (!ctrl.canPageForward()) { return; } var newOffset = MdTabsPaginationService.increasePageOffset(getElements(), ctrl.offsetLeft); ctrl.offsetLeft = fixOffset(newOffset); }
javascript
function nextPage () { if (!ctrl.canPageForward()) { return; } var newOffset = MdTabsPaginationService.increasePageOffset(getElements(), ctrl.offsetLeft); ctrl.offsetLeft = fixOffset(newOffset); }
[ "function", "nextPage", "(", ")", "{", "if", "(", "!", "ctrl", ".", "canPageForward", "(", ")", ")", "{", "return", ";", "}", "var", "newOffset", "=", "MdTabsPaginationService", ".", "increasePageOffset", "(", "getElements", "(", ")", ",", "ctrl", ".", "...
Slides the tabs over approximately one page forward.
[ "Slides", "the", "tabs", "over", "approximately", "one", "page", "forward", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L366-L372
train
angular/material
src/components/tabs/js/tabsController.js
previousPage
function previousPage () { if (!ctrl.canPageBack()) { return; } var newOffset = MdTabsPaginationService.decreasePageOffset(getElements(), ctrl.offsetLeft); // Set the new offset ctrl.offsetLeft = fixOffset(newOffset); }
javascript
function previousPage () { if (!ctrl.canPageBack()) { return; } var newOffset = MdTabsPaginationService.decreasePageOffset(getElements(), ctrl.offsetLeft); // Set the new offset ctrl.offsetLeft = fixOffset(newOffset); }
[ "function", "previousPage", "(", ")", "{", "if", "(", "!", "ctrl", ".", "canPageBack", "(", ")", ")", "{", "return", ";", "}", "var", "newOffset", "=", "MdTabsPaginationService", ".", "decreasePageOffset", "(", "getElements", "(", ")", ",", "ctrl", ".", ...
Slides the tabs over approximately one page backward.
[ "Slides", "the", "tabs", "over", "approximately", "one", "page", "backward", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L377-L384
train
angular/material
src/components/tabs/js/tabsController.js
handleWindowResize
function handleWindowResize () { ctrl.lastSelectedIndex = ctrl.selectedIndex; ctrl.offsetLeft = fixOffset(ctrl.offsetLeft); $mdUtil.nextTick(function () { ctrl.updateInkBarStyles(); updatePagination(); }); }
javascript
function handleWindowResize () { ctrl.lastSelectedIndex = ctrl.selectedIndex; ctrl.offsetLeft = fixOffset(ctrl.offsetLeft); $mdUtil.nextTick(function () { ctrl.updateInkBarStyles(); updatePagination(); }); }
[ "function", "handleWindowResize", "(", ")", "{", "ctrl", ".", "lastSelectedIndex", "=", "ctrl", ".", "selectedIndex", ";", "ctrl", ".", "offsetLeft", "=", "fixOffset", "(", "ctrl", ".", "offsetLeft", ")", ";", "$mdUtil", ".", "nextTick", "(", "function", "("...
Update size calculations when the window is resized.
[ "Update", "size", "calculations", "when", "the", "window", "is", "resized", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L389-L397
train