repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
examples/phonegap1/plugins/cordova-plugin-file/www/blackberry10/resolveLocalFileSystemURI.js
resolveNative
function resolveNative(success, fail, path, fsType, options, size) { window.webkitRequestFileSystem( fsType, size, function (fs) { if (path === '') { //no path provided, call success with root file system success(createEntryFromNative(fs.root)); ...
javascript
function resolveNative(success, fail, path, fsType, options, size) { window.webkitRequestFileSystem( fsType, size, function (fs) { if (path === '') { //no path provided, call success with root file system success(createEntryFromNative(fs.root)); ...
[ "function", "resolveNative", "(", "success", ",", "fail", ",", "path", ",", "fsType", ",", "options", ",", "size", ")", "{", "window", ".", "webkitRequestFileSystem", "(", "fsType", ",", "size", ",", "function", "(", "fs", ")", "{", "if", "(", "path", ...
find path using webkit file system
[ "find", "path", "using", "webkit", "file", "system" ]
252f591fcc833ac9fe7fb0f535d351e0879a873c
https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/252f591fcc833ac9fe7fb0f535d351e0879a873c/examples/phonegap1/plugins/cordova-plugin-file/www/blackberry10/resolveLocalFileSystemURI.js#L132-L172
train
BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
examples/phonegap1/platforms/ios/www/plugins/cordova-plugin-vibration/www/vibration.js
function (pattern, repeat) { repeat = (typeof repeat !== 'undefined') ? repeat : -1; pattern = pattern.unshift(0); // add a 0 at beginning for backwards compatibility from w3c spec exec(null, null, 'Vibration', 'vibrateWithPattern', [pattern, repeat]); }
javascript
function (pattern, repeat) { repeat = (typeof repeat !== 'undefined') ? repeat : -1; pattern = pattern.unshift(0); // add a 0 at beginning for backwards compatibility from w3c spec exec(null, null, 'Vibration', 'vibrateWithPattern', [pattern, repeat]); }
[ "function", "(", "pattern", ",", "repeat", ")", "{", "repeat", "=", "(", "typeof", "repeat", "!==", "'undefined'", ")", "?", "repeat", ":", "-", "1", ";", "pattern", "=", "pattern", ".", "unshift", "(", "0", ")", ";", "// add a 0 at beginning for backwards...
Vibrates the device with a given pattern. @param {Array of Integer} pattern Pattern with which to vibrate the device. Pass in an array of integers that are the durations for which to turn on or off the vibrator in milliseconds. The first value indicates the number of milliseconds to wait before turning the vibrator...
[ "Vibrates", "the", "device", "with", "a", "given", "pattern", "." ]
252f591fcc833ac9fe7fb0f535d351e0879a873c
https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/252f591fcc833ac9fe7fb0f535d351e0879a873c/examples/phonegap1/platforms/ios/www/plugins/cordova-plugin-vibration/www/vibration.js#L105-L109
train
BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/processConfigXml.js
read
function read(context) { const projectRoot = getProjectRoot(context); const configXml = getConfigXml(projectRoot); const branchXml = getBranchXml(configXml); const branchPreferences = getBranchPreferences( context, configXml, branchXml ); validateBranchPreferences(branchPrefer...
javascript
function read(context) { const projectRoot = getProjectRoot(context); const configXml = getConfigXml(projectRoot); const branchXml = getBranchXml(configXml); const branchPreferences = getBranchPreferences( context, configXml, branchXml ); validateBranchPreferences(branchPrefer...
[ "function", "read", "(", "context", ")", "{", "const", "projectRoot", "=", "getProjectRoot", "(", "context", ")", ";", "const", "configXml", "=", "getConfigXml", "(", "projectRoot", ")", ";", "const", "branchXml", "=", "getBranchXml", "(", "configXml", ")", ...
read branch config from config.xml
[ "read", "branch", "config", "from", "config", ".", "xml" ]
252f591fcc833ac9fe7fb0f535d351e0879a873c
https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/252f591fcc833ac9fe7fb0f535d351e0879a873c/examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/processConfigXml.js#L13-L26
train
BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/processConfigXml.js
getConfigXml
function getConfigXml(projectRoot) { const pathToConfigXml = path.join(projectRoot, "config.xml"); const configXml = xmlHelper.readXmlAsJson(pathToConfigXml); if (configXml == null) { throw new Error( "BRANCH SDK: A config.xml is not found in project's root directory. Docs https://goo.gl/GijG...
javascript
function getConfigXml(projectRoot) { const pathToConfigXml = path.join(projectRoot, "config.xml"); const configXml = xmlHelper.readXmlAsJson(pathToConfigXml); if (configXml == null) { throw new Error( "BRANCH SDK: A config.xml is not found in project's root directory. Docs https://goo.gl/GijG...
[ "function", "getConfigXml", "(", "projectRoot", ")", "{", "const", "pathToConfigXml", "=", "path", ".", "join", "(", "projectRoot", ",", "\"config.xml\"", ")", ";", "const", "configXml", "=", "xmlHelper", ".", "readXmlAsJson", "(", "pathToConfigXml", ")", ";", ...
read config.xml
[ "read", "config", ".", "xml" ]
252f591fcc833ac9fe7fb0f535d351e0879a873c
https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/252f591fcc833ac9fe7fb0f535d351e0879a873c/examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/processConfigXml.js#L29-L40
train
BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/processConfigXml.js
getProjectName
function getProjectName(configXml) { let output = null; if (configXml.widget.hasOwnProperty("name")) { const name = configXml.widget.name[0]; if (typeof name === "string") { // handle <name>Branch Cordova</name> output = configXml.widget.name[0]; } else { // handle <nam...
javascript
function getProjectName(configXml) { let output = null; if (configXml.widget.hasOwnProperty("name")) { const name = configXml.widget.name[0]; if (typeof name === "string") { // handle <name>Branch Cordova</name> output = configXml.widget.name[0]; } else { // handle <nam...
[ "function", "getProjectName", "(", "configXml", ")", "{", "let", "output", "=", "null", ";", "if", "(", "configXml", ".", "widget", ".", "hasOwnProperty", "(", "\"name\"", ")", ")", "{", "const", "name", "=", "configXml", ".", "widget", ".", "name", "[",...
read project name from config.xml
[ "read", "project", "name", "from", "config", ".", "xml" ]
252f591fcc833ac9fe7fb0f535d351e0879a873c
https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/252f591fcc833ac9fe7fb0f535d351e0879a873c/examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/processConfigXml.js#L79-L93
train
BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/processConfigXml.js
getProjectModule
function getProjectModule(context) { const projectRoot = getProjectRoot(context); const projectPath = path.join(projectRoot, "platforms", "ios"); try { // pre 5.0 cordova structure return context .requireCordovaModule("cordova-lib/src/plugman/platforms") .ios.parseProjectFile(pr...
javascript
function getProjectModule(context) { const projectRoot = getProjectRoot(context); const projectPath = path.join(projectRoot, "platforms", "ios"); try { // pre 5.0 cordova structure return context .requireCordovaModule("cordova-lib/src/plugman/platforms") .ios.parseProjectFile(pr...
[ "function", "getProjectModule", "(", "context", ")", "{", "const", "projectRoot", "=", "getProjectRoot", "(", "context", ")", ";", "const", "projectPath", "=", "path", ".", "join", "(", "projectRoot", ",", "\"platforms\"", ",", "\"ios\"", ")", ";", "try", "{...
read iOS project module from cordova context
[ "read", "iOS", "project", "module", "from", "cordova", "context" ]
252f591fcc833ac9fe7fb0f535d351e0879a873c
https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/252f591fcc833ac9fe7fb0f535d351e0879a873c/examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/processConfigXml.js#L128-L148
train
BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/updateNpmVersion.js
updateNpmVersion
function updateNpmVersion(pluginConfig, config, callback) { const files = readFilePaths(FILES); const version = config.nextRelease.version; let git = ""; for (let i = 0; i < files.length; i++) { // update const file = files[i]; const content = readContent(file); const updated = ...
javascript
function updateNpmVersion(pluginConfig, config, callback) { const files = readFilePaths(FILES); const version = config.nextRelease.version; let git = ""; for (let i = 0; i < files.length; i++) { // update const file = files[i]; const content = readContent(file); const updated = ...
[ "function", "updateNpmVersion", "(", "pluginConfig", ",", "config", ",", "callback", ")", "{", "const", "files", "=", "readFilePaths", "(", "FILES", ")", ";", "const", "version", "=", "config", ".", "nextRelease", ".", "version", ";", "let", "git", "=", "\...
updates the npm version in semantic-release pre
[ "updates", "the", "npm", "version", "in", "semantic", "-", "release", "pre" ]
252f591fcc833ac9fe7fb0f535d351e0879a873c
https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/252f591fcc833ac9fe7fb0f535d351e0879a873c/examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/updateNpmVersion.js#L14-L31
train
BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/updateNpmVersion.js
updateVersion
function updateVersion(file, content, version) { const prev = /id="branch-cordova-sdk"[\s]*version="\d+\.\d+\.\d+"/gim; const next = `id="branch-cordova-sdk"\n version="${version}"`; try { if (isFileXml(file)) { content = content.replace(prev, next); } else { isChange = content...
javascript
function updateVersion(file, content, version) { const prev = /id="branch-cordova-sdk"[\s]*version="\d+\.\d+\.\d+"/gim; const next = `id="branch-cordova-sdk"\n version="${version}"`; try { if (isFileXml(file)) { content = content.replace(prev, next); } else { isChange = content...
[ "function", "updateVersion", "(", "file", ",", "content", ",", "version", ")", "{", "const", "prev", "=", "/", "id=\"branch-cordova-sdk\"[\\s]*version=\"\\d+\\.\\d+\\.\\d+\"", "/", "gim", ";", "const", "next", "=", "`", "\\n", "${", "version", "}", "`", ";", "...
update content based on xml or json
[ "update", "content", "based", "on", "xml", "or", "json" ]
252f591fcc833ac9fe7fb0f535d351e0879a873c
https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/252f591fcc833ac9fe7fb0f535d351e0879a873c/examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/updateNpmVersion.js#L51-L68
train
BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/updateNpmVersion.js
readFilePaths
function readFilePaths(files) { const locations = []; for (let i = 0; i < files.length; i++) { const file = files[i]; const location = path.join(__dirname, "../../../", file); locations.push(location); } return locations; }
javascript
function readFilePaths(files) { const locations = []; for (let i = 0; i < files.length; i++) { const file = files[i]; const location = path.join(__dirname, "../../../", file); locations.push(location); } return locations; }
[ "function", "readFilePaths", "(", "files", ")", "{", "const", "locations", "=", "[", "]", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "files", ".", "length", ";", "i", "++", ")", "{", "const", "file", "=", "files", "[", "i", "]", ";",...
get the absolute path of the files within the root directory
[ "get", "the", "absolute", "path", "of", "the", "files", "within", "the", "root", "directory" ]
252f591fcc833ac9fe7fb0f535d351e0879a873c
https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/252f591fcc833ac9fe7fb0f535d351e0879a873c/examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/updateNpmVersion.js#L71-L79
train
BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/updateNpmVersion.js
commitChanges
function commitChanges(git, version) { git += `git commit -m "chore: updated npm version to ${version}" && git push`; exec(git, (err, stdout, stderr) => { if (err) { throw new Error( "BRANCH SDK: Failed to commit git changes for the npm version. Docs https://goo.gl/GijGKP" ); ...
javascript
function commitChanges(git, version) { git += `git commit -m "chore: updated npm version to ${version}" && git push`; exec(git, (err, stdout, stderr) => { if (err) { throw new Error( "BRANCH SDK: Failed to commit git changes for the npm version. Docs https://goo.gl/GijGKP" ); ...
[ "function", "commitChanges", "(", "git", ",", "version", ")", "{", "git", "+=", "`", "${", "version", "}", "`", ";", "exec", "(", "git", ",", "(", "err", ",", "stdout", ",", "stderr", ")", "=>", "{", "if", "(", "err", ")", "{", "throw", "new", ...
push file code changes to github
[ "push", "file", "code", "changes", "to", "github" ]
252f591fcc833ac9fe7fb0f535d351e0879a873c
https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/252f591fcc833ac9fe7fb0f535d351e0879a873c/examples/cordova1/plugins/branch-cordova-sdk/src/scripts/npm/updateNpmVersion.js#L82-L91
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
registerComponent
function registerComponent(Vue, name, definition) { Vue._shards_vue_components_ = Vue._shards_vue_components_ || {}; var loaded = Vue._shards_vue_components_[name]; if (!loaded && definition && name) { Vue._shards_vue_components_[name] = true; Vue.component(name, definit...
javascript
function registerComponent(Vue, name, definition) { Vue._shards_vue_components_ = Vue._shards_vue_components_ || {}; var loaded = Vue._shards_vue_components_[name]; if (!loaded && definition && name) { Vue._shards_vue_components_[name] = true; Vue.component(name, definit...
[ "function", "registerComponent", "(", "Vue", ",", "name", ",", "definition", ")", "{", "Vue", ".", "_shards_vue_components_", "=", "Vue", ".", "_shards_vue_components_", "||", "{", "}", ";", "var", "loaded", "=", "Vue", ".", "_shards_vue_components_", "[", "na...
Register a component plugin.
[ "Register", "a", "component", "plugin", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L29-L39
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
registerComponents
function registerComponents(Vue, components) { for (var component in components) { registerComponent(Vue, component, components[component]); } }
javascript
function registerComponents(Vue, components) { for (var component in components) { registerComponent(Vue, component, components[component]); } }
[ "function", "registerComponents", "(", "Vue", ",", "components", ")", "{", "for", "(", "var", "component", "in", "components", ")", "{", "registerComponent", "(", "Vue", ",", "component", ",", "components", "[", "component", "]", ")", ";", "}", "}" ]
Register a group of components.
[ "Register", "a", "group", "of", "components", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L42-L46
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
registerDirective
function registerDirective(Vue, name, definition) { Vue._shards_vue_directives_ = Vue._shards_vue_directives_ || {}; var loaded = Vue._shards_vue_directives_[name]; if (!loaded && definition && name) { Vue._shards_vue_directives_[name] = true; Vue.directive(name, definit...
javascript
function registerDirective(Vue, name, definition) { Vue._shards_vue_directives_ = Vue._shards_vue_directives_ || {}; var loaded = Vue._shards_vue_directives_[name]; if (!loaded && definition && name) { Vue._shards_vue_directives_[name] = true; Vue.directive(name, definit...
[ "function", "registerDirective", "(", "Vue", ",", "name", ",", "definition", ")", "{", "Vue", ".", "_shards_vue_directives_", "=", "Vue", ".", "_shards_vue_directives_", "||", "{", "}", ";", "var", "loaded", "=", "Vue", ".", "_shards_vue_directives_", "[", "na...
Register a directive as being loaded. returns true if directive plugin already registered
[ "Register", "a", "directive", "as", "being", "loaded", ".", "returns", "true", "if", "directive", "plugin", "already", "registered" ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L49-L59
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
registerDirectives
function registerDirectives(Vue, directives) { for (var directive in directives) { registerDirective(Vue, directive, directives[directive]); } }
javascript
function registerDirectives(Vue, directives) { for (var directive in directives) { registerDirective(Vue, directive, directives[directive]); } }
[ "function", "registerDirectives", "(", "Vue", ",", "directives", ")", "{", "for", "(", "var", "directive", "in", "directives", ")", "{", "registerDirective", "(", "Vue", ",", "directive", ",", "directives", "[", "directive", "]", ")", ";", "}", "}" ]
Register a group of directives as being loaded.
[ "Register", "a", "group", "of", "directives", "as", "being", "loaded", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L62-L66
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
function (el, className) { if (className && isElement(el)) { return el.classList.contains(className) } return false }
javascript
function (el, className) { if (className && isElement(el)) { return el.classList.contains(className) } return false }
[ "function", "(", "el", ",", "className", ")", "{", "if", "(", "className", "&&", "isElement", "(", "el", ")", ")", "{", "return", "el", ".", "classList", ".", "contains", "(", "className", ")", "}", "return", "false", "}" ]
Checks whether an element has a particular class name, or not.
[ "Checks", "whether", "an", "element", "has", "a", "particular", "class", "name", "or", "not", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L141-L147
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
function (el, attr, value) { if (attr && isElement(el)) { el.setAttribute(attr, value); } }
javascript
function (el, attr, value) { if (attr && isElement(el)) { el.setAttribute(attr, value); } }
[ "function", "(", "el", ",", "attr", ",", "value", ")", "{", "if", "(", "attr", "&&", "isElement", "(", "el", ")", ")", "{", "el", ".", "setAttribute", "(", "attr", ",", "value", ")", ";", "}", "}" ]
Sets an attribute on an element
[ "Sets", "an", "attribute", "on", "an", "element" ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L189-L193
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
function (el) { return !isElement(el) || el.disabled || el.classList.contains('disabled') || Boolean(el.getAttribute('disabled')) }
javascript
function (el) { return !isElement(el) || el.disabled || el.classList.contains('disabled') || Boolean(el.getAttribute('disabled')) }
[ "function", "(", "el", ")", "{", "return", "!", "isElement", "(", "el", ")", "||", "el", ".", "disabled", "||", "el", ".", "classList", ".", "contains", "(", "'disabled'", ")", "||", "Boolean", "(", "el", ".", "getAttribute", "(", "'disabled'", ")", ...
Checks whether an element is disabled, or not.
[ "Checks", "whether", "an", "element", "is", "disabled", "or", "not", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L212-L217
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
function (el) { return isElement(el) && document.body.contains(el) && el.getBoundingClientRect().height > 0 && el.getBoundingClientRect().width > 0 }
javascript
function (el) { return isElement(el) && document.body.contains(el) && el.getBoundingClientRect().height > 0 && el.getBoundingClientRect().width > 0 }
[ "function", "(", "el", ")", "{", "return", "isElement", "(", "el", ")", "&&", "document", ".", "body", ".", "contains", "(", "el", ")", "&&", "el", ".", "getBoundingClientRect", "(", ")", ".", "height", ">", "0", "&&", "el", ".", "getBoundingClientRect...
Determines if an HTML element is visible - Faster than CSS check
[ "Determines", "if", "an", "HTML", "element", "is", "visible", "-", "Faster", "than", "CSS", "check" ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L220-L225
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
function (selector, root) { if (!isElement(root)) { root = document; } return root.querySelector(selector) || null }
javascript
function (selector, root) { if (!isElement(root)) { root = document; } return root.querySelector(selector) || null }
[ "function", "(", "selector", ",", "root", ")", "{", "if", "(", "!", "isElement", "(", "root", ")", ")", "{", "root", "=", "document", ";", "}", "return", "root", ".", "querySelector", "(", "selector", ")", "||", "null", "}" ]
Selects an element.
[ "Selects", "an", "element", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L228-L234
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
function (selector, root) { if (!isElement(root)) { return null } var Closest = Element.prototype.closest || function (sel) { var element = this; if (!document.documentElement.contains(element)) { return null ...
javascript
function (selector, root) { if (!isElement(root)) { return null } var Closest = Element.prototype.closest || function (sel) { var element = this; if (!document.documentElement.contains(element)) { return null ...
[ "function", "(", "selector", ",", "root", ")", "{", "if", "(", "!", "isElement", "(", "root", ")", ")", "{", "return", "null", "}", "var", "Closest", "=", "Element", ".", "prototype", ".", "closest", "||", "function", "(", "sel", ")", "{", "var", "...
Finds closest element matching selector.
[ "Finds", "closest", "element", "matching", "selector", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L237-L263
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
function (type, breakpoint, val) { if (!!val === false) { return false } var className = type; if (breakpoint) { className += "-" + (breakpoint.replace(type, '')); // -md ? } if (type === 'col' && (val === '' || val === true)) { retu...
javascript
function (type, breakpoint, val) { if (!!val === false) { return false } var className = type; if (breakpoint) { className += "-" + (breakpoint.replace(type, '')); // -md ? } if (type === 'col' && (val === '' || val === true)) { retu...
[ "function", "(", "type", ",", "breakpoint", ",", "val", ")", "{", "if", "(", "!", "!", "val", "===", "false", ")", "{", "return", "false", "}", "var", "className", "=", "type", ";", "if", "(", "breakpoint", ")", "{", "className", "+=", "\"-\"", "+"...
Creates Bootstrap specific breakpoint classes.
[ "Creates", "Bootstrap", "specific", "breakpoint", "classes", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L4573-L4589
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
generateProp
function generateProp(type, defaultVal) { if ( type === void 0 ) type = [Boolean, String, Number]; if ( defaultVal === void 0 ) defaultVal = null; return { default: defaultVal, type: type } }
javascript
function generateProp(type, defaultVal) { if ( type === void 0 ) type = [Boolean, String, Number]; if ( defaultVal === void 0 ) defaultVal = null; return { default: defaultVal, type: type } }
[ "function", "generateProp", "(", "type", ",", "defaultVal", ")", "{", "if", "(", "type", "===", "void", "0", ")", "type", "=", "[", "Boolean", ",", "String", ",", "Number", "]", ";", "if", "(", "defaultVal", "===", "void", "0", ")", "defaultVal", "="...
Generates component properties.
[ "Generates", "component", "properties", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L4592-L4600
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
createBreakpointMap
function createBreakpointMap(propGenArgs, defaultValue, breakpointWrapper) { if ( propGenArgs === void 0 ) propGenArgs = null; if ( breakpointWrapper === void 0 ) breakpointWrapper = null; var breakpointWrapperArgs = [], len = arguments.length - 3; while ( len-- > 0 ) breakpointWrapperAr...
javascript
function createBreakpointMap(propGenArgs, defaultValue, breakpointWrapper) { if ( propGenArgs === void 0 ) propGenArgs = null; if ( breakpointWrapper === void 0 ) breakpointWrapper = null; var breakpointWrapperArgs = [], len = arguments.length - 3; while ( len-- > 0 ) breakpointWrapperAr...
[ "function", "createBreakpointMap", "(", "propGenArgs", ",", "defaultValue", ",", "breakpointWrapper", ")", "{", "if", "(", "propGenArgs", "===", "void", "0", ")", "propGenArgs", "=", "null", ";", "if", "(", "breakpointWrapper", "===", "void", "0", ")", "breakp...
Creates breakpoint maps
[ "Creates", "breakpoint", "maps" ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L4611-L4622
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
CancelableEvent
function CancelableEvent (type, eventInit) { if ( eventInit === void 0 ) eventInit = {}; Object.assign(this, CancelableEvent.defaults(), eventInit, { type: type }); Object.defineProperties(this, { type: _makeCancelableEventProps(), cancelable: _makeCancelableEventProps(...
javascript
function CancelableEvent (type, eventInit) { if ( eventInit === void 0 ) eventInit = {}; Object.assign(this, CancelableEvent.defaults(), eventInit, { type: type }); Object.defineProperties(this, { type: _makeCancelableEventProps(), cancelable: _makeCancelableEventProps(...
[ "function", "CancelableEvent", "(", "type", ",", "eventInit", ")", "{", "if", "(", "eventInit", "===", "void", "0", ")", "eventInit", "=", "{", "}", ";", "Object", ".", "assign", "(", "this", ",", "CancelableEvent", ".", "defaults", "(", ")", ",", "eve...
Custom cancelable event.
[ "Custom", "cancelable", "event", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L7744-L7772
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
function () { if (this$1._config.animation) { var initConfigAnimation = this$1._config.animation || false; if (getAttr(TPElement, 'x-placement') !== null) { return } removeClass(TPElement, TP_STATE_CLASSES.FADE...
javascript
function () { if (this$1._config.animation) { var initConfigAnimation = this$1._config.animation || false; if (getAttr(TPElement, 'x-placement') !== null) { return } removeClass(TPElement, TP_STATE_CLASSES.FADE...
[ "function", "(", ")", "{", "if", "(", "this$1", ".", "_config", ".", "animation", ")", "{", "var", "initConfigAnimation", "=", "this$1", ".", "_config", ".", "animation", "||", "false", ";", "if", "(", "getAttr", "(", "TPElement", ",", "'x-placement'", "...
Prep the transition complete handler
[ "Prep", "the", "transition", "complete", "handler" ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L15128-L15157
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
DOMObserver
function DOMObserver (el, callback, opts) { if ( opts === void 0 ) opts = null; if (opts === null) { opts = { subtree: true, childList: true, characterData: true, attributes: true, attributeFilter: ['class', 's...
javascript
function DOMObserver (el, callback, opts) { if ( opts === void 0 ) opts = null; if (opts === null) { opts = { subtree: true, childList: true, characterData: true, attributes: true, attributeFilter: ['class', 's...
[ "function", "DOMObserver", "(", "el", ",", "callback", ",", "opts", ")", "{", "if", "(", "opts", "===", "void", "0", ")", "opts", "=", "null", ";", "if", "(", "opts", "===", "null", ")", "{", "opts", "=", "{", "subtree", ":", "true", ",", "childL...
Observes DOM changes. @see http://stackoverflow.com/questions/3219758
[ "Observes", "DOM", "changes", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L15838-L15889
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
getUpdatedConfig
function getUpdatedConfig() { var updatedConfig = Object.assign({}, this.baseConfig); // override title if slot is used if (this.$refs.title) { updatedConfig.title = this.$refs.title; updatedConfig.html = true; } ...
javascript
function getUpdatedConfig() { var updatedConfig = Object.assign({}, this.baseConfig); // override title if slot is used if (this.$refs.title) { updatedConfig.title = this.$refs.title; updatedConfig.html = true; } ...
[ "function", "getUpdatedConfig", "(", ")", "{", "var", "updatedConfig", "=", "Object", ".", "assign", "(", "{", "}", ",", "this", ".", "baseConfig", ")", ";", "// override title if slot is used", "if", "(", "this", ".", "$refs", ".", "title", ")", "{", "upd...
Returns the updated config.
[ "Returns", "the", "updated", "config", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L16058-L16074
train
DesignRevision/shards-vue
dist/shards-vue.umd.js
parseBindings
function parseBindings(bindings) { var config = {}; switch (typeof bindings.value) { case 'string': case 'function': config.title = bindings.value; break case 'object': config = Object.assign({}, bindings.value); ...
javascript
function parseBindings(bindings) { var config = {}; switch (typeof bindings.value) { case 'string': case 'function': config.title = bindings.value; break case 'object': config = Object.assign({}, bindings.value); ...
[ "function", "parseBindings", "(", "bindings", ")", "{", "var", "config", "=", "{", "}", ";", "switch", "(", "typeof", "bindings", ".", "value", ")", "{", "case", "'string'", ":", "case", "'function'", ":", "config", ".", "title", "=", "bindings", ".", ...
Bindings parser.
[ "Bindings", "parser", "." ]
b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3
https://github.com/DesignRevision/shards-vue/blob/b10a2489d7a5b544b3e1ba46e6b1c673046cc3c3/dist/shards-vue.umd.js#L18677-L18758
train
atmist/snazzy-info-window
src/snazzy-info-window.js
mergeDefaultOptions
function mergeDefaultOptions(opts) { const copy = {}; copyKeys(copy, _defaultOptions); copyKeys(copy, opts); Object.keys(_defaultOptions).forEach((key) => { const obj = _defaultOptions[key]; if (typeof obj === 'object') { const objCopy = {}; copyKeys(objCopy, obj)...
javascript
function mergeDefaultOptions(opts) { const copy = {}; copyKeys(copy, _defaultOptions); copyKeys(copy, opts); Object.keys(_defaultOptions).forEach((key) => { const obj = _defaultOptions[key]; if (typeof obj === 'object') { const objCopy = {}; copyKeys(objCopy, obj)...
[ "function", "mergeDefaultOptions", "(", "opts", ")", "{", "const", "copy", "=", "{", "}", ";", "copyKeys", "(", "copy", ",", "_defaultOptions", ")", ";", "copyKeys", "(", "copy", ",", "opts", ")", ";", "Object", ".", "keys", "(", "_defaultOptions", ")", ...
We need to safely merge options from the defaults. This will make sure settings like edgeOffset are properly assigned.
[ "We", "need", "to", "safely", "merge", "options", "from", "the", "defaults", ".", "This", "will", "make", "sure", "settings", "like", "edgeOffset", "are", "properly", "assigned", "." ]
dd49636d356f204d15008c8190aefbe2f743364f
https://github.com/atmist/snazzy-info-window/blob/dd49636d356f204d15008c8190aefbe2f743364f/src/snazzy-info-window.js#L40-L54
train
atmist/snazzy-info-window
src/snazzy-info-window.js
parseAttribute
function parseAttribute(attribute, defaultValue) { // 1em, 1.0em, 0.1em, .1em, 1. em const re = /^(-{0,1}\.{0,1}\d+(\.\d+)?)[\s|\.]*(\w*)$/; if (attribute && re.test(attribute)) { const match = re.exec(attribute); const number = match[1]; const units = match[3] || 'px'; re...
javascript
function parseAttribute(attribute, defaultValue) { // 1em, 1.0em, 0.1em, .1em, 1. em const re = /^(-{0,1}\.{0,1}\d+(\.\d+)?)[\s|\.]*(\w*)$/; if (attribute && re.test(attribute)) { const match = re.exec(attribute); const number = match[1]; const units = match[3] || 'px'; re...
[ "function", "parseAttribute", "(", "attribute", ",", "defaultValue", ")", "{", "// 1em, 1.0em, 0.1em, .1em, 1. em", "const", "re", "=", "/", "^(-{0,1}\\.{0,1}\\d+(\\.\\d+)?)[\\s|\\.]*(\\w*)$", "/", ";", "if", "(", "attribute", "&&", "re", ".", "test", "(", "attribu...
Parse a css attribute into the numeric portion and the units
[ "Parse", "a", "css", "attribute", "into", "the", "numeric", "portion", "and", "the", "units" ]
dd49636d356f204d15008c8190aefbe2f743364f
https://github.com/atmist/snazzy-info-window/blob/dd49636d356f204d15008c8190aefbe2f743364f/src/snazzy-info-window.js#L57-L70
train
atmist/snazzy-info-window
src/snazzy-info-window.js
setHTML
function setHTML(container, content) { if (container) { // Clear out everything in the container while (container.firstChild) { container.removeChild(container.firstChild); } if (content) { if (typeof content === 'string') { container.innerHTML...
javascript
function setHTML(container, content) { if (container) { // Clear out everything in the container while (container.firstChild) { container.removeChild(container.firstChild); } if (content) { if (typeof content === 'string') { container.innerHTML...
[ "function", "setHTML", "(", "container", ",", "content", ")", "{", "if", "(", "container", ")", "{", "// Clear out everything in the container", "while", "(", "container", ".", "firstChild", ")", "{", "container", ".", "removeChild", "(", "container", ".", "firs...
Set the html of a container. Should support both raw text and a single DOM Element.
[ "Set", "the", "html", "of", "a", "container", ".", "Should", "support", "both", "raw", "text", "and", "a", "single", "DOM", "Element", "." ]
dd49636d356f204d15008c8190aefbe2f743364f
https://github.com/atmist/snazzy-info-window/blob/dd49636d356f204d15008c8190aefbe2f743364f/src/snazzy-info-window.js#L74-L88
train
atmist/snazzy-info-window
src/snazzy-info-window.js
toLatLng
function toLatLng(v) { if (v !== undefined && v !== null) { if (v instanceof google.maps.LatLng) { return v; } else if (v.lat !== undefined && v.lng !== undefined) { return new google.maps.LatLng(v); } } return null; }
javascript
function toLatLng(v) { if (v !== undefined && v !== null) { if (v instanceof google.maps.LatLng) { return v; } else if (v.lat !== undefined && v.lng !== undefined) { return new google.maps.LatLng(v); } } return null; }
[ "function", "toLatLng", "(", "v", ")", "{", "if", "(", "v", "!==", "undefined", "&&", "v", "!==", "null", ")", "{", "if", "(", "v", "instanceof", "google", ".", "maps", ".", "LatLng", ")", "{", "return", "v", ";", "}", "else", "if", "(", "v", "...
Convert the value into a Google Map LatLng
[ "Convert", "the", "value", "into", "a", "Google", "Map", "LatLng" ]
dd49636d356f204d15008c8190aefbe2f743364f
https://github.com/atmist/snazzy-info-window/blob/dd49636d356f204d15008c8190aefbe2f743364f/src/snazzy-info-window.js#L110-L119
train
atmist/snazzy-info-window
dist/snazzy-info-window.js
applyCss
function applyCss(element, args) { if (element && args) { for (var i = 0; i < args.length; i++) { var className = args[i]; if (className) { if (element.className) { ...
javascript
function applyCss(element, args) { if (element && args) { for (var i = 0; i < args.length; i++) { var className = args[i]; if (className) { if (element.className) { ...
[ "function", "applyCss", "(", "element", ",", "args", ")", "{", "if", "(", "element", "&&", "args", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "var", "className", "=", "args", "[",...
Used for creating new elements
[ "Used", "for", "creating", "new", "elements" ]
dd49636d356f204d15008c8190aefbe2f743364f
https://github.com/atmist/snazzy-info-window/blob/dd49636d356f204d15008c8190aefbe2f743364f/dist/snazzy-info-window.js#L527-L539
train
securing/gattacker
standalone/blueRadiosCmd.js
blueRadiosAT
function blueRadiosAT(command){ if (! wsclient.listeners('notification').length) { console.log('subscribe to RX notification'); //listen for notification response wsclient.on('notification', function(peripheralId, serviceUuid, characteristicUuid, data) { // console.log("NOTIFICATION: " + data.toString('hex') +...
javascript
function blueRadiosAT(command){ if (! wsclient.listeners('notification').length) { console.log('subscribe to RX notification'); //listen for notification response wsclient.on('notification', function(peripheralId, serviceUuid, characteristicUuid, data) { // console.log("NOTIFICATION: " + data.toString('hex') +...
[ "function", "blueRadiosAT", "(", "command", ")", "{", "if", "(", "!", "wsclient", ".", "listeners", "(", "'notification'", ")", ".", "length", ")", "{", "console", ".", "log", "(", "'subscribe to RX notification'", ")", ";", "//listen for notification response", ...
command - string
[ "command", "-", "string" ]
a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68
https://github.com/securing/gattacker/blob/a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68/standalone/blueRadiosCmd.js#L82-L103
train
securing/gattacker
advertise.js
dumpLog
function dumpLog(type, peripheralId, serviceUuid, uuid, data ){ var dumpFile=dumpPath + '/' + peripheralId + '.log'; if (servicesLookup[serviceUuid]) { var serviceName = servicesLookup[serviceUuid].name; var characteristicName = servicesLookup[serviceUuid].characteristics[uuid].name; } ...
javascript
function dumpLog(type, peripheralId, serviceUuid, uuid, data ){ var dumpFile=dumpPath + '/' + peripheralId + '.log'; if (servicesLookup[serviceUuid]) { var serviceName = servicesLookup[serviceUuid].name; var characteristicName = servicesLookup[serviceUuid].characteristics[uuid].name; } ...
[ "function", "dumpLog", "(", "type", ",", "peripheralId", ",", "serviceUuid", ",", "uuid", ",", "data", ")", "{", "var", "dumpFile", "=", "dumpPath", "+", "'/'", "+", "peripheralId", "+", "'.log'", ";", "if", "(", "servicesLookup", "[", "serviceUuid", "]", ...
dump transmission log to file
[ "dump", "transmission", "log", "to", "file" ]
a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68
https://github.com/securing/gattacker/blob/a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68/advertise.js#L185-L205
train
securing/gattacker
gattacker2nrf.js
formatUuid
function formatUuid(Uuid) { var formatted=''; //expand short service/characteristic UUID if (Uuid.length == 4) { formatted='0000' + Uuid + '-0000-1000-8000-00805f9b34fb'; } else { //just add dashes formatted = Uuid.slice(0,8)+'-'+Uuid.slice(8,12)+'-'+Uuid.slice(12,16)+'-'+Uuid.slice(16,20)+'-'+Uuid.slice(20,3...
javascript
function formatUuid(Uuid) { var formatted=''; //expand short service/characteristic UUID if (Uuid.length == 4) { formatted='0000' + Uuid + '-0000-1000-8000-00805f9b34fb'; } else { //just add dashes formatted = Uuid.slice(0,8)+'-'+Uuid.slice(8,12)+'-'+Uuid.slice(12,16)+'-'+Uuid.slice(16,20)+'-'+Uuid.slice(20,3...
[ "function", "formatUuid", "(", "Uuid", ")", "{", "var", "formatted", "=", "''", ";", "//expand short service/characteristic UUID", "if", "(", "Uuid", ".", "length", "==", "4", ")", "{", "formatted", "=", "'0000'", "+", "Uuid", "+", "'-0000-1000-8000-00805f9b34fb...
nrf requires strict UUID format
[ "nrf", "requires", "strict", "UUID", "format" ]
a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68
https://github.com/securing/gattacker/blob/a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68/gattacker2nrf.js#L30-L40
train
securing/gattacker
hookFunctions/lock.js
lockCrc
function lockCrc(inputStr){ res = 0xff; inputHex = new Buffer(inputStr,'hex'); //start from the second byte for (i = 1; i<= inputHex.length; i++) { res = res ^ inputHex[i]; } //add padding reshex = (res+0x100).toString(16).substr(-2); // console.log(reshex); return(inputStr+reshex); }
javascript
function lockCrc(inputStr){ res = 0xff; inputHex = new Buffer(inputStr,'hex'); //start from the second byte for (i = 1; i<= inputHex.length; i++) { res = res ^ inputHex[i]; } //add padding reshex = (res+0x100).toString(16).substr(-2); // console.log(reshex); return(inputStr+reshex); }
[ "function", "lockCrc", "(", "inputStr", ")", "{", "res", "=", "0xff", ";", "inputHex", "=", "new", "Buffer", "(", "inputStr", ",", "'hex'", ")", ";", "//start from the second byte ", "for", "(", "i", "=", "1", ";", "i", "<=", "inputHex", ".", "length", ...
returns string with calculated CRC attached
[ "returns", "string", "with", "calculated", "CRC", "attached" ]
a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68
https://github.com/securing/gattacker/blob/a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68/hookFunctions/lock.js#L99-L113
train
securing/gattacker
scan.js
checkFile
function checkFile(peripheralId, callback) { if (overWriteServices) { callback(false); } else { fs.stat(devicesPath + '/' + peripheralId + '.srv.json', function(err, stat) { if(err == null) { callback(true); // console.log('File exists'); } else { callback(false) }...
javascript
function checkFile(peripheralId, callback) { if (overWriteServices) { callback(false); } else { fs.stat(devicesPath + '/' + peripheralId + '.srv.json', function(err, stat) { if(err == null) { callback(true); // console.log('File exists'); } else { callback(false) }...
[ "function", "checkFile", "(", "peripheralId", ",", "callback", ")", "{", "if", "(", "overWriteServices", ")", "{", "callback", "(", "false", ")", ";", "}", "else", "{", "fs", ".", "stat", "(", "devicesPath", "+", "'/'", "+", "peripheralId", "+", "'.srv.j...
check if the services file exists
[ "check", "if", "the", "services", "file", "exists" ]
a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68
https://github.com/securing/gattacker/blob/a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68/scan.js#L77-L90
train
securing/gattacker
ws-slave.js
readRaw
function readRaw(peripheralId, serviceUuid, uuid, callback){ //todo catch exceptions var handle = servicesCache[peripheralId].services[serviceUuid].characteristics[uuid].handle; var peripheral = peripherals[peripheralId]; //if not connected, connect checkConnected(peripheral, function(){ peripheral.readH...
javascript
function readRaw(peripheralId, serviceUuid, uuid, callback){ //todo catch exceptions var handle = servicesCache[peripheralId].services[serviceUuid].characteristics[uuid].handle; var peripheral = peripherals[peripheralId]; //if not connected, connect checkConnected(peripheral, function(){ peripheral.readH...
[ "function", "readRaw", "(", "peripheralId", ",", "serviceUuid", ",", "uuid", ",", "callback", ")", "{", "//todo catch exceptions", "var", "handle", "=", "servicesCache", "[", "peripheralId", "]", ".", "services", "[", "serviceUuid", "]", ".", "characteristics", ...
read by handle
[ "read", "by", "handle" ]
a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68
https://github.com/securing/gattacker/blob/a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68/ws-slave.js#L352-L377
train
securing/gattacker
ws-slave.js
writeRaw
function writeRaw(peripheralId, serviceUuid, uuid, data, withoutResponse, callback){ //todo catch exceptions var handle = servicesCache[peripheralId].services[serviceUuid].characteristics[uuid].handle; var peripheral = peripherals[peripheralId]; //if not connected, connect checkConnected(peripheral, function...
javascript
function writeRaw(peripheralId, serviceUuid, uuid, data, withoutResponse, callback){ //todo catch exceptions var handle = servicesCache[peripheralId].services[serviceUuid].characteristics[uuid].handle; var peripheral = peripherals[peripheralId]; //if not connected, connect checkConnected(peripheral, function...
[ "function", "writeRaw", "(", "peripheralId", ",", "serviceUuid", ",", "uuid", ",", "data", ",", "withoutResponse", ",", "callback", ")", "{", "//todo catch exceptions", "var", "handle", "=", "servicesCache", "[", "peripheralId", "]", ".", "services", "[", "servi...
write by handle
[ "write", "by", "handle" ]
a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68
https://github.com/securing/gattacker/blob/a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68/ws-slave.js#L380-L401
train
securing/gattacker
ws-slave.js
checkConnected
function checkConnected(peripheral, callback){ if (peripheral.state === 'connected') { debug(' - connected'); if (callback) { callback(); } } else if (peripheral.state === 'connecting'){ debug(' - connecting....'); //wait until the connection completes, invoke callback peripheral.once('conne...
javascript
function checkConnected(peripheral, callback){ if (peripheral.state === 'connected') { debug(' - connected'); if (callback) { callback(); } } else if (peripheral.state === 'connecting'){ debug(' - connecting....'); //wait until the connection completes, invoke callback peripheral.once('conne...
[ "function", "checkConnected", "(", "peripheral", ",", "callback", ")", "{", "if", "(", "peripheral", ".", "state", "===", "'connected'", ")", "{", "debug", "(", "' - connected'", ")", ";", "if", "(", "callback", ")", "{", "callback", "(", ")", ";", "}", ...
check whether connected to peripheral, if not - reconnect, and then invoke peripheral function
[ "check", "whether", "connected", "to", "peripheral", "if", "not", "-", "reconnect", "and", "then", "invoke", "peripheral", "function" ]
a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68
https://github.com/securing/gattacker/blob/a8dd58cc10b1804cd1bc3c9f71a639a8bcfeee68/ws-slave.js#L498-L528
train
Yomguithereal/baobab
src/helpers.js
index
function index(a, fn) { let i, l; for (i = 0, l = a.length; i < l; i++) { if (fn(a[i])) return i; } return -1; }
javascript
function index(a, fn) { let i, l; for (i = 0, l = a.length; i < l; i++) { if (fn(a[i])) return i; } return -1; }
[ "function", "index", "(", "a", ",", "fn", ")", "{", "let", "i", ",", "l", ";", "for", "(", "i", "=", "0", ",", "l", "=", "a", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "fn", "(", "a", "[", "i", "]", ")", ...
Function returning the index of the first element of a list matching the given predicate. @param {array} a - The target array. @param {function} fn - The predicate function. @return {mixed} - The index of the first matching item or -1.
[ "Function", "returning", "the", "index", "of", "the", "first", "element", "of", "a", "list", "matching", "the", "given", "predicate", "." ]
d0b7319117d929efb585b031ccebd01c13310f6e
https://github.com/Yomguithereal/baobab/blob/d0b7319117d929efb585b031ccebd01c13310f6e/src/helpers.js#L22-L29
train
Yomguithereal/baobab
src/helpers.js
slice
function slice(array) { const newArray = new Array(array.length); let i, l; for (i = 0, l = array.length; i < l; i++) newArray[i] = array[i]; return newArray; }
javascript
function slice(array) { const newArray = new Array(array.length); let i, l; for (i = 0, l = array.length; i < l; i++) newArray[i] = array[i]; return newArray; }
[ "function", "slice", "(", "array", ")", "{", "const", "newArray", "=", "new", "Array", "(", "array", ".", "length", ")", ";", "let", "i", ",", "l", ";", "for", "(", "i", "=", "0", ",", "l", "=", "array", ".", "length", ";", "i", "<", "l", ";"...
Efficient slice function used to clone arrays or parts of them. @param {array} array - The array to slice. @return {array} - The sliced array.
[ "Efficient", "slice", "function", "used", "to", "clone", "arrays", "or", "parts", "of", "them", "." ]
d0b7319117d929efb585b031ccebd01c13310f6e
https://github.com/Yomguithereal/baobab/blob/d0b7319117d929efb585b031ccebd01c13310f6e/src/helpers.js#L37-L47
train
Yomguithereal/baobab
src/helpers.js
cloneRegexp
function cloneRegexp(re) { const pattern = re.source; let flags = ''; if (re.global) flags += 'g'; if (re.multiline) flags += 'm'; if (re.ignoreCase) flags += 'i'; if (re.sticky) flags += 'y'; if (re.unicode) flags += 'u'; return new RegExp(pattern, flags); }
javascript
function cloneRegexp(re) { const pattern = re.source; let flags = ''; if (re.global) flags += 'g'; if (re.multiline) flags += 'm'; if (re.ignoreCase) flags += 'i'; if (re.sticky) flags += 'y'; if (re.unicode) flags += 'u'; return new RegExp(pattern, flags); }
[ "function", "cloneRegexp", "(", "re", ")", "{", "const", "pattern", "=", "re", ".", "source", ";", "let", "flags", "=", "''", ";", "if", "(", "re", ".", "global", ")", "flags", "+=", "'g'", ";", "if", "(", "re", ".", "multiline", ")", "flags", "+...
Function cloning the given regular expression. Supports `y` and `u` flags already. @param {RegExp} re - The target regular expression. @return {RegExp} - The cloned regular expression.
[ "Function", "cloning", "the", "given", "regular", "expression", ".", "Supports", "y", "and", "u", "flags", "already", "." ]
d0b7319117d929efb585b031ccebd01c13310f6e
https://github.com/Yomguithereal/baobab/blob/d0b7319117d929efb585b031ccebd01c13310f6e/src/helpers.js#L144-L156
train
Yomguithereal/baobab
src/helpers.js
cloner
function cloner(deep, item) { if (!item || typeof item !== 'object' || item instanceof Error || item instanceof MonkeyDefinition || item instanceof Monkey || ('ArrayBuffer' in global && item instanceof ArrayBuffer)) return item; // Array if (type.array(item)) { if (deep) { ...
javascript
function cloner(deep, item) { if (!item || typeof item !== 'object' || item instanceof Error || item instanceof MonkeyDefinition || item instanceof Monkey || ('ArrayBuffer' in global && item instanceof ArrayBuffer)) return item; // Array if (type.array(item)) { if (deep) { ...
[ "function", "cloner", "(", "deep", ",", "item", ")", "{", "if", "(", "!", "item", "||", "typeof", "item", "!==", "'object'", "||", "item", "instanceof", "Error", "||", "item", "instanceof", "MonkeyDefinition", "||", "item", "instanceof", "Monkey", "||", "(...
Function cloning the given variable. @todo: implement a faster way to clone an array. @param {boolean} deep - Should we deep clone the variable. @param {mixed} item - The variable to clone @return {mixed} - The cloned variable.
[ "Function", "cloning", "the", "given", "variable", "." ]
d0b7319117d929efb585b031ccebd01c13310f6e
https://github.com/Yomguithereal/baobab/blob/d0b7319117d929efb585b031ccebd01c13310f6e/src/helpers.js#L167-L231
train
Yomguithereal/baobab
src/helpers.js
compare
function compare(object, description) { let ok = true, k; // If we reached here via a recursive call, object may be undefined because // not all items in a collection will have the same deep nesting structure. if (!object) return false; for (k in description) { if (type.object(description[k]))...
javascript
function compare(object, description) { let ok = true, k; // If we reached here via a recursive call, object may be undefined because // not all items in a collection will have the same deep nesting structure. if (!object) return false; for (k in description) { if (type.object(description[k]))...
[ "function", "compare", "(", "object", ",", "description", ")", "{", "let", "ok", "=", "true", ",", "k", ";", "// If we reached here via a recursive call, object may be undefined because", "// not all items in a collection will have the same deep nesting structure.", "if", "(", ...
Function comparing an object's properties to a given descriptive object. @param {object} object - The object to compare. @param {object} description - The description's mapping. @return {boolean} - Whether the object matches the description.
[ "Function", "comparing", "an", "object", "s", "properties", "to", "a", "given", "descriptive", "object", "." ]
d0b7319117d929efb585b031ccebd01c13310f6e
https://github.com/Yomguithereal/baobab/blob/d0b7319117d929efb585b031ccebd01c13310f6e/src/helpers.js#L261-L284
train
Yomguithereal/baobab
src/helpers.js
freezer
function freezer(deep, o) { if (typeof o !== 'object' || o === null || o instanceof Monkey) return; Object.freeze(o); if (!deep) return; if (Array.isArray(o)) { // Iterating through the elements let i, l; for (i = 0, l = o.length; i < l; i++) deepFreeze(o[i]); ...
javascript
function freezer(deep, o) { if (typeof o !== 'object' || o === null || o instanceof Monkey) return; Object.freeze(o); if (!deep) return; if (Array.isArray(o)) { // Iterating through the elements let i, l; for (i = 0, l = o.length; i < l; i++) deepFreeze(o[i]); ...
[ "function", "freezer", "(", "deep", ",", "o", ")", "{", "if", "(", "typeof", "o", "!==", "'object'", "||", "o", "===", "null", "||", "o", "instanceof", "Monkey", ")", "return", ";", "Object", ".", "freeze", "(", "o", ")", ";", "if", "(", "!", "de...
Function freezing the given variable if possible. @param {boolean} deep - Should we recursively freeze the given objects? @param {object} o - The variable to freeze. @return {object} - The merged object.
[ "Function", "freezing", "the", "given", "variable", "if", "possible", "." ]
d0b7319117d929efb585b031ccebd01c13310f6e
https://github.com/Yomguithereal/baobab/blob/d0b7319117d929efb585b031ccebd01c13310f6e/src/helpers.js#L293-L332
train
Yomguithereal/baobab
src/cursor.js
makeSetter
function makeSetter(name, typeChecker) { /** * Binding a setter method to the Cursor class and having the following * definition. * * Note: this is not really possible to make those setters variadic because * it would create an impossible polymorphism with path. * * @todo: perform value validati...
javascript
function makeSetter(name, typeChecker) { /** * Binding a setter method to the Cursor class and having the following * definition. * * Note: this is not really possible to make those setters variadic because * it would create an impossible polymorphism with path. * * @todo: perform value validati...
[ "function", "makeSetter", "(", "name", ",", "typeChecker", ")", "{", "/**\n * Binding a setter method to the Cursor class and having the following\n * definition.\n *\n * Note: this is not really possible to make those setters variadic because\n * it would create an impossible polymorphism...
Function creating a setter method for the Cursor class. @param {string} name - the method's name. @param {function} [typeChecker] - a function checking that the given value is valid for the given operation.
[ "Function", "creating", "a", "setter", "method", "for", "the", "Cursor", "class", "." ]
d0b7319117d929efb585b031ccebd01c13310f6e
https://github.com/Yomguithereal/baobab/blob/d0b7319117d929efb585b031ccebd01c13310f6e/src/cursor.js#L777-L839
train
toomuchdesign/react-minimal-pie-chart
src/ReactMinimalPieChart.js
extendData
function extendData({ data, lengthAngle: totalAngle, totalValue, paddingAngle, }) { const total = totalValue || sumValues(data); const normalizedTotalAngle = valueBetween(totalAngle, -360, 360); const numberOfPaddings = Math.abs(normalizedTotalAngle) === 360 ? data.length : data.length - 1; const de...
javascript
function extendData({ data, lengthAngle: totalAngle, totalValue, paddingAngle, }) { const total = totalValue || sumValues(data); const normalizedTotalAngle = valueBetween(totalAngle, -360, 360); const numberOfPaddings = Math.abs(normalizedTotalAngle) === 360 ? data.length : data.length - 1; const de...
[ "function", "extendData", "(", "{", "data", ",", "lengthAngle", ":", "totalAngle", ",", "totalValue", ",", "paddingAngle", ",", "}", ")", "{", "const", "total", "=", "totalValue", "||", "sumValues", "(", "data", ")", ";", "const", "normalizedTotalAngle", "="...
Append "percentage", "degrees" and "startOffset" into each data entry
[ "Append", "percentage", "degrees", "and", "startOffset", "into", "each", "data", "entry" ]
03158af5ddecde83361909ccd185ae8b5064bdf5
https://github.com/toomuchdesign/react-minimal-pie-chart/blob/03158af5ddecde83361909ccd185ae8b5064bdf5/src/ReactMinimalPieChart.js#L22-L51
train
HubSpot/Singularity
SingularityUI/gulpfile.js
function(req, res, next) { if (req.headers.accept && req.headers.accept.startsWith('text/html')) { req.url = '/index.html'; // eslint-disable-line no-param-reassign } next(); }
javascript
function(req, res, next) { if (req.headers.accept && req.headers.accept.startsWith('text/html')) { req.url = '/index.html'; // eslint-disable-line no-param-reassign } next(); }
[ "function", "(", "req", ",", "res", ",", "next", ")", "{", "if", "(", "req", ".", "headers", ".", "accept", "&&", "req", ".", "headers", ".", "accept", ".", "startsWith", "(", "'text/html'", ")", ")", "{", "req", ".", "url", "=", "'/index.html'", "...
Serve index.html for all unknown requests
[ "Serve", "index", ".", "html", "for", "all", "unknown", "requests" ]
2402934c40c8f86670c703d87e3016de3bab5a26
https://github.com/HubSpot/Singularity/blob/2402934c40c8f86670c703d87e3016de3bab5a26/SingularityUI/gulpfile.js#L130-L135
train
AndiDittrich/Node.CLI-Progress
examples/example-align.js
showPreset
function showPreset(name, pos){ console.log(_colors.magenta('Preset: ' + name)); // create a new progress bar with preset var bar = new _progress.Bar({ align: pos }, _progress.Presets[name] || _progress.Presets.legacy); bar.start(200, 0); // random value 1..200 bar.update(Math.floor((...
javascript
function showPreset(name, pos){ console.log(_colors.magenta('Preset: ' + name)); // create a new progress bar with preset var bar = new _progress.Bar({ align: pos }, _progress.Presets[name] || _progress.Presets.legacy); bar.start(200, 0); // random value 1..200 bar.update(Math.floor((...
[ "function", "showPreset", "(", "name", ",", "pos", ")", "{", "console", ".", "log", "(", "_colors", ".", "magenta", "(", "'Preset: '", "+", "name", ")", ")", ";", "// create a new progress bar with preset", "var", "bar", "=", "new", "_progress", ".", "Bar", ...
helper function to display preset
[ "helper", "function", "to", "display", "preset" ]
5cb2a261a604d272e7a4019e66c2954547bea696
https://github.com/AndiDittrich/Node.CLI-Progress/blob/5cb2a261a604d272e7a4019e66c2954547bea696/examples/example-align.js#L5-L18
train
IonicaBizau/github-contributions
lib/contributions/calendar.js
getDateTime
function getDateTime(obj) { // get date, hour, minute, second, year, month and day var date = new Date() , hour = date.getHours() , min = date.getMinutes() , sec = date.getSeconds() , year = date.getFullYear() , month = date.getMonth() + 1 , day = date.getDate() ; ...
javascript
function getDateTime(obj) { // get date, hour, minute, second, year, month and day var date = new Date() , hour = date.getHours() , min = date.getMinutes() , sec = date.getSeconds() , year = date.getFullYear() , month = date.getMonth() + 1 , day = date.getDate() ; ...
[ "function", "getDateTime", "(", "obj", ")", "{", "// get date, hour, minute, second, year, month and day", "var", "date", "=", "new", "Date", "(", ")", ",", "hour", "=", "date", ".", "getHours", "(", ")", ",", "min", "=", "date", ".", "getMinutes", "(", ")",...
Returns the time in the moment when it's called If `obj` is true an object is returned
[ "Returns", "the", "time", "in", "the", "moment", "when", "it", "s", "called", "If", "obj", "is", "true", "an", "object", "is", "returned" ]
6c3eeb7613f779603b911d35ac4ffb6b0d52b514
https://github.com/IonicaBizau/github-contributions/blob/6c3eeb7613f779603b911d35ac4ffb6b0d52b514/lib/contributions/calendar.js#L6-L37
train
IonicaBizau/github-contributions
lib/client_handler/index.js
Openfile
function Openfile(i, path) { // !Optimized: use child_process module to open local file with local path (function() { var cmdArr = [ 'nautilus ' + path , 'start "" "' + path + '"' , 'konqueror ' + path , 'o...
javascript
function Openfile(i, path) { // !Optimized: use child_process module to open local file with local path (function() { var cmdArr = [ 'nautilus ' + path , 'start "" "' + path + '"' , 'konqueror ' + path , 'o...
[ "function", "Openfile", "(", "i", ",", "path", ")", "{", "// !Optimized: use child_process module to open local file with local path", "(", "function", "(", ")", "{", "var", "cmdArr", "=", "[", "'nautilus '", "+", "path", ",", "'start \"\" \"'", "+", "path", "+", ...
Use Script to open local file with local path
[ "Use", "Script", "to", "open", "local", "file", "with", "local", "path" ]
6c3eeb7613f779603b911d35ac4ffb6b0d52b514
https://github.com/IonicaBizau/github-contributions/blob/6c3eeb7613f779603b911d35ac4ffb6b0d52b514/lib/client_handler/index.js#L37-L70
train
gdsestimating/dxf-parser
src/DxfArrayScanner.js
parseGroupValue
function parseGroupValue(code, value) { if(code <= 9) return value; if(code >= 10 && code <= 59) return parseFloat(value); if(code >= 60 && code <= 99) return parseInt(value); if(code >= 100 && code <= 109) return value; if(code >= 110 && code <= 149) return parseFloat(value); if(code >= 160 && code <= 179) retur...
javascript
function parseGroupValue(code, value) { if(code <= 9) return value; if(code >= 10 && code <= 59) return parseFloat(value); if(code >= 60 && code <= 99) return parseInt(value); if(code >= 100 && code <= 109) return value; if(code >= 110 && code <= 149) return parseFloat(value); if(code >= 160 && code <= 179) retur...
[ "function", "parseGroupValue", "(", "code", ",", "value", ")", "{", "if", "(", "code", "<=", "9", ")", "return", "value", ";", "if", "(", "code", ">=", "10", "&&", "code", "<=", "59", ")", "return", "parseFloat", "(", "value", ")", ";", "if", "(", ...
Parse a value to its proper type. See pages 3 - 10 of the AutoCad DXF 2012 reference given at the top of this file @param code @param value @returns {*}
[ "Parse", "a", "value", "to", "its", "proper", "type", ".", "See", "pages", "3", "-", "10", "of", "the", "AutoCad", "DXF", "2012", "reference", "given", "at", "the", "top", "of", "this", "file" ]
887a26af9181c62bb5d016b606882d9897f5b7d7
https://github.com/gdsestimating/dxf-parser/blob/887a26af9181c62bb5d016b606882d9897f5b7d7/src/DxfArrayScanner.js#L105-L132
train
bolt-design-system/bolt
packages/build-tools/tasks/task-collections.js
getExtraTasks
async function getExtraTasks() { config = config || (await getConfig()); switch (config.env) { case 'pl': extraTasks.patternLab = require('./pattern-lab-tasks'); break; case 'static': extraTasks.static = require('./static-tasks'); break; case 'pwa': delete require.cache[re...
javascript
async function getExtraTasks() { config = config || (await getConfig()); switch (config.env) { case 'pl': extraTasks.patternLab = require('./pattern-lab-tasks'); break; case 'static': extraTasks.static = require('./static-tasks'); break; case 'pwa': delete require.cache[re...
[ "async", "function", "getExtraTasks", "(", ")", "{", "config", "=", "config", "||", "(", "await", "getConfig", "(", ")", ")", ";", "switch", "(", "config", ".", "env", ")", "{", "case", "'pl'", ":", "extraTasks", ".", "patternLab", "=", "require", "(",...
These tasks are present based on optional conditions like `config.env` and should only be `require`-ed when it's the right env due to each file's setup where it tries to grab specific files - and of course the tasks should only run in the correct `env` as well.
[ "These", "tasks", "are", "present", "based", "on", "optional", "conditions", "like", "config", ".", "env", "and", "should", "only", "be", "require", "-", "ed", "when", "it", "s", "the", "right", "env", "due", "to", "each", "file", "s", "setup", "where", ...
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/tasks/task-collections.js#L17-L40
train
bolt-design-system/bolt
packages/build-tools/utils/cache.js
getFileHash
function getFileHash(filePath, callback) { var stream = fs.ReadStream(filePath); var md5sum = crypto.createHash('md5'); stream.on('data', function(data) { md5sum.update(data); }); stream.on('end', function() { callback(md5sum.digest('hex')); }); }
javascript
function getFileHash(filePath, callback) { var stream = fs.ReadStream(filePath); var md5sum = crypto.createHash('md5'); stream.on('data', function(data) { md5sum.update(data); }); stream.on('end', function() { callback(md5sum.digest('hex')); }); }
[ "function", "getFileHash", "(", "filePath", ",", "callback", ")", "{", "var", "stream", "=", "fs", ".", "ReadStream", "(", "filePath", ")", ";", "var", "md5sum", "=", "crypto", ".", "createHash", "(", "'md5'", ")", ";", "stream", ".", "on", "(", "'data...
given the path to a local file being streamed, returns back the MD5 hash to quickly check if a file's contents have changed.
[ "given", "the", "path", "to", "a", "local", "file", "being", "streamed", "returns", "back", "the", "MD5", "hash", "to", "quickly", "check", "if", "a", "file", "s", "contents", "have", "changed", "." ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/cache.js#L8-L19
train
bolt-design-system/bolt
packages/build-tools/tasks/internal-tasks.js
mkDirs
async function mkDirs() { config = config || (await getConfig()); try { return Promise.all([ config.wwwDir ? mkdirp(config.wwwDir) : null, config.dataDir ? mkdirp(config.dataDir) : null, config.buildDir ? mkdirp(config.buildDir) : null, ]); } catch (error) { log.errorAndExit('Could ...
javascript
async function mkDirs() { config = config || (await getConfig()); try { return Promise.all([ config.wwwDir ? mkdirp(config.wwwDir) : null, config.dataDir ? mkdirp(config.dataDir) : null, config.buildDir ? mkdirp(config.buildDir) : null, ]); } catch (error) { log.errorAndExit('Could ...
[ "async", "function", "mkDirs", "(", ")", "{", "config", "=", "config", "||", "(", "await", "getConfig", "(", ")", ")", ";", "try", "{", "return", "Promise", ".", "all", "(", "[", "config", ".", "wwwDir", "?", "mkdirp", "(", "config", ".", "wwwDir", ...
Makes all directories in config @async @returns {Promise}
[ "Makes", "all", "directories", "in", "config" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/tasks/internal-tasks.js#L16-L28
train
bolt-design-system/bolt
packages/servers/ssr-server/index.js
setupServer
async function setupServer() { return new Promise(async (resolve, reject) => { config = config || (await getConfig()); config.components.individual = []; config.prod = true; config.enableCache = true; config.mode = 'server'; config.env = 'pwa'; config.sourceMaps = false; config.copy = ...
javascript
async function setupServer() { return new Promise(async (resolve, reject) => { config = config || (await getConfig()); config.components.individual = []; config.prod = true; config.enableCache = true; config.mode = 'server'; config.env = 'pwa'; config.sourceMaps = false; config.copy = ...
[ "async", "function", "setupServer", "(", ")", "{", "return", "new", "Promise", "(", "async", "(", "resolve", ",", "reject", ")", "=>", "{", "config", "=", "config", "||", "(", "await", "getConfig", "(", ")", ")", ";", "config", ".", "components", ".", ...
listen for when we need to auto-shut down + track open server connections
[ "listen", "for", "when", "we", "need", "to", "auto", "-", "shut", "down", "+", "track", "open", "server", "connections" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/servers/ssr-server/index.js#L110-L148
train
bolt-design-system/bolt
packages/uikit-workshop/src/scripts/utils/postmessage.js
receiveIframeMessage
function receiveIframeMessage(event) { // does the origin sending the message match the current host? if not dev/null the request if ( window.location.protocol !== 'file:' && event.origin !== window.location.protocol + '//' + window.location.host ) { return; } let path; let data = {}; try { ...
javascript
function receiveIframeMessage(event) { // does the origin sending the message match the current host? if not dev/null the request if ( window.location.protocol !== 'file:' && event.origin !== window.location.protocol + '//' + window.location.host ) { return; } let path; let data = {}; try { ...
[ "function", "receiveIframeMessage", "(", "event", ")", "{", "// does the origin sending the message match the current host? if not dev/null the request", "if", "(", "window", ".", "location", ".", "protocol", "!==", "'file:'", "&&", "event", ".", "origin", "!==", "window", ...
watch the iframe source so that it can be sent back to everyone else.
[ "watch", "the", "iframe", "source", "so", "that", "it", "can", "be", "sent", "back", "to", "everyone", "else", "." ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/uikit-workshop/src/scripts/utils/postmessage.js#L37-L86
train
bolt-design-system/bolt
packages/build-tools/create-webpack-config.js
buildWebpackEntry
async function buildWebpackEntry() { const { components } = await getBoltManifest(); const entry = {}; const globalEntryName = 'bolt-global'; if (components.global) { entry[globalEntryName] = []; components.global.forEach(component => { if (component.assets.style) { entry...
javascript
async function buildWebpackEntry() { const { components } = await getBoltManifest(); const entry = {}; const globalEntryName = 'bolt-global'; if (components.global) { entry[globalEntryName] = []; components.global.forEach(component => { if (component.assets.style) { entry...
[ "async", "function", "buildWebpackEntry", "(", ")", "{", "const", "{", "components", "}", "=", "await", "getBoltManifest", "(", ")", ";", "const", "entry", "=", "{", "}", ";", "const", "globalEntryName", "=", "'bolt-global'", ";", "if", "(", "components", ...
Build WebPack config's `entry` object @link https://webpack.js.org/configuration/entry-context/#entry @returns {object} entry - WebPack config `entry`
[ "Build", "WebPack", "config", "s", "entry", "object" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/create-webpack-config.js#L147-L193
train
bolt-design-system/bolt
packages/build-tools/utils/yaml.js
readYamlFile
function readYamlFile(file) { return new Promise((resolve, reject) => { readFile(file, 'utf8') .then(data => resolve(fromYaml(data))) .catch(reject); }); }
javascript
function readYamlFile(file) { return new Promise((resolve, reject) => { readFile(file, 'utf8') .then(data => resolve(fromYaml(data))) .catch(reject); }); }
[ "function", "readYamlFile", "(", "file", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "readFile", "(", "file", ",", "'utf8'", ")", ".", "then", "(", "data", "=>", "resolve", "(", "fromYaml", "(", "data", "...
Read Yaml File into Object @param {string} file - File path @returns {Promise<object>} Promise resolves with yaml file as object @see fromYaml @see writeYamlFile
[ "Read", "Yaml", "File", "into", "Object" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/yaml.js#L37-L43
train
bolt-design-system/bolt
packages/build-tools/utils/yaml.js
writeYamlFile
function writeYamlFile(file, data) { return new Promise((resolve, reject) => { writeFile(file, toYaml(data)) .then(resolve) .catch(reject); }); }
javascript
function writeYamlFile(file, data) { return new Promise((resolve, reject) => { writeFile(file, toYaml(data)) .then(resolve) .catch(reject); }); }
[ "function", "writeYamlFile", "(", "file", ",", "data", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "writeFile", "(", "file", ",", "toYaml", "(", "data", ")", ")", ".", "then", "(", "resolve", ")", ".", ...
Write Yaml string to File @param {string} file - File path @param {object} data - Object to turn into Yaml @returns {Promise} @see readYamlFile @see toYaml
[ "Write", "Yaml", "string", "to", "File" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/yaml.js#L69-L75
train
bolt-design-system/bolt
packages/build-tools/tasks/api-tasks/bolt-pkg-versions.js
generatePackageData
async function generatePackageData() { boltPackages.forEach(async pkg => { if (pkg.version !== '0.0.0' && pkg.private !== true) { const name = pkg.name; try { const pkgInfo = await packageJson(name, { allVersions: true, }); processedPackages.push(pkgInfo); nu...
javascript
async function generatePackageData() { boltPackages.forEach(async pkg => { if (pkg.version !== '0.0.0' && pkg.private !== true) { const name = pkg.name; try { const pkgInfo = await packageJson(name, { allVersions: true, }); processedPackages.push(pkgInfo); nu...
[ "async", "function", "generatePackageData", "(", ")", "{", "boltPackages", ".", "forEach", "(", "async", "pkg", "=>", "{", "if", "(", "pkg", ".", "version", "!==", "'0.0.0'", "&&", "pkg", ".", "private", "!==", "true", ")", "{", "const", "name", "=", "...
iterator for forEach loop so we know when we're done
[ "iterator", "for", "forEach", "loop", "so", "we", "know", "when", "we", "re", "done" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/tasks/api-tasks/bolt-pkg-versions.js#L16-L56
train
bolt-design-system/bolt
packages/build-tools/tasks/static-tasks.js
getPage
async function getPage(file) { config = config || (await asyncConfig()); if (config.verbosity > 3) { log.dim(`Getting info for: ${file}`); } const url = path .relative(config.srcDir, file) .replace('.md', '.html') .split('/') .map(x => x.replace(/^[0-9]*-/, '')) // Removing number prefix `0...
javascript
async function getPage(file) { config = config || (await asyncConfig()); if (config.verbosity > 3) { log.dim(`Getting info for: ${file}`); } const url = path .relative(config.srcDir, file) .replace('.md', '.html') .split('/') .map(x => x.replace(/^[0-9]*-/, '')) // Removing number prefix `0...
[ "async", "function", "getPage", "(", "file", ")", "{", "config", "=", "config", "||", "(", "await", "asyncConfig", "(", ")", ")", ";", "if", "(", "config", ".", "verbosity", ">", "3", ")", "{", "log", ".", "dim", "(", "`", "${", "file", "}", "`",...
Get data for a single page that is Markdown or HTML with Yaml front matter @param {string} file - Path to source file @returns {Promise<{srcPath: string, distPath: string, meta: object, body: string}>} page - Page Data
[ "Get", "data", "for", "a", "single", "page", "that", "is", "Markdown", "or", "HTML", "with", "Yaml", "front", "matter" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/tasks/static-tasks.js#L55-L91
train
bolt-design-system/bolt
packages/build-tools/tasks/static-tasks.js
getPages
async function getPages(srcDir) { config = config || (await asyncConfig()); /** @type Array<String> */ const allPaths = await globby([ path.join(srcDir, '**/*.{md,html}'), '!**/_*/**/*.{md,html}', '!**/pattern-lab/**/*', '!**/_*.{md,html}', ]); return Promise.all(allPaths.map(getPage)).then(p...
javascript
async function getPages(srcDir) { config = config || (await asyncConfig()); /** @type Array<String> */ const allPaths = await globby([ path.join(srcDir, '**/*.{md,html}'), '!**/_*/**/*.{md,html}', '!**/pattern-lab/**/*', '!**/_*.{md,html}', ]); return Promise.all(allPaths.map(getPage)).then(p...
[ "async", "function", "getPages", "(", "srcDir", ")", "{", "config", "=", "config", "||", "(", "await", "asyncConfig", "(", ")", ")", ";", "/** @type Array<String> */", "const", "allPaths", "=", "await", "globby", "(", "[", "path", ".", "join", "(", "srcDir...
Get data for all pages @param {string} files - Source directory @see getPage @returns {Promise<object[]>} - An array of page data objects
[ "Get", "data", "for", "all", "pages" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/tasks/static-tasks.js#L99-L117
train
bolt-design-system/bolt
packages/build-tools/tasks/static-tasks.js
getSiteData
async function getSiteData(pages) { config = config || (await asyncConfig()); const nestedPages = await getNestedPages(config.srcDir); const site = { nestedPages, pages: pages.map(page => ({ url: page.url, meta: page.meta, // choosing not to have `page.body` in here on purpose })), ...
javascript
async function getSiteData(pages) { config = config || (await asyncConfig()); const nestedPages = await getNestedPages(config.srcDir); const site = { nestedPages, pages: pages.map(page => ({ url: page.url, meta: page.meta, // choosing not to have `page.body` in here on purpose })), ...
[ "async", "function", "getSiteData", "(", "pages", ")", "{", "config", "=", "config", "||", "(", "await", "asyncConfig", "(", ")", ")", ";", "const", "nestedPages", "=", "await", "getNestedPages", "(", "config", ".", "srcDir", ")", ";", "const", "site", "...
Get the site data based on the pages @param {object} pages @returns {{pages}}
[ "Get", "the", "site", "data", "based", "on", "the", "pages" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/tasks/static-tasks.js#L173-L186
train
bolt-design-system/bolt
packages/build-tools/tasks/static-tasks.js
compile
async function compile(exitOnError = true) { config = config || (await asyncConfig()); const startMessage = chalk.blue('Compiling Static Site...'); const startTime = timer.start(); let spinner; if (config.verbosity > 2) { console.log(startMessage); } else { spinner = ora(startMessage).start(); } ...
javascript
async function compile(exitOnError = true) { config = config || (await asyncConfig()); const startMessage = chalk.blue('Compiling Static Site...'); const startTime = timer.start(); let spinner; if (config.verbosity > 2) { console.log(startMessage); } else { spinner = ora(startMessage).start(); } ...
[ "async", "function", "compile", "(", "exitOnError", "=", "true", ")", "{", "config", "=", "config", "||", "(", "await", "asyncConfig", "(", ")", ")", ";", "const", "startMessage", "=", "chalk", ".", "blue", "(", "'Compiling Static Site...'", ")", ";", "con...
The main event - compile the whole site @returns {Promise<any[]>}
[ "The", "main", "event", "-", "compile", "the", "whole", "site" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/tasks/static-tasks.js#L192-L250
train
bolt-design-system/bolt
packages/twig-renderer/twig-renderer.js
init
async function init(keepAlive = false) { state = STATES.STARTING; const config = await getConfig(); const relativeFrom = path.dirname(config.configFileUsed); // console.log({ config }); twigNamespaces = await getTwigNamespaceConfig( relativeFrom, config.extraTwigNamespaces, ); twigRenderer = new T...
javascript
async function init(keepAlive = false) { state = STATES.STARTING; const config = await getConfig(); const relativeFrom = path.dirname(config.configFileUsed); // console.log({ config }); twigNamespaces = await getTwigNamespaceConfig( relativeFrom, config.extraTwigNamespaces, ); twigRenderer = new T...
[ "async", "function", "init", "(", "keepAlive", "=", "false", ")", "{", "state", "=", "STATES", ".", "STARTING", ";", "const", "config", "=", "await", "getConfig", "(", ")", ";", "const", "relativeFrom", "=", "path", ".", "dirname", "(", "config", ".", ...
Initialize Twig Renderer instance @param {Boolean} keepAlive - Optionally tell the Twig renderer service to keep alive to help speed up requests
[ "Initialize", "Twig", "Renderer", "instance" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/twig-renderer/twig-renderer.js#L21-L43
train
bolt-design-system/bolt
packages/twig-renderer/twig-renderer.js
render
async function render(template, data = {}, keepAlive = false) { await prep(keepAlive); const results = await twigRenderer.render(template, data); return results; }
javascript
async function render(template, data = {}, keepAlive = false) { await prep(keepAlive); const results = await twigRenderer.render(template, data); return results; }
[ "async", "function", "render", "(", "template", ",", "data", "=", "{", "}", ",", "keepAlive", "=", "false", ")", "{", "await", "prep", "(", "keepAlive", ")", ";", "const", "results", "=", "await", "twigRenderer", ".", "render", "(", "template", ",", "d...
Render Twig Template @param {string} template - Template name (i.e. `@bolt/button.twig`) @param {Object} data - Optional data to pass to template @param {Boolean} keepAlive - Optionally tell the Twig renderer service to keep alive to help speed up requests @return {Promise<{{ ok: boolean, html: string, message: string}...
[ "Render", "Twig", "Template" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/twig-renderer/twig-renderer.js#L72-L76
train
bolt-design-system/bolt
packages/twig-renderer/twig-renderer.js
renderString
async function renderString(templateString, data = {}, keepAlive = false) { await prep(keepAlive); const results = await twigRenderer.renderString(templateString, data); // console.log({ results }); return results; }
javascript
async function renderString(templateString, data = {}, keepAlive = false) { await prep(keepAlive); const results = await twigRenderer.renderString(templateString, data); // console.log({ results }); return results; }
[ "async", "function", "renderString", "(", "templateString", ",", "data", "=", "{", "}", ",", "keepAlive", "=", "false", ")", "{", "await", "prep", "(", "keepAlive", ")", ";", "const", "results", "=", "await", "twigRenderer", ".", "renderString", "(", "temp...
Render Twig String @param {string} templateString - String that is a Twig template (i.e. `<p>{{ text }}</p>`) @param {Object} data - Optional data to pass to template @param {Boolean} keepAlive - Optionally tell the Twig renderer service to keep alive to help speed up requests @return {Promise<{{ ok: boolean, html: str...
[ "Render", "Twig", "String" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/twig-renderer/twig-renderer.js#L85-L90
train
bolt-design-system/bolt
packages/build-tools/utils/general.js
uniqueArray
function uniqueArray(item) { const u = {}; const newArray = []; for (let i = 0, l = item.length; i < l; ++i) { if (!{}.hasOwnProperty.call(u, item[i])) { newArray.push(item[i]); u[item[i]] = 1; } } return newArray; }
javascript
function uniqueArray(item) { const u = {}; const newArray = []; for (let i = 0, l = item.length; i < l; ++i) { if (!{}.hasOwnProperty.call(u, item[i])) { newArray.push(item[i]); u[item[i]] = 1; } } return newArray; }
[ "function", "uniqueArray", "(", "item", ")", "{", "const", "u", "=", "{", "}", ";", "const", "newArray", "=", "[", "]", ";", "for", "(", "let", "i", "=", "0", ",", "l", "=", "item", ".", "length", ";", "i", "<", "l", ";", "++", "i", ")", "{...
Make an array unique by removing duplicate entries. @param item {Array} @returns {Array}
[ "Make", "an", "array", "unique", "by", "removing", "duplicate", "entries", "." ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/general.js#L30-L40
train
bolt-design-system/bolt
packages/build-tools/utils/general.js
ensureFileExists
function ensureFileExists(filePath) { fs.access(filePath, err => { if (err) { log.errorAndExit( 'This file ^^^ does not exist and it was referenced in package.json for that component, please make sure the file path is correct.', filePath, ); } }); }
javascript
function ensureFileExists(filePath) { fs.access(filePath, err => { if (err) { log.errorAndExit( 'This file ^^^ does not exist and it was referenced in package.json for that component, please make sure the file path is correct.', filePath, ); } }); }
[ "function", "ensureFileExists", "(", "filePath", ")", "{", "fs", ".", "access", "(", "filePath", ",", "err", "=>", "{", "if", "(", "err", ")", "{", "log", ".", "errorAndExit", "(", "'This file ^^^ does not exist and it was referenced in package.json for that component...
Ensure a file exists We don't want to do anything with the file now, we just want to provide an early error if a path is wrong. This is called async and by the time an error is thrown, we may be several steps ahead with WebPack probably already trying to start - that's ok, we don't want to hold up the process everytime...
[ "Ensure", "a", "file", "exists", "We", "don", "t", "want", "to", "do", "anything", "with", "the", "file", "now", "we", "just", "want", "to", "provide", "an", "early", "error", "if", "a", "path", "is", "wrong", ".", "This", "is", "called", "async", "a...
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/general.js#L48-L57
train
bolt-design-system/bolt
packages/build-tools/utils/general.js
dirExists
async function dirExists(path) { try { const stats = await stat(path); return stats.isDirectory() ? true : false; } catch (err) { return false; } }
javascript
async function dirExists(path) { try { const stats = await stat(path); return stats.isDirectory() ? true : false; } catch (err) { return false; } }
[ "async", "function", "dirExists", "(", "path", ")", "{", "try", "{", "const", "stats", "=", "await", "stat", "(", "path", ")", ";", "return", "stats", ".", "isDirectory", "(", ")", "?", "true", ":", "false", ";", "}", "catch", "(", "err", ")", "{",...
Check if a directory exists @param path {string} - Path to the directory to check
[ "Check", "if", "a", "directory", "exists" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/general.js#L76-L83
train
bolt-design-system/bolt
scripts/check-run.js
execAndReport
async function execAndReport({ cmd, name }) { try { const { failed, // code, // timedOut, stdout, stderr, // message, } = await execa.shell(cmd); process.stdout.write(stdout); process.stderr.write(stderr); await setCheckRun({ name, status: 'completed...
javascript
async function execAndReport({ cmd, name }) { try { const { failed, // code, // timedOut, stdout, stderr, // message, } = await execa.shell(cmd); process.stdout.write(stdout); process.stderr.write(stderr); await setCheckRun({ name, status: 'completed...
[ "async", "function", "execAndReport", "(", "{", "cmd", ",", "name", "}", ")", "{", "try", "{", "const", "{", "failed", ",", "// code,", "// timedOut,", "stdout", ",", "stderr", ",", "// message,", "}", "=", "await", "execa", ".", "shell", "(", "cmd", "...
Exec Shell Command and Report Results to GitHub Checks @param {Object} opt @param {string} opt.cmd - Shell command to execute from CWD @param {string} opt.name - GitHub Checks Name @return {Promise<boolean>} Did cmd fail?
[ "Exec", "Shell", "Command", "and", "Report", "Results", "to", "GitHub", "Checks" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/scripts/check-run.js#L86-L136
train
bolt-design-system/bolt
packages/build-tools/utils/sh.js
sh
async function sh( cmd, args, exitOnError, streamOutput, showCmdOnError = true, exitImmediately = false, ) { return new Promise((resolve, reject) => { const child = execa(cmd, args); let output = ''; if (streamOutput) { child.stdout.pipe(process.stdout); child.stderr.pipe(process....
javascript
async function sh( cmd, args, exitOnError, streamOutput, showCmdOnError = true, exitImmediately = false, ) { return new Promise((resolve, reject) => { const child = execa(cmd, args); let output = ''; if (streamOutput) { child.stdout.pipe(process.stdout); child.stderr.pipe(process....
[ "async", "function", "sh", "(", "cmd", ",", "args", ",", "exitOnError", ",", "streamOutput", ",", "showCmdOnError", "=", "true", ",", "exitImmediately", "=", "false", ",", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>...
Run shell command @param cmd {string} - Command to run @param args {string[]} - args to pass to `cmd` @param exitOnError {boolean} - If that should exit non-zero or carry one. @param streamOutput {boolean} - Should output be sent to stdout as it happens? It always gets passed to resolve at end. @param showCmdOnError {b...
[ "Run", "shell", "command" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/sh.js#L14-L75
train
bolt-design-system/bolt
packages/components/bolt-ul/src/ul.js
addNestedLevelProps
function addNestedLevelProps(childNode, level) { let currentLevel = level; if (childNode.tagName) { childNode.level = currentLevel; } return currentLevel; }
javascript
function addNestedLevelProps(childNode, level) { let currentLevel = level; if (childNode.tagName) { childNode.level = currentLevel; } return currentLevel; }
[ "function", "addNestedLevelProps", "(", "childNode", ",", "level", ")", "{", "let", "currentLevel", "=", "level", ";", "if", "(", "childNode", ".", "tagName", ")", "{", "childNode", ".", "level", "=", "currentLevel", ";", "}", "return", "currentLevel", ";", ...
list-specific helper function to set nested children's `level` prop automatically
[ "list", "-", "specific", "helper", "function", "to", "set", "nested", "children", "s", "level", "prop", "automatically" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/components/bolt-ul/src/ul.js#L10-L18
train
bolt-design-system/bolt
packages/build-tools/cli.js
updateConfig
async function updateConfig(options, programInstance) { await configStore.updateConfig(config => { originalConfig = config; config.verbosity = typeof program.verbosity === 'undefined' ? config.verbosity : program.verbosity; config.openServerAtStart = ...
javascript
async function updateConfig(options, programInstance) { await configStore.updateConfig(config => { originalConfig = config; config.verbosity = typeof program.verbosity === 'undefined' ? config.verbosity : program.verbosity; config.openServerAtStart = ...
[ "async", "function", "updateConfig", "(", "options", ",", "programInstance", ")", "{", "await", "configStore", ".", "updateConfig", "(", "config", "=>", "{", "originalConfig", "=", "config", ";", "config", ".", "verbosity", "=", "typeof", "program", ".", "verb...
Update config with all options flags @param {Object} options @param programInstance - The commander `program` @returns {Object} config - Final updated config
[ "Update", "config", "with", "all", "options", "flags" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/cli.js#L66-L156
train
bolt-design-system/bolt
packages/build-tools/plugins/postcss-themify/src/index.js
translateColor
function translateColor(colorArr, variationName, execMode) { const [colorVar, alpha] = colorArr; // returns the real color representation if (!options.palette) { options.palette = getColorPalette(); } const underlineColor = options.palette[variationName][colorVar]; if (!underlineColor) { // varia...
javascript
function translateColor(colorArr, variationName, execMode) { const [colorVar, alpha] = colorArr; // returns the real color representation if (!options.palette) { options.palette = getColorPalette(); } const underlineColor = options.palette[variationName][colorVar]; if (!underlineColor) { // varia...
[ "function", "translateColor", "(", "colorArr", ",", "variationName", ",", "execMode", ")", "{", "const", "[", "colorVar", ",", "alpha", "]", "=", "colorArr", ";", "// returns the real color representation", "if", "(", "!", "options", ".", "palette", ")", "{", ...
Get the underline color, according to the execution mode @param colorArr two sized array with the color and the alpha @param variationName the name of the variation. e.g. light / dark @param execMode
[ "Get", "the", "underline", "color", "according", "to", "the", "execution", "mode" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/plugins/postcss-themify/src/index.js#L200-L237
train
bolt-design-system/bolt
packages/build-tools/plugins/postcss-themify/src/index.js
processRules
function processRules(root) { root.walkRules(rule => { if (!hasThemify(rule.toString())) { return; } let aggragatedSelectorsMap = {}; let aggragatedSelectors = []; let createdRules = []; const variationRules = { [defaultVariation]: rule, }; rule.walkDecls(decl => { ...
javascript
function processRules(root) { root.walkRules(rule => { if (!hasThemify(rule.toString())) { return; } let aggragatedSelectorsMap = {}; let aggragatedSelectors = []; let createdRules = []; const variationRules = { [defaultVariation]: rule, }; rule.walkDecls(decl => { ...
[ "function", "processRules", "(", "root", ")", "{", "root", ".", "walkRules", "(", "rule", "=>", "{", "if", "(", "!", "hasThemify", "(", "rule", ".", "toString", "(", ")", ")", ")", "{", "return", ";", "}", "let", "aggragatedSelectorsMap", "=", "{", "...
Walk through all rules, and replace each themify occurrence with the corresponding CSS variable. @example background-color: themify(primary-300, 0.5) => background-color: rgba(var(--primary-300),0.6) @param root
[ "Walk", "through", "all", "rules", "and", "replace", "each", "themify", "occurrence", "with", "the", "corresponding", "CSS", "variable", "." ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/plugins/postcss-themify/src/index.js#L244-L328
train
bolt-design-system/bolt
packages/build-tools/plugins/postcss-themify/src/index.js
createRuleWithVariation
function createRuleWithVariation(rule, variationName) { const selector = getSelectorName(rule, variationName); return postcss.rule({ selector, }); }
javascript
function createRuleWithVariation(rule, variationName) { const selector = getSelectorName(rule, variationName); return postcss.rule({ selector, }); }
[ "function", "createRuleWithVariation", "(", "rule", ",", "variationName", ")", "{", "const", "selector", "=", "getSelectorName", "(", "rule", ",", "variationName", ")", ";", "return", "postcss", ".", "rule", "(", "{", "selector", ",", "}", ")", ";", "}" ]
Create a new rule for the given variation, out of the original rule @param rule @param variationName
[ "Create", "a", "new", "rule", "for", "the", "given", "variation", "out", "of", "the", "original", "rule" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/plugins/postcss-themify/src/index.js#L477-L482
train
bolt-design-system/bolt
packages/build-tools/plugins/postcss-themify/src/index.js
createFallbackRuleWithVariation
function createFallbackRuleWithVariation(rule, variationName) { const selector = getSelectorName(rule, variationName, true); return postcss.rule({ selector, }); }
javascript
function createFallbackRuleWithVariation(rule, variationName) { const selector = getSelectorName(rule, variationName, true); return postcss.rule({ selector, }); }
[ "function", "createFallbackRuleWithVariation", "(", "rule", ",", "variationName", ")", "{", "const", "selector", "=", "getSelectorName", "(", "rule", ",", "variationName", ",", "true", ")", ";", "return", "postcss", ".", "rule", "(", "{", "selector", ",", "}",...
Create a new fallback-specific rule for the given variation, out of the original @param rule @param variationName
[ "Create", "a", "new", "fallback", "-", "specific", "rule", "for", "the", "given", "variation", "out", "of", "the", "original" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/plugins/postcss-themify/src/index.js#L489-L494
train
bolt-design-system/bolt
packages/build-tools/plugins/postcss-themify/src/index.js
getSelectorName
function getSelectorName(rule, variationName, isFallbackSelector = false) { const selectorPrefix = `.${options.classPrefix || ''}${variationName}`; // console.log(variationName); if (isFallbackSelector) { return rule.selectors .map(selector => { let selectors = []; let initialSelector ...
javascript
function getSelectorName(rule, variationName, isFallbackSelector = false) { const selectorPrefix = `.${options.classPrefix || ''}${variationName}`; // console.log(variationName); if (isFallbackSelector) { return rule.selectors .map(selector => { let selectors = []; let initialSelector ...
[ "function", "getSelectorName", "(", "rule", ",", "variationName", ",", "isFallbackSelector", "=", "false", ")", "{", "const", "selectorPrefix", "=", "`", "${", "options", ".", "classPrefix", "||", "''", "}", "${", "variationName", "}", "`", ";", "// console.lo...
Get a selector name for the given rule and variation, deliberately increasing the CSS class's specificity when generating CSS selectors for IE 11 so we can account for specificity conflicts when nesting themed components inside other themes. @param rule @param variationName @param isFallbackSelector
[ "Get", "a", "selector", "name", "for", "the", "given", "rule", "and", "variation", "deliberately", "increasing", "the", "CSS", "class", "s", "specificity", "when", "generating", "CSS", "selectors", "for", "IE", "11", "so", "we", "can", "account", "for", "spe...
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/plugins/postcss-themify/src/index.js#L505-L533
train
bolt-design-system/bolt
packages/build-tools/utils/log.js
errorAndExit
function errorAndExit(msg, logMe) { // @todo Only trigger if `verbosity > 1` if (logMe) { // Adding some empty lines before error message for readability console.log(); console.log(); console.log(logMe); } error(`Error: ${msg}`); // There's a few ways to handle exiting // This is suggested...
javascript
function errorAndExit(msg, logMe) { // @todo Only trigger if `verbosity > 1` if (logMe) { // Adding some empty lines before error message for readability console.log(); console.log(); console.log(logMe); } error(`Error: ${msg}`); // There's a few ways to handle exiting // This is suggested...
[ "function", "errorAndExit", "(", "msg", ",", "logMe", ")", "{", "// @todo Only trigger if `verbosity > 1`", "if", "(", "logMe", ")", "{", "// Adding some empty lines before error message for readability", "console", ".", "log", "(", ")", ";", "console", ".", "log", "(...
Displays info, an error message, and then exits the cli @param {string} msg - Message @param {*} logMe - Passed to `console.log`
[ "Displays", "info", "an", "error", "message", "and", "then", "exits", "the", "cli" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/log.js#L50-L73
train
bolt-design-system/bolt
packages/components/bolt-nav-indicator/nav-indicator.js
activateGumshoeLink
function activateGumshoeLink() { const originalTarget = nav.nav; let originalTargetHref; let normalizedTarget; if (originalTarget) { originalTargetHref = originalTarget.getAttribute('href'); } else { originalTargetHref = nav.nav.ge...
javascript
function activateGumshoeLink() { const originalTarget = nav.nav; let originalTargetHref; let normalizedTarget; if (originalTarget) { originalTargetHref = originalTarget.getAttribute('href'); } else { originalTargetHref = nav.nav.ge...
[ "function", "activateGumshoeLink", "(", ")", "{", "const", "originalTarget", "=", "nav", ".", "nav", ";", "let", "originalTargetHref", ";", "let", "normalizedTarget", ";", "if", "(", "originalTarget", ")", "{", "originalTargetHref", "=", "originalTarget", ".", "...
logic once we know we should try to animate in a gumshoe-activated link
[ "logic", "once", "we", "know", "we", "should", "try", "to", "animate", "in", "a", "gumshoe", "-", "activated", "link" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/components/bolt-nav-indicator/nav-indicator.js#L82-L123
train
bolt-design-system/bolt
packages/build-tools/utils/manifest.js
flattenDeep
function flattenDeep(arr1) { return arr1.reduce( (acc, val) => Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), [], ); }
javascript
function flattenDeep(arr1) { return arr1.reduce( (acc, val) => Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), [], ); }
[ "function", "flattenDeep", "(", "arr1", ")", "{", "return", "arr1", ".", "reduce", "(", "(", "acc", ",", "val", ")", "=>", "Array", ".", "isArray", "(", "val", ")", "?", "acc", ".", "concat", "(", "flattenDeep", "(", "val", ")", ")", ":", "acc", ...
recursively flatten heavily nested arrays
[ "recursively", "flatten", "heavily", "nested", "arrays" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/manifest.js#L13-L19
train
bolt-design-system/bolt
packages/build-tools/utils/manifest.js
aggregateBoltDependencies
async function aggregateBoltDependencies(data) { let componentDependencies = []; let componentsWithoutDeps = data; componentsWithoutDeps.forEach(item => { if (item.deps) { componentDependencies.push([...item.deps]); } }); componentDependencies = flattenDeep(componentDependencies); component...
javascript
async function aggregateBoltDependencies(data) { let componentDependencies = []; let componentsWithoutDeps = data; componentsWithoutDeps.forEach(item => { if (item.deps) { componentDependencies.push([...item.deps]); } }); componentDependencies = flattenDeep(componentDependencies); component...
[ "async", "function", "aggregateBoltDependencies", "(", "data", ")", "{", "let", "componentDependencies", "=", "[", "]", ";", "let", "componentsWithoutDeps", "=", "data", ";", "componentsWithoutDeps", ".", "forEach", "(", "item", "=>", "{", "if", "(", "item", "...
loop through package-specific dependencies to merge and dedupe
[ "loop", "through", "package", "-", "specific", "dependencies", "to", "merge", "and", "dedupe" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/manifest.js#L177-L205
train
bolt-design-system/bolt
packages/build-tools/utils/manifest.js
getAllDirs
async function getAllDirs(relativeFrom) { const dirs = []; const manifest = await getBoltManifest(); [manifest.components.global, manifest.components.individual].forEach( componentList => { componentList.forEach(component => { dirs.push( relativeFrom ? path.relative(relativ...
javascript
async function getAllDirs(relativeFrom) { const dirs = []; const manifest = await getBoltManifest(); [manifest.components.global, manifest.components.individual].forEach( componentList => { componentList.forEach(component => { dirs.push( relativeFrom ? path.relative(relativ...
[ "async", "function", "getAllDirs", "(", "relativeFrom", ")", "{", "const", "dirs", "=", "[", "]", ";", "const", "manifest", "=", "await", "getBoltManifest", "(", ")", ";", "[", "manifest", ".", "components", ".", "global", ",", "manifest", ".", "components...
Get all directories for components in Bolt Manifest @param relativeFrom {string} - If present, the path will be relative from this, else it will be absolute. @returns {Array<String>} {dirs} - List of all component/package paths in Bolt Manifest
[ "Get", "all", "directories", "for", "components", "in", "Bolt", "Manifest" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/manifest.js#L242-L258
train
bolt-design-system/bolt
packages/build-tools/utils/manifest.js
getTwigNamespaceConfig
async function getTwigNamespaceConfig(relativeFrom, extraNamespaces = {}) { const config = await getConfig(); const namespaces = {}; const allDirs = []; const manifest = await getBoltManifest(); const global = manifest.components.global; const individual = manifest.components.individual; [global, individ...
javascript
async function getTwigNamespaceConfig(relativeFrom, extraNamespaces = {}) { const config = await getConfig(); const namespaces = {}; const allDirs = []; const manifest = await getBoltManifest(); const global = manifest.components.global; const individual = manifest.components.individual; [global, individ...
[ "async", "function", "getTwigNamespaceConfig", "(", "relativeFrom", ",", "extraNamespaces", "=", "{", "}", ")", "{", "const", "config", "=", "await", "getConfig", "(", ")", ";", "const", "namespaces", "=", "{", "}", ";", "const", "allDirs", "=", "[", "]", ...
Builds config for Twig Namespaces @param relativeFrom {string} - If present, the path will be relative from this, else it will be absolute. @param extraNamespaces {object} - Extra namespaces to add to file in [this format](https://packagist.org/packages/evanlovely/plugin-twig-namespaces) @async @see writeTwigNamespaceF...
[ "Builds", "config", "for", "Twig", "Namespaces" ]
c63ab37dbee8f35aa5472be2d9688f989b20fd21
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/manifest.js#L322-L396
train
chjj/pty.js
lib/pty.js
Socket
function Socket(options) { if (!(this instanceof Socket)) { return new Socket(options); } var tty = process.binding('tty_wrap'); var guessHandleType = tty.guessHandleType; tty.guessHandleType = function() { return 'PIPE'; }; net.Socket.call(this, options); tty.guessHandleType = guessHandleType; ...
javascript
function Socket(options) { if (!(this instanceof Socket)) { return new Socket(options); } var tty = process.binding('tty_wrap'); var guessHandleType = tty.guessHandleType; tty.guessHandleType = function() { return 'PIPE'; }; net.Socket.call(this, options); tty.guessHandleType = guessHandleType; ...
[ "function", "Socket", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Socket", ")", ")", "{", "return", "new", "Socket", "(", "options", ")", ";", "}", "var", "tty", "=", "process", ".", "binding", "(", "'tty_wrap'", ")", ";", ...
Wrap net.Socket for a workaround
[ "Wrap", "net", ".", "Socket", "for", "a", "workaround" ]
fe63a412574f45ee6bb6d8fab4a5c102107b5201
https://github.com/chjj/pty.js/blob/fe63a412574f45ee6bb6d8fab4a5c102107b5201/lib/pty.js#L430-L441
train
chjj/pty.js
lib/pty_win.js
Agent
function Agent(file, args, env, cwd, cols, rows, debug) { var self = this; // Increment the number of pipes created. pipeIncr++; // Unique identifier per pipe created. var timestamp = Date.now(); // The data pipe is the direct connection to the forked terminal. this.dataPipe = '\\\\.\\pipe\\winpty-data...
javascript
function Agent(file, args, env, cwd, cols, rows, debug) { var self = this; // Increment the number of pipes created. pipeIncr++; // Unique identifier per pipe created. var timestamp = Date.now(); // The data pipe is the direct connection to the forked terminal. this.dataPipe = '\\\\.\\pipe\\winpty-data...
[ "function", "Agent", "(", "file", ",", "args", ",", "env", ",", "cwd", ",", "cols", ",", "rows", ",", "debug", ")", "{", "var", "self", "=", "this", ";", "// Increment the number of pipes created.", "pipeIncr", "++", ";", "// Unique identifier per pipe created."...
Agent. Internal class. Everytime a new pseudo terminal is created it is contained within agent.exe. When this process is started there are two available named pipes (control and data socket).
[ "Agent", ".", "Internal", "class", "." ]
fe63a412574f45ee6bb6d8fab4a5c102107b5201
https://github.com/chjj/pty.js/blob/fe63a412574f45ee6bb6d8fab4a5c102107b5201/lib/pty_win.js#L24-L74
train
harrisiirak/cron-parser
lib/expression.js
isWildcardRange
function isWildcardRange(range, constraints) { if (range instanceof Array && !range.length) { return false; } if (constraints.length !== 2) { return false; } return range.length === (constraints[1] - (constraints[0] < 1 ? - 1 : 0)); }
javascript
function isWildcardRange(range, constraints) { if (range instanceof Array && !range.length) { return false; } if (constraints.length !== 2) { return false; } return range.length === (constraints[1] - (constraints[0] < 1 ? - 1 : 0)); }
[ "function", "isWildcardRange", "(", "range", ",", "constraints", ")", "{", "if", "(", "range", "instanceof", "Array", "&&", "!", "range", ".", "length", ")", "{", "return", "false", ";", "}", "if", "(", "constraints", ".", "length", "!==", "2", ")", "{...
Detect if input range fully matches constraint bounds @param {Array} range Input range @param {Array} constraints Input constraints @returns {Boolean} @private
[ "Detect", "if", "input", "range", "fully", "matches", "constraint", "bounds" ]
b6cfece825f0894194f5d002c0051b9a7f09ce12
https://github.com/harrisiirak/cron-parser/blob/b6cfece825f0894194f5d002c0051b9a7f09ce12/lib/expression.js#L21-L31
train
harrisiirak/cron-parser
lib/expression.js
CronExpression
function CronExpression (fields, options) { this._options = options; this._utc = options.utc || false; this._tz = this._utc ? 'UTC' : options.tz; this._currentDate = new CronDate(options.currentDate, this._tz); this._startDate = options.startDate ? new CronDate(options.startDate, this._tz) : null; this._end...
javascript
function CronExpression (fields, options) { this._options = options; this._utc = options.utc || false; this._tz = this._utc ? 'UTC' : options.tz; this._currentDate = new CronDate(options.currentDate, this._tz); this._startDate = options.startDate ? new CronDate(options.startDate, this._tz) : null; this._end...
[ "function", "CronExpression", "(", "fields", ",", "options", ")", "{", "this", ".", "_options", "=", "options", ";", "this", ".", "_utc", "=", "options", ".", "utc", "||", "false", ";", "this", ".", "_tz", "=", "this", ".", "_utc", "?", "'UTC'", ":",...
Construct a new expression parser Options: currentDate: iterator start date endDate: iterator end date @constructor @private @param {Object} fields Expression fields parsed values @param {Object} options Parser options
[ "Construct", "a", "new", "expression", "parser" ]
b6cfece825f0894194f5d002c0051b9a7f09ce12
https://github.com/harrisiirak/cron-parser/blob/b6cfece825f0894194f5d002c0051b9a7f09ce12/lib/expression.js#L45-L56
train
harrisiirak/cron-parser
lib/expression.js
parseRepeat
function parseRepeat (val) { var repeatInterval = 1; var atoms = val.split('/'); if (atoms.length > 1) { return parseRange(atoms[0], atoms[atoms.length - 1]); } return parseRange(val, repeatInterval); }
javascript
function parseRepeat (val) { var repeatInterval = 1; var atoms = val.split('/'); if (atoms.length > 1) { return parseRange(atoms[0], atoms[atoms.length - 1]); } return parseRange(val, repeatInterval); }
[ "function", "parseRepeat", "(", "val", ")", "{", "var", "repeatInterval", "=", "1", ";", "var", "atoms", "=", "val", ".", "split", "(", "'/'", ")", ";", "if", "(", "atoms", ".", "length", ">", "1", ")", "{", "return", "parseRange", "(", "atoms", "[...
Parse repetition interval @param {String} val @return {Array}
[ "Parse", "repetition", "interval" ]
b6cfece825f0894194f5d002c0051b9a7f09ce12
https://github.com/harrisiirak/cron-parser/blob/b6cfece825f0894194f5d002c0051b9a7f09ce12/lib/expression.js#L276-L285
train
harrisiirak/cron-parser
lib/expression.js
matchSchedule
function matchSchedule (value, sequence) { for (var i = 0, c = sequence.length; i < c; i++) { if (sequence[i] >= value) { return sequence[i] === value; } } return sequence[0] === value; }
javascript
function matchSchedule (value, sequence) { for (var i = 0, c = sequence.length; i < c; i++) { if (sequence[i] >= value) { return sequence[i] === value; } } return sequence[0] === value; }
[ "function", "matchSchedule", "(", "value", ",", "sequence", ")", "{", "for", "(", "var", "i", "=", "0", ",", "c", "=", "sequence", ".", "length", ";", "i", "<", "c", ";", "i", "++", ")", "{", "if", "(", "sequence", "[", "i", "]", ">=", "value",...
Match field value @param {String} value @param {Array} sequence @return {Boolean} @private
[ "Match", "field", "value" ]
b6cfece825f0894194f5d002c0051b9a7f09ce12
https://github.com/harrisiirak/cron-parser/blob/b6cfece825f0894194f5d002c0051b9a7f09ce12/lib/expression.js#L409-L417
train
harrisiirak/cron-parser
lib/expression.js
isNthDayMatch
function isNthDayMatch(date, nthDayOfWeek) { if (nthDayOfWeek < 6) { if ( date.getDate() < 8 && nthDayOfWeek === 1 // First occurence has to happen in first 7 days of the month ) { return true; } var offset = date.getDate() % 7 ? 1 : 0; // Math is off by 1 when dayOf...
javascript
function isNthDayMatch(date, nthDayOfWeek) { if (nthDayOfWeek < 6) { if ( date.getDate() < 8 && nthDayOfWeek === 1 // First occurence has to happen in first 7 days of the month ) { return true; } var offset = date.getDate() % 7 ? 1 : 0; // Math is off by 1 when dayOf...
[ "function", "isNthDayMatch", "(", "date", ",", "nthDayOfWeek", ")", "{", "if", "(", "nthDayOfWeek", "<", "6", ")", "{", "if", "(", "date", ".", "getDate", "(", ")", "<", "8", "&&", "nthDayOfWeek", "===", "1", "// First occurence has to happen in first 7 days o...
Helps determine if the provided date is the correct nth occurence of the desired day of week. @param {CronDate} date @param {Number} nthDayOfWeek @return {Boolean} @private
[ "Helps", "determine", "if", "the", "provided", "date", "is", "the", "correct", "nth", "occurence", "of", "the", "desired", "day", "of", "week", "." ]
b6cfece825f0894194f5d002c0051b9a7f09ce12
https://github.com/harrisiirak/cron-parser/blob/b6cfece825f0894194f5d002c0051b9a7f09ce12/lib/expression.js#L428-L445
train
pixijs/pixi-particles
docs/examples/js/ParticleExample.js
function(){ // Update the next frame updateId = requestAnimationFrame(update); var now = Date.now(); if (emitter) emitter.update((now - elapsed) * 0.001); framerate.innerHTML = (1000 / (now - elapsed)).toFixed(2); elapsed = now; if(emitter && particleCount) particleCount.innerHTML = em...
javascript
function(){ // Update the next frame updateId = requestAnimationFrame(update); var now = Date.now(); if (emitter) emitter.update((now - elapsed) * 0.001); framerate.innerHTML = (1000 / (now - elapsed)).toFixed(2); elapsed = now; if(emitter && particleCount) particleCount.innerHTML = em...
[ "function", "(", ")", "{", "// Update the next frame", "updateId", "=", "requestAnimationFrame", "(", "update", ")", ";", "var", "now", "=", "Date", ".", "now", "(", ")", ";", "if", "(", "emitter", ")", "emitter", ".", "update", "(", "(", "now", "-", "...
Update function every frame
[ "Update", "function", "every", "frame" ]
163262fe65ac8ebe4e8c5c4d485610571a54291b
https://github.com/pixijs/pixi-particles/blob/163262fe65ac8ebe4e8c5c4d485610571a54291b/docs/examples/js/ParticleExample.js#L38-L56
train
tristen/tablesort
src/tablesort.js
function(a, b) { a = a.trim().toLowerCase(); b = b.trim().toLowerCase(); if (a === b) return 0; if (a < b) return 1; return -1; }
javascript
function(a, b) { a = a.trim().toLowerCase(); b = b.trim().toLowerCase(); if (a === b) return 0; if (a < b) return 1; return -1; }
[ "function", "(", "a", ",", "b", ")", "{", "a", "=", "a", ".", "trim", "(", ")", ".", "toLowerCase", "(", ")", ";", "b", "=", "b", ".", "trim", "(", ")", ".", "toLowerCase", "(", ")", ";", "if", "(", "a", "===", "b", ")", "return", "0", ";...
Default sort method if no better sort method is found
[ "Default", "sort", "method", "if", "no", "better", "sort", "method", "is", "found" ]
3f9153b3e5f6d87ec8f9d83bb0c986d705661402
https://github.com/tristen/tablesort/blob/3f9153b3e5f6d87ec8f9d83bb0c986d705661402/src/tablesort.js#L31-L39
train
tristen/tablesort
src/tablesort.js
function(sort, antiStabilize) { return function(a, b) { var unstableResult = sort(a.td, b.td); if (unstableResult === 0) { if (antiStabilize) return b.index - a.index; return a.index - b.index; } return unstableResult; }; }
javascript
function(sort, antiStabilize) { return function(a, b) { var unstableResult = sort(a.td, b.td); if (unstableResult === 0) { if (antiStabilize) return b.index - a.index; return a.index - b.index; } return unstableResult; }; }
[ "function", "(", "sort", ",", "antiStabilize", ")", "{", "return", "function", "(", "a", ",", "b", ")", "{", "var", "unstableResult", "=", "sort", "(", "a", ".", "td", ",", "b", ".", "td", ")", ";", "if", "(", "unstableResult", "===", "0", ")", "...
Stable sort function If two elements are equal under the original sort function, then there relative order is reversed
[ "Stable", "sort", "function", "If", "two", "elements", "are", "equal", "under", "the", "original", "sort", "function", "then", "there", "relative", "order", "is", "reversed" ]
3f9153b3e5f6d87ec8f9d83bb0c986d705661402
https://github.com/tristen/tablesort/blob/3f9153b3e5f6d87ec8f9d83bb0c986d705661402/src/tablesort.js#L44-L55
train
xiongwilee/Gracejs
middleware/session/index.js
extendContext
function extendContext(context, opts) { Object.defineProperties(context, { [CONTEXT_SESSION]: { get() { if (this[_CONTEXT_SESSION]) return this[_CONTEXT_SESSION]; this[_CONTEXT_SESSION] = new ContextSession(this, opts); return this[_CONTEXT_SESSION]; }, enumerable: true ...
javascript
function extendContext(context, opts) { Object.defineProperties(context, { [CONTEXT_SESSION]: { get() { if (this[_CONTEXT_SESSION]) return this[_CONTEXT_SESSION]; this[_CONTEXT_SESSION] = new ContextSession(this, opts); return this[_CONTEXT_SESSION]; }, enumerable: true ...
[ "function", "extendContext", "(", "context", ",", "opts", ")", "{", "Object", ".", "defineProperties", "(", "context", ",", "{", "[", "CONTEXT_SESSION", "]", ":", "{", "get", "(", ")", "{", "if", "(", "this", "[", "_CONTEXT_SESSION", "]", ")", "return", ...
extend context prototype, add session properties @param {Object} context koa's context prototype @param {Object} opts session options @api private
[ "extend", "context", "prototype", "add", "session", "properties" ]
a4ca954d28ddcd1c39a0b3eefe16e79a390fb507
https://github.com/xiongwilee/Gracejs/blob/a4ca954d28ddcd1c39a0b3eefe16e79a390fb507/middleware/session/index.js#L103-L130
train
xiongwilee/Gracejs
middleware/router/lib/router.js
Router
function Router(opts) { if (!(this instanceof Router)) { return new Router(opts); } this.opts = opts || {}; this.methods = this.opts.methods || [ 'HEAD', 'OPTIONS', 'GET', 'PUT', 'PATCH', 'POST', 'DELETE' ]; this.params = {}; this.stack = []; this.MATCHS = {}; }
javascript
function Router(opts) { if (!(this instanceof Router)) { return new Router(opts); } this.opts = opts || {}; this.methods = this.opts.methods || [ 'HEAD', 'OPTIONS', 'GET', 'PUT', 'PATCH', 'POST', 'DELETE' ]; this.params = {}; this.stack = []; this.MATCHS = {}; }
[ "function", "Router", "(", "opts", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Router", ")", ")", "{", "return", "new", "Router", "(", "opts", ")", ";", "}", "this", ".", "opts", "=", "opts", "||", "{", "}", ";", "this", ".", "methods",...
Create a new router. @example Basic usage: ```javascript var app = require('koa')(); var router = require('koa-router')(); router.get('/', function *(next) {...}); app .use(router.routes()) .use(router.allowedMethods()); ``` @alias module:koa-router @param {Object=} opts @param {String=} opts.prefix prefix router...
[ "Create", "a", "new", "router", "." ]
a4ca954d28ddcd1c39a0b3eefe16e79a390fb507
https://github.com/xiongwilee/Gracejs/blob/a4ca954d28ddcd1c39a0b3eefe16e79a390fb507/middleware/router/lib/router.js#L47-L66
train