repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
electric-eloquence/fepper-ui
scripts/code-viewer.js
function () { if (!codeViewer.codeActive) { return; } if (window.getSelection().empty) { window.getSelection().empty(); } else if (window.getSelection().removeAllRanges) { window.getSelection().removeAllRanges(); } }
javascript
function () { if (!codeViewer.codeActive) { return; } if (window.getSelection().empty) { window.getSelection().empty(); } else if (window.getSelection().removeAllRanges) { window.getSelection().removeAllRanges(); } }
[ "function", "(", ")", "{", "if", "(", "!", "codeViewer", ".", "codeActive", ")", "{", "return", ";", "}", "if", "(", "window", ".", "getSelection", "(", ")", ".", "empty", ")", "{", "window", ".", "getSelection", "(", ")", ".", "empty", "(", ")", ";", "}", "else", "if", "(", "window", ".", "getSelection", "(", ")", ".", "removeAllRanges", ")", "{", "window", ".", "getSelection", "(", ")", ".", "removeAllRanges", "(", ")", ";", "}", "}" ]
Clear any selection of code when swapping tabs or opening a new pattern.
[ "Clear", "any", "selection", "of", "code", "when", "swapping", "tabs", "or", "opening", "a", "new", "pattern", "." ]
58281efcb426c137881937956c7383cd4a30c878
https://github.com/electric-eloquence/fepper-ui/blob/58281efcb426c137881937956c7383cd4a30c878/scripts/code-viewer.js#L68-L79
train
electric-eloquence/fepper-ui
scripts/code-viewer.js
function () { $sgCodeContainer // Has class sg-view-container. .css('bottom', -$document.outerHeight()) .addClass('anim-ready'); // Make sure the close button handles the click. $('#sg-code-close-btn').click(function (e) { e.preventDefault(); codeViewer.closeCode(); }); // Make sure the click events are handled on the HTML tab. $(codeViewer.ids.e).click(function (e) { e.preventDefault(); codeViewer.swapCode('e'); }); // Make sure the click events are handled on the Mustache tab. $(codeViewer.ids.m).click(function (e) { e.preventDefault(); codeViewer.swapCode('m'); }); }
javascript
function () { $sgCodeContainer // Has class sg-view-container. .css('bottom', -$document.outerHeight()) .addClass('anim-ready'); // Make sure the close button handles the click. $('#sg-code-close-btn').click(function (e) { e.preventDefault(); codeViewer.closeCode(); }); // Make sure the click events are handled on the HTML tab. $(codeViewer.ids.e).click(function (e) { e.preventDefault(); codeViewer.swapCode('e'); }); // Make sure the click events are handled on the Mustache tab. $(codeViewer.ids.m).click(function (e) { e.preventDefault(); codeViewer.swapCode('m'); }); }
[ "function", "(", ")", "{", "$sgCodeContainer", ".", "css", "(", "'bottom'", ",", "-", "$document", ".", "outerHeight", "(", ")", ")", ".", "addClass", "(", "'anim-ready'", ")", ";", "$", "(", "'#sg-code-close-btn'", ")", ".", "click", "(", "function", "(", "e", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "codeViewer", ".", "closeCode", "(", ")", ";", "}", ")", ";", "$", "(", "codeViewer", ".", "ids", ".", "e", ")", ".", "click", "(", "function", "(", "e", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "codeViewer", ".", "swapCode", "(", "'e'", ")", ";", "}", ")", ";", "$", "(", "codeViewer", ".", "ids", ".", "m", ")", ".", "click", "(", "function", "(", "e", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "codeViewer", ".", "swapCode", "(", "'m'", ")", ";", "}", ")", ";", "}" ]
Add the basic markup and events for the code container.
[ "Add", "the", "basic", "markup", "and", "events", "for", "the", "code", "container", "." ]
58281efcb426c137881937956c7383cd4a30c878
https://github.com/electric-eloquence/fepper-ui/blob/58281efcb426c137881937956c7383cd4a30c878/scripts/code-viewer.js#L98-L120
train
electric-eloquence/fepper-ui
scripts/code-viewer.js
function () { let encoded = this.responseText; // We sometimes want markup code to be in an HTML-like template language with tags delimited by stashes. // In order for js-beautify to indent such code correctly, any space between control characters #, ^, and /, and // the variable name must be removed. However, we want to add the spaces back later. // \u00A0 is   a space character not enterable by keyboard, and therefore a good delimiter. encoded = encoded.replace(/(\{\{#)(\s+)(\S+)/g, '$1$3$2\u00A0'); encoded = encoded.replace(/(\{\{\^)(\s+)(\S+)/g, '$1$3$2\u00A0'); encoded = encoded.replace(/(\{\{\/)(\s+)(\S+)/g, '$1$3$2\u00A0'); encoded = window.html_beautify(encoded, { indent_handlebars: true, indent_size: 2, wrap_line_length: 0 }); // Add back removed spaces to retain the look intended by the author. encoded = encoded.replace(/(\{\{#)(\S+)(\s+)\u00A0/g, '$1$3$2'); encoded = encoded.replace(/(\{\{\^)(\S+)(\s+)\u00A0/g, '$1$3$2'); encoded = encoded.replace(/(\{\{\/)(\S+)(\s+)\u00A0/g, '$1$3$2'); // Delete empty lines. encoded = encoded.replace(/^\s*$\n/gm, ''); // Encode with HTML entities. encoded = window.he.encode(encoded); codeViewer.encoded = encoded; if (codeViewer.tabActive === 'e') { codeViewer.activateDefaultTab('e', encoded); } }
javascript
function () { let encoded = this.responseText; // We sometimes want markup code to be in an HTML-like template language with tags delimited by stashes. // In order for js-beautify to indent such code correctly, any space between control characters #, ^, and /, and // the variable name must be removed. However, we want to add the spaces back later. // \u00A0 is   a space character not enterable by keyboard, and therefore a good delimiter. encoded = encoded.replace(/(\{\{#)(\s+)(\S+)/g, '$1$3$2\u00A0'); encoded = encoded.replace(/(\{\{\^)(\s+)(\S+)/g, '$1$3$2\u00A0'); encoded = encoded.replace(/(\{\{\/)(\s+)(\S+)/g, '$1$3$2\u00A0'); encoded = window.html_beautify(encoded, { indent_handlebars: true, indent_size: 2, wrap_line_length: 0 }); // Add back removed spaces to retain the look intended by the author. encoded = encoded.replace(/(\{\{#)(\S+)(\s+)\u00A0/g, '$1$3$2'); encoded = encoded.replace(/(\{\{\^)(\S+)(\s+)\u00A0/g, '$1$3$2'); encoded = encoded.replace(/(\{\{\/)(\S+)(\s+)\u00A0/g, '$1$3$2'); // Delete empty lines. encoded = encoded.replace(/^\s*$\n/gm, ''); // Encode with HTML entities. encoded = window.he.encode(encoded); codeViewer.encoded = encoded; if (codeViewer.tabActive === 'e') { codeViewer.activateDefaultTab('e', encoded); } }
[ "function", "(", ")", "{", "let", "encoded", "=", "this", ".", "responseText", ";", "encoded", "=", "encoded", ".", "replace", "(", "/", "(\\{\\{#)(\\s+)(\\S+)", "/", "g", ",", "'$1$3$2\\u00A0'", ")", ";", "\\u00A0", "encoded", "=", "encoded", ".", "replace", "(", "/", "(\\{\\{\\^)(\\s+)(\\S+)", "/", "g", ",", "'$1$3$2\\u00A0'", ")", ";", "\\u00A0", "encoded", "=", "encoded", ".", "replace", "(", "/", "(\\{\\{\\/)(\\s+)(\\S+)", "/", "g", ",", "'$1$3$2\\u00A0'", ")", ";", "\\u00A0", "encoded", "=", "window", ".", "html_beautify", "(", "encoded", ",", "{", "indent_handlebars", ":", "true", ",", "indent_size", ":", "2", ",", "wrap_line_length", ":", "0", "}", ")", ";", "encoded", "=", "encoded", ".", "replace", "(", "/", "(\\{\\{#)(\\S+)(\\s+)\\u00A0", "/", "g", ",", "'$1$3$2'", ")", ";", "encoded", "=", "encoded", ".", "replace", "(", "/", "(\\{\\{\\^)(\\S+)(\\s+)\\u00A0", "/", "g", ",", "'$1$3$2'", ")", ";", "encoded", "=", "encoded", ".", "replace", "(", "/", "(\\{\\{\\/)(\\S+)(\\s+)\\u00A0", "/", "g", ",", "'$1$3$2'", ")", ";", "encoded", "=", "encoded", ".", "replace", "(", "/", "^\\s*$\\n", "/", "gm", ",", "''", ")", ";", "}" ]
This runs once the AJAX request for the encoded markup is finished. If the encoded tab is the current active tab, it adds the content to the default code container
[ "This", "runs", "once", "the", "AJAX", "request", "for", "the", "encoded", "markup", "is", "finished", ".", "If", "the", "encoded", "tab", "is", "the", "current", "active", "tab", "it", "adds", "the", "content", "to", "the", "default", "code", "container" ]
58281efcb426c137881937956c7383cd4a30c878
https://github.com/electric-eloquence/fepper-ui/blob/58281efcb426c137881937956c7383cd4a30c878/scripts/code-viewer.js#L171-L204
train
electric-eloquence/fepper-ui
scripts/code-viewer.js
function () { let encoded = this.responseText; encoded = window.he.encode(encoded); codeViewer.mustache = encoded; if (codeViewer.tabActive === 'm') { codeViewer.activateDefaultTab('m', encoded); } }
javascript
function () { let encoded = this.responseText; encoded = window.he.encode(encoded); codeViewer.mustache = encoded; if (codeViewer.tabActive === 'm') { codeViewer.activateDefaultTab('m', encoded); } }
[ "function", "(", ")", "{", "let", "encoded", "=", "this", ".", "responseText", ";", "encoded", "=", "window", ".", "he", ".", "encode", "(", "encoded", ")", ";", "codeViewer", ".", "mustache", "=", "encoded", ";", "if", "(", "codeViewer", ".", "tabActive", "===", "'m'", ")", "{", "codeViewer", ".", "activateDefaultTab", "(", "'m'", ",", "encoded", ")", ";", "}", "}" ]
This runs once the AJAX request for the mustache markup is finished. If the mustache tab is the current active tab, it adds the content to the default code container.
[ "This", "runs", "once", "the", "AJAX", "request", "for", "the", "mustache", "markup", "is", "finished", ".", "If", "the", "mustache", "tab", "is", "the", "current", "active", "tab", "it", "adds", "the", "content", "to", "the", "default", "code", "container", "." ]
58281efcb426c137881937956c7383cd4a30c878
https://github.com/electric-eloquence/fepper-ui/blob/58281efcb426c137881937956c7383cd4a30c878/scripts/code-viewer.js#L210-L218
train
electric-eloquence/fepper-ui
scripts/code-viewer.js
function (type) { if (!codeViewer.codeActive) { return; } let fill = ''; codeViewer.tabActive = type; $sgCodeTitles.removeClass('sg-code-title-active'); switch (type) { case 'e': fill = codeViewer.encoded; $sgCodeTitleHtml.addClass('sg-code-title-active'); break; case 'm': fill = codeViewer.mustache; $sgCodeTitleMustache.addClass('sg-code-title-active'); break; } $sgCodeFill.removeClass().addClass('language-markup'); $sgCodeFill.html(fill); window.Prism.highlightElement($sgCodeFill[0]); codeViewer.clearSelection(); }
javascript
function (type) { if (!codeViewer.codeActive) { return; } let fill = ''; codeViewer.tabActive = type; $sgCodeTitles.removeClass('sg-code-title-active'); switch (type) { case 'e': fill = codeViewer.encoded; $sgCodeTitleHtml.addClass('sg-code-title-active'); break; case 'm': fill = codeViewer.mustache; $sgCodeTitleMustache.addClass('sg-code-title-active'); break; } $sgCodeFill.removeClass().addClass('language-markup'); $sgCodeFill.html(fill); window.Prism.highlightElement($sgCodeFill[0]); codeViewer.clearSelection(); }
[ "function", "(", "type", ")", "{", "if", "(", "!", "codeViewer", ".", "codeActive", ")", "{", "return", ";", "}", "let", "fill", "=", "''", ";", "codeViewer", ".", "tabActive", "=", "type", ";", "$sgCodeTitles", ".", "removeClass", "(", "'sg-code-title-active'", ")", ";", "switch", "(", "type", ")", "{", "case", "'e'", ":", "fill", "=", "codeViewer", ".", "encoded", ";", "$sgCodeTitleHtml", ".", "addClass", "(", "'sg-code-title-active'", ")", ";", "break", ";", "case", "'m'", ":", "fill", "=", "codeViewer", ".", "mustache", ";", "$sgCodeTitleMustache", ".", "addClass", "(", "'sg-code-title-active'", ")", ";", "break", ";", "}", "$sgCodeFill", ".", "removeClass", "(", ")", ".", "addClass", "(", "'language-markup'", ")", ";", "$sgCodeFill", ".", "html", "(", "fill", ")", ";", "window", ".", "Prism", ".", "highlightElement", "(", "$sgCodeFill", "[", "0", "]", ")", ";", "codeViewer", ".", "clearSelection", "(", ")", ";", "}" ]
Depending on what tab is clicked this swaps out the code container. Makes sure prism highlight is added. @param {string} type - Single letter abbreviation of type.
[ "Depending", "on", "what", "tab", "is", "clicked", "this", "swaps", "out", "the", "code", "container", ".", "Makes", "sure", "prism", "highlight", "is", "added", "." ]
58281efcb426c137881937956c7383cd4a30c878
https://github.com/electric-eloquence/fepper-ui/blob/58281efcb426c137881937956c7383cd4a30c878/scripts/code-viewer.js#L250-L280
train
Runnable/hermes
lib/event-jobs.js
EventJobs
function EventJobs (opts) { debug('EventJobs constructor'); this._publishedEvents = opts.publishedEvents || []; this._subscribedEvents = opts.subscribedEvents || []; this._name = opts.name; if (!this._name) { debug('error: name required for EventJobs'); throw new Error('name required for EventJobs'); } }
javascript
function EventJobs (opts) { debug('EventJobs constructor'); this._publishedEvents = opts.publishedEvents || []; this._subscribedEvents = opts.subscribedEvents || []; this._name = opts.name; if (!this._name) { debug('error: name required for EventJobs'); throw new Error('name required for EventJobs'); } }
[ "function", "EventJobs", "(", "opts", ")", "{", "debug", "(", "'EventJobs constructor'", ")", ";", "this", ".", "_publishedEvents", "=", "opts", ".", "publishedEvents", "||", "[", "]", ";", "this", ".", "_subscribedEvents", "=", "opts", ".", "subscribedEvents", "||", "[", "]", ";", "this", ".", "_name", "=", "opts", ".", "name", ";", "if", "(", "!", "this", ".", "_name", ")", "{", "debug", "(", "'error: name required for EventJobs'", ")", ";", "throw", "new", "Error", "(", "'name required for EventJobs'", ")", ";", "}", "}" ]
Used to handle all event operations @param {Object} opts options @param opts.publishedEvents array of strings of events which are going to be published to @param opts.subscribedEvents array of strings of events which are going to be subscribed to @param opts.name name of service
[ "Used", "to", "handle", "all", "event", "operations" ]
af660962b3bc67ed39811e17a4362a725442ff81
https://github.com/Runnable/hermes/blob/af660962b3bc67ed39811e17a4362a725442ff81/lib/event-jobs.js#L20-L30
train
kalamuna/metalsmith-metadata-convention
index.js
processFile
function processFile(file, filename, callback) { // Check if it matches the convention. if (path.extname(filename) === '.metadata') { // Find the name of the metadata. const name = path.basename(filename, '.metadata') // Recursively merge the meta data. const newMetadata = {} newMetadata[name] = file extend(true, metadata, newMetadata) // Remove the file since we've now processed it. delete files[filename] } callback() }
javascript
function processFile(file, filename, callback) { // Check if it matches the convention. if (path.extname(filename) === '.metadata') { // Find the name of the metadata. const name = path.basename(filename, '.metadata') // Recursively merge the meta data. const newMetadata = {} newMetadata[name] = file extend(true, metadata, newMetadata) // Remove the file since we've now processed it. delete files[filename] } callback() }
[ "function", "processFile", "(", "file", ",", "filename", ",", "callback", ")", "{", "if", "(", "path", ".", "extname", "(", "filename", ")", "===", "'.metadata'", ")", "{", "const", "name", "=", "path", ".", "basename", "(", "filename", ",", "'.metadata'", ")", "const", "newMetadata", "=", "{", "}", "newMetadata", "[", "name", "]", "=", "file", "extend", "(", "true", ",", "metadata", ",", "newMetadata", ")", "delete", "files", "[", "filename", "]", "}", "callback", "(", ")", "}" ]
Process a file, saving it as metadata if needed. @param {string} file The file of which is being processed. @param {string} filename The name of the given file. @param {function} callback The callback to call when the function is finished.
[ "Process", "a", "file", "saving", "it", "as", "metadata", "if", "needed", "." ]
9090759643305e5dec484c1688c14649111a5958
https://github.com/kalamuna/metalsmith-metadata-convention/blob/9090759643305e5dec484c1688c14649111a5958/index.js#L18-L34
train
unitejs/engine
assets/gulp/dist/tasks/util/json-helper.js
codify
function codify(object) { if (object === undefined) { return object; } else { let json = JSON.stringify(object, undefined, "\t"); // First substitue embedded double quotes with FFFF json = json.replace(/\\"/g, "\uFFFF"); // Now replace all property name quotes json = json.replace(/"([a-zA-Z_$][a-zA-Z0-9_$]+)":/g, "$1:"); // Now replace all other double quotes with single ones json = json.replace(/"/g, "'"); // And finally replace the FFFF with embedded double quotes json = json.replace(/\uFFFF/g, "\\\""); // Now remove quotes for known code variables json = json.replace(/'__dirname'/g, "__dirname"); return json; } }
javascript
function codify(object) { if (object === undefined) { return object; } else { let json = JSON.stringify(object, undefined, "\t"); // First substitue embedded double quotes with FFFF json = json.replace(/\\"/g, "\uFFFF"); // Now replace all property name quotes json = json.replace(/"([a-zA-Z_$][a-zA-Z0-9_$]+)":/g, "$1:"); // Now replace all other double quotes with single ones json = json.replace(/"/g, "'"); // And finally replace the FFFF with embedded double quotes json = json.replace(/\uFFFF/g, "\\\""); // Now remove quotes for known code variables json = json.replace(/'__dirname'/g, "__dirname"); return json; } }
[ "function", "codify", "(", "object", ")", "{", "if", "(", "object", "===", "undefined", ")", "{", "return", "object", ";", "}", "else", "{", "let", "json", "=", "JSON", ".", "stringify", "(", "object", ",", "undefined", ",", "\"\\t\"", ")", ";", "\\t", "json", "=", "json", ".", "replace", "(", "/", "\\\\\"", "/", "g", ",", "\"\\uFFFF\"", ")", ";", "\\uFFFF", "json", "=", "json", ".", "replace", "(", "/", "\"([a-zA-Z_$][a-zA-Z0-9_$]+)\":", "/", "g", ",", "\"$1:\"", ")", ";", "json", "=", "json", ".", "replace", "(", "/", "\"", "/", "g", ",", "\"'\"", ")", ";", "json", "=", "json", ".", "replace", "(", "/", "\\uFFFF", "/", "g", ",", "\"\\\\\\\"\"", ")", ";", "}", "}" ]
Gulp utils for client packages.
[ "Gulp", "utils", "for", "client", "packages", "." ]
8127a18cedf582e8949e70dcbfbce0f39a43664c
https://github.com/unitejs/engine/blob/8127a18cedf582e8949e70dcbfbce0f39a43664c/assets/gulp/dist/tasks/util/json-helper.js#L4-L21
train
kissyteam/kissy-xtemplate
lib/kg/kg-4.2.0/runtime/scope.js
Scope
function Scope(data, affix, parent) { if (data !== undefined) { this.data = data; } else { this.data = {}; } if (parent) { this.parent = parent; this.root = parent.root; } else { this.parent = undefined; this.root = this; } this.affix = affix || {}; this.ready = false; }
javascript
function Scope(data, affix, parent) { if (data !== undefined) { this.data = data; } else { this.data = {}; } if (parent) { this.parent = parent; this.root = parent.root; } else { this.parent = undefined; this.root = this; } this.affix = affix || {}; this.ready = false; }
[ "function", "Scope", "(", "data", ",", "affix", ",", "parent", ")", "{", "if", "(", "data", "!==", "undefined", ")", "{", "this", ".", "data", "=", "data", ";", "}", "else", "{", "this", ".", "data", "=", "{", "}", ";", "}", "if", "(", "parent", ")", "{", "this", ".", "parent", "=", "parent", ";", "this", ".", "root", "=", "parent", ".", "root", ";", "}", "else", "{", "this", ".", "parent", "=", "undefined", ";", "this", ".", "root", "=", "this", ";", "}", "this", ".", "affix", "=", "affix", "||", "{", "}", ";", "this", ".", "ready", "=", "false", ";", "}" ]
scope resolution for xtemplate like function in javascript but keep original data unmodified @author [email protected]
[ "scope", "resolution", "for", "xtemplate", "like", "function", "in", "javascript", "but", "keep", "original", "data", "unmodified" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kg/kg-4.2.0/runtime/scope.js#L5-L20
train
electric-eloquence/fepper-ui
scripts/html-scraper-ajax.js
selectorValidateAndParse
function selectorValidateAndParse(selectorRaw_) { const selectorRaw = selectorRaw_.trim(); const bracketOpenPos = selectorRaw.indexOf('['); const bracketClosePos = selectorRaw.indexOf(']'); let indexStr; let name = selectorRaw; // Slice selectorRaw to extract name and indexStr if submitted. if (bracketOpenPos > -1) { if (bracketClosePos === selectorRaw.length - 1) { indexStr = selectorRaw.slice(bracketOpenPos + 1, bracketClosePos); name = selectorRaw.slice(0, bracketOpenPos); } else { return null; } } // Validate that name is a css selector. // eslint-disable-next-line no-useless-escape if (!/^(#|\.)?[_a-z][\w#\-\.]*$/i.test(name)) { return null; } // If indexStr if submitted, validate it is an integer. if (indexStr) { if (!/^\d+$/.test(indexStr)) { return null; } } return name; }
javascript
function selectorValidateAndParse(selectorRaw_) { const selectorRaw = selectorRaw_.trim(); const bracketOpenPos = selectorRaw.indexOf('['); const bracketClosePos = selectorRaw.indexOf(']'); let indexStr; let name = selectorRaw; // Slice selectorRaw to extract name and indexStr if submitted. if (bracketOpenPos > -1) { if (bracketClosePos === selectorRaw.length - 1) { indexStr = selectorRaw.slice(bracketOpenPos + 1, bracketClosePos); name = selectorRaw.slice(0, bracketOpenPos); } else { return null; } } // Validate that name is a css selector. // eslint-disable-next-line no-useless-escape if (!/^(#|\.)?[_a-z][\w#\-\.]*$/i.test(name)) { return null; } // If indexStr if submitted, validate it is an integer. if (indexStr) { if (!/^\d+$/.test(indexStr)) { return null; } } return name; }
[ "function", "selectorValidateAndParse", "(", "selectorRaw_", ")", "{", "const", "selectorRaw", "=", "selectorRaw_", ".", "trim", "(", ")", ";", "const", "bracketOpenPos", "=", "selectorRaw", ".", "indexOf", "(", "'['", ")", ";", "const", "bracketClosePos", "=", "selectorRaw", ".", "indexOf", "(", "']'", ")", ";", "let", "indexStr", ";", "let", "name", "=", "selectorRaw", ";", "if", "(", "bracketOpenPos", ">", "-", "1", ")", "{", "if", "(", "bracketClosePos", "===", "selectorRaw", ".", "length", "-", "1", ")", "{", "indexStr", "=", "selectorRaw", ".", "slice", "(", "bracketOpenPos", "+", "1", ",", "bracketClosePos", ")", ";", "name", "=", "selectorRaw", ".", "slice", "(", "0", ",", "bracketOpenPos", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}", "if", "(", "!", "/", "^(#|\\.)?[_a-z][\\w#\\-\\.]*$", "/", "i", ".", "test", "(", "name", ")", ")", "{", "return", "null", ";", "}", "if", "(", "indexStr", ")", "{", "if", "(", "!", "/", "^\\d+$", "/", ".", "test", "(", "indexStr", ")", ")", "{", "return", "null", ";", "}", "}", "return", "name", ";", "}" ]
Validate syntax of Target Selector input. @param {string} selectorRaw_ - CSS selector plus optional array index. @returns {string|null} The selector name or null if invalid.
[ "Validate", "syntax", "of", "Target", "Selector", "input", "." ]
58281efcb426c137881937956c7383cd4a30c878
https://github.com/electric-eloquence/fepper-ui/blob/58281efcb426c137881937956c7383cd4a30c878/scripts/html-scraper-ajax.js#L56-L89
train
Creuna-Oslo/react-scripts
source/transforms/babel-utils.js
addThisDotProps
function addThisDotProps(path) { path.replaceWith( t.memberExpression( t.memberExpression(t.thisExpression(), t.identifier('props')), path.node ) ); }
javascript
function addThisDotProps(path) { path.replaceWith( t.memberExpression( t.memberExpression(t.thisExpression(), t.identifier('props')), path.node ) ); }
[ "function", "addThisDotProps", "(", "path", ")", "{", "path", ".", "replaceWith", "(", "t", ".", "memberExpression", "(", "t", ".", "memberExpression", "(", "t", ".", "thisExpression", "(", ")", ",", "t", ".", "identifier", "(", "'props'", ")", ")", ",", "path", ".", "node", ")", ")", ";", "}" ]
Replaces 'x' with 'this.props.x'
[ "Replaces", "x", "with", "this", ".", "props", ".", "x" ]
8a46924c85dab53e1e48d6397ce5cf0ba3a0ca64
https://github.com/Creuna-Oslo/react-scripts/blob/8a46924c85dab53e1e48d6397ce5cf0ba3a0ca64/source/transforms/babel-utils.js#L4-L11
train
Creuna-Oslo/react-scripts
source/transforms/babel-utils.js
isDestructuredPropsReference
function isDestructuredPropsReference(path) { const object = path.get('object'); if (!path.scope.hasOwnBinding(object.node.name)) { return; } const bindingValue = path.scope.bindings[object.node.name].path.get('init'); return ( (bindingValue.isMemberExpression() && bindingValue.get('object').isThisExpression() && bindingValue.get('property').isIdentifier({ name: 'props' })) || bindingValue.isThisExpression() ); }
javascript
function isDestructuredPropsReference(path) { const object = path.get('object'); if (!path.scope.hasOwnBinding(object.node.name)) { return; } const bindingValue = path.scope.bindings[object.node.name].path.get('init'); return ( (bindingValue.isMemberExpression() && bindingValue.get('object').isThisExpression() && bindingValue.get('property').isIdentifier({ name: 'props' })) || bindingValue.isThisExpression() ); }
[ "function", "isDestructuredPropsReference", "(", "path", ")", "{", "const", "object", "=", "path", ".", "get", "(", "'object'", ")", ";", "if", "(", "!", "path", ".", "scope", ".", "hasOwnBinding", "(", "object", ".", "node", ".", "name", ")", ")", "{", "return", ";", "}", "const", "bindingValue", "=", "path", ".", "scope", ".", "bindings", "[", "object", ".", "node", ".", "name", "]", ".", "path", ".", "get", "(", "'init'", ")", ";", "return", "(", "(", "bindingValue", ".", "isMemberExpression", "(", ")", "&&", "bindingValue", ".", "get", "(", "'object'", ")", ".", "isThisExpression", "(", ")", "&&", "bindingValue", ".", "get", "(", "'property'", ")", ".", "isIdentifier", "(", "{", "name", ":", "'props'", "}", ")", ")", "||", "bindingValue", ".", "isThisExpression", "(", ")", ")", ";", "}" ]
Checks whether a binding exists for an 'object' property of a MemberExpression, and if that binding is a reference to 'this.props' or 'this'. 'path' must be a MemberExpression NodePath.
[ "Checks", "whether", "a", "binding", "exists", "for", "an", "object", "property", "of", "a", "MemberExpression", "and", "if", "that", "binding", "is", "a", "reference", "to", "this", ".", "props", "or", "this", ".", "path", "must", "be", "a", "MemberExpression", "NodePath", "." ]
8a46924c85dab53e1e48d6397ce5cf0ba3a0ca64
https://github.com/Creuna-Oslo/react-scripts/blob/8a46924c85dab53e1e48d6397ce5cf0ba3a0ca64/source/transforms/babel-utils.js#L26-L40
train
Creuna-Oslo/react-scripts
source/transforms/babel-utils.js
isObjectMemberProperty
function isObjectMemberProperty(path) { return ( t.isMemberExpression(path.parent) && path.parentPath.get('property') === path ); }
javascript
function isObjectMemberProperty(path) { return ( t.isMemberExpression(path.parent) && path.parentPath.get('property') === path ); }
[ "function", "isObjectMemberProperty", "(", "path", ")", "{", "return", "(", "t", ".", "isMemberExpression", "(", "path", ".", "parent", ")", "&&", "path", ".", "parentPath", ".", "get", "(", "'property'", ")", "===", "path", ")", ";", "}" ]
Checks whether the path is the 'property' of a MemberExpression
[ "Checks", "whether", "the", "path", "is", "the", "property", "of", "a", "MemberExpression" ]
8a46924c85dab53e1e48d6397ce5cf0ba3a0ca64
https://github.com/Creuna-Oslo/react-scripts/blob/8a46924c85dab53e1e48d6397ce5cf0ba3a0ca64/source/transforms/babel-utils.js#L43-L48
train
virtualcodewarrior/webComponentBaseClass
src/webComponentBaseClass.js
createShadowDOM
function createShadowDOM(p_ComponentInstance, p_ComponentTemplate) { // retrieve the correct template from our map of previously stored templates const templateInstance = window.webComponentTemplates.get(p_ComponentTemplate); // if we are using the shadyCSS polyfill, we must initialize that now if (window.ShadyCSS) { window.ShadyCSS.prepareTemplate(templateInstance, p_ComponentTemplate); window.ShadyCSS.styleElement(p_ComponentInstance); } // create the shadow DOM root here const shadowRoot = p_ComponentInstance.attachShadow({ mode: 'open' }); shadowRoot.appendChild(templateInstance.content.cloneNode(true)); }
javascript
function createShadowDOM(p_ComponentInstance, p_ComponentTemplate) { // retrieve the correct template from our map of previously stored templates const templateInstance = window.webComponentTemplates.get(p_ComponentTemplate); // if we are using the shadyCSS polyfill, we must initialize that now if (window.ShadyCSS) { window.ShadyCSS.prepareTemplate(templateInstance, p_ComponentTemplate); window.ShadyCSS.styleElement(p_ComponentInstance); } // create the shadow DOM root here const shadowRoot = p_ComponentInstance.attachShadow({ mode: 'open' }); shadowRoot.appendChild(templateInstance.content.cloneNode(true)); }
[ "function", "createShadowDOM", "(", "p_ComponentInstance", ",", "p_ComponentTemplate", ")", "{", "const", "templateInstance", "=", "window", ".", "webComponentTemplates", ".", "get", "(", "p_ComponentTemplate", ")", ";", "if", "(", "window", ".", "ShadyCSS", ")", "{", "window", ".", "ShadyCSS", ".", "prepareTemplate", "(", "templateInstance", ",", "p_ComponentTemplate", ")", ";", "window", ".", "ShadyCSS", ".", "styleElement", "(", "p_ComponentInstance", ")", ";", "}", "const", "shadowRoot", "=", "p_ComponentInstance", ".", "attachShadow", "(", "{", "mode", ":", "'open'", "}", ")", ";", "shadowRoot", ".", "appendChild", "(", "templateInstance", ".", "content", ".", "cloneNode", "(", "true", ")", ")", ";", "}" ]
Create the shadow DOM and attach it to the given web component instance @param {HTMLElement} p_ComponentInstance The web component instance to which we are attaching the shadow DOM @param {string} p_ComponentTemplate The id of the web component template
[ "Create", "the", "shadow", "DOM", "and", "attach", "it", "to", "the", "given", "web", "component", "instance" ]
78bb9b352fd5cd6bdb287d01066bff1bd6cc07cb
https://github.com/virtualcodewarrior/webComponentBaseClass/blob/78bb9b352fd5cd6bdb287d01066bff1bd6cc07cb/src/webComponentBaseClass.js#L8-L20
train
KleeGroup/focus-notifications
src/reducers/visibility-filter.js
visibilityFilter
function visibilityFilter(state = SHOW_ALL, action = {}) { const {type, filter} = action; switch (type) { case SET_VISIBILITY_FILTER: return filter; default: return state; } }
javascript
function visibilityFilter(state = SHOW_ALL, action = {}) { const {type, filter} = action; switch (type) { case SET_VISIBILITY_FILTER: return filter; default: return state; } }
[ "function", "visibilityFilter", "(", "state", "=", "SHOW_ALL", ",", "action", "=", "{", "}", ")", "{", "const", "{", "type", ",", "filter", "}", "=", "action", ";", "switch", "(", "type", ")", "{", "case", "SET_VISIBILITY_FILTER", ":", "return", "filter", ";", "default", ":", "return", "state", ";", "}", "}" ]
reducer in charge of dealing with the visibility filter.
[ "reducer", "in", "charge", "of", "dealing", "with", "the", "visibility", "filter", "." ]
b9a529264b625a12c3d8d479f839f36f77b674f6
https://github.com/KleeGroup/focus-notifications/blob/b9a529264b625a12c3d8d479f839f36f77b674f6/src/reducers/visibility-filter.js#L5-L13
train
craterdog-bali/js-bali-component-framework
src/utilities/Iterator.js
Iterator
function Iterator(array) { // the array and current slot index are private attributes so methods that use them // are defined in the constructor var currentSlot = 0; // the slot before the first item this.toStart = function() { currentSlot = 0; // the slot before the first item }; this.toSlot = function(slot) { const size = array.length; if (slot > size) slot = size; if (slot < -size) slot = -size; if (slot < 0) slot = slot + size + 1; currentSlot = slot; }; this.toEnd = function() { currentSlot = array.length; // the slot after the last item }; this.hasPrevious = function() { return currentSlot > 0; }; this.hasNext = function() { return currentSlot < array.length; }; this.getPrevious = function() { if (!this.hasPrevious()) return; return array[--currentSlot]; }; this.getNext = function() { if (!this.hasNext()) return; return array[currentSlot++]; }; return this; }
javascript
function Iterator(array) { // the array and current slot index are private attributes so methods that use them // are defined in the constructor var currentSlot = 0; // the slot before the first item this.toStart = function() { currentSlot = 0; // the slot before the first item }; this.toSlot = function(slot) { const size = array.length; if (slot > size) slot = size; if (slot < -size) slot = -size; if (slot < 0) slot = slot + size + 1; currentSlot = slot; }; this.toEnd = function() { currentSlot = array.length; // the slot after the last item }; this.hasPrevious = function() { return currentSlot > 0; }; this.hasNext = function() { return currentSlot < array.length; }; this.getPrevious = function() { if (!this.hasPrevious()) return; return array[--currentSlot]; }; this.getNext = function() { if (!this.hasNext()) return; return array[currentSlot++]; }; return this; }
[ "function", "Iterator", "(", "array", ")", "{", "var", "currentSlot", "=", "0", ";", "this", ".", "toStart", "=", "function", "(", ")", "{", "currentSlot", "=", "0", ";", "}", ";", "this", ".", "toSlot", "=", "function", "(", "slot", ")", "{", "const", "size", "=", "array", ".", "length", ";", "if", "(", "slot", ">", "size", ")", "slot", "=", "size", ";", "if", "(", "slot", "<", "-", "size", ")", "slot", "=", "-", "size", ";", "if", "(", "slot", "<", "0", ")", "slot", "=", "slot", "+", "size", "+", "1", ";", "currentSlot", "=", "slot", ";", "}", ";", "this", ".", "toEnd", "=", "function", "(", ")", "{", "currentSlot", "=", "array", ".", "length", ";", "}", ";", "this", ".", "hasPrevious", "=", "function", "(", ")", "{", "return", "currentSlot", ">", "0", ";", "}", ";", "this", ".", "hasNext", "=", "function", "(", ")", "{", "return", "currentSlot", "<", "array", ".", "length", ";", "}", ";", "this", ".", "getPrevious", "=", "function", "(", ")", "{", "if", "(", "!", "this", ".", "hasPrevious", "(", ")", ")", "return", ";", "return", "array", "[", "--", "currentSlot", "]", ";", "}", ";", "this", ".", "getNext", "=", "function", "(", ")", "{", "if", "(", "!", "this", ".", "hasNext", "(", ")", ")", "return", ";", "return", "array", "[", "currentSlot", "++", "]", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTORS This constructor creates a new array iterator that allows the items in the array to be iterated over in either direction. @constructor @param {Array} array The array to be iterated over. @returns {Iterator} The new array iterator.
[ "PUBLIC", "CONSTRUCTORS", "This", "constructor", "creates", "a", "new", "array", "iterator", "that", "allows", "the", "items", "in", "the", "array", "to", "be", "iterated", "over", "in", "either", "direction", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/utilities/Iterator.js#L42-L83
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/stylesheet-debug.js
StyleSheet
function StyleSheet(el) { /** * style/link element or selector * @cfg {HTMLElement|String} el */ /** * style/link element * @type {HTMLElement} * @property el */ if (el.el) { el = el.el; } el = this.el = Dom.get(el); // http://msdn.microsoft.com/en-us/library/ie/ms535871(v=vs.85).aspx // firefox 跨域时抛出异常 // http://msdn.microsoft.com/en-us/library/ie/ms535871(v=vs.85).aspx // firefox 跨域时抛出异常 var sheet = el.sheet || el.styleSheet; this.sheet = sheet; var cssRules = {}; this.cssRules = cssRules; var rulesName = sheet && 'cssRules' in sheet ? 'cssRules' : 'rules'; this.rulesName = rulesName; var domCssRules = sheet[rulesName]; var i, rule, selectorText, styleDeclaration; for (i = domCssRules.length - 1; i >= 0; i--) { rule = domCssRules[i]; selectorText = rule.selectorText; // 去重 // 去重 if (styleDeclaration = cssRules[selectorText]) { styleDeclaration.style.cssText += ';' + styleDeclaration.style.cssText; deleteRule(sheet, i); } else { cssRules[selectorText] = rule; } } }
javascript
function StyleSheet(el) { /** * style/link element or selector * @cfg {HTMLElement|String} el */ /** * style/link element * @type {HTMLElement} * @property el */ if (el.el) { el = el.el; } el = this.el = Dom.get(el); // http://msdn.microsoft.com/en-us/library/ie/ms535871(v=vs.85).aspx // firefox 跨域时抛出异常 // http://msdn.microsoft.com/en-us/library/ie/ms535871(v=vs.85).aspx // firefox 跨域时抛出异常 var sheet = el.sheet || el.styleSheet; this.sheet = sheet; var cssRules = {}; this.cssRules = cssRules; var rulesName = sheet && 'cssRules' in sheet ? 'cssRules' : 'rules'; this.rulesName = rulesName; var domCssRules = sheet[rulesName]; var i, rule, selectorText, styleDeclaration; for (i = domCssRules.length - 1; i >= 0; i--) { rule = domCssRules[i]; selectorText = rule.selectorText; // 去重 // 去重 if (styleDeclaration = cssRules[selectorText]) { styleDeclaration.style.cssText += ';' + styleDeclaration.style.cssText; deleteRule(sheet, i); } else { cssRules[selectorText] = rule; } } }
[ "function", "StyleSheet", "(", "el", ")", "{", "if", "(", "el", ".", "el", ")", "{", "el", "=", "el", ".", "el", ";", "}", "el", "=", "this", ".", "el", "=", "Dom", ".", "get", "(", "el", ")", ";", "var", "sheet", "=", "el", ".", "sheet", "||", "el", ".", "styleSheet", ";", "this", ".", "sheet", "=", "sheet", ";", "var", "cssRules", "=", "{", "}", ";", "this", ".", "cssRules", "=", "cssRules", ";", "var", "rulesName", "=", "sheet", "&&", "'cssRules'", "in", "sheet", "?", "'cssRules'", ":", "'rules'", ";", "this", ".", "rulesName", "=", "rulesName", ";", "var", "domCssRules", "=", "sheet", "[", "rulesName", "]", ";", "var", "i", ",", "rule", ",", "selectorText", ",", "styleDeclaration", ";", "for", "(", "i", "=", "domCssRules", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "rule", "=", "domCssRules", "[", "i", "]", ";", "selectorText", "=", "rule", ".", "selectorText", ";", "if", "(", "styleDeclaration", "=", "cssRules", "[", "selectorText", "]", ")", "{", "styleDeclaration", ".", "style", ".", "cssText", "+=", "';'", "+", "styleDeclaration", ".", "style", ".", "cssText", ";", "deleteRule", "(", "sheet", ",", "i", ")", ";", "}", "else", "{", "cssRules", "[", "selectorText", "]", "=", "rule", ";", "}", "}", "}" ]
Normalize operation about stylesheet @class KISSY.StyleSheet @param el {HTMLElement} style/link element Normalize operation about stylesheet @class KISSY.StyleSheet @param el {HTMLElement} style/link element
[ "Normalize", "operation", "about", "stylesheet" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/stylesheet-debug.js#L26-L62
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/stylesheet-debug.js
function (selectorText) { var rule, css, selector, cssRules = this.cssRules; if (selectorText) { rule = cssRules[selectorText]; return rule ? rule.style.cssText : null; } else { css = []; for (selector in cssRules) { rule = cssRules[selector]; css.push(rule.selectorText + ' {' + rule.style.cssText + '}'); } return css.join('\n'); } }
javascript
function (selectorText) { var rule, css, selector, cssRules = this.cssRules; if (selectorText) { rule = cssRules[selectorText]; return rule ? rule.style.cssText : null; } else { css = []; for (selector in cssRules) { rule = cssRules[selector]; css.push(rule.selectorText + ' {' + rule.style.cssText + '}'); } return css.join('\n'); } }
[ "function", "(", "selectorText", ")", "{", "var", "rule", ",", "css", ",", "selector", ",", "cssRules", "=", "this", ".", "cssRules", ";", "if", "(", "selectorText", ")", "{", "rule", "=", "cssRules", "[", "selectorText", "]", ";", "return", "rule", "?", "rule", ".", "style", ".", "cssText", ":", "null", ";", "}", "else", "{", "css", "=", "[", "]", ";", "for", "(", "selector", "in", "cssRules", ")", "{", "rule", "=", "cssRules", "[", "selector", "]", ";", "css", ".", "push", "(", "rule", ".", "selectorText", "+", "' {'", "+", "rule", ".", "style", ".", "cssText", "+", "'}'", ")", ";", "}", "return", "css", ".", "join", "(", "'\\n'", ")", ";", "}", "}" ]
Get cssText corresponding to specified selectorText @param {String} selectorText specified selector as string @return {String} CssText corresponding to specified selectorText
[ "Get", "cssText", "corresponding", "to", "specified", "selectorText" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/stylesheet-debug.js#L142-L155
train
craterdog-bali/js-bali-component-framework
src/elements/Probability.js
Probability
function Probability(value, parameters) { abstractions.Element.call(this, utilities.types.PROBABILITY, parameters); if (value === undefined) value = 0; // default value if (!isFinite(value) || value < 0 || value > 1) { throw new utilities.Exception({ $module: '/bali/elements/Probability', $procedure: '$Probability', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid probability value was passed to the constructor."' }); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Probability(value, parameters) { abstractions.Element.call(this, utilities.types.PROBABILITY, parameters); if (value === undefined) value = 0; // default value if (!isFinite(value) || value < 0 || value > 1) { throw new utilities.Exception({ $module: '/bali/elements/Probability', $procedure: '$Probability', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid probability value was passed to the constructor."' }); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Probability", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "PROBABILITY", ",", "parameters", ")", ";", "if", "(", "value", "===", "undefined", ")", "value", "=", "0", ";", "if", "(", "!", "isFinite", "(", "value", ")", "||", "value", "<", "0", "||", "value", ">", "1", ")", "{", "throw", "new", "utilities", ".", "Exception", "(", "{", "$module", ":", "'/bali/elements/Probability'", ",", "$procedure", ":", "'$Probability'", ",", "$exception", ":", "'$invalidParameter'", ",", "$parameter", ":", "value", ".", "toString", "(", ")", ",", "$text", ":", "'\"An invalid probability value was passed to the constructor.\"'", "}", ")", ";", "}", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new probability element using the specified value. @param {Number} value The value of the probability. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Probability} The new probability element.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "probability", "element", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Probability.js#L29-L47
train
rezeus/kernel
lib/index.js
boot
function boot() { if (config === null) { // TODO [NSTDFRZN] Be sure nested objects are frozen too config = Object.freeze(gatherConfigFromEnv()); } ee.emitAsync('booting_backing') .then(() => { ee.emit('booting'); ee.emit('booted'); }) .catch((err) => { ee.emit('error', err); // TODO [ERR2BTERR] Maybe err -> BootError(err) }); }
javascript
function boot() { if (config === null) { // TODO [NSTDFRZN] Be sure nested objects are frozen too config = Object.freeze(gatherConfigFromEnv()); } ee.emitAsync('booting_backing') .then(() => { ee.emit('booting'); ee.emit('booted'); }) .catch((err) => { ee.emit('error', err); // TODO [ERR2BTERR] Maybe err -> BootError(err) }); }
[ "function", "boot", "(", ")", "{", "if", "(", "config", "===", "null", ")", "{", "config", "=", "Object", ".", "freeze", "(", "gatherConfigFromEnv", "(", ")", ")", ";", "}", "ee", ".", "emitAsync", "(", "'booting_backing'", ")", ".", "then", "(", "(", ")", "=>", "{", "ee", ".", "emit", "(", "'booting'", ")", ";", "ee", ".", "emit", "(", "'booted'", ")", ";", "}", ")", ".", "catch", "(", "(", "err", ")", "=>", "{", "ee", ".", "emit", "(", "'error'", ",", "err", ")", ";", "}", ")", ";", "}" ]
Boot the kernel to start the application. To do that emits 'boot_backing' and 'boot' events to listeners. If the kernel wasn't configured so far gathers configuration automatically from environment variables.
[ "Boot", "the", "kernel", "to", "start", "the", "application", ".", "To", "do", "that", "emits", "boot_backing", "and", "boot", "events", "to", "listeners", "." ]
4ce1c0509973b7512a284e483f1d6da5788bf7ea
https://github.com/rezeus/kernel/blob/4ce1c0509973b7512a284e483f1d6da5788bf7ea/lib/index.js#L46-L60
train
rjenkinsjr/lufo
lufo-cli/src/lufo.js
function (isJson, transformer) { printHelpOnExit = false; return function (value) { if (isJson) { console.log(JSON.stringify(value, null, 2)); } else if (typeof transformer === 'function') { console.log(transformer(value)); } else { console.log(value); } if (theUfo) theUfo.disconnect(); }; }
javascript
function (isJson, transformer) { printHelpOnExit = false; return function (value) { if (isJson) { console.log(JSON.stringify(value, null, 2)); } else if (typeof transformer === 'function') { console.log(transformer(value)); } else { console.log(value); } if (theUfo) theUfo.disconnect(); }; }
[ "function", "(", "isJson", ",", "transformer", ")", "{", "printHelpOnExit", "=", "false", ";", "return", "function", "(", "value", ")", "{", "if", "(", "isJson", ")", "{", "console", ".", "log", "(", "JSON", ".", "stringify", "(", "value", ",", "null", ",", "2", ")", ")", ";", "}", "else", "if", "(", "typeof", "transformer", "===", "'function'", ")", "{", "console", ".", "log", "(", "transformer", "(", "value", ")", ")", ";", "}", "else", "{", "console", ".", "log", "(", "value", ")", ";", "}", "if", "(", "theUfo", ")", "theUfo", ".", "disconnect", "(", ")", ";", "}", ";", "}" ]
Helper function to reduce boilerplate when running getter commands.
[ "Helper", "function", "to", "reduce", "boilerplate", "when", "running", "getter", "commands", "." ]
bd2465eaf81cac2212735bd2f33d62355c72ab93
https://github.com/rjenkinsjr/lufo/blob/bd2465eaf81cac2212735bd2f33d62355c72ab93/lufo-cli/src/lufo.js#L14-L26
train
rjenkinsjr/lufo
lufo-cli/src/lufo.js
function (obj) { printHelpOnExit = false; if (_.isError(obj)) { console.error(obj); } else { console.error(`ERROR: ${obj.toString()}`); } if (theUfo) theUfo.disconnect(); process.exitCode = 1; }
javascript
function (obj) { printHelpOnExit = false; if (_.isError(obj)) { console.error(obj); } else { console.error(`ERROR: ${obj.toString()}`); } if (theUfo) theUfo.disconnect(); process.exitCode = 1; }
[ "function", "(", "obj", ")", "{", "printHelpOnExit", "=", "false", ";", "if", "(", "_", ".", "isError", "(", "obj", ")", ")", "{", "console", ".", "error", "(", "obj", ")", ";", "}", "else", "{", "console", ".", "error", "(", "`", "${", "obj", ".", "toString", "(", ")", "}", "`", ")", ";", "}", "if", "(", "theUfo", ")", "theUfo", ".", "disconnect", "(", ")", ";", "process", ".", "exitCode", "=", "1", ";", "}" ]
Helper function for printing errors and setting the exit code.
[ "Helper", "function", "for", "printing", "errors", "and", "setting", "the", "exit", "code", "." ]
bd2465eaf81cac2212735bd2f33d62355c72ab93
https://github.com/rjenkinsjr/lufo/blob/bd2465eaf81cac2212735bd2f33d62355c72ab93/lufo-cli/src/lufo.js#L28-L37
train
rjenkinsjr/lufo
lufo-cli/src/lufo.js
function (...args) { let value = false; args.forEach((arg) => { if (value === false) { if (arg === true || (typeof arg === 'string' && arg.toLowerCase() === 'true') || arg === 1) { value = true; } } }); return value; }
javascript
function (...args) { let value = false; args.forEach((arg) => { if (value === false) { if (arg === true || (typeof arg === 'string' && arg.toLowerCase() === 'true') || arg === 1) { value = true; } } }); return value; }
[ "function", "(", "...", "args", ")", "{", "let", "value", "=", "false", ";", "args", ".", "forEach", "(", "(", "arg", ")", "=>", "{", "if", "(", "value", "===", "false", ")", "{", "if", "(", "arg", "===", "true", "||", "(", "typeof", "arg", "===", "'string'", "&&", "arg", ".", "toLowerCase", "(", ")", "===", "'true'", ")", "||", "arg", "===", "1", ")", "{", "value", "=", "true", ";", "}", "}", "}", ")", ";", "return", "value", ";", "}" ]
Helper function for parsing boolean CLI arguments.
[ "Helper", "function", "for", "parsing", "boolean", "CLI", "arguments", "." ]
bd2465eaf81cac2212735bd2f33d62355c72ab93
https://github.com/rjenkinsjr/lufo/blob/bd2465eaf81cac2212735bd2f33d62355c72ab93/lufo-cli/src/lufo.js#L39-L49
train
rjenkinsjr/lufo
lufo-cli/src/lufo.js
function () { const options = {}; options.host = cli.ufo || process.env.LUFO_ADDRESS || ''; options.password = cli.password || process.env.LUFO_PASSWORD || undefined; options.localHost = cli.localHost || process.env.LUFO_LOCALHOST || undefined; options.localUdpPort = parseInt(cli.localUdpPort || process.env.LUFO_LOCAL_UDP, 10) || undefined; options.remoteUdpPort = parseInt(cli.remoteUdpPort || process.env.LUFO_REMOTE_UDP, 10) || undefined; options.localTcpPort = parseInt(cli.localTcpPort || process.env.LUFO_LOCAL_TCP, 10) || undefined; options.remoteTcpPort = parseInt(cli.remoteTcpPort || process.env.LUFO_REMOTE_TCP, 10) || undefined; options.immediate = parseBoolean(cli.immediate, process.env.LUFO_IMMEDIATE) || undefined; return options; }
javascript
function () { const options = {}; options.host = cli.ufo || process.env.LUFO_ADDRESS || ''; options.password = cli.password || process.env.LUFO_PASSWORD || undefined; options.localHost = cli.localHost || process.env.LUFO_LOCALHOST || undefined; options.localUdpPort = parseInt(cli.localUdpPort || process.env.LUFO_LOCAL_UDP, 10) || undefined; options.remoteUdpPort = parseInt(cli.remoteUdpPort || process.env.LUFO_REMOTE_UDP, 10) || undefined; options.localTcpPort = parseInt(cli.localTcpPort || process.env.LUFO_LOCAL_TCP, 10) || undefined; options.remoteTcpPort = parseInt(cli.remoteTcpPort || process.env.LUFO_REMOTE_TCP, 10) || undefined; options.immediate = parseBoolean(cli.immediate, process.env.LUFO_IMMEDIATE) || undefined; return options; }
[ "function", "(", ")", "{", "const", "options", "=", "{", "}", ";", "options", ".", "host", "=", "cli", ".", "ufo", "||", "process", ".", "env", ".", "LUFO_ADDRESS", "||", "''", ";", "options", ".", "password", "=", "cli", ".", "password", "||", "process", ".", "env", ".", "LUFO_PASSWORD", "||", "undefined", ";", "options", ".", "localHost", "=", "cli", ".", "localHost", "||", "process", ".", "env", ".", "LUFO_LOCALHOST", "||", "undefined", ";", "options", ".", "localUdpPort", "=", "parseInt", "(", "cli", ".", "localUdpPort", "||", "process", ".", "env", ".", "LUFO_LOCAL_UDP", ",", "10", ")", "||", "undefined", ";", "options", ".", "remoteUdpPort", "=", "parseInt", "(", "cli", ".", "remoteUdpPort", "||", "process", ".", "env", ".", "LUFO_REMOTE_UDP", ",", "10", ")", "||", "undefined", ";", "options", ".", "localTcpPort", "=", "parseInt", "(", "cli", ".", "localTcpPort", "||", "process", ".", "env", ".", "LUFO_LOCAL_TCP", ",", "10", ")", "||", "undefined", ";", "options", ".", "remoteTcpPort", "=", "parseInt", "(", "cli", ".", "remoteTcpPort", "||", "process", ".", "env", ".", "LUFO_REMOTE_TCP", ",", "10", ")", "||", "undefined", ";", "options", ".", "immediate", "=", "parseBoolean", "(", "cli", ".", "immediate", ",", "process", ".", "env", ".", "LUFO_IMMEDIATE", ")", "||", "undefined", ";", "return", "options", ";", "}" ]
Helper function to construct a UfoOptions object.
[ "Helper", "function", "to", "construct", "a", "UfoOptions", "object", "." ]
bd2465eaf81cac2212735bd2f33d62355c72ab93
https://github.com/rjenkinsjr/lufo/blob/bd2465eaf81cac2212735bd2f33d62355c72ab93/lufo-cli/src/lufo.js#L51-L62
train
rjenkinsjr/lufo
lufo-cli/src/lufo.js
function (action) { printHelpOnExit = false; const cliOptions = getOptions(); if (cliOptions.host) { if (net.isIPv4(cliOptions.host)) { theUfo = new Ufo(cliOptions); theUfo.connect() .then(action.bind(theUfo)) .catch(quitError); } else { quitError(`Invalid UFO IP address provided: ${cliOptions.host}.`); } } else { quitError('No UFO IP address provided.'); } }
javascript
function (action) { printHelpOnExit = false; const cliOptions = getOptions(); if (cliOptions.host) { if (net.isIPv4(cliOptions.host)) { theUfo = new Ufo(cliOptions); theUfo.connect() .then(action.bind(theUfo)) .catch(quitError); } else { quitError(`Invalid UFO IP address provided: ${cliOptions.host}.`); } } else { quitError('No UFO IP address provided.'); } }
[ "function", "(", "action", ")", "{", "printHelpOnExit", "=", "false", ";", "const", "cliOptions", "=", "getOptions", "(", ")", ";", "if", "(", "cliOptions", ".", "host", ")", "{", "if", "(", "net", ".", "isIPv4", "(", "cliOptions", ".", "host", ")", ")", "{", "theUfo", "=", "new", "Ufo", "(", "cliOptions", ")", ";", "theUfo", ".", "connect", "(", ")", ".", "then", "(", "action", ".", "bind", "(", "theUfo", ")", ")", ".", "catch", "(", "quitError", ")", ";", "}", "else", "{", "quitError", "(", "`", "${", "cliOptions", ".", "host", "}", "`", ")", ";", "}", "}", "else", "{", "quitError", "(", "'No UFO IP address provided.'", ")", ";", "}", "}" ]
Helper function for assembling the UFO object based on the given args. The UFO object created by this method is bound to "this" in the action callback.
[ "Helper", "function", "for", "assembling", "the", "UFO", "object", "based", "on", "the", "given", "args", ".", "The", "UFO", "object", "created", "by", "this", "method", "is", "bound", "to", "this", "in", "the", "action", "callback", "." ]
bd2465eaf81cac2212735bd2f33d62355c72ab93
https://github.com/rjenkinsjr/lufo/blob/bd2465eaf81cac2212735bd2f33d62355c72ab93/lufo-cli/src/lufo.js#L65-L80
train
fisker/cssgrace-lite
lib/index.js
ieInlineBlockHack
function ieInlineBlockHack(decl, i) { if (decl.prop == 'display' && decl.value == 'inline-block') { var reBefore = decl.raws.before.replace(reBLANK_LINE, '$1') insertDecl(decl, i, { raws: { before: reBefore }, prop: '*zoom', value: 1 }) insertDecl(decl, i, { raws: { before: reBefore }, prop: '*display', value: 'inline' }) } }
javascript
function ieInlineBlockHack(decl, i) { if (decl.prop == 'display' && decl.value == 'inline-block') { var reBefore = decl.raws.before.replace(reBLANK_LINE, '$1') insertDecl(decl, i, { raws: { before: reBefore }, prop: '*zoom', value: 1 }) insertDecl(decl, i, { raws: { before: reBefore }, prop: '*display', value: 'inline' }) } }
[ "function", "ieInlineBlockHack", "(", "decl", ",", "i", ")", "{", "if", "(", "decl", ".", "prop", "==", "'display'", "&&", "decl", ".", "value", "==", "'inline-block'", ")", "{", "var", "reBefore", "=", "decl", ".", "raws", ".", "before", ".", "replace", "(", "reBLANK_LINE", ",", "'$1'", ")", "insertDecl", "(", "decl", ",", "i", ",", "{", "raws", ":", "{", "before", ":", "reBefore", "}", ",", "prop", ":", "'*zoom'", ",", "value", ":", "1", "}", ")", "insertDecl", "(", "decl", ",", "i", ",", "{", "raws", ":", "{", "before", ":", "reBefore", "}", ",", "prop", ":", "'*display'", ",", "value", ":", "'inline'", "}", ")", "}", "}" ]
IE inline-block hack
[ "IE", "inline", "-", "block", "hack" ]
e8d15ec56a2dcf5cc01fcbcabe14362bc22d7f3d
https://github.com/fisker/cssgrace-lite/blob/e8d15ec56a2dcf5cc01fcbcabe14362bc22d7f3d/lib/index.js#L148-L167
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/base.js
function (s2) { var self = this; return !!util.reduce(self.keys, function (v, k) { return v && self[k] === s2[k]; }, 1); }
javascript
function (s2) { var self = this; return !!util.reduce(self.keys, function (v, k) { return v && self[k] === s2[k]; }, 1); }
[ "function", "(", "s2", ")", "{", "var", "self", "=", "this", ";", "return", "!", "!", "util", ".", "reduce", "(", "self", ".", "keys", ",", "function", "(", "v", ",", "k", ")", "{", "return", "v", "&&", "self", "[", "k", "]", "===", "s2", "[", "k", "]", ";", "}", ",", "1", ")", ";", "}" ]
whether current observer equals s2 @param {KISSY.Event.Observer} s2 another observer @return {Boolean}
[ "whether", "current", "observer", "equals", "s2" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/base.js#L211-L216
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/base.js
function (event, ce) { var ret, self = this; ret = self.fn.call(self.context || ce.currentTarget, event, self.data); if (self.once) { //noinspection JSUnresolvedFunction ce.removeObserver(self); } return ret; }
javascript
function (event, ce) { var ret, self = this; ret = self.fn.call(self.context || ce.currentTarget, event, self.data); if (self.once) { //noinspection JSUnresolvedFunction ce.removeObserver(self); } return ret; }
[ "function", "(", "event", ",", "ce", ")", "{", "var", "ret", ",", "self", "=", "this", ";", "ret", "=", "self", ".", "fn", ".", "call", "(", "self", ".", "context", "||", "ce", ".", "currentTarget", ",", "event", ",", "self", ".", "data", ")", ";", "if", "(", "self", ".", "once", ")", "{", "ce", ".", "removeObserver", "(", "self", ")", ";", "}", "return", "ret", ";", "}" ]
simple run current observer's user-defined function @param {KISSY.Event.Object} event @param {KISSY.Event.Observable} ce @return {*} return value of current observer's user-defined function
[ "simple", "run", "current", "observer", "s", "user", "-", "defined", "function" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/base.js#L223-L231
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/base.js
function (event, ce) { var ret = this.simpleNotify(event, ce); // return false 等价 preventDefault + stopPropagation // return false 等价 preventDefault + stopPropagation if (ret === false) { event.halt(); } return ret; }
javascript
function (event, ce) { var ret = this.simpleNotify(event, ce); // return false 等价 preventDefault + stopPropagation // return false 等价 preventDefault + stopPropagation if (ret === false) { event.halt(); } return ret; }
[ "function", "(", "event", ",", "ce", ")", "{", "var", "ret", "=", "this", ".", "simpleNotify", "(", "event", ",", "ce", ")", ";", "if", "(", "ret", "===", "false", ")", "{", "event", ".", "halt", "(", ")", ";", "}", "return", "ret", ";", "}" ]
current observer's notification. @protected @param {KISSY.Event.Object} event @param {KISSY.Event.Observable} ce
[ "current", "observer", "s", "notification", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/base.js#L238-L245
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/base.js
function (event, ce) { var self = this, _ksGroups = event._ksGroups; // handler's group does not match specified groups (at fire step) // handler's group does not match specified groups (at fire step) if (_ksGroups && (!self.groups || !self.groups.match(_ksGroups))) { return undef; } return self.notifyInternal(event, ce); }
javascript
function (event, ce) { var self = this, _ksGroups = event._ksGroups; // handler's group does not match specified groups (at fire step) // handler's group does not match specified groups (at fire step) if (_ksGroups && (!self.groups || !self.groups.match(_ksGroups))) { return undef; } return self.notifyInternal(event, ce); }
[ "function", "(", "event", ",", "ce", ")", "{", "var", "self", "=", "this", ",", "_ksGroups", "=", "event", ".", "_ksGroups", ";", "if", "(", "_ksGroups", "&&", "(", "!", "self", ".", "groups", "||", "!", "self", ".", "groups", ".", "match", "(", "_ksGroups", ")", ")", ")", "{", "return", "undef", ";", "}", "return", "self", ".", "notifyInternal", "(", "event", ",", "ce", ")", ";", "}" ]
run current observer's user-defined function @param event @param ce
[ "run", "current", "observer", "s", "user", "-", "defined", "function" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/base.js#L251-L258
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/base.js
Observable
function Observable(cfg) { var self = this; self.currentTarget = null; util.mix(self, cfg); self.reset(); /** * current event type * @cfg {String} type */ }
javascript
function Observable(cfg) { var self = this; self.currentTarget = null; util.mix(self, cfg); self.reset(); /** * current event type * @cfg {String} type */ }
[ "function", "Observable", "(", "cfg", ")", "{", "var", "self", "=", "this", ";", "self", ".", "currentTarget", "=", "null", ";", "util", ".", "mix", "(", "self", ",", "cfg", ")", ";", "self", ".", "reset", "(", ")", ";", "}" ]
base custom event for registering and un-registering observer for specified event. @class KISSY.Event.Observable @private @param {Object} cfg custom event's attribute base custom event for registering and un-registering observer for specified event. @class KISSY.Event.Observable @private @param {Object} cfg custom event's attribute
[ "base", "custom", "event", "for", "registering", "and", "un", "-", "registering", "observer", "for", "specified", "event", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/base.js#L280-L288
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/base.js
function (observer) { var self = this, i, observers = self.observers, len = observers.length; for (i = 0; i < len; i++) { if (observers[i] === observer) { observers.splice(i, 1); break; } } self.checkMemory(); }
javascript
function (observer) { var self = this, i, observers = self.observers, len = observers.length; for (i = 0; i < len; i++) { if (observers[i] === observer) { observers.splice(i, 1); break; } } self.checkMemory(); }
[ "function", "(", "observer", ")", "{", "var", "self", "=", "this", ",", "i", ",", "observers", "=", "self", ".", "observers", ",", "len", "=", "observers", ".", "length", ";", "for", "(", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "observers", "[", "i", "]", "===", "observer", ")", "{", "observers", ".", "splice", "(", "i", ",", "1", ")", ";", "break", ";", "}", "}", "self", ".", "checkMemory", "(", ")", ";", "}" ]
remove one observer from current event's observers @param {KISSY.Event.Observer} observer
[ "remove", "one", "observer", "from", "current", "event", "s", "observers" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/base.js#L313-L322
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/base.js
function (observer) { var observers = this.observers, i; for (i = observers.length - 1; i >= 0; --i) { /* If multiple identical EventListeners are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListener method. */ if (observer.equals(observers[i])) { return i; } } return -1; }
javascript
function (observer) { var observers = this.observers, i; for (i = observers.length - 1; i >= 0; --i) { /* If multiple identical EventListeners are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListener method. */ if (observer.equals(observers[i])) { return i; } } return -1; }
[ "function", "(", "observer", ")", "{", "var", "observers", "=", "this", ".", "observers", ",", "i", ";", "for", "(", "i", "=", "observers", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "if", "(", "observer", ".", "equals", "(", "observers", "[", "i", "]", ")", ")", "{", "return", "i", ";", "}", "}", "return", "-", "1", ";", "}" ]
Search for a specified observer within current event's observers @param {KISSY.Event.Observer} observer @return {Number} observer's index in observers
[ "Search", "for", "a", "specified", "observer", "within", "current", "event", "s", "observers" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/base.js#L334-L349
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/url-debug.js
function (str, parseQueryString) { var m = str.match(URI_SPLIT_REG) || [], ret = {}; // old ie 7: return "" for unmatched regexp ... // old ie 7: return "" for unmatched regexp ... for (var part in REG_INFO) { ret[part] = m[REG_INFO[part]]; } if (ret.protocol) { ret.protocol = ret.protocol.toLowerCase(); } if (ret.hostname) { ret.hostname = ret.hostname.toLowerCase(); } var protocol = ret.protocol; if (protocol) { ret.slashes = str.lastIndexOf(protocol + '//') !== -1; } // mailto: [email protected] // mailto: [email protected] if (protocol && !needDoubleSlash(protocol.slice(0, -1))) { if (!ret.slashes) { str = str.slice(0, protocol.length) + '//' + str.slice(protocol.length); ret = url.parse(str, parseQueryString); ret.slashes = null; return ret; } } else { // http://www.g.cn // pathname => / if (ret.hostname && !ret.pathname) { ret.pathname = '/'; } } ret.path = ret.pathname; if (ret.search) { ret.path += ret.search; } ret.host = ret.hostname; if (ret.port) { ret.host = ret.hostname + ':' + ret.port; } if (ret.search) { ret.query = ret.search.substring(1); } if (parseQueryString && ret.query) { ret.query = querystring.parse(ret.query); } ret.href = url.format(ret); return ret; }
javascript
function (str, parseQueryString) { var m = str.match(URI_SPLIT_REG) || [], ret = {}; // old ie 7: return "" for unmatched regexp ... // old ie 7: return "" for unmatched regexp ... for (var part in REG_INFO) { ret[part] = m[REG_INFO[part]]; } if (ret.protocol) { ret.protocol = ret.protocol.toLowerCase(); } if (ret.hostname) { ret.hostname = ret.hostname.toLowerCase(); } var protocol = ret.protocol; if (protocol) { ret.slashes = str.lastIndexOf(protocol + '//') !== -1; } // mailto: [email protected] // mailto: [email protected] if (protocol && !needDoubleSlash(protocol.slice(0, -1))) { if (!ret.slashes) { str = str.slice(0, protocol.length) + '//' + str.slice(protocol.length); ret = url.parse(str, parseQueryString); ret.slashes = null; return ret; } } else { // http://www.g.cn // pathname => / if (ret.hostname && !ret.pathname) { ret.pathname = '/'; } } ret.path = ret.pathname; if (ret.search) { ret.path += ret.search; } ret.host = ret.hostname; if (ret.port) { ret.host = ret.hostname + ':' + ret.port; } if (ret.search) { ret.query = ret.search.substring(1); } if (parseQueryString && ret.query) { ret.query = querystring.parse(ret.query); } ret.href = url.format(ret); return ret; }
[ "function", "(", "str", ",", "parseQueryString", ")", "{", "var", "m", "=", "str", ".", "match", "(", "URI_SPLIT_REG", ")", "||", "[", "]", ",", "ret", "=", "{", "}", ";", "for", "(", "var", "part", "in", "REG_INFO", ")", "{", "ret", "[", "part", "]", "=", "m", "[", "REG_INFO", "[", "part", "]", "]", ";", "}", "if", "(", "ret", ".", "protocol", ")", "{", "ret", ".", "protocol", "=", "ret", ".", "protocol", ".", "toLowerCase", "(", ")", ";", "}", "if", "(", "ret", ".", "hostname", ")", "{", "ret", ".", "hostname", "=", "ret", ".", "hostname", ".", "toLowerCase", "(", ")", ";", "}", "var", "protocol", "=", "ret", ".", "protocol", ";", "if", "(", "protocol", ")", "{", "ret", ".", "slashes", "=", "str", ".", "lastIndexOf", "(", "protocol", "+", "'//'", ")", "!==", "-", "1", ";", "}", "if", "(", "protocol", "&&", "!", "needDoubleSlash", "(", "protocol", ".", "slice", "(", "0", ",", "-", "1", ")", ")", ")", "{", "if", "(", "!", "ret", ".", "slashes", ")", "{", "str", "=", "str", ".", "slice", "(", "0", ",", "protocol", ".", "length", ")", "+", "'//'", "+", "str", ".", "slice", "(", "protocol", ".", "length", ")", ";", "ret", "=", "url", ".", "parse", "(", "str", ",", "parseQueryString", ")", ";", "ret", ".", "slashes", "=", "null", ";", "return", "ret", ";", "}", "}", "else", "{", "if", "(", "ret", ".", "hostname", "&&", "!", "ret", ".", "pathname", ")", "{", "ret", ".", "pathname", "=", "'/'", ";", "}", "}", "ret", ".", "path", "=", "ret", ".", "pathname", ";", "if", "(", "ret", ".", "search", ")", "{", "ret", ".", "path", "+=", "ret", ".", "search", ";", "}", "ret", ".", "host", "=", "ret", ".", "hostname", ";", "if", "(", "ret", ".", "port", ")", "{", "ret", ".", "host", "=", "ret", ".", "hostname", "+", "':'", "+", "ret", ".", "port", ";", "}", "if", "(", "ret", ".", "search", ")", "{", "ret", ".", "query", "=", "ret", ".", "search", ".", "substring", "(", "1", ")", ";", "}", "if", "(", "parseQueryString", "&&", "ret", ".", "query", ")", "{", "ret", ".", "query", "=", "querystring", ".", "parse", "(", "ret", ".", "query", ")", ";", "}", "ret", ".", "href", "=", "url", ".", "format", "(", "ret", ")", ";", "return", "ret", ";", "}" ]
parse a url to a structured object @param {String} str url string @param {Boolean} [parseQueryString] whether parse query string to structured object @return {Object}
[ "parse", "a", "url", "to", "a", "structured", "object" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/url-debug.js#L100-L147
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/url-debug.js
function (url, serializeArray) { var host = url.host; if (host === undef && url.hostname) { host = encodeURIComponent(url.hostname); if (url.port) { host += ':' + url.port; } } var search = url.search; var query = url.query; if (search === undef && query !== undef) { if (typeof query !== 'string') { query = querystring.stringify(query, undef, undef, serializeArray); } if (query) { search = '?' + query; } } if (search && search.charAt(0) !== '?') { search = '?' + search; } var hash = url.hash || ''; if (hash && hash.charAt(0) !== '#') { hash = '#' + hash; } var pathname = url.pathname || ''; var out = [], protocol, auth; if (protocol = url.protocol) { if (protocol.slice(0 - 1) !== ':') { protocol += ':'; } out.push(encodeSpecialChars(protocol, reDisallowedInProtocolOrAuth)); } if (host !== undef) { if (this.slashes || protocol && needDoubleSlash(protocol)) { out.push('//'); } if (auth = url.auth) { out.push(encodeSpecialChars(auth, reDisallowedInProtocolOrAuth)); out.push('@'); } out.push(host); } if (pathname) { out.push(encodeSpecialChars(pathname, reDisallowedInPathName)); } if (search) { out.push(search); } if (hash) { out.push('#' + encodeSpecialChars(hash.substring(1), reDisallowedInHash)); } return out.join(''); }
javascript
function (url, serializeArray) { var host = url.host; if (host === undef && url.hostname) { host = encodeURIComponent(url.hostname); if (url.port) { host += ':' + url.port; } } var search = url.search; var query = url.query; if (search === undef && query !== undef) { if (typeof query !== 'string') { query = querystring.stringify(query, undef, undef, serializeArray); } if (query) { search = '?' + query; } } if (search && search.charAt(0) !== '?') { search = '?' + search; } var hash = url.hash || ''; if (hash && hash.charAt(0) !== '#') { hash = '#' + hash; } var pathname = url.pathname || ''; var out = [], protocol, auth; if (protocol = url.protocol) { if (protocol.slice(0 - 1) !== ':') { protocol += ':'; } out.push(encodeSpecialChars(protocol, reDisallowedInProtocolOrAuth)); } if (host !== undef) { if (this.slashes || protocol && needDoubleSlash(protocol)) { out.push('//'); } if (auth = url.auth) { out.push(encodeSpecialChars(auth, reDisallowedInProtocolOrAuth)); out.push('@'); } out.push(host); } if (pathname) { out.push(encodeSpecialChars(pathname, reDisallowedInPathName)); } if (search) { out.push(search); } if (hash) { out.push('#' + encodeSpecialChars(hash.substring(1), reDisallowedInHash)); } return out.join(''); }
[ "function", "(", "url", ",", "serializeArray", ")", "{", "var", "host", "=", "url", ".", "host", ";", "if", "(", "host", "===", "undef", "&&", "url", ".", "hostname", ")", "{", "host", "=", "encodeURIComponent", "(", "url", ".", "hostname", ")", ";", "if", "(", "url", ".", "port", ")", "{", "host", "+=", "':'", "+", "url", ".", "port", ";", "}", "}", "var", "search", "=", "url", ".", "search", ";", "var", "query", "=", "url", ".", "query", ";", "if", "(", "search", "===", "undef", "&&", "query", "!==", "undef", ")", "{", "if", "(", "typeof", "query", "!==", "'string'", ")", "{", "query", "=", "querystring", ".", "stringify", "(", "query", ",", "undef", ",", "undef", ",", "serializeArray", ")", ";", "}", "if", "(", "query", ")", "{", "search", "=", "'?'", "+", "query", ";", "}", "}", "if", "(", "search", "&&", "search", ".", "charAt", "(", "0", ")", "!==", "'?'", ")", "{", "search", "=", "'?'", "+", "search", ";", "}", "var", "hash", "=", "url", ".", "hash", "||", "''", ";", "if", "(", "hash", "&&", "hash", ".", "charAt", "(", "0", ")", "!==", "'#'", ")", "{", "hash", "=", "'#'", "+", "hash", ";", "}", "var", "pathname", "=", "url", ".", "pathname", "||", "''", ";", "var", "out", "=", "[", "]", ",", "protocol", ",", "auth", ";", "if", "(", "protocol", "=", "url", ".", "protocol", ")", "{", "if", "(", "protocol", ".", "slice", "(", "0", "-", "1", ")", "!==", "':'", ")", "{", "protocol", "+=", "':'", ";", "}", "out", ".", "push", "(", "encodeSpecialChars", "(", "protocol", ",", "reDisallowedInProtocolOrAuth", ")", ")", ";", "}", "if", "(", "host", "!==", "undef", ")", "{", "if", "(", "this", ".", "slashes", "||", "protocol", "&&", "needDoubleSlash", "(", "protocol", ")", ")", "{", "out", ".", "push", "(", "'//'", ")", ";", "}", "if", "(", "auth", "=", "url", ".", "auth", ")", "{", "out", ".", "push", "(", "encodeSpecialChars", "(", "auth", ",", "reDisallowedInProtocolOrAuth", ")", ")", ";", "out", ".", "push", "(", "'@'", ")", ";", "}", "out", ".", "push", "(", "host", ")", ";", "}", "if", "(", "pathname", ")", "{", "out", ".", "push", "(", "encodeSpecialChars", "(", "pathname", ",", "reDisallowedInPathName", ")", ")", ";", "}", "if", "(", "search", ")", "{", "out", ".", "push", "(", "search", ")", ";", "}", "if", "(", "hash", ")", "{", "out", ".", "push", "(", "'#'", "+", "encodeSpecialChars", "(", "hash", ".", "substring", "(", "1", ")", ",", "reDisallowedInHash", ")", ")", ";", "}", "return", "out", ".", "join", "(", "''", ")", ";", "}" ]
Take a parsed URL object, and return a formatted URL string. @param {Object} url parsed from url.parse @param {Boolean} [serializeArray=true] whether add '[]' to array key of query data
[ "Take", "a", "parsed", "URL", "object", "and", "return", "a", "formatted", "URL", "string", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/url-debug.js#L153-L206
train
jonschlinkert/list-item
index.js
character
function character(options = {}) { let chars = options.chars || ['-', '*', '+']; if (typeof chars === 'string') { return fill(...chars.split('..'), options); } return chars; }
javascript
function character(options = {}) { let chars = options.chars || ['-', '*', '+']; if (typeof chars === 'string') { return fill(...chars.split('..'), options); } return chars; }
[ "function", "character", "(", "options", "=", "{", "}", ")", "{", "let", "chars", "=", "options", ".", "chars", "||", "[", "'-'", ",", "'*'", ",", "'+'", "]", ";", "if", "(", "typeof", "chars", "===", "'string'", ")", "{", "return", "fill", "(", "...", "chars", ".", "split", "(", "'..'", ")", ",", "options", ")", ";", "}", "return", "chars", ";", "}" ]
Create the array of characters to use as bullets. - http://spec.commonmark.org/0.19/#list-items - https://daringfireball.net/projects/markdown/syntax#list - https://help.github.com/articles/markdown-basics/#lists @param {Object} `opts` Options to pass to [fill-range][] @return {Array}
[ "Create", "the", "array", "of", "characters", "to", "use", "as", "bullets", "." ]
fb3827cd1a1af00ff636a41a0c6ad547ef31f3a0
https://github.com/jonschlinkert/list-item/blob/fb3827cd1a1af00ff636a41a0c6ad547ef31f3a0/index.js#L89-L97
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function (index) { var self = this; if (typeof index === 'number') { if (index >= self.length) { return null; } else { return new Node(self[index]); } } else { return new Node(index); } }
javascript
function (index) { var self = this; if (typeof index === 'number') { if (index >= self.length) { return null; } else { return new Node(self[index]); } } else { return new Node(index); } }
[ "function", "(", "index", ")", "{", "var", "self", "=", "this", ";", "if", "(", "typeof", "index", "===", "'number'", ")", "{", "if", "(", "index", ">=", "self", ".", "length", ")", "{", "return", "null", ";", "}", "else", "{", "return", "new", "Node", "(", "self", "[", "index", "]", ")", ";", "}", "}", "else", "{", "return", "new", "Node", "(", "index", ")", ";", "}", "}" ]
Get one node at index @param {Number} index Index position. @return {KISSY.Node}
[ "Get", "one", "node", "at", "index" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L107-L118
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function (selector, context, index) { if (typeof context === 'number') { index = context; context = undefined; } var list = Node.all(selector, context).getDOMNodes(), ret = new Node(this); if (index === undefined) { push.apply(ret, list); } else { var args = [ index, 0 ]; args.push.apply(args, list); AP.splice.apply(ret, args); } return ret; }
javascript
function (selector, context, index) { if (typeof context === 'number') { index = context; context = undefined; } var list = Node.all(selector, context).getDOMNodes(), ret = new Node(this); if (index === undefined) { push.apply(ret, list); } else { var args = [ index, 0 ]; args.push.apply(args, list); AP.splice.apply(ret, args); } return ret; }
[ "function", "(", "selector", ",", "context", ",", "index", ")", "{", "if", "(", "typeof", "context", "===", "'number'", ")", "{", "index", "=", "context", ";", "context", "=", "undefined", ";", "}", "var", "list", "=", "Node", ".", "all", "(", "selector", ",", "context", ")", ".", "getDOMNodes", "(", ")", ",", "ret", "=", "new", "Node", "(", "this", ")", ";", "if", "(", "index", "===", "undefined", ")", "{", "push", ".", "apply", "(", "ret", ",", "list", ")", ";", "}", "else", "{", "var", "args", "=", "[", "index", ",", "0", "]", ";", "args", ".", "push", ".", "apply", "(", "args", ",", "list", ")", ";", "AP", ".", "splice", ".", "apply", "(", "ret", ",", "args", ")", ";", "}", "return", "ret", ";", "}" ]
return a new Node object which consists of current node list and parameter node list. @param {KISSY.Node} selector Selector string or html string or common dom node. @param {KISSY.Node|Number} [context] Search context for selector @param {Number} [index] Insert position. @return {KISSY.Node} a new Node
[ "return", "a", "new", "Node", "object", "which", "consists", "of", "current", "node", "list", "and", "parameter", "node", "list", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L126-L143
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function (fn, context) { var self = this; util.each(self, function (n, i) { n = new Node(n); return fn.call(context || n, n, i, self); }); return self; }
javascript
function (fn, context) { var self = this; util.each(self, function (n, i) { n = new Node(n); return fn.call(context || n, n, i, self); }); return self; }
[ "function", "(", "fn", ",", "context", ")", "{", "var", "self", "=", "this", ";", "util", ".", "each", "(", "self", ",", "function", "(", "n", ",", "i", ")", "{", "n", "=", "new", "Node", "(", "n", ")", ";", "return", "fn", ".", "call", "(", "context", "||", "n", ",", "n", ",", "i", ",", "self", ")", ";", "}", ")", ";", "return", "self", ";", "}" ]
Applies the given function to each Node in the Node. @param {Function} fn The function to apply. It receives 3 arguments: the current node instance, the node's index, and the Node instance @param [context] An optional context to apply the function with Default context is the current Node instance @return {KISSY.Node}
[ "Applies", "the", "given", "function", "to", "each", "Node", "in", "the", "Node", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L170-L177
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function (selector) { var ret, self = this; if (self.length > 0) { ret = Node.all(selector, self); } else { ret = new Node(); } ret.__parent = self; return ret; }
javascript
function (selector) { var ret, self = this; if (self.length > 0) { ret = Node.all(selector, self); } else { ret = new Node(); } ret.__parent = self; return ret; }
[ "function", "(", "selector", ")", "{", "var", "ret", ",", "self", "=", "this", ";", "if", "(", "self", ".", "length", ">", "0", ")", "{", "ret", "=", "Node", ".", "all", "(", "selector", ",", "self", ")", ";", "}", "else", "{", "ret", "=", "new", "Node", "(", ")", ";", "}", "ret", ".", "__parent", "=", "self", ";", "return", "ret", ";", "}" ]
Get node list which are descendants of current node list. @param {String} selector Selector string @return {KISSY.Node}
[ "Get", "node", "list", "which", "are", "descendants", "of", "current", "node", "list", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L206-L215
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function (selector) { var self = this, all = self.all(selector), ret = all.length ? all.slice(0, 1) : null; if (ret) { ret.__parent = self; } return ret; }
javascript
function (selector) { var self = this, all = self.all(selector), ret = all.length ? all.slice(0, 1) : null; if (ret) { ret.__parent = self; } return ret; }
[ "function", "(", "selector", ")", "{", "var", "self", "=", "this", ",", "all", "=", "self", ".", "all", "(", "selector", ")", ",", "ret", "=", "all", ".", "length", "?", "all", ".", "slice", "(", "0", ",", "1", ")", ":", "null", ";", "if", "(", "ret", ")", "{", "ret", ".", "__parent", "=", "self", ";", "}", "return", "ret", ";", "}" ]
Get node list which match selector under current node list sub tree. @param {String} selector @return {KISSY.Node}
[ "Get", "node", "list", "which", "match", "selector", "under", "current", "node", "list", "sub", "tree", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L221-L227
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function (selector, context) { // are we dealing with html string ? // TextNode 仍需要自己 new Node if (typeof selector === 'string' && (selector = util.trim(selector)) && selector.length >= 3 && util.startsWith(selector, '<') && util.endsWith(selector, '>')) { var attrs; if (context) { if (context.getDOMNode) { context = context[0]; } if (!context.nodeType) { attrs = context; context = arguments[2]; } } return new Node(selector, attrs, context); } return new Node(Dom.query(selector, context)); }
javascript
function (selector, context) { // are we dealing with html string ? // TextNode 仍需要自己 new Node if (typeof selector === 'string' && (selector = util.trim(selector)) && selector.length >= 3 && util.startsWith(selector, '<') && util.endsWith(selector, '>')) { var attrs; if (context) { if (context.getDOMNode) { context = context[0]; } if (!context.nodeType) { attrs = context; context = arguments[2]; } } return new Node(selector, attrs, context); } return new Node(Dom.query(selector, context)); }
[ "function", "(", "selector", ",", "context", ")", "{", "if", "(", "typeof", "selector", "===", "'string'", "&&", "(", "selector", "=", "util", ".", "trim", "(", "selector", ")", ")", "&&", "selector", ".", "length", ">=", "3", "&&", "util", ".", "startsWith", "(", "selector", ",", "'<'", ")", "&&", "util", ".", "endsWith", "(", "selector", ",", "'>'", ")", ")", "{", "var", "attrs", ";", "if", "(", "context", ")", "{", "if", "(", "context", ".", "getDOMNode", ")", "{", "context", "=", "context", "[", "0", "]", ";", "}", "if", "(", "!", "context", ".", "nodeType", ")", "{", "attrs", "=", "context", ";", "context", "=", "arguments", "[", "2", "]", ";", "}", "}", "return", "new", "Node", "(", "selector", ",", "attrs", ",", "context", ")", ";", "}", "return", "new", "Node", "(", "Dom", ".", "query", "(", "selector", ",", "context", ")", ")", ";", "}" ]
Get node list from selector or construct new node list from html string. Can also called from KISSY.all @param {String|KISSY.Node} selector Selector string or html string or common dom node. @param {String|KISSY.Node} [context] Search context for selector @return {KISSY.Node} @member KISSY.Node @static
[ "Get", "node", "list", "from", "selector", "or", "construct", "new", "node", "list", "from", "html", "string", ".", "Can", "also", "called", "from", "KISSY", ".", "all" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L239-L256
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function (selector, context) { var all = Node.all(selector, context); return all.length ? all.slice(0, 1) : null; }
javascript
function (selector, context) { var all = Node.all(selector, context); return all.length ? all.slice(0, 1) : null; }
[ "function", "(", "selector", ",", "context", ")", "{", "var", "all", "=", "Node", ".", "all", "(", "selector", ",", "context", ")", ";", "return", "all", ".", "length", "?", "all", ".", "slice", "(", "0", ",", "1", ")", ":", "null", ";", "}" ]
Get node list with length of one from selector or construct new node list from html string. @param {String|KISSY.Node} selector Selector string or html string or common dom node. @param {String|KISSY.Node} [context] Search context for selector @return {KISSY.Node} @member KISSY.Node @static
[ "Get", "node", "list", "with", "length", "of", "one", "from", "selector", "or", "construct", "new", "node", "list", "from", "html", "string", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L266-L269
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function () { var self = this, l = self.length, needClone = self.length > 1, originArgs = util.makeArray(arguments); var cfg = originArgs[0]; var AnimConstructor = Anim; if (cfg.to) { AnimConstructor = cfg.Anim || Anim; } else { cfg = originArgs[1]; if (cfg) { AnimConstructor = cfg.Anim || Anim; } } for (var i = 0; i < l; i++) { var elem = self[i]; var args = needClone ? util.clone(originArgs) : originArgs, arg0 = args[0]; if (arg0.to) { arg0.node = elem; new AnimConstructor(arg0).run(); } else { AnimConstructor.apply(undefined, [elem].concat(args)).run(); } } return self; }
javascript
function () { var self = this, l = self.length, needClone = self.length > 1, originArgs = util.makeArray(arguments); var cfg = originArgs[0]; var AnimConstructor = Anim; if (cfg.to) { AnimConstructor = cfg.Anim || Anim; } else { cfg = originArgs[1]; if (cfg) { AnimConstructor = cfg.Anim || Anim; } } for (var i = 0; i < l; i++) { var elem = self[i]; var args = needClone ? util.clone(originArgs) : originArgs, arg0 = args[0]; if (arg0.to) { arg0.node = elem; new AnimConstructor(arg0).run(); } else { AnimConstructor.apply(undefined, [elem].concat(args)).run(); } } return self; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "l", "=", "self", ".", "length", ",", "needClone", "=", "self", ".", "length", ">", "1", ",", "originArgs", "=", "util", ".", "makeArray", "(", "arguments", ")", ";", "var", "cfg", "=", "originArgs", "[", "0", "]", ";", "var", "AnimConstructor", "=", "Anim", ";", "if", "(", "cfg", ".", "to", ")", "{", "AnimConstructor", "=", "cfg", ".", "Anim", "||", "Anim", ";", "}", "else", "{", "cfg", "=", "originArgs", "[", "1", "]", ";", "if", "(", "cfg", ")", "{", "AnimConstructor", "=", "cfg", ".", "Anim", "||", "Anim", ";", "}", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "var", "elem", "=", "self", "[", "i", "]", ";", "var", "args", "=", "needClone", "?", "util", ".", "clone", "(", "originArgs", ")", ":", "originArgs", ",", "arg0", "=", "args", "[", "0", "]", ";", "if", "(", "arg0", ".", "to", ")", "{", "arg0", ".", "node", "=", "elem", ";", "new", "AnimConstructor", "(", "arg0", ")", ".", "run", "(", ")", ";", "}", "else", "{", "AnimConstructor", ".", "apply", "(", "undefined", ",", "[", "elem", "]", ".", "concat", "(", "args", ")", ")", ".", "run", "(", ")", ";", "}", "}", "return", "self", ";", "}" ]
animate for current node list. @chainable @member KISSY.Node
[ "animate", "for", "current", "node", "list", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L616-L639
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function (end, clearQueue, queue) { var self = this; util.each(self, function (elem) { Anim.stop(elem, end, clearQueue, queue); }); return self; }
javascript
function (end, clearQueue, queue) { var self = this; util.each(self, function (elem) { Anim.stop(elem, end, clearQueue, queue); }); return self; }
[ "function", "(", "end", ",", "clearQueue", ",", "queue", ")", "{", "var", "self", "=", "this", ";", "util", ".", "each", "(", "self", ",", "function", "(", "elem", ")", "{", "Anim", ".", "stop", "(", "elem", ",", "end", ",", "clearQueue", ",", "queue", ")", ";", "}", ")", ";", "return", "self", ";", "}" ]
stop anim of current node list. @param {Boolean} [end] see {@link KISSY.Anim#static-method-stop} @param [clearQueue] @param [queue] @chainable @member KISSY.Node
[ "stop", "anim", "of", "current", "node", "list", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L648-L654
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function (end, queue) { var self = this; util.each(self, function (elem) { Anim.pause(elem, queue); }); return self; }
javascript
function (end, queue) { var self = this; util.each(self, function (elem) { Anim.pause(elem, queue); }); return self; }
[ "function", "(", "end", ",", "queue", ")", "{", "var", "self", "=", "this", ";", "util", ".", "each", "(", "self", ",", "function", "(", "elem", ")", "{", "Anim", ".", "pause", "(", "elem", ",", "queue", ")", ";", "}", ")", ";", "return", "self", ";", "}" ]
pause anim of current node list. @param {Boolean} end see {@link KISSY.Anim#static-method-pause} @param queue @chainable @member KISSY.Node
[ "pause", "anim", "of", "current", "node", "list", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L662-L668
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function (end, queue) { var self = this; util.each(self, function (elem) { Anim.resume(elem, queue); }); return self; }
javascript
function (end, queue) { var self = this; util.each(self, function (elem) { Anim.resume(elem, queue); }); return self; }
[ "function", "(", "end", ",", "queue", ")", "{", "var", "self", "=", "this", ";", "util", ".", "each", "(", "self", ",", "function", "(", "elem", ")", "{", "Anim", ".", "resume", "(", "elem", ",", "queue", ")", ";", "}", ")", ";", "return", "self", ";", "}" ]
resume anim of current node list. @param {Boolean} end see {@link KISSY.Anim#static-method-resume} @param queue @chainable @member KISSY.Node
[ "resume", "anim", "of", "current", "node", "list", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L676-L682
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function () { var self = this; for (var i = 0; i < self.length; i++) { if (Anim.isRunning(self[i])) { return true; } } return false; }
javascript
function () { var self = this; for (var i = 0; i < self.length; i++) { if (Anim.isRunning(self[i])) { return true; } } return false; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "self", ".", "length", ";", "i", "++", ")", "{", "if", "(", "Anim", ".", "isRunning", "(", "self", "[", "i", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
whether one of current node list is animating. @return {Boolean} @member KISSY.Node
[ "whether", "one", "of", "current", "node", "list", "is", "animating", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L688-L696
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/node-debug.js
function () { var self = this; for (var i = 0; i < self.length; i++) { if (Anim.isPaused(self[i])) { return true; } } return false; }
javascript
function () { var self = this; for (var i = 0; i < self.length; i++) { if (Anim.isPaused(self[i])) { return true; } } return false; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "self", ".", "length", ";", "i", "++", ")", "{", "if", "(", "Anim", ".", "isPaused", "(", "self", "[", "i", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
whether one of current node list 's animation is paused. @return {Boolean} @member KISSY.Node
[ "whether", "one", "of", "current", "node", "list", "s", "animation", "is", "paused", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/node-debug.js#L702-L710
train
craterdog-bali/js-bali-component-framework
src/utilities/Exception.js
Exception
function Exception(attributes, cause) { this.stack = Error().stack; if (this.stack) this.stack = 'Exception' + this.stack.slice(5); // replace 'Error' with 'Exception' this.attributes = this.convert(attributes); this.message = this.attributes.getValue('$text').getValue(); this.cause = cause; return this; }
javascript
function Exception(attributes, cause) { this.stack = Error().stack; if (this.stack) this.stack = 'Exception' + this.stack.slice(5); // replace 'Error' with 'Exception' this.attributes = this.convert(attributes); this.message = this.attributes.getValue('$text').getValue(); this.cause = cause; return this; }
[ "function", "Exception", "(", "attributes", ",", "cause", ")", "{", "this", ".", "stack", "=", "Error", "(", ")", ".", "stack", ";", "if", "(", "this", ".", "stack", ")", "this", ".", "stack", "=", "'Exception'", "+", "this", ".", "stack", ".", "slice", "(", "5", ")", ";", "this", ".", "attributes", "=", "this", ".", "convert", "(", "attributes", ")", ";", "this", ".", "message", "=", "this", ".", "attributes", ".", "getValue", "(", "'$text'", ")", ".", "getValue", "(", ")", ";", "this", ".", "cause", "=", "cause", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTORS This constructor creates a new Bali exception with the specified attributes. @constructor @param {Object} attributes An object containing the exception attributes. @param {Object} cause An optional exception that caused this one. @returns {Exception} The new exception.
[ "PUBLIC", "CONSTRUCTORS", "This", "constructor", "creates", "a", "new", "Bali", "exception", "with", "the", "specified", "attributes", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/utilities/Exception.js#L23-L30
train
UnsignedInt8/LINQ
linq.js
aggregate
function aggregate(transform) { switch (arguments.length) { case 1: return aggregate_seed_transform_selector.apply(this, [undefined, arguments[0]]); default: return aggregate_seed_transform_selector.apply(this, arguments); } }
javascript
function aggregate(transform) { switch (arguments.length) { case 1: return aggregate_seed_transform_selector.apply(this, [undefined, arguments[0]]); default: return aggregate_seed_transform_selector.apply(this, arguments); } }
[ "function", "aggregate", "(", "transform", ")", "{", "switch", "(", "arguments", ".", "length", ")", "{", "case", "1", ":", "return", "aggregate_seed_transform_selector", ".", "apply", "(", "this", ",", "[", "undefined", ",", "arguments", "[", "0", "]", "]", ")", ";", "default", ":", "return", "aggregate_seed_transform_selector", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "}" ]
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value. @param seed The initial accumulator value. @param transform An accumulator function to be invoked on each element. @param resultTransform A function to transform the final accumulator value into the result value. @return The transformed final accumulator value. transform: (current, next) -> result
[ "Applies", "an", "accumulator", "function", "over", "a", "sequence", ".", "The", "specified", "seed", "value", "is", "used", "as", "the", "initial", "accumulator", "value", "and", "the", "specified", "function", "is", "used", "to", "select", "the", "result", "value", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L26-L33
train
UnsignedInt8/LINQ
linq.js
any
function any(predicate) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; for (let item of this) { if (predicate(item)) return true; } return false; }
javascript
function any(predicate) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; for (let item of this) { if (predicate(item)) return true; } return false; }
[ "function", "any", "(", "predicate", ")", "{", "predicate", "=", "typeof", "predicate", "===", "'function'", "?", "predicate", ":", "util", ".", "defaultPredicate", ";", "for", "(", "let", "item", "of", "this", ")", "{", "if", "(", "predicate", "(", "item", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determines whether a sequence contains any elements. @param {(Function)} predicate The function called per iteraction till returns true. @return Any elements satisfy a condition returns true, or returns false. predicate: (T) -> Boolean
[ "Determines", "whether", "a", "sequence", "contains", "any", "elements", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L79-L87
train
UnsignedInt8/LINQ
linq.js
contains
function contains(item, equalityComparer) { equalityComparer = typeof equalityComparer === 'function' ? equalityComparer : util.defaultEqualityComparer; for (let i of this) { if (equalityComparer(i, item)) return true; } return false; }
javascript
function contains(item, equalityComparer) { equalityComparer = typeof equalityComparer === 'function' ? equalityComparer : util.defaultEqualityComparer; for (let i of this) { if (equalityComparer(i, item)) return true; } return false; }
[ "function", "contains", "(", "item", ",", "equalityComparer", ")", "{", "equalityComparer", "=", "typeof", "equalityComparer", "===", "'function'", "?", "equalityComparer", ":", "util", ".", "defaultEqualityComparer", ";", "for", "(", "let", "i", "of", "this", ")", "{", "if", "(", "equalityComparer", "(", "i", ",", "item", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determines whether a sequence contains a specified element by using the default equality comparer. @param item The item which you want to check. @param {(Function)} equalityComparer The equality comparer. equalityComparer: (item1, item2) -> Boolean
[ "Determines", "whether", "a", "sequence", "contains", "a", "specified", "element", "by", "using", "the", "default", "equality", "comparer", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L122-L130
train
UnsignedInt8/LINQ
linq.js
count
function count(predicate) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; let c = 0; for (let item of this) { if (predicate(item)) c++; } return c; }
javascript
function count(predicate) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; let c = 0; for (let item of this) { if (predicate(item)) c++; } return c; }
[ "function", "count", "(", "predicate", ")", "{", "predicate", "=", "typeof", "predicate", "===", "'function'", "?", "predicate", ":", "util", ".", "defaultPredicate", ";", "let", "c", "=", "0", ";", "for", "(", "let", "item", "of", "this", ")", "{", "if", "(", "predicate", "(", "item", ")", ")", "c", "++", ";", "}", "return", "c", ";", "}" ]
Returns a number that represents how many elements in the specified sequence satisfy a condition. @param {(Function)} predicate The condition for compute item counts @return Return the count which satisfy a condition.
[ "Returns", "a", "number", "that", "represents", "how", "many", "elements", "in", "the", "specified", "sequence", "satisfy", "a", "condition", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L138-L148
train
UnsignedInt8/LINQ
linq.js
elementAt
function elementAt(index, defaultValue) { let i = 0; for (let item of this) { if (i === index) return item; i++; } return defaultValue; }
javascript
function elementAt(index, defaultValue) { let i = 0; for (let item of this) { if (i === index) return item; i++; } return defaultValue; }
[ "function", "elementAt", "(", "index", ",", "defaultValue", ")", "{", "let", "i", "=", "0", ";", "for", "(", "let", "item", "of", "this", ")", "{", "if", "(", "i", "===", "index", ")", "return", "item", ";", "i", "++", ";", "}", "return", "defaultValue", ";", "}" ]
Returns the element at a specified index in a sequence. @param positon The zero-base index of element which you want. @param defaultValue The default value if the index is out of range. @return The element at a specified index or default value
[ "Returns", "the", "element", "at", "a", "specified", "index", "in", "a", "sequence", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L203-L212
train
UnsignedInt8/LINQ
linq.js
first
function first(predicate) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; let error = new Error('No element satisfies the condition in predicate.'); let firstElement = firstOrDefault.apply(this, [predicate, error]); if (firstElement === error) throw error; return firstElement; }
javascript
function first(predicate) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; let error = new Error('No element satisfies the condition in predicate.'); let firstElement = firstOrDefault.apply(this, [predicate, error]); if (firstElement === error) throw error; return firstElement; }
[ "function", "first", "(", "predicate", ")", "{", "predicate", "=", "typeof", "predicate", "===", "'function'", "?", "predicate", ":", "util", ".", "defaultPredicate", ";", "let", "error", "=", "new", "Error", "(", "'No element satisfies the condition in predicate.'", ")", ";", "let", "firstElement", "=", "firstOrDefault", ".", "apply", "(", "this", ",", "[", "predicate", ",", "error", "]", ")", ";", "if", "(", "firstElement", "===", "error", ")", "throw", "error", ";", "return", "firstElement", ";", "}" ]
Returns the first element in a sequence that satisfies a specified condition or throws an error if not found. @param {(Function)} predicate The function called per iteraction till returns true. @param defaultValue The default value. @return The first element which satisfy condition or default value.
[ "Returns", "the", "first", "element", "in", "a", "sequence", "that", "satisfies", "a", "specified", "condition", "or", "throws", "an", "error", "if", "not", "found", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L265-L273
train
UnsignedInt8/LINQ
linq.js
firstOrDefault
function firstOrDefault(predicate, defaultValue) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; for (let item of this) { if (predicate(item)) return item; } return defaultValue; }
javascript
function firstOrDefault(predicate, defaultValue) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; for (let item of this) { if (predicate(item)) return item; } return defaultValue; }
[ "function", "firstOrDefault", "(", "predicate", ",", "defaultValue", ")", "{", "predicate", "=", "typeof", "predicate", "===", "'function'", "?", "predicate", ":", "util", ".", "defaultPredicate", ";", "for", "(", "let", "item", "of", "this", ")", "{", "if", "(", "predicate", "(", "item", ")", ")", "return", "item", ";", "}", "return", "defaultValue", ";", "}" ]
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. @param {(Function)} predicate The function called per iteraction till returns true. @param defaultValue The default value.
[ "Returns", "the", "first", "element", "of", "the", "sequence", "that", "satisfies", "a", "condition", "or", "a", "default", "value", "if", "no", "such", "element", "is", "found", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L281-L289
train
UnsignedInt8/LINQ
linq.js
last
function last(predicate, defaultValue) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; let lastValue; let found = false; for (let item of this.where(predicate)) { lastValue = item; found = true; } return found ? lastValue : defaultValue; }
javascript
function last(predicate, defaultValue) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; let lastValue; let found = false; for (let item of this.where(predicate)) { lastValue = item; found = true; } return found ? lastValue : defaultValue; }
[ "function", "last", "(", "predicate", ",", "defaultValue", ")", "{", "predicate", "=", "typeof", "predicate", "===", "'function'", "?", "predicate", ":", "util", ".", "defaultPredicate", ";", "let", "lastValue", ";", "let", "found", "=", "false", ";", "for", "(", "let", "item", "of", "this", ".", "where", "(", "predicate", ")", ")", "{", "lastValue", "=", "item", ";", "found", "=", "true", ";", "}", "return", "found", "?", "lastValue", ":", "defaultValue", ";", "}" ]
Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. @param predicate A function to test each element for a condition. @param defaultValue The default value if no such element is found. @return Default value if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that passes the test in the predicate function.
[ "Returns", "the", "last", "element", "of", "a", "sequence", "that", "satisfies", "a", "condition", "or", "a", "default", "value", "if", "no", "such", "element", "is", "found", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L439-L450
train
UnsignedInt8/LINQ
linq.js
max
function max(keySelector, comparer) { let itComparer = typeof comparer === 'function' ? comparer : util.defaultComparer; let itKeySelector = typeof keySelector === 'function' ? keySelector : (i) => i; let maximum = this.firstOrDefault(); for (let item of this) { maximum = itComparer(itKeySelector(item), itKeySelector(maximum)) > 0 ? item : maximum; } return maximum; }
javascript
function max(keySelector, comparer) { let itComparer = typeof comparer === 'function' ? comparer : util.defaultComparer; let itKeySelector = typeof keySelector === 'function' ? keySelector : (i) => i; let maximum = this.firstOrDefault(); for (let item of this) { maximum = itComparer(itKeySelector(item), itKeySelector(maximum)) > 0 ? item : maximum; } return maximum; }
[ "function", "max", "(", "keySelector", ",", "comparer", ")", "{", "let", "itComparer", "=", "typeof", "comparer", "===", "'function'", "?", "comparer", ":", "util", ".", "defaultComparer", ";", "let", "itKeySelector", "=", "typeof", "keySelector", "===", "'function'", "?", "keySelector", ":", "(", "i", ")", "=>", "i", ";", "let", "maximum", "=", "this", ".", "firstOrDefault", "(", ")", ";", "for", "(", "let", "item", "of", "this", ")", "{", "maximum", "=", "itComparer", "(", "itKeySelector", "(", "item", ")", ",", "itKeySelector", "(", "maximum", ")", ")", ">", "0", "?", "item", ":", "maximum", ";", "}", "return", "maximum", ";", "}" ]
Returns the maximum value in a sequence. @param keySelector A transform function to apply to each element. @param comparer A comparer function to check with item is greater. @return The maximum value in the sequence. keySelector: (T) -> key comparer: (item1, item2) -> -1|0|1
[ "Returns", "the", "maximum", "value", "in", "a", "sequence", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L461-L472
train
UnsignedInt8/LINQ
linq.js
min
function min(keySelector, comparer) { let itComparer = typeof comparer === 'function' ? comparer : util.defaultComparer; let itKeySelector = typeof keySelector === 'function' ? keySelector : (i) => i; let minimum = this.firstOrDefault(); for (let item of this) { minimum = itComparer(itKeySelector(item), itKeySelector(minimum)) < 0 ? item : minimum; } return minimum; }
javascript
function min(keySelector, comparer) { let itComparer = typeof comparer === 'function' ? comparer : util.defaultComparer; let itKeySelector = typeof keySelector === 'function' ? keySelector : (i) => i; let minimum = this.firstOrDefault(); for (let item of this) { minimum = itComparer(itKeySelector(item), itKeySelector(minimum)) < 0 ? item : minimum; } return minimum; }
[ "function", "min", "(", "keySelector", ",", "comparer", ")", "{", "let", "itComparer", "=", "typeof", "comparer", "===", "'function'", "?", "comparer", ":", "util", ".", "defaultComparer", ";", "let", "itKeySelector", "=", "typeof", "keySelector", "===", "'function'", "?", "keySelector", ":", "(", "i", ")", "=>", "i", ";", "let", "minimum", "=", "this", ".", "firstOrDefault", "(", ")", ";", "for", "(", "let", "item", "of", "this", ")", "{", "minimum", "=", "itComparer", "(", "itKeySelector", "(", "item", ")", ",", "itKeySelector", "(", "minimum", ")", ")", "<", "0", "?", "item", ":", "minimum", ";", "}", "return", "minimum", ";", "}" ]
Returns the minimum value in a sequence. @param keySelector A transform function to apply to each element. @param comparer A comparer function to check with item is less. @return The minimum value in the sequence.
[ "Returns", "the", "minimum", "value", "in", "a", "sequence", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L481-L492
train
UnsignedInt8/LINQ
linq.js
sequenceEqual
function sequenceEqual(otherSequence, equalityComparer) { equalityComparer = typeof equalityComparer === 'function' ? equalityComparer : util.defaultEqualityComparer; let selfIterator = this[Symbol.iterator] ? this[Symbol.iterator]() : undefined; let otherIterator = otherSequence[Symbol.iterator] ? otherSequence[Symbol.iterator]() : undefined; if (toLinqable([selfIterator, otherIterator]).any(i => i === undefined)) return false; let selfItem; let otherItem; do { selfItem = selfIterator.next(); otherItem = otherIterator.next(); if (!equalityComparer(selfItem.value, otherItem.value)) return false; } while (!selfItem.done); return selfItem.done === otherItem.done; }
javascript
function sequenceEqual(otherSequence, equalityComparer) { equalityComparer = typeof equalityComparer === 'function' ? equalityComparer : util.defaultEqualityComparer; let selfIterator = this[Symbol.iterator] ? this[Symbol.iterator]() : undefined; let otherIterator = otherSequence[Symbol.iterator] ? otherSequence[Symbol.iterator]() : undefined; if (toLinqable([selfIterator, otherIterator]).any(i => i === undefined)) return false; let selfItem; let otherItem; do { selfItem = selfIterator.next(); otherItem = otherIterator.next(); if (!equalityComparer(selfItem.value, otherItem.value)) return false; } while (!selfItem.done); return selfItem.done === otherItem.done; }
[ "function", "sequenceEqual", "(", "otherSequence", ",", "equalityComparer", ")", "{", "equalityComparer", "=", "typeof", "equalityComparer", "===", "'function'", "?", "equalityComparer", ":", "util", ".", "defaultEqualityComparer", ";", "let", "selfIterator", "=", "this", "[", "Symbol", ".", "iterator", "]", "?", "this", "[", "Symbol", ".", "iterator", "]", "(", ")", ":", "undefined", ";", "let", "otherIterator", "=", "otherSequence", "[", "Symbol", ".", "iterator", "]", "?", "otherSequence", "[", "Symbol", ".", "iterator", "]", "(", ")", ":", "undefined", ";", "if", "(", "toLinqable", "(", "[", "selfIterator", ",", "otherIterator", "]", ")", ".", "any", "(", "i", "=>", "i", "===", "undefined", ")", ")", "return", "false", ";", "let", "selfItem", ";", "let", "otherItem", ";", "do", "{", "selfItem", "=", "selfIterator", ".", "next", "(", ")", ";", "otherItem", "=", "otherIterator", ".", "next", "(", ")", ";", "if", "(", "!", "equalityComparer", "(", "selfItem", ".", "value", ",", "otherItem", ".", "value", ")", ")", "return", "false", ";", "}", "while", "(", "!", "selfItem", ".", "done", ")", ";", "return", "selfItem", ".", "done", "===", "otherItem", ".", "done", ";", "}" ]
Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type. @param otherSequence A sequence to compare to the first sequence. @return true if the two source sequences are of equal length and their corresponding elements are equal according to the equality comparer for their type; otherwise, false.
[ "Determines", "whether", "two", "sequences", "are", "equal", "by", "comparing", "the", "elements", "by", "using", "the", "default", "equality", "comparer", "for", "their", "type", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L644-L662
train
UnsignedInt8/LINQ
linq.js
single
function single(predicate, defaultValue) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; let count = 0; let singleItem = undefined; for (let item of this) { if (predicate(item)) { if (singleItem === undefined) { singleItem = item; } else { throw new Error('More than one element satisfies the condition in predicate.'); } } count++; } if (singleItem === undefined && arguments.length == 2) return defaultValue; if (count === 0) throw new Error('The source sequence is empty.'); if (!singleItem) throw new Error('No element satisfies the condition in predicate.'); return singleItem; }
javascript
function single(predicate, defaultValue) { predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate; let count = 0; let singleItem = undefined; for (let item of this) { if (predicate(item)) { if (singleItem === undefined) { singleItem = item; } else { throw new Error('More than one element satisfies the condition in predicate.'); } } count++; } if (singleItem === undefined && arguments.length == 2) return defaultValue; if (count === 0) throw new Error('The source sequence is empty.'); if (!singleItem) throw new Error('No element satisfies the condition in predicate.'); return singleItem; }
[ "function", "single", "(", "predicate", ",", "defaultValue", ")", "{", "predicate", "=", "typeof", "predicate", "===", "'function'", "?", "predicate", ":", "util", ".", "defaultPredicate", ";", "let", "count", "=", "0", ";", "let", "singleItem", "=", "undefined", ";", "for", "(", "let", "item", "of", "this", ")", "{", "if", "(", "predicate", "(", "item", ")", ")", "{", "if", "(", "singleItem", "===", "undefined", ")", "{", "singleItem", "=", "item", ";", "}", "else", "{", "throw", "new", "Error", "(", "'More than one element satisfies the condition in predicate.'", ")", ";", "}", "}", "count", "++", ";", "}", "if", "(", "singleItem", "===", "undefined", "&&", "arguments", ".", "length", "==", "2", ")", "return", "defaultValue", ";", "if", "(", "count", "===", "0", ")", "throw", "new", "Error", "(", "'The source sequence is empty.'", ")", ";", "if", "(", "!", "singleItem", ")", "throw", "new", "Error", "(", "'No element satisfies the condition in predicate.'", ")", ";", "return", "singleItem", ";", "}" ]
Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition or sequence is empty. @param predicate A function to test an element for a condition. @param defaultValue The default value if no such element exists. @return The single element of the input sequence that satisfies a condition.
[ "Returns", "the", "only", "element", "of", "a", "sequence", "that", "satisfies", "a", "specified", "condition", "or", "a", "default", "value", "if", "no", "such", "element", "exists", ";", "this", "method", "throws", "an", "exception", "if", "more", "than", "one", "element", "satisfies", "the", "condition", "or", "sequence", "is", "empty", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L671-L694
train
UnsignedInt8/LINQ
linq.js
sum
function sum(transform) { let sum = 0; let seq = typeof transform === 'function' ? this.select(transform) : this; for (let item of seq) { sum += Number.parseFloat(item); } return sum; }
javascript
function sum(transform) { let sum = 0; let seq = typeof transform === 'function' ? this.select(transform) : this; for (let item of seq) { sum += Number.parseFloat(item); } return sum; }
[ "function", "sum", "(", "transform", ")", "{", "let", "sum", "=", "0", ";", "let", "seq", "=", "typeof", "transform", "===", "'function'", "?", "this", ".", "select", "(", "transform", ")", ":", "this", ";", "for", "(", "let", "item", "of", "seq", ")", "{", "sum", "+=", "Number", ".", "parseFloat", "(", "item", ")", ";", "}", "return", "sum", ";", "}" ]
Computes the sum of a sequence. @param transform The transform function called per interaction. @return The sum of the values in the sequence.
[ "Computes", "the", "sum", "of", "a", "sequence", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L742-L751
train
UnsignedInt8/LINQ
linq.js
toMap
function toMap(keySelector, elementSelector) { if (!keySelector) return new Map(this); elementSelector = typeof elementSelector === 'function' ? elementSelector : i => i; let map = new Map(); for (let item of this) { let key = keySelector(item); let element = elementSelector(item); map.set(key, element); } return map; }
javascript
function toMap(keySelector, elementSelector) { if (!keySelector) return new Map(this); elementSelector = typeof elementSelector === 'function' ? elementSelector : i => i; let map = new Map(); for (let item of this) { let key = keySelector(item); let element = elementSelector(item); map.set(key, element); } return map; }
[ "function", "toMap", "(", "keySelector", ",", "elementSelector", ")", "{", "if", "(", "!", "keySelector", ")", "return", "new", "Map", "(", "this", ")", ";", "elementSelector", "=", "typeof", "elementSelector", "===", "'function'", "?", "elementSelector", ":", "i", "=>", "i", ";", "let", "map", "=", "new", "Map", "(", ")", ";", "for", "(", "let", "item", "of", "this", ")", "{", "let", "key", "=", "keySelector", "(", "item", ")", ";", "let", "element", "=", "elementSelector", "(", "item", ")", ";", "map", ".", "set", "(", "key", ",", "element", ")", ";", "}", "return", "map", ";", "}" ]
Creates a map from a sequenece according to a specified key selector function, a comparer, and an element selector function. @param keySelector A function to extract a key from each element. @param elementSelector A transform function to produce a result element value from each element. @return A map that contains values from the input sequence. keySelector: (item) -> key (Required) elementSelector: (item) -> value (Optional)
[ "Creates", "a", "map", "from", "a", "sequenece", "according", "to", "a", "specified", "key", "selector", "function", "a", "comparer", "and", "an", "element", "selector", "function", "." ]
24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8
https://github.com/UnsignedInt8/LINQ/blob/24d2a88ab3687b6c72c2d21d392bc39f1af7a0f8/linq.js#L837-L850
train
pogosandbox/pogobuf-signature
encryption/builder.js
function(options) { if (!options) options = {}; this.initTime = options.initTime || new Date().getTime(); this.time_since_start = options.time_since_start || null; this.time = options.time || null; this.version = options.version || '0.45'; this.forcedUk25 = options.uk25 || null; if (options.protos) { this.ProtoSignature = options.protos.Networking.Envelopes.Signature; } else { throw new Error('Passing protos object is now mandatory.'); } this.utils = new Utils(); this.fields = { session_hash: options.session_hash || options.unk22 || crypto.randomBytes(16) }; }
javascript
function(options) { if (!options) options = {}; this.initTime = options.initTime || new Date().getTime(); this.time_since_start = options.time_since_start || null; this.time = options.time || null; this.version = options.version || '0.45'; this.forcedUk25 = options.uk25 || null; if (options.protos) { this.ProtoSignature = options.protos.Networking.Envelopes.Signature; } else { throw new Error('Passing protos object is now mandatory.'); } this.utils = new Utils(); this.fields = { session_hash: options.session_hash || options.unk22 || crypto.randomBytes(16) }; }
[ "function", "(", "options", ")", "{", "if", "(", "!", "options", ")", "options", "=", "{", "}", ";", "this", ".", "initTime", "=", "options", ".", "initTime", "||", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "this", ".", "time_since_start", "=", "options", ".", "time_since_start", "||", "null", ";", "this", ".", "time", "=", "options", ".", "time", "||", "null", ";", "this", ".", "version", "=", "options", ".", "version", "||", "'0.45'", ";", "this", ".", "forcedUk25", "=", "options", ".", "uk25", "||", "null", ";", "if", "(", "options", ".", "protos", ")", "{", "this", ".", "ProtoSignature", "=", "options", ".", "protos", ".", "Networking", ".", "Envelopes", ".", "Signature", ";", "}", "else", "{", "throw", "new", "Error", "(", "'Passing protos object is now mandatory.'", ")", ";", "}", "this", ".", "utils", "=", "new", "Utils", "(", ")", ";", "this", ".", "fields", "=", "{", "session_hash", ":", "options", ".", "session_hash", "||", "options", ".", "unk22", "||", "crypto", ".", "randomBytes", "(", "16", ")", "}", ";", "}" ]
the signature builder @constructor @param {Object} [options] - a set of options and defaults to send to the signature builder @param {number} [options[].initTime] - time in ms to use as the app's startup time @param {Buffer} [options[].unk22] - a 32-byte Buffer to use as `unk22` @param {String} [options[].version] - The version to run on, defaults to 0.45
[ "the", "signature", "builder" ]
85be21ec2d7cf58eb569447c44bc46c55095d226
https://github.com/pogosandbox/pogobuf-signature/blob/85be21ec2d7cf58eb569447c44bc46c55095d226/encryption/builder.js#L15-L33
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/date/format.js
function (calendar) { var time = calendar.getTime(); calendar = /**@type {KISSY.Date.Gregorian} @ignore*/ new GregorianCalendar(this.timezoneOffset, this.locale); calendar.setTime(time); var i, ret = [], pattern = this.pattern, len = pattern.length; for (i = 0; i < len; i++) { var comp = pattern[i]; if (comp.text) { ret.push(comp.text); } else if ('field' in comp) { ret.push(formatField(comp.field, comp.count, this.locale, calendar)); } } return ret.join(''); }
javascript
function (calendar) { var time = calendar.getTime(); calendar = /**@type {KISSY.Date.Gregorian} @ignore*/ new GregorianCalendar(this.timezoneOffset, this.locale); calendar.setTime(time); var i, ret = [], pattern = this.pattern, len = pattern.length; for (i = 0; i < len; i++) { var comp = pattern[i]; if (comp.text) { ret.push(comp.text); } else if ('field' in comp) { ret.push(formatField(comp.field, comp.count, this.locale, calendar)); } } return ret.join(''); }
[ "function", "(", "calendar", ")", "{", "var", "time", "=", "calendar", ".", "getTime", "(", ")", ";", "calendar", "=", "new", "GregorianCalendar", "(", "this", ".", "timezoneOffset", ",", "this", ".", "locale", ")", ";", "calendar", ".", "setTime", "(", "time", ")", ";", "var", "i", ",", "ret", "=", "[", "]", ",", "pattern", "=", "this", ".", "pattern", ",", "len", "=", "pattern", ".", "length", ";", "for", "(", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "comp", "=", "pattern", "[", "i", "]", ";", "if", "(", "comp", ".", "text", ")", "{", "ret", ".", "push", "(", "comp", ".", "text", ")", ";", "}", "else", "if", "(", "'field'", "in", "comp", ")", "{", "ret", ".", "push", "(", "formatField", "(", "comp", ".", "field", ",", "comp", ".", "count", ",", "this", ".", "locale", ",", "calendar", ")", ")", ";", "}", "}", "return", "ret", ".", "join", "(", "''", ")", ";", "}" ]
format a GregorianDate instance according to specified pattern @param {KISSY.Date.Gregorian} calendar GregorianDate instance @returns {string} formatted string of GregorianDate instance
[ "format", "a", "GregorianDate", "instance", "according", "to", "specified", "pattern" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/date/format.js#L729-L745
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/date/format.js
function (dateStr) { var calendar = /**@type {KISSY.Date.Gregorian} @ignore*/ new GregorianCalendar(this.timezoneOffset, this.locale), i, j, tmp = {}, obeyCount = false, dateStrLen = dateStr.length, errorIndex = -1, startIndex = 0, oldStartIndex = 0, pattern = this.pattern, len = pattern.length; loopPattern: { for (i = 0; errorIndex < 0 && i < len; i++) { var comp = pattern[i], text, textLen; oldStartIndex = startIndex; if (text = comp.text) { textLen = text.length; if (textLen + startIndex > dateStrLen) { errorIndex = startIndex; } else { for (j = 0; j < textLen; j++) { if (text.charAt(j) !== dateStr.charAt(j + startIndex)) { errorIndex = startIndex; break loopPattern; } } startIndex += textLen; } } else if ('field' in comp) { obeyCount = false; var nextComp = pattern[i + 1]; if (nextComp) { if ('field' in nextComp) { obeyCount = true; } else { var c = nextComp.text.charAt(0); if (c >= '0' && c <= '9') { obeyCount = true; } } } startIndex = parseField(calendar, dateStr, startIndex, comp.field, comp.count, this.locale, obeyCount, tmp); if (startIndex === oldStartIndex) { errorIndex = startIndex; } } } } if (errorIndex >= 0) { logger.error('error when parsing date'); logger.error(dateStr); logger.error(dateStr.substring(0, errorIndex) + '^'); return undefined; } return calendar; }
javascript
function (dateStr) { var calendar = /**@type {KISSY.Date.Gregorian} @ignore*/ new GregorianCalendar(this.timezoneOffset, this.locale), i, j, tmp = {}, obeyCount = false, dateStrLen = dateStr.length, errorIndex = -1, startIndex = 0, oldStartIndex = 0, pattern = this.pattern, len = pattern.length; loopPattern: { for (i = 0; errorIndex < 0 && i < len; i++) { var comp = pattern[i], text, textLen; oldStartIndex = startIndex; if (text = comp.text) { textLen = text.length; if (textLen + startIndex > dateStrLen) { errorIndex = startIndex; } else { for (j = 0; j < textLen; j++) { if (text.charAt(j) !== dateStr.charAt(j + startIndex)) { errorIndex = startIndex; break loopPattern; } } startIndex += textLen; } } else if ('field' in comp) { obeyCount = false; var nextComp = pattern[i + 1]; if (nextComp) { if ('field' in nextComp) { obeyCount = true; } else { var c = nextComp.text.charAt(0); if (c >= '0' && c <= '9') { obeyCount = true; } } } startIndex = parseField(calendar, dateStr, startIndex, comp.field, comp.count, this.locale, obeyCount, tmp); if (startIndex === oldStartIndex) { errorIndex = startIndex; } } } } if (errorIndex >= 0) { logger.error('error when parsing date'); logger.error(dateStr); logger.error(dateStr.substring(0, errorIndex) + '^'); return undefined; } return calendar; }
[ "function", "(", "dateStr", ")", "{", "var", "calendar", "=", "new", "GregorianCalendar", "(", "this", ".", "timezoneOffset", ",", "this", ".", "locale", ")", ",", "i", ",", "j", ",", "tmp", "=", "{", "}", ",", "obeyCount", "=", "false", ",", "dateStrLen", "=", "dateStr", ".", "length", ",", "errorIndex", "=", "-", "1", ",", "startIndex", "=", "0", ",", "oldStartIndex", "=", "0", ",", "pattern", "=", "this", ".", "pattern", ",", "len", "=", "pattern", ".", "length", ";", "loopPattern", ":", "{", "for", "(", "i", "=", "0", ";", "errorIndex", "<", "0", "&&", "i", "<", "len", ";", "i", "++", ")", "{", "var", "comp", "=", "pattern", "[", "i", "]", ",", "text", ",", "textLen", ";", "oldStartIndex", "=", "startIndex", ";", "if", "(", "text", "=", "comp", ".", "text", ")", "{", "textLen", "=", "text", ".", "length", ";", "if", "(", "textLen", "+", "startIndex", ">", "dateStrLen", ")", "{", "errorIndex", "=", "startIndex", ";", "}", "else", "{", "for", "(", "j", "=", "0", ";", "j", "<", "textLen", ";", "j", "++", ")", "{", "if", "(", "text", ".", "charAt", "(", "j", ")", "!==", "dateStr", ".", "charAt", "(", "j", "+", "startIndex", ")", ")", "{", "errorIndex", "=", "startIndex", ";", "break", "loopPattern", ";", "}", "}", "startIndex", "+=", "textLen", ";", "}", "}", "else", "if", "(", "'field'", "in", "comp", ")", "{", "obeyCount", "=", "false", ";", "var", "nextComp", "=", "pattern", "[", "i", "+", "1", "]", ";", "if", "(", "nextComp", ")", "{", "if", "(", "'field'", "in", "nextComp", ")", "{", "obeyCount", "=", "true", ";", "}", "else", "{", "var", "c", "=", "nextComp", ".", "text", ".", "charAt", "(", "0", ")", ";", "if", "(", "c", ">=", "'0'", "&&", "c", "<=", "'9'", ")", "{", "obeyCount", "=", "true", ";", "}", "}", "}", "startIndex", "=", "parseField", "(", "calendar", ",", "dateStr", ",", "startIndex", ",", "comp", ".", "field", ",", "comp", ".", "count", ",", "this", ".", "locale", ",", "obeyCount", ",", "tmp", ")", ";", "if", "(", "startIndex", "===", "oldStartIndex", ")", "{", "errorIndex", "=", "startIndex", ";", "}", "}", "}", "}", "if", "(", "errorIndex", ">=", "0", ")", "{", "logger", ".", "error", "(", "'error when parsing date'", ")", ";", "logger", ".", "error", "(", "dateStr", ")", ";", "logger", ".", "error", "(", "dateStr", ".", "substring", "(", "0", ",", "errorIndex", ")", "+", "'^'", ")", ";", "return", "undefined", ";", "}", "return", "calendar", ";", "}" ]
parse a formatted string of GregorianDate instance according to specified pattern @param {String} dateStr formatted string of GregorianDate @returns {KISSY.Date.Gregorian}
[ "parse", "a", "formatted", "string", "of", "GregorianDate", "instance", "according", "to", "specified", "pattern" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/date/format.js#L751-L799
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/date/format.js
function (dateStyle, timeStyle, locale, timeZoneOffset) { locale = locale || defaultLocale; var datePattern = ''; if (dateStyle !== undefined) { datePattern = locale.datePatterns[dateStyle]; } var timePattern = ''; if (timeStyle !== undefined) { timePattern = locale.timePatterns[timeStyle]; } var pattern = datePattern; if (timePattern) { if (datePattern) { pattern = util.substitute(locale.dateTimePattern, { date: datePattern, time: timePattern }); } else { pattern = timePattern; } } return new DateTimeFormat(pattern, locale, timeZoneOffset); }
javascript
function (dateStyle, timeStyle, locale, timeZoneOffset) { locale = locale || defaultLocale; var datePattern = ''; if (dateStyle !== undefined) { datePattern = locale.datePatterns[dateStyle]; } var timePattern = ''; if (timeStyle !== undefined) { timePattern = locale.timePatterns[timeStyle]; } var pattern = datePattern; if (timePattern) { if (datePattern) { pattern = util.substitute(locale.dateTimePattern, { date: datePattern, time: timePattern }); } else { pattern = timePattern; } } return new DateTimeFormat(pattern, locale, timeZoneOffset); }
[ "function", "(", "dateStyle", ",", "timeStyle", ",", "locale", ",", "timeZoneOffset", ")", "{", "locale", "=", "locale", "||", "defaultLocale", ";", "var", "datePattern", "=", "''", ";", "if", "(", "dateStyle", "!==", "undefined", ")", "{", "datePattern", "=", "locale", ".", "datePatterns", "[", "dateStyle", "]", ";", "}", "var", "timePattern", "=", "''", ";", "if", "(", "timeStyle", "!==", "undefined", ")", "{", "timePattern", "=", "locale", ".", "timePatterns", "[", "timeStyle", "]", ";", "}", "var", "pattern", "=", "datePattern", ";", "if", "(", "timePattern", ")", "{", "if", "(", "datePattern", ")", "{", "pattern", "=", "util", ".", "substitute", "(", "locale", ".", "dateTimePattern", ",", "{", "date", ":", "datePattern", ",", "time", ":", "timePattern", "}", ")", ";", "}", "else", "{", "pattern", "=", "timePattern", ";", "}", "}", "return", "new", "DateTimeFormat", "(", "pattern", ",", "locale", ",", "timeZoneOffset", ")", ";", "}" ]
get a formatter instance of specified date style and time style. @param {KISSY.Date.Formatter.Style} dateStyle date format style @param {KISSY.Date.Formatter.Style} timeStyle time format style @param {Object} locale @param {Number} timeZoneOffset time zone offset by minutes @returns {KISSY.Date.Gregorian} @static
[ "get", "a", "formatter", "instance", "of", "specified", "date", "style", "and", "time", "style", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/date/format.js#L835-L857
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/attribute-debug.js
__fireAttrChange
function __fireAttrChange(self, when, name, prevVal, newVal, subAttrName, attrName, data) { attrName = attrName || name; return self.fire(whenAttrChangeEventName(when, name), util.mix({ attrName: attrName, subAttrName: subAttrName, prevVal: prevVal, newVal: newVal }, data)); }
javascript
function __fireAttrChange(self, when, name, prevVal, newVal, subAttrName, attrName, data) { attrName = attrName || name; return self.fire(whenAttrChangeEventName(when, name), util.mix({ attrName: attrName, subAttrName: subAttrName, prevVal: prevVal, newVal: newVal }, data)); }
[ "function", "__fireAttrChange", "(", "self", ",", "when", ",", "name", ",", "prevVal", ",", "newVal", ",", "subAttrName", ",", "attrName", ",", "data", ")", "{", "attrName", "=", "attrName", "||", "name", ";", "return", "self", ".", "fire", "(", "whenAttrChangeEventName", "(", "when", ",", "name", ")", ",", "util", ".", "mix", "(", "{", "attrName", ":", "attrName", ",", "subAttrName", ":", "subAttrName", ",", "prevVal", ":", "prevVal", ",", "newVal", ":", "newVal", "}", ",", "data", ")", ")", ";", "}" ]
fire attribute value change fire attribute value change
[ "fire", "attribute", "value", "change", "fire", "attribute", "value", "change" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/attribute-debug.js#L48-L56
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/attribute-debug.js
function () { var self = this, o = {}, a, attrs = self.getAttrs(); for (a in attrs) { o[a] = self.get(a); } return o; }
javascript
function () { var self = this, o = {}, a, attrs = self.getAttrs(); for (a in attrs) { o[a] = self.get(a); } return o; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "o", "=", "{", "}", ",", "a", ",", "attrs", "=", "self", ".", "getAttrs", "(", ")", ";", "for", "(", "a", "in", "attrs", ")", "{", "o", "[", "a", "]", "=", "self", ".", "get", "(", "a", ")", ";", "}", "return", "o", ";", "}" ]
get un-cloned attr value collections @return {Object}
[ "get", "un", "-", "cloned", "attr", "value", "collections" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/attribute-debug.js#L354-L360
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/attribute-debug.js
function (name, attrConfig, override) { var self = this, attrs = self.getAttrs(), attr, // shadow clone cfg = util.merge(attrConfig); if (cfg.value && typeof cfg.value === 'object') { cfg.value = util.clone(cfg.value); LoggerManger.log('please use valueFn instead of value for ' + name + ' attribute', 'warn'); } if (attr = attrs[name]) { util.mix(attr, cfg, override); } else { attrs[name] = cfg; } return self; }
javascript
function (name, attrConfig, override) { var self = this, attrs = self.getAttrs(), attr, // shadow clone cfg = util.merge(attrConfig); if (cfg.value && typeof cfg.value === 'object') { cfg.value = util.clone(cfg.value); LoggerManger.log('please use valueFn instead of value for ' + name + ' attribute', 'warn'); } if (attr = attrs[name]) { util.mix(attr, cfg, override); } else { attrs[name] = cfg; } return self; }
[ "function", "(", "name", ",", "attrConfig", ",", "override", ")", "{", "var", "self", "=", "this", ",", "attrs", "=", "self", ".", "getAttrs", "(", ")", ",", "attr", ",", "cfg", "=", "util", ".", "merge", "(", "attrConfig", ")", ";", "if", "(", "cfg", ".", "value", "&&", "typeof", "cfg", ".", "value", "===", "'object'", ")", "{", "cfg", ".", "value", "=", "util", ".", "clone", "(", "cfg", ".", "value", ")", ";", "LoggerManger", ".", "log", "(", "'please use valueFn instead of value for '", "+", "name", "+", "' attribute'", ",", "'warn'", ")", ";", "}", "if", "(", "attr", "=", "attrs", "[", "name", "]", ")", "{", "util", ".", "mix", "(", "attr", ",", "cfg", ",", "override", ")", ";", "}", "else", "{", "attrs", "[", "name", "]", "=", "cfg", ";", "}", "return", "self", ";", "}" ]
Adds an attribute with the provided configuration to the host object. @param {String} name attrName @param {Object} attrConfig The config supports the following properties @param [attrConfig.value] simple object or system native object @param [attrConfig.valueFn] a function which can return current attribute 's default value @param {Function} [attrConfig.setter] call when set attribute 's value pass current attribute 's value as parameter if return value is not undefined,set returned value as real value @param {Function} [attrConfig.getter] call when get attribute 's value pass current attribute 's value as parameter return getter's returned value to invoker @param {Function} [attrConfig.validator] call before set attribute 's value if return false,cancel this set action @param {Boolean} [override] whether override existing attribute config ,default true @chainable
[ "Adds", "an", "attribute", "with", "the", "provided", "configuration", "to", "the", "host", "object", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/attribute-debug.js#L378-L392
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/attribute-debug.js
function (attrConfigs, initialValues) { var self = this; util.each(attrConfigs, function (attrConfig, name) { self.addAttr(name, attrConfig); }); if (initialValues) { self.set(initialValues); } return self; }
javascript
function (attrConfigs, initialValues) { var self = this; util.each(attrConfigs, function (attrConfig, name) { self.addAttr(name, attrConfig); }); if (initialValues) { self.set(initialValues); } return self; }
[ "function", "(", "attrConfigs", ",", "initialValues", ")", "{", "var", "self", "=", "this", ";", "util", ".", "each", "(", "attrConfigs", ",", "function", "(", "attrConfig", ",", "name", ")", "{", "self", ".", "addAttr", "(", "name", ",", "attrConfig", ")", ";", "}", ")", ";", "if", "(", "initialValues", ")", "{", "self", ".", "set", "(", "initialValues", ")", ";", "}", "return", "self", ";", "}" ]
Configures a group of attributes, and sets initial values. @param {Object} attrConfigs An object with attribute name/configuration pairs. @param {Object} initialValues user defined initial values @chainable
[ "Configures", "a", "group", "of", "attributes", "and", "sets", "initial", "values", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/attribute-debug.js#L399-L408
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/attribute-debug.js
function (name) { var self = this; var __attrVals = getAttrVals(self); var __attrs = self.getAttrs(); if (self.hasAttr(name)) { delete __attrs[name]; delete __attrVals[name]; } return self; }
javascript
function (name) { var self = this; var __attrVals = getAttrVals(self); var __attrs = self.getAttrs(); if (self.hasAttr(name)) { delete __attrs[name]; delete __attrVals[name]; } return self; }
[ "function", "(", "name", ")", "{", "var", "self", "=", "this", ";", "var", "__attrVals", "=", "getAttrVals", "(", "self", ")", ";", "var", "__attrs", "=", "self", ".", "getAttrs", "(", ")", ";", "if", "(", "self", ".", "hasAttr", "(", "name", ")", ")", "{", "delete", "__attrs", "[", "name", "]", ";", "delete", "__attrVals", "[", "name", "]", ";", "}", "return", "self", ";", "}" ]
Removes an attribute from the host object. @chainable
[ "Removes", "an", "attribute", "from", "the", "host", "object", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/attribute-debug.js#L421-L430
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/attribute-debug.js
function (name, value, opts) { var self = this, e; if (typeof name !== 'string') { opts = value; opts = opts || {}; var all = Object(name), attrs = [], errors = []; for (name in all) { // bulk validation // if any one failed,all values are not set if ((e = validate(self, name, all[name], all)) !== undefined) { errors.push(e); } } if (errors.length) { if (opts.error) { opts.error(errors); } return FALSE; } for (name in all) { setInternal(self, name, all[name], opts, attrs); } var attrNames = [], prevVals = [], newVals = [], subAttrNames = []; util.each(attrs, function (attr) { prevVals.push(attr.prevVal); newVals.push(attr.newVal); attrNames.push(attr.attrName); subAttrNames.push(attr.subAttrName); }); if (attrNames.length) { __fireAttrChange(self, '', '*', prevVals, newVals, subAttrNames, attrNames, opts.data); } return self; } opts = opts || {}; // validator check // validator check e = validate(self, name, value); if (e !== undefined) { if (opts.error) { opts.error(e); } return FALSE; } return setInternal(self, name, value, opts); }
javascript
function (name, value, opts) { var self = this, e; if (typeof name !== 'string') { opts = value; opts = opts || {}; var all = Object(name), attrs = [], errors = []; for (name in all) { // bulk validation // if any one failed,all values are not set if ((e = validate(self, name, all[name], all)) !== undefined) { errors.push(e); } } if (errors.length) { if (opts.error) { opts.error(errors); } return FALSE; } for (name in all) { setInternal(self, name, all[name], opts, attrs); } var attrNames = [], prevVals = [], newVals = [], subAttrNames = []; util.each(attrs, function (attr) { prevVals.push(attr.prevVal); newVals.push(attr.newVal); attrNames.push(attr.attrName); subAttrNames.push(attr.subAttrName); }); if (attrNames.length) { __fireAttrChange(self, '', '*', prevVals, newVals, subAttrNames, attrNames, opts.data); } return self; } opts = opts || {}; // validator check // validator check e = validate(self, name, value); if (e !== undefined) { if (opts.error) { opts.error(e); } return FALSE; } return setInternal(self, name, value, opts); }
[ "function", "(", "name", ",", "value", ",", "opts", ")", "{", "var", "self", "=", "this", ",", "e", ";", "if", "(", "typeof", "name", "!==", "'string'", ")", "{", "opts", "=", "value", ";", "opts", "=", "opts", "||", "{", "}", ";", "var", "all", "=", "Object", "(", "name", ")", ",", "attrs", "=", "[", "]", ",", "errors", "=", "[", "]", ";", "for", "(", "name", "in", "all", ")", "{", "if", "(", "(", "e", "=", "validate", "(", "self", ",", "name", ",", "all", "[", "name", "]", ",", "all", ")", ")", "!==", "undefined", ")", "{", "errors", ".", "push", "(", "e", ")", ";", "}", "}", "if", "(", "errors", ".", "length", ")", "{", "if", "(", "opts", ".", "error", ")", "{", "opts", ".", "error", "(", "errors", ")", ";", "}", "return", "FALSE", ";", "}", "for", "(", "name", "in", "all", ")", "{", "setInternal", "(", "self", ",", "name", ",", "all", "[", "name", "]", ",", "opts", ",", "attrs", ")", ";", "}", "var", "attrNames", "=", "[", "]", ",", "prevVals", "=", "[", "]", ",", "newVals", "=", "[", "]", ",", "subAttrNames", "=", "[", "]", ";", "util", ".", "each", "(", "attrs", ",", "function", "(", "attr", ")", "{", "prevVals", ".", "push", "(", "attr", ".", "prevVal", ")", ";", "newVals", ".", "push", "(", "attr", ".", "newVal", ")", ";", "attrNames", ".", "push", "(", "attr", ".", "attrName", ")", ";", "subAttrNames", ".", "push", "(", "attr", ".", "subAttrName", ")", ";", "}", ")", ";", "if", "(", "attrNames", ".", "length", ")", "{", "__fireAttrChange", "(", "self", ",", "''", ",", "'*'", ",", "prevVals", ",", "newVals", ",", "subAttrNames", ",", "attrNames", ",", "opts", ".", "data", ")", ";", "}", "return", "self", ";", "}", "opts", "=", "opts", "||", "{", "}", ";", "e", "=", "validate", "(", "self", ",", "name", ",", "value", ")", ";", "if", "(", "e", "!==", "undefined", ")", "{", "if", "(", "opts", ".", "error", ")", "{", "opts", ".", "error", "(", "e", ")", ";", "}", "return", "FALSE", ";", "}", "return", "setInternal", "(", "self", ",", "name", ",", "value", ",", "opts", ")", ";", "}" ]
Sets the value of an attribute. @param {String|Object} name attribute 's name or attribute name and value map @param [value] attribute 's value @param {Object} [opts] some options @param {Boolean} [opts.silent] whether fire change event @param {Function} [opts.error] error handler @return {Boolean} whether pass validator
[ "Sets", "the", "value", "of", "an", "attribute", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/attribute-debug.js#L440-L484
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/attribute-debug.js
function (name, value) { var self = this, setValue, // if host does not have meta info corresponding to (name,value) // then register on demand in order to collect all data meta info // 一定要注册属性元数据,否则其他模块通过 _attrs 不能枚举到所有有效属性 // 因为属性在声明注册前可以直接设置值 attrConfig = ensureNonEmpty(self.getAttrs(), name), setter = attrConfig.setter; // if setter has effect // if setter has effect if (setter && (setter = normalFn(self, setter))) { setValue = setter.call(self, value, name); } if (setValue === INVALID) { return FALSE; } if (setValue !== undefined) { value = setValue; } // finally set // finally set getAttrVals(self)[name] = value; return undefined; }
javascript
function (name, value) { var self = this, setValue, // if host does not have meta info corresponding to (name,value) // then register on demand in order to collect all data meta info // 一定要注册属性元数据,否则其他模块通过 _attrs 不能枚举到所有有效属性 // 因为属性在声明注册前可以直接设置值 attrConfig = ensureNonEmpty(self.getAttrs(), name), setter = attrConfig.setter; // if setter has effect // if setter has effect if (setter && (setter = normalFn(self, setter))) { setValue = setter.call(self, value, name); } if (setValue === INVALID) { return FALSE; } if (setValue !== undefined) { value = setValue; } // finally set // finally set getAttrVals(self)[name] = value; return undefined; }
[ "function", "(", "name", ",", "value", ")", "{", "var", "self", "=", "this", ",", "setValue", ",", "attrConfig", "=", "ensureNonEmpty", "(", "self", ".", "getAttrs", "(", ")", ",", "name", ")", ",", "setter", "=", "attrConfig", ".", "setter", ";", "if", "(", "setter", "&&", "(", "setter", "=", "normalFn", "(", "self", ",", "setter", ")", ")", ")", "{", "setValue", "=", "setter", ".", "call", "(", "self", ",", "value", ",", "name", ")", ";", "}", "if", "(", "setValue", "===", "INVALID", ")", "{", "return", "FALSE", ";", "}", "if", "(", "setValue", "!==", "undefined", ")", "{", "value", "=", "setValue", ";", "}", "getAttrVals", "(", "self", ")", "[", "name", "]", "=", "value", ";", "return", "undefined", ";", "}" ]
internal use, no event involved, just set. override by model @protected
[ "internal", "use", "no", "event", "involved", "just", "set", ".", "override", "by", "model" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/attribute-debug.js#L490-L510
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/attribute-debug.js
function (name) { var self = this, dot = '.', path, attrVals = getAttrVals(self), attrConfig, getter, ret; if (name.indexOf(dot) !== -1) { path = name.split(dot); name = path.shift(); } attrConfig = ensureNonEmpty(self.getAttrs(), name, 1); getter = attrConfig.getter; // get user-set value or default value //user-set value takes privilege // get user-set value or default value //user-set value takes privilege ret = name in attrVals ? attrVals[name] : getDefAttrVal(self, name); // invoke getter for this attribute // invoke getter for this attribute if (getter && (getter = normalFn(self, getter))) { ret = getter.call(self, ret, name); } if (!(name in attrVals) && ret !== undefined) { attrVals[name] = ret; } if (path) { ret = getValueByPath(ret, path); } return ret; }
javascript
function (name) { var self = this, dot = '.', path, attrVals = getAttrVals(self), attrConfig, getter, ret; if (name.indexOf(dot) !== -1) { path = name.split(dot); name = path.shift(); } attrConfig = ensureNonEmpty(self.getAttrs(), name, 1); getter = attrConfig.getter; // get user-set value or default value //user-set value takes privilege // get user-set value or default value //user-set value takes privilege ret = name in attrVals ? attrVals[name] : getDefAttrVal(self, name); // invoke getter for this attribute // invoke getter for this attribute if (getter && (getter = normalFn(self, getter))) { ret = getter.call(self, ret, name); } if (!(name in attrVals) && ret !== undefined) { attrVals[name] = ret; } if (path) { ret = getValueByPath(ret, path); } return ret; }
[ "function", "(", "name", ")", "{", "var", "self", "=", "this", ",", "dot", "=", "'.'", ",", "path", ",", "attrVals", "=", "getAttrVals", "(", "self", ")", ",", "attrConfig", ",", "getter", ",", "ret", ";", "if", "(", "name", ".", "indexOf", "(", "dot", ")", "!==", "-", "1", ")", "{", "path", "=", "name", ".", "split", "(", "dot", ")", ";", "name", "=", "path", ".", "shift", "(", ")", ";", "}", "attrConfig", "=", "ensureNonEmpty", "(", "self", ".", "getAttrs", "(", ")", ",", "name", ",", "1", ")", ";", "getter", "=", "attrConfig", ".", "getter", ";", "ret", "=", "name", "in", "attrVals", "?", "attrVals", "[", "name", "]", ":", "getDefAttrVal", "(", "self", ",", "name", ")", ";", "if", "(", "getter", "&&", "(", "getter", "=", "normalFn", "(", "self", ",", "getter", ")", ")", ")", "{", "ret", "=", "getter", ".", "call", "(", "self", ",", "ret", ",", "name", ")", ";", "}", "if", "(", "!", "(", "name", "in", "attrVals", ")", "&&", "ret", "!==", "undefined", ")", "{", "attrVals", "[", "name", "]", "=", "ret", ";", "}", "if", "(", "path", ")", "{", "ret", "=", "getValueByPath", "(", "ret", ",", "path", ")", ";", "}", "return", "ret", ";", "}" ]
Gets the current value of the attribute. @param {String} name attribute 's name @return {*}
[ "Gets", "the", "current", "value", "of", "the", "attribute", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/attribute-debug.js#L516-L539
train
craterdog-bali/js-bali-component-framework
src/elements/Text.js
Text
function Text(value, parameters) { abstractions.Element.call(this, utilities.types.TEXT, parameters); value = value || ''; // default value // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Text(value, parameters) { abstractions.Element.call(this, utilities.types.TEXT, parameters); value = value || ''; // default value // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Text", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "TEXT", ",", "parameters", ")", ";", "value", "=", "value", "||", "''", ";", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new text string element using the specified value. @constructor @param {String} value The value of the text string. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Text} The new text string.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "text", "string", "element", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Text.js#L30-L38
train
KTH/kth-node-cortina-block
index.js
_getEnvSpecificConfig
function _getEnvSpecificConfig () { const prodDefaults = { env: 'prod', url: null, debug: false, version: 'head', language: 'en', redisKey: 'CortinaBlock_', redisExpire: 600, redis: null, blocks: { title: '1.260060', megaMenu: '1.855134', secondaryMenu: '1.865038', image: '1.77257', footer: '1.202278', search: '1.77262', language: { 'en_UK': '1.77273', 'sv_SE': '1.272446' }, analytics: '1.464751', gtmAnalytics: '1.714097', gtmNoscript: '1.714099' } } const refDefaults = { env: 'ref', url: null, debug: false, version: 'head', language: 'en', redisKey: 'CortinaBlock_', redisExpire: 600, redis: null, blocks: { title: '1.260060', megaMenu: '1.855134', secondaryMenu: '1.865038', image: '1.77257', footer: '1.202278', search: '1.77262', language: { 'en_UK': '1.77273', 'sv_SE': '1.272446' }, analytics: '1.464751', gtmAnalytics: '1.714097', gtmNoscript: '1.714099' } } const devDefaults = { env: 'dev', url: null, debug: false, version: 'head', language: 'en', redisKey: 'CortinaBlock_', redisExpire: 600, redis: null, blocks: { title: '1.260060', megaMenu: '1.260064', secondaryMenu: '1.865038', image: '1.77257', footer: '1.202278', search: '1.77262', language: { 'en_UK': '1.77273', 'sv_SE': '1.272446' }, analytics: '1.464751', gtmAnalytics: '1.714097', gtmNoscript: '1.714099' } } const host = process.env['SERVER_HOST_URL'] const hostEnv = _getHostEnv(host) const cmhost = process.env['CM_HOST_URL'] const cmHostEnv = _getHostEnv(cmhost) // CM_HOST_URL is used when working with Azure if (cmHostEnv) { if (cmHostEnv === 'prod') { return prodDefaults } else if (cmHostEnv === 'ref') { return refDefaults } else { return devDefaults } } if (hostEnv && hostEnv === 'prod') { return prodDefaults } else if (hostEnv === 'ref') { return refDefaults } else { return devDefaults } }
javascript
function _getEnvSpecificConfig () { const prodDefaults = { env: 'prod', url: null, debug: false, version: 'head', language: 'en', redisKey: 'CortinaBlock_', redisExpire: 600, redis: null, blocks: { title: '1.260060', megaMenu: '1.855134', secondaryMenu: '1.865038', image: '1.77257', footer: '1.202278', search: '1.77262', language: { 'en_UK': '1.77273', 'sv_SE': '1.272446' }, analytics: '1.464751', gtmAnalytics: '1.714097', gtmNoscript: '1.714099' } } const refDefaults = { env: 'ref', url: null, debug: false, version: 'head', language: 'en', redisKey: 'CortinaBlock_', redisExpire: 600, redis: null, blocks: { title: '1.260060', megaMenu: '1.855134', secondaryMenu: '1.865038', image: '1.77257', footer: '1.202278', search: '1.77262', language: { 'en_UK': '1.77273', 'sv_SE': '1.272446' }, analytics: '1.464751', gtmAnalytics: '1.714097', gtmNoscript: '1.714099' } } const devDefaults = { env: 'dev', url: null, debug: false, version: 'head', language: 'en', redisKey: 'CortinaBlock_', redisExpire: 600, redis: null, blocks: { title: '1.260060', megaMenu: '1.260064', secondaryMenu: '1.865038', image: '1.77257', footer: '1.202278', search: '1.77262', language: { 'en_UK': '1.77273', 'sv_SE': '1.272446' }, analytics: '1.464751', gtmAnalytics: '1.714097', gtmNoscript: '1.714099' } } const host = process.env['SERVER_HOST_URL'] const hostEnv = _getHostEnv(host) const cmhost = process.env['CM_HOST_URL'] const cmHostEnv = _getHostEnv(cmhost) // CM_HOST_URL is used when working with Azure if (cmHostEnv) { if (cmHostEnv === 'prod') { return prodDefaults } else if (cmHostEnv === 'ref') { return refDefaults } else { return devDefaults } } if (hostEnv && hostEnv === 'prod') { return prodDefaults } else if (hostEnv === 'ref') { return refDefaults } else { return devDefaults } }
[ "function", "_getEnvSpecificConfig", "(", ")", "{", "const", "prodDefaults", "=", "{", "env", ":", "'prod'", ",", "url", ":", "null", ",", "debug", ":", "false", ",", "version", ":", "'head'", ",", "language", ":", "'en'", ",", "redisKey", ":", "'CortinaBlock_'", ",", "redisExpire", ":", "600", ",", "redis", ":", "null", ",", "blocks", ":", "{", "title", ":", "'1.260060'", ",", "megaMenu", ":", "'1.855134'", ",", "secondaryMenu", ":", "'1.865038'", ",", "image", ":", "'1.77257'", ",", "footer", ":", "'1.202278'", ",", "search", ":", "'1.77262'", ",", "language", ":", "{", "'en_UK'", ":", "'1.77273'", ",", "'sv_SE'", ":", "'1.272446'", "}", ",", "analytics", ":", "'1.464751'", ",", "gtmAnalytics", ":", "'1.714097'", ",", "gtmNoscript", ":", "'1.714099'", "}", "}", "const", "refDefaults", "=", "{", "env", ":", "'ref'", ",", "url", ":", "null", ",", "debug", ":", "false", ",", "version", ":", "'head'", ",", "language", ":", "'en'", ",", "redisKey", ":", "'CortinaBlock_'", ",", "redisExpire", ":", "600", ",", "redis", ":", "null", ",", "blocks", ":", "{", "title", ":", "'1.260060'", ",", "megaMenu", ":", "'1.855134'", ",", "secondaryMenu", ":", "'1.865038'", ",", "image", ":", "'1.77257'", ",", "footer", ":", "'1.202278'", ",", "search", ":", "'1.77262'", ",", "language", ":", "{", "'en_UK'", ":", "'1.77273'", ",", "'sv_SE'", ":", "'1.272446'", "}", ",", "analytics", ":", "'1.464751'", ",", "gtmAnalytics", ":", "'1.714097'", ",", "gtmNoscript", ":", "'1.714099'", "}", "}", "const", "devDefaults", "=", "{", "env", ":", "'dev'", ",", "url", ":", "null", ",", "debug", ":", "false", ",", "version", ":", "'head'", ",", "language", ":", "'en'", ",", "redisKey", ":", "'CortinaBlock_'", ",", "redisExpire", ":", "600", ",", "redis", ":", "null", ",", "blocks", ":", "{", "title", ":", "'1.260060'", ",", "megaMenu", ":", "'1.260064'", ",", "secondaryMenu", ":", "'1.865038'", ",", "image", ":", "'1.77257'", ",", "footer", ":", "'1.202278'", ",", "search", ":", "'1.77262'", ",", "language", ":", "{", "'en_UK'", ":", "'1.77273'", ",", "'sv_SE'", ":", "'1.272446'", "}", ",", "analytics", ":", "'1.464751'", ",", "gtmAnalytics", ":", "'1.714097'", ",", "gtmNoscript", ":", "'1.714099'", "}", "}", "const", "host", "=", "process", ".", "env", "[", "'SERVER_HOST_URL'", "]", "const", "hostEnv", "=", "_getHostEnv", "(", "host", ")", "const", "cmhost", "=", "process", ".", "env", "[", "'CM_HOST_URL'", "]", "const", "cmHostEnv", "=", "_getHostEnv", "(", "cmhost", ")", "if", "(", "cmHostEnv", ")", "{", "if", "(", "cmHostEnv", "===", "'prod'", ")", "{", "return", "prodDefaults", "}", "else", "if", "(", "cmHostEnv", "===", "'ref'", ")", "{", "return", "refDefaults", "}", "else", "{", "return", "devDefaults", "}", "}", "if", "(", "hostEnv", "&&", "hostEnv", "===", "'prod'", ")", "{", "return", "prodDefaults", "}", "else", "if", "(", "hostEnv", "===", "'ref'", ")", "{", "return", "refDefaults", "}", "else", "{", "return", "devDefaults", "}", "}" ]
This function makes a decision based on the HOST_URL environment variable on whether we are in production, referens or development and serves the correct config. Most values are the same but could be different based on the current state in choosen Cortina environment. Eg. if we have imported a database dum from one environment in to the other.
[ "This", "function", "makes", "a", "decision", "based", "on", "the", "HOST_URL", "environment", "variable", "on", "whether", "we", "are", "in", "production", "referens", "or", "development", "and", "serves", "the", "correct", "config", "." ]
db07ce1b6e3ffdbb565be312e91e2244aad20042
https://github.com/KTH/kth-node-cortina-block/blob/db07ce1b6e3ffdbb565be312e91e2244aad20042/index.js#L18-L121
train
KTH/kth-node-cortina-block
index.js
_getHostEnv
function _getHostEnv (hostUrl) { if (hostUrl) { if (hostUrl.startsWith('https://www.kth')) { return 'prod' } else if (hostUrl.startsWith('https://www-r.referens.sys.kth') || hostUrl.startsWith('https://app-r.referens.sys.kth')) { return 'ref' } else if (hostUrl.startsWith('http://localhost')) { return 'dev' } else { return 'prod' } } }
javascript
function _getHostEnv (hostUrl) { if (hostUrl) { if (hostUrl.startsWith('https://www.kth')) { return 'prod' } else if (hostUrl.startsWith('https://www-r.referens.sys.kth') || hostUrl.startsWith('https://app-r.referens.sys.kth')) { return 'ref' } else if (hostUrl.startsWith('http://localhost')) { return 'dev' } else { return 'prod' } } }
[ "function", "_getHostEnv", "(", "hostUrl", ")", "{", "if", "(", "hostUrl", ")", "{", "if", "(", "hostUrl", ".", "startsWith", "(", "'https://www.kth'", ")", ")", "{", "return", "'prod'", "}", "else", "if", "(", "hostUrl", ".", "startsWith", "(", "'https://www-r.referens.sys.kth'", ")", "||", "hostUrl", ".", "startsWith", "(", "'https://app-r.referens.sys.kth'", ")", ")", "{", "return", "'ref'", "}", "else", "if", "(", "hostUrl", ".", "startsWith", "(", "'http://localhost'", ")", ")", "{", "return", "'dev'", "}", "else", "{", "return", "'prod'", "}", "}", "}" ]
Get the current environment from the given Host or Content Management Host. @param {*} host the given host URL.
[ "Get", "the", "current", "environment", "from", "the", "given", "Host", "or", "Content", "Management", "Host", "." ]
db07ce1b6e3ffdbb565be312e91e2244aad20042
https://github.com/KTH/kth-node-cortina-block/blob/db07ce1b6e3ffdbb565be312e91e2244aad20042/index.js#L127-L139
train
KTH/kth-node-cortina-block
index.js
_buildUrl
function _buildUrl (config, type, multi) { let url = config.url let language = _getLanguage(config.language) let block = multi ? config.blocks[type][language] : config.blocks[type] let version = _getVersion(config.version) return `${url}${block}?v=${version}&l=${language}` }
javascript
function _buildUrl (config, type, multi) { let url = config.url let language = _getLanguage(config.language) let block = multi ? config.blocks[type][language] : config.blocks[type] let version = _getVersion(config.version) return `${url}${block}?v=${version}&l=${language}` }
[ "function", "_buildUrl", "(", "config", ",", "type", ",", "multi", ")", "{", "let", "url", "=", "config", ".", "url", "let", "language", "=", "_getLanguage", "(", "config", ".", "language", ")", "let", "block", "=", "multi", "?", "config", ".", "blocks", "[", "type", "]", "[", "language", "]", ":", "config", ".", "blocks", "[", "type", "]", "let", "version", "=", "_getVersion", "(", "config", ".", "version", ")", "return", "`", "${", "url", "}", "${", "block", "}", "${", "version", "}", "${", "language", "}", "`", "}" ]
Build API url to Cortins from where to retrieve the blocks. @param {*} config the given config @param {*} type the block type eg. image @param {*} multi
[ "Build", "API", "url", "to", "Cortins", "from", "where", "to", "retrieve", "the", "blocks", "." ]
db07ce1b6e3ffdbb565be312e91e2244aad20042
https://github.com/KTH/kth-node-cortina-block/blob/db07ce1b6e3ffdbb565be312e91e2244aad20042/index.js#L171-L177
train
KTH/kth-node-cortina-block
index.js
_getBlock
function _getBlock (config, type, multi) { const options = { uri: _buildUrl(config, type, multi) } if (config.headers) { options['headers'] = config.headers } return request.get(options).then(result => { return { blockName: type, result: result } }) }
javascript
function _getBlock (config, type, multi) { const options = { uri: _buildUrl(config, type, multi) } if (config.headers) { options['headers'] = config.headers } return request.get(options).then(result => { return { blockName: type, result: result } }) }
[ "function", "_getBlock", "(", "config", ",", "type", ",", "multi", ")", "{", "const", "options", "=", "{", "uri", ":", "_buildUrl", "(", "config", ",", "type", ",", "multi", ")", "}", "if", "(", "config", ".", "headers", ")", "{", "options", "[", "'headers'", "]", "=", "config", ".", "headers", "}", "return", "request", ".", "get", "(", "options", ")", ".", "then", "(", "result", "=>", "{", "return", "{", "blockName", ":", "type", ",", "result", ":", "result", "}", "}", ")", "}" ]
Gets the block based on the given config and type. @param {*} config the given config @param {*} type the block type eg. image @param {*} multi
[ "Gets", "the", "block", "based", "on", "the", "given", "config", "and", "type", "." ]
db07ce1b6e3ffdbb565be312e91e2244aad20042
https://github.com/KTH/kth-node-cortina-block/blob/db07ce1b6e3ffdbb565be312e91e2244aad20042/index.js#L204-L213
train
KTH/kth-node-cortina-block
index.js
_getAll
function _getAll (config) { return Promise.all( handleBlocks(config) ).then(function (results) { let result = {} results.forEach(function (block) { result[block.blockName] = block.result }) return result }) .catch(err => { var blockName = err.options ? err.options.uri : 'NO URI FOUND' log.error(`WARNING! NO BLOCKS WILL BE LOADED DUE TO ERROR IN ONE OF THE BLOCKS. FIX ALL BROKEN BLOCKS IMMEDIATELY. ATTEMPTED TO LOAD BLOCK: ${blockName}`) throw err }) }
javascript
function _getAll (config) { return Promise.all( handleBlocks(config) ).then(function (results) { let result = {} results.forEach(function (block) { result[block.blockName] = block.result }) return result }) .catch(err => { var blockName = err.options ? err.options.uri : 'NO URI FOUND' log.error(`WARNING! NO BLOCKS WILL BE LOADED DUE TO ERROR IN ONE OF THE BLOCKS. FIX ALL BROKEN BLOCKS IMMEDIATELY. ATTEMPTED TO LOAD BLOCK: ${blockName}`) throw err }) }
[ "function", "_getAll", "(", "config", ")", "{", "return", "Promise", ".", "all", "(", "handleBlocks", "(", "config", ")", ")", ".", "then", "(", "function", "(", "results", ")", "{", "let", "result", "=", "{", "}", "results", ".", "forEach", "(", "function", "(", "block", ")", "{", "result", "[", "block", ".", "blockName", "]", "=", "block", ".", "result", "}", ")", "return", "result", "}", ")", ".", "catch", "(", "err", "=>", "{", "var", "blockName", "=", "err", ".", "options", "?", "err", ".", "options", ".", "uri", ":", "'NO URI FOUND'", "log", ".", "error", "(", "`", "${", "blockName", "}", "`", ")", "throw", "err", "}", ")", "}" ]
Fetch all Cortina blocks from API. @param config the given cinfig @returns {Promise} @private
[ "Fetch", "all", "Cortina", "blocks", "from", "API", "." ]
db07ce1b6e3ffdbb565be312e91e2244aad20042
https://github.com/KTH/kth-node-cortina-block/blob/db07ce1b6e3ffdbb565be312e91e2244aad20042/index.js#L231-L249
train
KTH/kth-node-cortina-block
index.js
handleBlocks
function handleBlocks (config) { let blocks = [] let blocksObj = config.blocks for (let i in blocksObj) { if (blocksObj.hasOwnProperty(i)) { if (isLanguage(blocksObj[i])) { blocks.push(_getBlock(config, 'language', true)) } else { blocks.push(_getBlock(config, i)) } } } return blocks }
javascript
function handleBlocks (config) { let blocks = [] let blocksObj = config.blocks for (let i in blocksObj) { if (blocksObj.hasOwnProperty(i)) { if (isLanguage(blocksObj[i])) { blocks.push(_getBlock(config, 'language', true)) } else { blocks.push(_getBlock(config, i)) } } } return blocks }
[ "function", "handleBlocks", "(", "config", ")", "{", "let", "blocks", "=", "[", "]", "let", "blocksObj", "=", "config", ".", "blocks", "for", "(", "let", "i", "in", "blocksObj", ")", "{", "if", "(", "blocksObj", ".", "hasOwnProperty", "(", "i", ")", ")", "{", "if", "(", "isLanguage", "(", "blocksObj", "[", "i", "]", ")", ")", "{", "blocks", ".", "push", "(", "_getBlock", "(", "config", ",", "'language'", ",", "true", ")", ")", "}", "else", "{", "blocks", ".", "push", "(", "_getBlock", "(", "config", ",", "i", ")", ")", "}", "}", "}", "return", "blocks", "}" ]
Handles all the blocks based on the given config. @param config @returns {Array}
[ "Handles", "all", "the", "blocks", "based", "on", "the", "given", "config", "." ]
db07ce1b6e3ffdbb565be312e91e2244aad20042
https://github.com/KTH/kth-node-cortina-block/blob/db07ce1b6e3ffdbb565be312e91e2244aad20042/index.js#L256-L269
train
KTH/kth-node-cortina-block
index.js
_getRedisItem
function _getRedisItem (config) { let key = _buildRedisKey(config.redisKey, config.language) return config.redis.hgetallAsync(key) }
javascript
function _getRedisItem (config) { let key = _buildRedisKey(config.redisKey, config.language) return config.redis.hgetallAsync(key) }
[ "function", "_getRedisItem", "(", "config", ")", "{", "let", "key", "=", "_buildRedisKey", "(", "config", ".", "redisKey", ",", "config", ".", "language", ")", "return", "config", ".", "redis", ".", "hgetallAsync", "(", "key", ")", "}" ]
Wrap a Redis get call in a Promise. @param config @returns {Promise} @private
[ "Wrap", "a", "Redis", "get", "call", "in", "a", "Promise", "." ]
db07ce1b6e3ffdbb565be312e91e2244aad20042
https://github.com/KTH/kth-node-cortina-block/blob/db07ce1b6e3ffdbb565be312e91e2244aad20042/index.js#L286-L289
train
KTH/kth-node-cortina-block
index.js
_setRedisItem
function _setRedisItem (config, blocks) { let key = _buildRedisKey(config.redisKey, config.language) return config.redis.hmsetAsync(key, blocks) .then(function () { return config.redis.expireAsync(key, config.redisExpire) }) .then(function () { return blocks }) }
javascript
function _setRedisItem (config, blocks) { let key = _buildRedisKey(config.redisKey, config.language) return config.redis.hmsetAsync(key, blocks) .then(function () { return config.redis.expireAsync(key, config.redisExpire) }) .then(function () { return blocks }) }
[ "function", "_setRedisItem", "(", "config", ",", "blocks", ")", "{", "let", "key", "=", "_buildRedisKey", "(", "config", ".", "redisKey", ",", "config", ".", "language", ")", "return", "config", ".", "redis", ".", "hmsetAsync", "(", "key", ",", "blocks", ")", ".", "then", "(", "function", "(", ")", "{", "return", "config", ".", "redis", ".", "expireAsync", "(", "key", ",", "config", ".", "redisExpire", ")", "}", ")", ".", "then", "(", "function", "(", ")", "{", "return", "blocks", "}", ")", "}" ]
Wrap Redis set call in a Promise. @param config @param blocks @returns {Promise} @private
[ "Wrap", "Redis", "set", "call", "in", "a", "Promise", "." ]
db07ce1b6e3ffdbb565be312e91e2244aad20042
https://github.com/KTH/kth-node-cortina-block/blob/db07ce1b6e3ffdbb565be312e91e2244aad20042/index.js#L298-L307
train
KTH/kth-node-cortina-block
index.js
_getEnvUrl
function _getEnvUrl (currentEnv, config) { if (currentEnv && config) { if (currentEnv === 'prod') { return config.urls.prod } else if (currentEnv === 'ref') { return config.urls.ref } else { return config.urls.dev } } }
javascript
function _getEnvUrl (currentEnv, config) { if (currentEnv && config) { if (currentEnv === 'prod') { return config.urls.prod } else if (currentEnv === 'ref') { return config.urls.ref } else { return config.urls.dev } } }
[ "function", "_getEnvUrl", "(", "currentEnv", ",", "config", ")", "{", "if", "(", "currentEnv", "&&", "config", ")", "{", "if", "(", "currentEnv", "===", "'prod'", ")", "{", "return", "config", ".", "urls", ".", "prod", "}", "else", "if", "(", "currentEnv", "===", "'ref'", ")", "{", "return", "config", ".", "urls", ".", "ref", "}", "else", "{", "return", "config", ".", "urls", ".", "dev", "}", "}", "}" ]
Get the url for the current environmen. @param {*} currentEnv current environment. @param {*} config the given config.
[ "Get", "the", "url", "for", "the", "current", "environmen", "." ]
db07ce1b6e3ffdbb565be312e91e2244aad20042
https://github.com/KTH/kth-node-cortina-block/blob/db07ce1b6e3ffdbb565be312e91e2244aad20042/index.js#L507-L517
train
craterdog-bali/js-bali-component-framework
src/elements/Reserved.js
Reserved
function Reserved(value, parameters) { abstractions.Element.call(this, utilities.types.RESERVED, parameters); if (!value || !/^[a-zA-Z][0-9a-zA-Z]*(-[0-9]+)?$/g.test(value)) { throw new utilities.Exception({ $module: '/bali/elements/Reserved', $procedure: '$Reserved', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid reserved symbol value was passed to the constructor."' }); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Reserved(value, parameters) { abstractions.Element.call(this, utilities.types.RESERVED, parameters); if (!value || !/^[a-zA-Z][0-9a-zA-Z]*(-[0-9]+)?$/g.test(value)) { throw new utilities.Exception({ $module: '/bali/elements/Reserved', $procedure: '$Reserved', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid reserved symbol value was passed to the constructor."' }); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Reserved", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "RESERVED", ",", "parameters", ")", ";", "if", "(", "!", "value", "||", "!", "/", "^[a-zA-Z][0-9a-zA-Z]*(-[0-9]+)?$", "/", "g", ".", "test", "(", "value", ")", ")", "{", "throw", "new", "utilities", ".", "Exception", "(", "{", "$module", ":", "'/bali/elements/Reserved'", ",", "$procedure", ":", "'$Reserved'", ",", "$exception", ":", "'$invalidParameter'", ",", "$parameter", ":", "value", ".", "toString", "(", ")", ",", "$text", ":", "'\"An invalid reserved symbol value was passed to the constructor.\"'", "}", ")", ";", "}", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new reserved identifier using the specified value. @param {String} value The value of the reserved identifier. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Reserved} The new reserved identifier.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "reserved", "identifier", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Reserved.js#L30-L46
train
squiggle-lang/squiggle-lang
src/scope.js
Scope
function Scope(parent) { var map = Object.create(null); var api = {}; api.markAsUsed = function(k) { if (typeof k !== "string") { throw new Error("Scope keys must be strings: " + k); } if (api.hasOwnVar(k)) { map[k].used = true; return api; } if (parent) { return parent.markAsUsed(k); } throw new Error("tried to use a variable before declaration: " + k); }; api.ownUnusedVars = function() { return Object .keys(map) .filter(function(k) { return !map[k].used; }) .map(function(k) { return map[k]; }); }; api.get = function(k) { if (api.hasOwnVar(k)) { return map[k]; } if (parent) { return parent.get(k); } throw new Error("no such variable " + k); }; api.declare = function(k, v) { // v.line :: number // v.column :: number // v.used :: boolean // Underscore is not a valid variable, so don't put it in the scope. if (k === "_") { return api; } v.name = k; // TODO: Unbreak the linter so I can use this check. Redeclaring a variable is not ok, but it's currently happening due to hoisting. // if (api.hasOwnVar(k)) { // throw new Error("cannot redeclare variable " + k); // } if (api.hasOwnVar(k)) { v.used = api.get(k).used; } map[k] = v; return api; }; api.hasVar = function(k) { if (api.hasOwnVar(k)) { return true; } if (parent) { return parent.hasVar(k); } return false; }; api.hasOwnVar = function(k) { return {}.hasOwnProperty.call(map, k); }; api.ownVars = function() { return Object.keys(map); }; api.bareToString = function() { var innards = Object .keys(map) .map(function(k) { return k + ":" + (map[k].used ? "T" : "F"); }) .join(" "); var s = "{" + innards + "}"; if (parent) { return parent.bareToString() + " > " + s; } return s; }; api.toString = function() { return "#Scope[" + api.bareToString() + "]"; }; api.parent = parent; return Object.freeze(api); }
javascript
function Scope(parent) { var map = Object.create(null); var api = {}; api.markAsUsed = function(k) { if (typeof k !== "string") { throw new Error("Scope keys must be strings: " + k); } if (api.hasOwnVar(k)) { map[k].used = true; return api; } if (parent) { return parent.markAsUsed(k); } throw new Error("tried to use a variable before declaration: " + k); }; api.ownUnusedVars = function() { return Object .keys(map) .filter(function(k) { return !map[k].used; }) .map(function(k) { return map[k]; }); }; api.get = function(k) { if (api.hasOwnVar(k)) { return map[k]; } if (parent) { return parent.get(k); } throw new Error("no such variable " + k); }; api.declare = function(k, v) { // v.line :: number // v.column :: number // v.used :: boolean // Underscore is not a valid variable, so don't put it in the scope. if (k === "_") { return api; } v.name = k; // TODO: Unbreak the linter so I can use this check. Redeclaring a variable is not ok, but it's currently happening due to hoisting. // if (api.hasOwnVar(k)) { // throw new Error("cannot redeclare variable " + k); // } if (api.hasOwnVar(k)) { v.used = api.get(k).used; } map[k] = v; return api; }; api.hasVar = function(k) { if (api.hasOwnVar(k)) { return true; } if (parent) { return parent.hasVar(k); } return false; }; api.hasOwnVar = function(k) { return {}.hasOwnProperty.call(map, k); }; api.ownVars = function() { return Object.keys(map); }; api.bareToString = function() { var innards = Object .keys(map) .map(function(k) { return k + ":" + (map[k].used ? "T" : "F"); }) .join(" "); var s = "{" + innards + "}"; if (parent) { return parent.bareToString() + " > " + s; } return s; }; api.toString = function() { return "#Scope[" + api.bareToString() + "]"; }; api.parent = parent; return Object.freeze(api); }
[ "function", "Scope", "(", "parent", ")", "{", "var", "map", "=", "Object", ".", "create", "(", "null", ")", ";", "var", "api", "=", "{", "}", ";", "api", ".", "markAsUsed", "=", "function", "(", "k", ")", "{", "if", "(", "typeof", "k", "!==", "\"string\"", ")", "{", "throw", "new", "Error", "(", "\"Scope keys must be strings: \"", "+", "k", ")", ";", "}", "if", "(", "api", ".", "hasOwnVar", "(", "k", ")", ")", "{", "map", "[", "k", "]", ".", "used", "=", "true", ";", "return", "api", ";", "}", "if", "(", "parent", ")", "{", "return", "parent", ".", "markAsUsed", "(", "k", ")", ";", "}", "throw", "new", "Error", "(", "\"tried to use a variable before declaration: \"", "+", "k", ")", ";", "}", ";", "api", ".", "ownUnusedVars", "=", "function", "(", ")", "{", "return", "Object", ".", "keys", "(", "map", ")", ".", "filter", "(", "function", "(", "k", ")", "{", "return", "!", "map", "[", "k", "]", ".", "used", ";", "}", ")", ".", "map", "(", "function", "(", "k", ")", "{", "return", "map", "[", "k", "]", ";", "}", ")", ";", "}", ";", "api", ".", "get", "=", "function", "(", "k", ")", "{", "if", "(", "api", ".", "hasOwnVar", "(", "k", ")", ")", "{", "return", "map", "[", "k", "]", ";", "}", "if", "(", "parent", ")", "{", "return", "parent", ".", "get", "(", "k", ")", ";", "}", "throw", "new", "Error", "(", "\"no such variable \"", "+", "k", ")", ";", "}", ";", "api", ".", "declare", "=", "function", "(", "k", ",", "v", ")", "{", "if", "(", "k", "===", "\"_\"", ")", "{", "return", "api", ";", "}", "v", ".", "name", "=", "k", ";", "if", "(", "api", ".", "hasOwnVar", "(", "k", ")", ")", "{", "v", ".", "used", "=", "api", ".", "get", "(", "k", ")", ".", "used", ";", "}", "map", "[", "k", "]", "=", "v", ";", "return", "api", ";", "}", ";", "api", ".", "hasVar", "=", "function", "(", "k", ")", "{", "if", "(", "api", ".", "hasOwnVar", "(", "k", ")", ")", "{", "return", "true", ";", "}", "if", "(", "parent", ")", "{", "return", "parent", ".", "hasVar", "(", "k", ")", ";", "}", "return", "false", ";", "}", ";", "api", ".", "hasOwnVar", "=", "function", "(", "k", ")", "{", "return", "{", "}", ".", "hasOwnProperty", ".", "call", "(", "map", ",", "k", ")", ";", "}", ";", "api", ".", "ownVars", "=", "function", "(", ")", "{", "return", "Object", ".", "keys", "(", "map", ")", ";", "}", ";", "api", ".", "bareToString", "=", "function", "(", ")", "{", "var", "innards", "=", "Object", ".", "keys", "(", "map", ")", ".", "map", "(", "function", "(", "k", ")", "{", "return", "k", "+", "\":\"", "+", "(", "map", "[", "k", "]", ".", "used", "?", "\"T\"", ":", "\"F\"", ")", ";", "}", ")", ".", "join", "(", "\" \"", ")", ";", "var", "s", "=", "\"{\"", "+", "innards", "+", "\"}\"", ";", "if", "(", "parent", ")", "{", "return", "parent", ".", "bareToString", "(", ")", "+", "\" > \"", "+", "s", ";", "}", "return", "s", ";", "}", ";", "api", ".", "toString", "=", "function", "(", ")", "{", "return", "\"#Scope[\"", "+", "api", ".", "bareToString", "(", ")", "+", "\"]\"", ";", "}", ";", "api", ".", "parent", "=", "parent", ";", "return", "Object", ".", "freeze", "(", "api", ")", ";", "}" ]
Scope is essentially a class for managing variable scopes. It allows nesting. Nested Scopes are used to track nested scopes. It's like JavaScript's prototypal inheritance, but easier to follow what's happening.
[ "Scope", "is", "essentially", "a", "class", "for", "managing", "variable", "scopes", ".", "It", "allows", "nesting", ".", "Nested", "Scopes", "are", "used", "to", "track", "nested", "scopes", ".", "It", "s", "like", "JavaScript", "s", "prototypal", "inheritance", "but", "easier", "to", "follow", "what", "s", "happening", "." ]
74a2ac34fbc54443a69c31ae256db2d8db5448b0
https://github.com/squiggle-lang/squiggle-lang/blob/74a2ac34fbc54443a69c31ae256db2d8db5448b0/src/scope.js#L12-L96
train
bq/corbel-js
src/ec/paymentMethodsBuilder.js
function (params, userId) { console.log('ecInterface.paymentmethod.add'); return this.request({ url: this._buildUri(this.uri, null, null, userId), method: corbel.request.method.POST, data: params }) .then(function (res) { return corbel.Services.getLocationId(res); }); }
javascript
function (params, userId) { console.log('ecInterface.paymentmethod.add'); return this.request({ url: this._buildUri(this.uri, null, null, userId), method: corbel.request.method.POST, data: params }) .then(function (res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", "params", ",", "userId", ")", "{", "console", ".", "log", "(", "'ecInterface.paymentmethod.add'", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ",", "null", ",", "null", ",", "userId", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "data", ":", "params", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
Add a new payment method for the logged user. @method @memberOf corbel.Ec.PaymentMethodBuilder @param {Object} params The params filter @param {String} params.data The card data encrypted (@see https://github.com/adyenpayments/client-side-encryption) @param {String} params.name User identifier related with de payment method @return {Promise} Q promise that resolves to a Payment {Object} or rejects with a {@link SilkRoadError}
[ "Add", "a", "new", "payment", "method", "for", "the", "logged", "user", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/src/ec/paymentMethodsBuilder.js#L61-L72
train
bq/corbel-js
src/ec/paymentMethodsBuilder.js
function (params) { console.log('ecInterface.paymentmethod.update'); return this.request({ url: this._buildUri(this.uri), method: corbel.request.method.PUT, data: params }) .then(function (res) { return corbel.Services.getLocationId(res); }); }
javascript
function (params) { console.log('ecInterface.paymentmethod.update'); return this.request({ url: this._buildUri(this.uri), method: corbel.request.method.PUT, data: params }) .then(function (res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", "params", ")", "{", "console", ".", "log", "(", "'ecInterface.paymentmethod.update'", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", ",", "data", ":", "params", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
Updates a current payment method for the logged user. @method @memberOf corbel.Ec.PaymentMethodBuilder @param {Object} params The params filter @param {String} params.data The card data encrypted (@see https://github.com/adyenpayments/client-side-encryption) @param {String} params.name User identifier related with de payment method @return {Promise} Q promise that resolves to a Payment {Object} or rejects with a {@link SilkRoadError}
[ "Updates", "a", "current", "payment", "method", "for", "the", "logged", "user", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/src/ec/paymentMethodsBuilder.js#L88-L99
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/dom/selector.js
matchImmediate
function matchImmediate(el, match) { var matched = 1, startEl = el, relativeOp, startMatch = match; do { matched &= singleMatch(el, match); if (matched) { // advance match = match && match.prev; if (!match) { return true; } relativeOp = relativeExpr[match.nextCombinator]; el = dir(el, relativeOp.dir); if (!relativeOp.immediate) { return { // advance for non-immediate el: el, match: match }; } } else { relativeOp = relativeExpr[match.nextCombinator]; if (relativeOp.immediate) { // retreat but advance startEl return { el: dir(startEl, relativeExpr[startMatch.nextCombinator].dir), match: startMatch }; } else { // advance (before immediate match + jump unmatched) return { el: el && dir(el, relativeOp.dir), match: match }; } } } while (el); // only occur when match immediate // only occur when match immediate return { el: dir(startEl, relativeExpr[startMatch.nextCombinator].dir), match: startMatch }; }
javascript
function matchImmediate(el, match) { var matched = 1, startEl = el, relativeOp, startMatch = match; do { matched &= singleMatch(el, match); if (matched) { // advance match = match && match.prev; if (!match) { return true; } relativeOp = relativeExpr[match.nextCombinator]; el = dir(el, relativeOp.dir); if (!relativeOp.immediate) { return { // advance for non-immediate el: el, match: match }; } } else { relativeOp = relativeExpr[match.nextCombinator]; if (relativeOp.immediate) { // retreat but advance startEl return { el: dir(startEl, relativeExpr[startMatch.nextCombinator].dir), match: startMatch }; } else { // advance (before immediate match + jump unmatched) return { el: el && dir(el, relativeOp.dir), match: match }; } } } while (el); // only occur when match immediate // only occur when match immediate return { el: dir(startEl, relativeExpr[startMatch.nextCombinator].dir), match: startMatch }; }
[ "function", "matchImmediate", "(", "el", ",", "match", ")", "{", "var", "matched", "=", "1", ",", "startEl", "=", "el", ",", "relativeOp", ",", "startMatch", "=", "match", ";", "do", "{", "matched", "&=", "singleMatch", "(", "el", ",", "match", ")", ";", "if", "(", "matched", ")", "{", "match", "=", "match", "&&", "match", ".", "prev", ";", "if", "(", "!", "match", ")", "{", "return", "true", ";", "}", "relativeOp", "=", "relativeExpr", "[", "match", ".", "nextCombinator", "]", ";", "el", "=", "dir", "(", "el", ",", "relativeOp", ".", "dir", ")", ";", "if", "(", "!", "relativeOp", ".", "immediate", ")", "{", "return", "{", "el", ":", "el", ",", "match", ":", "match", "}", ";", "}", "}", "else", "{", "relativeOp", "=", "relativeExpr", "[", "match", ".", "nextCombinator", "]", ";", "if", "(", "relativeOp", ".", "immediate", ")", "{", "return", "{", "el", ":", "dir", "(", "startEl", ",", "relativeExpr", "[", "startMatch", ".", "nextCombinator", "]", ".", "dir", ")", ",", "match", ":", "startMatch", "}", ";", "}", "else", "{", "return", "{", "el", ":", "el", "&&", "dir", "(", "el", ",", "relativeOp", ".", "dir", ")", ",", "match", ":", "match", "}", ";", "}", "}", "}", "while", "(", "el", ")", ";", "return", "{", "el", ":", "dir", "(", "startEl", ",", "relativeExpr", "[", "startMatch", ".", "nextCombinator", "]", ".", "dir", ")", ",", "match", ":", "startMatch", "}", ";", "}" ]
match by adjacent immediate single selector match match by adjacent immediate single selector match
[ "match", "by", "adjacent", "immediate", "single", "selector", "match", "match", "by", "adjacent", "immediate", "single", "selector", "match" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/dom/selector.js#L376-L417
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/dom/selector.js
findFixedMatchFromHead
function findFixedMatchFromHead(el, head) { var relativeOp, cur = head; do { if (!singleMatch(el, cur)) { return null; } cur = cur.prev; if (!cur) { return true; } relativeOp = relativeExpr[cur.nextCombinator]; el = dir(el, relativeOp.dir); } while (el && relativeOp.immediate); if (!el) { return null; } return { el: el, match: cur }; }
javascript
function findFixedMatchFromHead(el, head) { var relativeOp, cur = head; do { if (!singleMatch(el, cur)) { return null; } cur = cur.prev; if (!cur) { return true; } relativeOp = relativeExpr[cur.nextCombinator]; el = dir(el, relativeOp.dir); } while (el && relativeOp.immediate); if (!el) { return null; } return { el: el, match: cur }; }
[ "function", "findFixedMatchFromHead", "(", "el", ",", "head", ")", "{", "var", "relativeOp", ",", "cur", "=", "head", ";", "do", "{", "if", "(", "!", "singleMatch", "(", "el", ",", "cur", ")", ")", "{", "return", "null", ";", "}", "cur", "=", "cur", ".", "prev", ";", "if", "(", "!", "cur", ")", "{", "return", "true", ";", "}", "relativeOp", "=", "relativeExpr", "[", "cur", ".", "nextCombinator", "]", ";", "el", "=", "dir", "(", "el", ",", "relativeOp", ".", "dir", ")", ";", "}", "while", "(", "el", "&&", "relativeOp", ".", "immediate", ")", ";", "if", "(", "!", "el", ")", "{", "return", "null", ";", "}", "return", "{", "el", ":", "el", ",", "match", ":", "cur", "}", ";", "}" ]
find fixed part, fixed with seeds find fixed part, fixed with seeds
[ "find", "fixed", "part", "fixed", "with", "seeds", "find", "fixed", "part", "fixed", "with", "seeds" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/dom/selector.js#L419-L439
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/dom/selector.js
matchSubInternal
function matchSubInternal(el, match) { var matchImmediateRet = matchImmediate(el, match); if (matchImmediateRet === true) { return true; } else { el = matchImmediateRet.el; match = matchImmediateRet.match; while (el) { if (matchSub(el, match)) { return true; } el = dir(el, relativeExpr[match.nextCombinator].dir); } return false; } }
javascript
function matchSubInternal(el, match) { var matchImmediateRet = matchImmediate(el, match); if (matchImmediateRet === true) { return true; } else { el = matchImmediateRet.el; match = matchImmediateRet.match; while (el) { if (matchSub(el, match)) { return true; } el = dir(el, relativeExpr[match.nextCombinator].dir); } return false; } }
[ "function", "matchSubInternal", "(", "el", ",", "match", ")", "{", "var", "matchImmediateRet", "=", "matchImmediate", "(", "el", ",", "match", ")", ";", "if", "(", "matchImmediateRet", "===", "true", ")", "{", "return", "true", ";", "}", "else", "{", "el", "=", "matchImmediateRet", ".", "el", ";", "match", "=", "matchImmediateRet", ".", "match", ";", "while", "(", "el", ")", "{", "if", "(", "matchSub", "(", "el", ",", "match", ")", ")", "{", "return", "true", ";", "}", "el", "=", "dir", "(", "el", ",", "relativeExpr", "[", "match", ".", "nextCombinator", "]", ".", "dir", ")", ";", "}", "return", "false", ";", "}", "}" ]
recursive match by sub selector string from right to left grouped by immediate selectors recursive match by sub selector string from right to left grouped by immediate selectors
[ "recursive", "match", "by", "sub", "selector", "string", "from", "right", "to", "left", "grouped", "by", "immediate", "selectors", "recursive", "match", "by", "sub", "selector", "string", "from", "right", "to", "left", "grouped", "by", "immediate", "selectors" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/dom/selector.js#L465-L480
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/feature-debug.js
getVendorInfo
function getVendorInfo(name) { if (name.indexOf('-') !== -1) { name = name.replace(RE_DASH, upperCase); } if (name in vendorInfos) { return vendorInfos[name]; } // if already prefixed or need not to prefix // if already prefixed or need not to prefix if (!documentElementStyle || name in documentElementStyle) { vendorInfos[name] = { propertyName: name, propertyNamePrefix: '' }; } else { var upperFirstName = name.charAt(0).toUpperCase() + name.slice(1), vendorName; for (var i = 0; i < propertyPrefixesLength; i++) { var propertyNamePrefix = propertyPrefixes[i]; vendorName = propertyNamePrefix + upperFirstName; if (vendorName in documentElementStyle) { vendorInfos[name] = { propertyName: vendorName, propertyNamePrefix: propertyNamePrefix }; } } vendorInfos[name] = vendorInfos[name] || null; } return vendorInfos[name]; }
javascript
function getVendorInfo(name) { if (name.indexOf('-') !== -1) { name = name.replace(RE_DASH, upperCase); } if (name in vendorInfos) { return vendorInfos[name]; } // if already prefixed or need not to prefix // if already prefixed or need not to prefix if (!documentElementStyle || name in documentElementStyle) { vendorInfos[name] = { propertyName: name, propertyNamePrefix: '' }; } else { var upperFirstName = name.charAt(0).toUpperCase() + name.slice(1), vendorName; for (var i = 0; i < propertyPrefixesLength; i++) { var propertyNamePrefix = propertyPrefixes[i]; vendorName = propertyNamePrefix + upperFirstName; if (vendorName in documentElementStyle) { vendorInfos[name] = { propertyName: vendorName, propertyNamePrefix: propertyNamePrefix }; } } vendorInfos[name] = vendorInfos[name] || null; } return vendorInfos[name]; }
[ "function", "getVendorInfo", "(", "name", ")", "{", "if", "(", "name", ".", "indexOf", "(", "'-'", ")", "!==", "-", "1", ")", "{", "name", "=", "name", ".", "replace", "(", "RE_DASH", ",", "upperCase", ")", ";", "}", "if", "(", "name", "in", "vendorInfos", ")", "{", "return", "vendorInfos", "[", "name", "]", ";", "}", "if", "(", "!", "documentElementStyle", "||", "name", "in", "documentElementStyle", ")", "{", "vendorInfos", "[", "name", "]", "=", "{", "propertyName", ":", "name", ",", "propertyNamePrefix", ":", "''", "}", ";", "}", "else", "{", "var", "upperFirstName", "=", "name", ".", "charAt", "(", "0", ")", ".", "toUpperCase", "(", ")", "+", "name", ".", "slice", "(", "1", ")", ",", "vendorName", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "propertyPrefixesLength", ";", "i", "++", ")", "{", "var", "propertyNamePrefix", "=", "propertyPrefixes", "[", "i", "]", ";", "vendorName", "=", "propertyNamePrefix", "+", "upperFirstName", ";", "if", "(", "vendorName", "in", "documentElementStyle", ")", "{", "vendorInfos", "[", "name", "]", "=", "{", "propertyName", ":", "vendorName", ",", "propertyNamePrefix", ":", "propertyNamePrefix", "}", ";", "}", "}", "vendorInfos", "[", "name", "]", "=", "vendorInfos", "[", "name", "]", "||", "null", ";", "}", "return", "vendorInfos", "[", "name", "]", ";", "}" ]
return prefixed css prefix name return prefixed css prefix name
[ "return", "prefixed", "css", "prefix", "name", "return", "prefixed", "css", "prefix", "name" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/feature-debug.js#L46-L74
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/feature-debug.js
function () { if (isTransform3dSupported !== undefined) { return isTransform3dSupported; } if (!documentElement || !getVendorInfo('transform')) { isTransform3dSupported = false; } else { // https://gist.github.com/lorenzopolidori/3794226 // ie9 does not support 3d transform // http://msdn.microsoft.com/en-us/ie/ff468705 try { var el = doc.createElement('p'); var transformProperty = getVendorInfo('transform').propertyName; documentElement.insertBefore(el, documentElement.firstChild); el.style[transformProperty] = 'translate3d(1px,1px,1px)'; var computedStyle = win.getComputedStyle(el); var has3d = computedStyle.getPropertyValue(transformProperty) || computedStyle[transformProperty]; documentElement.removeChild(el); isTransform3dSupported = has3d !== undefined && has3d.length > 0 && has3d !== 'none'; } catch (e) { // https://github.com/kissyteam/kissy/issues/563 isTransform3dSupported = true; } } return isTransform3dSupported; }
javascript
function () { if (isTransform3dSupported !== undefined) { return isTransform3dSupported; } if (!documentElement || !getVendorInfo('transform')) { isTransform3dSupported = false; } else { // https://gist.github.com/lorenzopolidori/3794226 // ie9 does not support 3d transform // http://msdn.microsoft.com/en-us/ie/ff468705 try { var el = doc.createElement('p'); var transformProperty = getVendorInfo('transform').propertyName; documentElement.insertBefore(el, documentElement.firstChild); el.style[transformProperty] = 'translate3d(1px,1px,1px)'; var computedStyle = win.getComputedStyle(el); var has3d = computedStyle.getPropertyValue(transformProperty) || computedStyle[transformProperty]; documentElement.removeChild(el); isTransform3dSupported = has3d !== undefined && has3d.length > 0 && has3d !== 'none'; } catch (e) { // https://github.com/kissyteam/kissy/issues/563 isTransform3dSupported = true; } } return isTransform3dSupported; }
[ "function", "(", ")", "{", "if", "(", "isTransform3dSupported", "!==", "undefined", ")", "{", "return", "isTransform3dSupported", ";", "}", "if", "(", "!", "documentElement", "||", "!", "getVendorInfo", "(", "'transform'", ")", ")", "{", "isTransform3dSupported", "=", "false", ";", "}", "else", "{", "try", "{", "var", "el", "=", "doc", ".", "createElement", "(", "'p'", ")", ";", "var", "transformProperty", "=", "getVendorInfo", "(", "'transform'", ")", ".", "propertyName", ";", "documentElement", ".", "insertBefore", "(", "el", ",", "documentElement", ".", "firstChild", ")", ";", "el", ".", "style", "[", "transformProperty", "]", "=", "'translate3d(1px,1px,1px)'", ";", "var", "computedStyle", "=", "win", ".", "getComputedStyle", "(", "el", ")", ";", "var", "has3d", "=", "computedStyle", ".", "getPropertyValue", "(", "transformProperty", ")", "||", "computedStyle", "[", "transformProperty", "]", ";", "documentElement", ".", "removeChild", "(", "el", ")", ";", "isTransform3dSupported", "=", "has3d", "!==", "undefined", "&&", "has3d", ".", "length", ">", "0", "&&", "has3d", "!==", "'none'", ";", "}", "catch", "(", "e", ")", "{", "isTransform3dSupported", "=", "true", ";", "}", "}", "return", "isTransform3dSupported", ";", "}" ]
whether support css transform 3d @returns {boolean}
[ "whether", "support", "css", "transform", "3d" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/feature-debug.js#L138-L163
train
voxpelli/node-jekyll-utils
lib/url.js
JekyllUrl
function JekyllUrl (options) { options = options || {}; this.template = options.template; this.placeholders = options.placeholders; this.permalink = options.permalink; if (!this.template) { throw new Error('One of template or permalink must be supplied.'); } }
javascript
function JekyllUrl (options) { options = options || {}; this.template = options.template; this.placeholders = options.placeholders; this.permalink = options.permalink; if (!this.template) { throw new Error('One of template or permalink must be supplied.'); } }
[ "function", "JekyllUrl", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "template", "=", "options", ".", "template", ";", "this", ".", "placeholders", "=", "options", ".", "placeholders", ";", "this", ".", "permalink", "=", "options", ".", "permalink", ";", "if", "(", "!", "this", ".", "template", ")", "{", "throw", "new", "Error", "(", "'One of template or permalink must be supplied.'", ")", ";", "}", "}" ]
Methods that generate a URL for a resource such as a Post or a Page. @example new JekyllUrl({ template: '/:categories/:title.html', placeholders: {':categories': 'ruby', ':title' => 'something'} }).toString(); @class JekyllUrl @param {object} options - One of :permalink or :template must be supplied. @param {string} options.template - The String used as template for URL generation, or example "/:path/:basename:output_ext", where a placeholder is prefixed with a colon. @param {string} options.:placeholders - A hash containing the placeholders which will be replaced when used inside the template. E.g. { year: (new Date()).getFullYear() } would replace the placeholder ":year" with the current year. @param {string} options.permalink - If supplied, no URL will be generated from the template. Instead, the given permalink will be used as URL. @see {@link https://github.com/jekyll/jekyll/blob/cc82d442223bdaee36a2aceada64008a0106d82b/lib/jekyll/url.rb|Mimicked Jekyll Code}
[ "Methods", "that", "generate", "a", "URL", "for", "a", "resource", "such", "as", "a", "Post", "or", "a", "Page", "." ]
785ba8934bdd001a0c041ae8c77b83ab70b1f442
https://github.com/voxpelli/node-jekyll-utils/blob/785ba8934bdd001a0c041ae8c77b83ab70b1f442/lib/url.js#L76-L86
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/tabs-debug.js
function (item, index) { var self = this, bar = self.get('bar'), selectedTab, tabItem, panelItem, barChildren = bar.get('children'), body = self.get('body'); if (typeof index === 'undefined') { index = barChildren.length; } tabItem = fromTabItemConfigToTabConfig(item); panelItem = { content: item.content }; bar.addChild(tabItem, index); selectedTab = barChildren[index]; body.addChild(panelItem, index); if (item.selected) { bar.set('selectedTab', selectedTab); body.set('selectedPanelIndex', index); } return self; }
javascript
function (item, index) { var self = this, bar = self.get('bar'), selectedTab, tabItem, panelItem, barChildren = bar.get('children'), body = self.get('body'); if (typeof index === 'undefined') { index = barChildren.length; } tabItem = fromTabItemConfigToTabConfig(item); panelItem = { content: item.content }; bar.addChild(tabItem, index); selectedTab = barChildren[index]; body.addChild(panelItem, index); if (item.selected) { bar.set('selectedTab', selectedTab); body.set('selectedPanelIndex', index); } return self; }
[ "function", "(", "item", ",", "index", ")", "{", "var", "self", "=", "this", ",", "bar", "=", "self", ".", "get", "(", "'bar'", ")", ",", "selectedTab", ",", "tabItem", ",", "panelItem", ",", "barChildren", "=", "bar", ".", "get", "(", "'children'", ")", ",", "body", "=", "self", ".", "get", "(", "'body'", ")", ";", "if", "(", "typeof", "index", "===", "'undefined'", ")", "{", "index", "=", "barChildren", ".", "length", ";", "}", "tabItem", "=", "fromTabItemConfigToTabConfig", "(", "item", ")", ";", "panelItem", "=", "{", "content", ":", "item", ".", "content", "}", ";", "bar", ".", "addChild", "(", "tabItem", ",", "index", ")", ";", "selectedTab", "=", "barChildren", "[", "index", "]", ";", "body", ".", "addChild", "(", "panelItem", ",", "index", ")", ";", "if", "(", "item", ".", "selected", ")", "{", "bar", ".", "set", "(", "'selectedTab'", ",", "selectedTab", ")", ";", "body", ".", "set", "(", "'selectedPanelIndex'", ",", "index", ")", ";", "}", "return", "self", ";", "}" ]
fired when selected tab is changed @event afterSelectedTabChange @member KISSY.Tabs @param {KISSY.Event.CustomEvent.Object} e @param {KISSY.Tabs.Tab} e.newVal selected tab fired before selected tab is changed @event beforeSelectedTabChange @member KISSY.Tabs @param {KISSY.Event.CustomEvent.Object} e @param {KISSY.Tabs.Tab} e.newVal tab to be selected fired when tab is closed @event afterTabClose @member KISSY.Tabs @param {KISSY.Event.CustomEvent.Object} e @param {KISSY.Tabs.Tab} e.target closed tab fired before tab is closed @event beforeTabClose @member KISSY.Tabs @param {KISSY.Event.CustomEvent.Object} e @param {KISSY.Tabs.Tab} e.target tab to be closed add one item to tabs @param {Object} item item description @param {String} item.content tab panel html @param {String} item.title tab bar html @param {String} item.closable whether this tab is closable @param {Number} index insert index @chainable
[ "fired", "when", "selected", "tab", "is", "changed" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/tabs-debug.js#L175-L190
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/tabs-debug.js
function (index, destroy) { var self = this, bar = /** @ignore @type KISSY.Component.Control */ self.get('bar'), barCs = bar.get('children'), tab = bar.getChildAt(index), body = /** @ignore @type KISSY.Component.Control */ self.get('body'); if (tab.get('selected')) { if (barCs.length === 1) { bar.set('selectedTab', null); } else if (index === 0) { bar.set('selectedTab', bar.getChildAt(index + 1)); } else { bar.set('selectedTab', bar.getChildAt(index - 1)); } } bar.removeChild(bar.getChildAt(index), destroy); body.removeChild(body.getChildAt(index), destroy); return self; }
javascript
function (index, destroy) { var self = this, bar = /** @ignore @type KISSY.Component.Control */ self.get('bar'), barCs = bar.get('children'), tab = bar.getChildAt(index), body = /** @ignore @type KISSY.Component.Control */ self.get('body'); if (tab.get('selected')) { if (barCs.length === 1) { bar.set('selectedTab', null); } else if (index === 0) { bar.set('selectedTab', bar.getChildAt(index + 1)); } else { bar.set('selectedTab', bar.getChildAt(index - 1)); } } bar.removeChild(bar.getChildAt(index), destroy); body.removeChild(body.getChildAt(index), destroy); return self; }
[ "function", "(", "index", ",", "destroy", ")", "{", "var", "self", "=", "this", ",", "bar", "=", "self", ".", "get", "(", "'bar'", ")", ",", "barCs", "=", "bar", ".", "get", "(", "'children'", ")", ",", "tab", "=", "bar", ".", "getChildAt", "(", "index", ")", ",", "body", "=", "self", ".", "get", "(", "'body'", ")", ";", "if", "(", "tab", ".", "get", "(", "'selected'", ")", ")", "{", "if", "(", "barCs", ".", "length", "===", "1", ")", "{", "bar", ".", "set", "(", "'selectedTab'", ",", "null", ")", ";", "}", "else", "if", "(", "index", "===", "0", ")", "{", "bar", ".", "set", "(", "'selectedTab'", ",", "bar", ".", "getChildAt", "(", "index", "+", "1", ")", ")", ";", "}", "else", "{", "bar", ".", "set", "(", "'selectedTab'", ",", "bar", ".", "getChildAt", "(", "index", "-", "1", ")", ")", ";", "}", "}", "bar", ".", "removeChild", "(", "bar", ".", "getChildAt", "(", "index", ")", ",", "destroy", ")", ";", "body", ".", "removeChild", "(", "body", ".", "getChildAt", "(", "index", ")", ",", "destroy", ")", ";", "return", "self", ";", "}" ]
remove specified tab from current tabs @param {Number} index @param {Boolean} destroy whether destroy specified tab and panel @chainable
[ "remove", "specified", "tab", "from", "current", "tabs" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/tabs-debug.js#L197-L219
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/tabs-debug.js
function (tab, destroy) { var index = util.indexOf(tab, this.get('bar').get('children')); return this.removeItemAt(index, destroy); }
javascript
function (tab, destroy) { var index = util.indexOf(tab, this.get('bar').get('children')); return this.removeItemAt(index, destroy); }
[ "function", "(", "tab", ",", "destroy", ")", "{", "var", "index", "=", "util", ".", "indexOf", "(", "tab", ",", "this", ".", "get", "(", "'bar'", ")", ".", "get", "(", "'children'", ")", ")", ";", "return", "this", ".", "removeItemAt", "(", "index", ",", "destroy", ")", ";", "}" ]
remove item by specified tab @param {KISSY.Tabs.Tab} tab @param {Boolean} destroy whether destroy specified tab and panel @chainable
[ "remove", "item", "by", "specified", "tab" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/tabs-debug.js#L226-L229
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/tabs-debug.js
function (panel, destroy) { var index = util.indexOf(panel, this.get('body').get('children')); return this.removeItemAt(index, destroy); }
javascript
function (panel, destroy) { var index = util.indexOf(panel, this.get('body').get('children')); return this.removeItemAt(index, destroy); }
[ "function", "(", "panel", ",", "destroy", ")", "{", "var", "index", "=", "util", ".", "indexOf", "(", "panel", ",", "this", ".", "get", "(", "'body'", ")", ".", "get", "(", "'children'", ")", ")", ";", "return", "this", ".", "removeItemAt", "(", "index", ",", "destroy", ")", ";", "}" ]
remove item by specified panel @param {KISSY.Tabs.Panel} panel @param {Boolean} destroy whether destroy specified tab and panel @chainable
[ "remove", "item", "by", "specified", "panel" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/tabs-debug.js#L236-L239
train