id int32 0 58k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
17,500 | ruddell/ignite-jhipster | boilerplate/app/shared/websockets/websocket.service.js | subscribeToChat | function subscribeToChat () {
console.tron.log('Subscribing to Chat')
if (!subscriptions.hasOwnProperty('chat')) {
subscriptions.chat = { subscribed: true }
connection.then(() => {
chatSubscriber = stompClient.subscribe('/topic/chat', onMessage.bind(this, 'chat'))
})
}
} | javascript | function subscribeToChat () {
console.tron.log('Subscribing to Chat')
if (!subscriptions.hasOwnProperty('chat')) {
subscriptions.chat = { subscribed: true }
connection.then(() => {
chatSubscriber = stompClient.subscribe('/topic/chat', onMessage.bind(this, 'chat'))
})
}
} | [
"function",
"subscribeToChat",
"(",
")",
"{",
"console",
".",
"tron",
".",
"log",
"(",
"'Subscribing to Chat'",
")",
"if",
"(",
"!",
"subscriptions",
".",
"hasOwnProperty",
"(",
"'chat'",
")",
")",
"{",
"subscriptions",
".",
"chat",
"=",
"{",
"subscribed",
... | methods for subscribing | [
"methods",
"for",
"subscribing"
] | 301c3aa9e4286715b0f5ad6f32f516672ea8d09d | https://github.com/ruddell/ignite-jhipster/blob/301c3aa9e4286715b0f5ad6f32f516672ea8d09d/boilerplate/app/shared/websockets/websocket.service.js#L93-L101 |
17,501 | ruddell/ignite-jhipster | boilerplate/app/shared/websockets/websocket.service.js | sendChat | function sendChat (ev) {
if (stompClient !== null && stompClient.connected) {
var p = '/topic/chat'
stompClient.send(p, {}, JSON.stringify(ev))
}
} | javascript | function sendChat (ev) {
if (stompClient !== null && stompClient.connected) {
var p = '/topic/chat'
stompClient.send(p, {}, JSON.stringify(ev))
}
} | [
"function",
"sendChat",
"(",
"ev",
")",
"{",
"if",
"(",
"stompClient",
"!==",
"null",
"&&",
"stompClient",
".",
"connected",
")",
"{",
"var",
"p",
"=",
"'/topic/chat'",
"stompClient",
".",
"send",
"(",
"p",
",",
"{",
"}",
",",
"JSON",
".",
"stringify",... | methods for sending | [
"methods",
"for",
"sending"
] | 301c3aa9e4286715b0f5ad6f32f516672ea8d09d | https://github.com/ruddell/ignite-jhipster/blob/301c3aa9e4286715b0f5ad6f32f516672ea8d09d/boilerplate/app/shared/websockets/websocket.service.js#L112-L117 |
17,502 | ruddell/ignite-jhipster | boilerplate/app/shared/websockets/websocket.service.js | onMessage | function onMessage (subscription, fullMessage) {
let msg = null
try {
msg = JSON.parse(fullMessage.body)
} catch (fullMessage) {
console.tron.error(`Error parsing : ${fullMessage}`)
}
if (msg) {
return em({ subscription, msg })
}
} | javascript | function onMessage (subscription, fullMessage) {
let msg = null
try {
msg = JSON.parse(fullMessage.body)
} catch (fullMessage) {
console.tron.error(`Error parsing : ${fullMessage}`)
}
if (msg) {
return em({ subscription, msg })
}
} | [
"function",
"onMessage",
"(",
"subscription",
",",
"fullMessage",
")",
"{",
"let",
"msg",
"=",
"null",
"try",
"{",
"msg",
"=",
"JSON",
".",
"parse",
"(",
"fullMessage",
".",
"body",
")",
"}",
"catch",
"(",
"fullMessage",
")",
"{",
"console",
".",
"tron... | when the message is received, send it to the WebsocketSaga | [
"when",
"the",
"message",
"is",
"received",
"send",
"it",
"to",
"the",
"WebsocketSaga"
] | 301c3aa9e4286715b0f5ad6f32f516672ea8d09d | https://github.com/ruddell/ignite-jhipster/blob/301c3aa9e4286715b0f5ad6f32f516672ea8d09d/boilerplate/app/shared/websockets/websocket.service.js#L120-L130 |
17,503 | ruddell/ignite-jhipster | boilerplate/app/shared/websockets/websocket.service.js | generateInterval | function generateInterval (k) {
let maxInterval = (Math.pow(2, k) - 1) * 1000
if (maxInterval > 30 * 1000) {
// If the generated interval is more than 30 seconds, truncate it down to 30 seconds.
maxInterval = 30 * 1000
}
// generate the interval to a random number between 0 and the maxInterval determin... | javascript | function generateInterval (k) {
let maxInterval = (Math.pow(2, k) - 1) * 1000
if (maxInterval > 30 * 1000) {
// If the generated interval is more than 30 seconds, truncate it down to 30 seconds.
maxInterval = 30 * 1000
}
// generate the interval to a random number between 0 and the maxInterval determin... | [
"function",
"generateInterval",
"(",
"k",
")",
"{",
"let",
"maxInterval",
"=",
"(",
"Math",
".",
"pow",
"(",
"2",
",",
"k",
")",
"-",
"1",
")",
"*",
"1000",
"if",
"(",
"maxInterval",
">",
"30",
"*",
"1000",
")",
"{",
"// If the generated interval is mo... | exponential backoff for reconnections | [
"exponential",
"backoff",
"for",
"reconnections"
] | 301c3aa9e4286715b0f5ad6f32f516672ea8d09d | https://github.com/ruddell/ignite-jhipster/blob/301c3aa9e4286715b0f5ad6f32f516672ea8d09d/boilerplate/app/shared/websockets/websocket.service.js#L164-L173 |
17,504 | ztoben/assets-webpack-plugin | lib/pathTemplate.js | function (data) {
return this.fields.reduce(function (output, field) {
var replacement = ''
var placeholder = field.placeholder
var width = field.width
if (field.prefix) {
output += field.prefix
}
if (placeholder) {
replacement = data[placeholder] || ''
i... | javascript | function (data) {
return this.fields.reduce(function (output, field) {
var replacement = ''
var placeholder = field.placeholder
var width = field.width
if (field.prefix) {
output += field.prefix
}
if (placeholder) {
replacement = data[placeholder] || ''
i... | [
"function",
"(",
"data",
")",
"{",
"return",
"this",
".",
"fields",
".",
"reduce",
"(",
"function",
"(",
"output",
",",
"field",
")",
"{",
"var",
"replacement",
"=",
"''",
"var",
"placeholder",
"=",
"field",
".",
"placeholder",
"var",
"width",
"=",
"fi... | Applies data to this template and outputs a filename.
@param Object data | [
"Applies",
"data",
"to",
"this",
"template",
"and",
"outputs",
"a",
"filename",
"."
] | 1a3239f3f7f01301154e51ba0a7ce6fd362a629a | https://github.com/ztoben/assets-webpack-plugin/blob/1a3239f3f7f01301154e51ba0a7ce6fd362a629a/lib/pathTemplate.js#L40-L59 | |
17,505 | IonicaBizau/medium-editor-markdown | dist/me-markdown.standalone.js | Rules | function Rules (options) {
this.options = options;
this._keep = [];
this._remove = [];
this.blankRule = {
replacement: options.blankReplacement
};
this.keepReplacement = options.keepReplacement;
this.defaultRule = {
replacement: options.defaultReplacement
};
this.array = [];
for (var key... | javascript | function Rules (options) {
this.options = options;
this._keep = [];
this._remove = [];
this.blankRule = {
replacement: options.blankReplacement
};
this.keepReplacement = options.keepReplacement;
this.defaultRule = {
replacement: options.defaultReplacement
};
this.array = [];
for (var key... | [
"function",
"Rules",
"(",
"options",
")",
"{",
"this",
".",
"options",
"=",
"options",
";",
"this",
".",
"_keep",
"=",
"[",
"]",
";",
"this",
".",
"_remove",
"=",
"[",
"]",
";",
"this",
".",
"blankRule",
"=",
"{",
"replacement",
":",
"options",
"."... | Manages a collection of rules used to convert HTML to Markdown | [
"Manages",
"a",
"collection",
"of",
"rules",
"used",
"to",
"convert",
"HTML",
"to",
"Markdown"
] | e35601361d4708c8077199e58b8b09700c6bd059 | https://github.com/IonicaBizau/medium-editor-markdown/blob/e35601361d4708c8077199e58b8b09700c6bd059/dist/me-markdown.standalone.js#L299-L316 |
17,506 | IonicaBizau/medium-editor-markdown | dist/me-markdown.standalone.js | function (input) {
if (!canConvert(input)) {
throw new TypeError(
input + ' is not a string, or an element/document/fragment node.'
)
}
if (input === '') return ''
var output = process.call(this, new RootNode(input));
return postProcess.call(this, output)
} | javascript | function (input) {
if (!canConvert(input)) {
throw new TypeError(
input + ' is not a string, or an element/document/fragment node.'
)
}
if (input === '') return ''
var output = process.call(this, new RootNode(input));
return postProcess.call(this, output)
} | [
"function",
"(",
"input",
")",
"{",
"if",
"(",
"!",
"canConvert",
"(",
"input",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"input",
"+",
"' is not a string, or an element/document/fragment node.'",
")",
"}",
"if",
"(",
"input",
"===",
"''",
")",
"retur... | The entry point for converting a string or DOM node to Markdown
@public
@param {String|HTMLElement} input The string or DOM node to convert
@returns A Markdown representation of the input
@type String | [
"The",
"entry",
"point",
"for",
"converting",
"a",
"string",
"or",
"DOM",
"node",
"to",
"Markdown"
] | e35601361d4708c8077199e58b8b09700c6bd059 | https://github.com/IonicaBizau/medium-editor-markdown/blob/e35601361d4708c8077199e58b8b09700c6bd059/dist/me-markdown.standalone.js#L699-L710 | |
17,507 | IonicaBizau/medium-editor-markdown | dist/me-markdown.standalone.js | function (plugin) {
if (Array.isArray(plugin)) {
for (var i = 0; i < plugin.length; i++) this.use(plugin[i]);
} else if (typeof plugin === 'function') {
plugin(this);
} else {
throw new TypeError('plugin must be a Function or an Array of Functions')
}
return this
} | javascript | function (plugin) {
if (Array.isArray(plugin)) {
for (var i = 0; i < plugin.length; i++) this.use(plugin[i]);
} else if (typeof plugin === 'function') {
plugin(this);
} else {
throw new TypeError('plugin must be a Function or an Array of Functions')
}
return this
} | [
"function",
"(",
"plugin",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"plugin",
")",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"plugin",
".",
"length",
";",
"i",
"++",
")",
"this",
".",
"use",
"(",
"plugin",
"[",
"i",... | Add one or more plugins
@public
@param {Function|Array} plugin The plugin or array of plugins to add
@returns The Turndown instance for chaining
@type Object | [
"Add",
"one",
"or",
"more",
"plugins"
] | e35601361d4708c8077199e58b8b09700c6bd059 | https://github.com/IonicaBizau/medium-editor-markdown/blob/e35601361d4708c8077199e58b8b09700c6bd059/dist/me-markdown.standalone.js#L720-L729 | |
17,508 | IonicaBizau/medium-editor-markdown | dist/me-markdown.standalone.js | function (string) {
return (
string
// Escape backslash escapes!
.replace(/\\(\S)/g, '\\\\$1')
// Escape headings
.replace(/^(#{1,6} )/gm, '\\$1')
// Escape hr
.replace(/^([-*_] *){3,}$/gm, function (match, character) {
return match.split(character).... | javascript | function (string) {
return (
string
// Escape backslash escapes!
.replace(/\\(\S)/g, '\\\\$1')
// Escape headings
.replace(/^(#{1,6} )/gm, '\\$1')
// Escape hr
.replace(/^([-*_] *){3,}$/gm, function (match, character) {
return match.split(character).... | [
"function",
"(",
"string",
")",
"{",
"return",
"(",
"string",
"// Escape backslash escapes!",
".",
"replace",
"(",
"/",
"\\\\(\\S)",
"/",
"g",
",",
"'\\\\\\\\$1'",
")",
"// Escape headings",
".",
"replace",
"(",
"/",
"^(#{1,6} )",
"/",
"gm",
",",
"'\\\\$1'",
... | Escapes Markdown syntax
@public
@param {String} string The string to escape
@returns A string with Markdown syntax escaped
@type String | [
"Escapes",
"Markdown",
"syntax"
] | e35601361d4708c8077199e58b8b09700c6bd059 | https://github.com/IonicaBizau/medium-editor-markdown/blob/e35601361d4708c8077199e58b8b09700c6bd059/dist/me-markdown.standalone.js#L779-L822 | |
17,509 | IonicaBizau/medium-editor-markdown | dist/me-markdown.standalone.js | process | function process (parentNode) {
var self = this;
return reduce.call(parentNode.childNodes, function (output, node) {
node = new Node(node);
var replacement = '';
if (node.nodeType === 3) {
replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);
} else if (node.nodeType === 1... | javascript | function process (parentNode) {
var self = this;
return reduce.call(parentNode.childNodes, function (output, node) {
node = new Node(node);
var replacement = '';
if (node.nodeType === 3) {
replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);
} else if (node.nodeType === 1... | [
"function",
"process",
"(",
"parentNode",
")",
"{",
"var",
"self",
"=",
"this",
";",
"return",
"reduce",
".",
"call",
"(",
"parentNode",
".",
"childNodes",
",",
"function",
"(",
"output",
",",
"node",
")",
"{",
"node",
"=",
"new",
"Node",
"(",
"node",
... | Reduces a DOM node down to its Markdown string equivalent
@private
@param {HTMLElement} parentNode The node to convert
@returns A Markdown representation of the node
@type String | [
"Reduces",
"a",
"DOM",
"node",
"down",
"to",
"its",
"Markdown",
"string",
"equivalent"
] | e35601361d4708c8077199e58b8b09700c6bd059 | https://github.com/IonicaBizau/medium-editor-markdown/blob/e35601361d4708c8077199e58b8b09700c6bd059/dist/me-markdown.standalone.js#L833-L847 |
17,510 | IonicaBizau/medium-editor-markdown | dist/me-markdown.standalone.js | postProcess | function postProcess (output) {
var self = this;
this.rules.forEach(function (rule) {
if (typeof rule.append === 'function') {
output = join(output, rule.append(self.options));
}
});
return output.replace(/^[\t\r\n]+/, '').replace(/[\t\r\n\s]+$/, '')
} | javascript | function postProcess (output) {
var self = this;
this.rules.forEach(function (rule) {
if (typeof rule.append === 'function') {
output = join(output, rule.append(self.options));
}
});
return output.replace(/^[\t\r\n]+/, '').replace(/[\t\r\n\s]+$/, '')
} | [
"function",
"postProcess",
"(",
"output",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"rules",
".",
"forEach",
"(",
"function",
"(",
"rule",
")",
"{",
"if",
"(",
"typeof",
"rule",
".",
"append",
"===",
"'function'",
")",
"{",
"output",
"=... | Appends strings as each rule requires and trims the output
@private
@param {String} output The conversion output
@returns A trimmed version of the ouput
@type String | [
"Appends",
"strings",
"as",
"each",
"rule",
"requires",
"and",
"trims",
"the",
"output"
] | e35601361d4708c8077199e58b8b09700c6bd059 | https://github.com/IonicaBizau/medium-editor-markdown/blob/e35601361d4708c8077199e58b8b09700c6bd059/dist/me-markdown.standalone.js#L857-L866 |
17,511 | wix/protractor-helpers | dist/protractor-helpers.js | function (matchedValue, expectedValue, currencySymbol, isFraction) {
// get value with fraction
expectedValue = getNumberWithCommas(expectedValue);
if (isFraction === true && expectedValue.indexOf('.') === -1) {
expectedValue += '.00';
}
// add minus and symbol if needed
var expression = '^';
if (matc... | javascript | function (matchedValue, expectedValue, currencySymbol, isFraction) {
// get value with fraction
expectedValue = getNumberWithCommas(expectedValue);
if (isFraction === true && expectedValue.indexOf('.') === -1) {
expectedValue += '.00';
}
// add minus and symbol if needed
var expression = '^';
if (matc... | [
"function",
"(",
"matchedValue",
",",
"expectedValue",
",",
"currencySymbol",
",",
"isFraction",
")",
"{",
"// get value with fraction",
"expectedValue",
"=",
"getNumberWithCommas",
"(",
"expectedValue",
")",
";",
"if",
"(",
"isFraction",
"===",
"true",
"&&",
"expec... | Creates a regular expression to match money representation with or without spaces in between
@param matchedValue - the number that is tested
@param expectedValue - the number to match against
@param currencySymbol[optional] {string} - the symbol to match against.
if not specify - validate that there is no symbol.
@para... | [
"Creates",
"a",
"regular",
"expression",
"to",
"match",
"money",
"representation",
"with",
"or",
"without",
"spaces",
"in",
"between"
] | f496e47c38e4de2e847c300bfead6c9f17a52bcc | https://github.com/wix/protractor-helpers/blob/f496e47c38e4de2e847c300bfead6c9f17a52bcc/dist/protractor-helpers.js#L297-L314 | |
17,512 | hsluv/hsluv | website/generate-images.js | round | function round(num, places) {
const n = Math.pow(10, places);
return Math.round(num * n) / n;
} | javascript | function round(num, places) {
const n = Math.pow(10, places);
return Math.round(num * n) / n;
} | [
"function",
"round",
"(",
"num",
",",
"places",
")",
"{",
"const",
"n",
"=",
"Math",
".",
"pow",
"(",
"10",
",",
"places",
")",
";",
"return",
"Math",
".",
"round",
"(",
"num",
"*",
"n",
")",
"/",
"n",
";",
"}"
] | Rounds number to a given number of decimal places | [
"Rounds",
"number",
"to",
"a",
"given",
"number",
"of",
"decimal",
"places"
] | ba6a9ee7d80eb669ba90de975902b0bf574fd045 | https://github.com/hsluv/hsluv/blob/ba6a9ee7d80eb669ba90de975902b0bf574fd045/website/generate-images.js#L64-L67 |
17,513 | bbecquet/Leaflet.PolylineDecorator | src/L.PolylineDecorator.js | function(patternDef, latLngs) {
return {
symbolFactory: patternDef.symbol,
// Parse offset and repeat values, managing the two cases:
// absolute (in pixels) or relative (in percentage of the polyline length)
offset: parseRelativeOrAbsoluteValue(patternDef.offset)... | javascript | function(patternDef, latLngs) {
return {
symbolFactory: patternDef.symbol,
// Parse offset and repeat values, managing the two cases:
// absolute (in pixels) or relative (in percentage of the polyline length)
offset: parseRelativeOrAbsoluteValue(patternDef.offset)... | [
"function",
"(",
"patternDef",
",",
"latLngs",
")",
"{",
"return",
"{",
"symbolFactory",
":",
"patternDef",
".",
"symbol",
",",
"// Parse offset and repeat values, managing the two cases:",
"// absolute (in pixels) or relative (in percentage of the polyline length)",
"offset",
":... | Parse the pattern definition | [
"Parse",
"the",
"pattern",
"definition"
] | 96858e837a07c08e08dbba1c6751abdec9a85433 | https://github.com/bbecquet/Leaflet.PolylineDecorator/blob/96858e837a07c08e08dbba1c6751abdec9a85433/src/L.PolylineDecorator.js#L80-L89 | |
17,514 | bbecquet/Leaflet.PolylineDecorator | src/L.PolylineDecorator.js | function() {
const allPathCoords = this._paths.reduce((acc, path) => acc.concat(path), []);
return L.latLngBounds(allPathCoords);
} | javascript | function() {
const allPathCoords = this._paths.reduce((acc, path) => acc.concat(path), []);
return L.latLngBounds(allPathCoords);
} | [
"function",
"(",
")",
"{",
"const",
"allPathCoords",
"=",
"this",
".",
"_paths",
".",
"reduce",
"(",
"(",
"acc",
",",
"path",
")",
"=>",
"acc",
".",
"concat",
"(",
"path",
")",
",",
"[",
"]",
")",
";",
"return",
"L",
".",
"latLngBounds",
"(",
"al... | As real pattern bounds depends on map zoom and bounds,
we just compute the total bounds of all paths decorated by this instance. | [
"As",
"real",
"pattern",
"bounds",
"depends",
"on",
"map",
"zoom",
"and",
"bounds",
"we",
"just",
"compute",
"the",
"total",
"bounds",
"of",
"all",
"paths",
"decorated",
"by",
"this",
"instance",
"."
] | 96858e837a07c08e08dbba1c6751abdec9a85433 | https://github.com/bbecquet/Leaflet.PolylineDecorator/blob/96858e837a07c08e08dbba1c6751abdec9a85433/src/L.PolylineDecorator.js#L107-L110 | |
17,515 | bbecquet/Leaflet.PolylineDecorator | src/L.PolylineDecorator.js | function(latLngs, symbolFactory, directionPoints) {
return directionPoints.map((directionPoint, i) =>
symbolFactory.buildSymbol(directionPoint, latLngs, this._map, i, directionPoints.length)
);
} | javascript | function(latLngs, symbolFactory, directionPoints) {
return directionPoints.map((directionPoint, i) =>
symbolFactory.buildSymbol(directionPoint, latLngs, this._map, i, directionPoints.length)
);
} | [
"function",
"(",
"latLngs",
",",
"symbolFactory",
",",
"directionPoints",
")",
"{",
"return",
"directionPoints",
".",
"map",
"(",
"(",
"directionPoint",
",",
"i",
")",
"=>",
"symbolFactory",
".",
"buildSymbol",
"(",
"directionPoint",
",",
"latLngs",
",",
"this... | Returns an array of ILayers object | [
"Returns",
"an",
"array",
"of",
"ILayers",
"object"
] | 96858e837a07c08e08dbba1c6751abdec9a85433 | https://github.com/bbecquet/Leaflet.PolylineDecorator/blob/96858e837a07c08e08dbba1c6751abdec9a85433/src/L.PolylineDecorator.js#L119-L123 | |
17,516 | bbecquet/Leaflet.PolylineDecorator | src/L.PolylineDecorator.js | function(latLngs, pattern) {
if (latLngs.length < 2) {
return [];
}
const pathAsPoints = latLngs.map(latLng => this._map.project(latLng));
return projectPatternOnPointPath(pathAsPoints, pattern)
.map(point => ({
latLng: this._map.unproject(L.point(... | javascript | function(latLngs, pattern) {
if (latLngs.length < 2) {
return [];
}
const pathAsPoints = latLngs.map(latLng => this._map.project(latLng));
return projectPatternOnPointPath(pathAsPoints, pattern)
.map(point => ({
latLng: this._map.unproject(L.point(... | [
"function",
"(",
"latLngs",
",",
"pattern",
")",
"{",
"if",
"(",
"latLngs",
".",
"length",
"<",
"2",
")",
"{",
"return",
"[",
"]",
";",
"}",
"const",
"pathAsPoints",
"=",
"latLngs",
".",
"map",
"(",
"latLng",
"=>",
"this",
".",
"_map",
".",
"projec... | Compute pairs of LatLng and heading angle,
that define positions and directions of the symbols on the path | [
"Compute",
"pairs",
"of",
"LatLng",
"and",
"heading",
"angle",
"that",
"define",
"positions",
"and",
"directions",
"of",
"the",
"symbols",
"on",
"the",
"path"
] | 96858e837a07c08e08dbba1c6751abdec9a85433 | https://github.com/bbecquet/Leaflet.PolylineDecorator/blob/96858e837a07c08e08dbba1c6751abdec9a85433/src/L.PolylineDecorator.js#L129-L139 | |
17,517 | bbecquet/Leaflet.PolylineDecorator | src/L.PolylineDecorator.js | function(pattern) {
const mapBounds = this._map.getBounds().pad(0.1);
return this._paths.map(path => {
const directionPoints = this._getDirectionPoints(path, pattern)
// filter out invisible points
.filter(point => mapBounds.contains(point.latLng));
... | javascript | function(pattern) {
const mapBounds = this._map.getBounds().pad(0.1);
return this._paths.map(path => {
const directionPoints = this._getDirectionPoints(path, pattern)
// filter out invisible points
.filter(point => mapBounds.contains(point.latLng));
... | [
"function",
"(",
"pattern",
")",
"{",
"const",
"mapBounds",
"=",
"this",
".",
"_map",
".",
"getBounds",
"(",
")",
".",
"pad",
"(",
"0.1",
")",
";",
"return",
"this",
".",
"_paths",
".",
"map",
"(",
"path",
"=>",
"{",
"const",
"directionPoints",
"=",
... | Returns all symbols for a given pattern as an array of FeatureGroup | [
"Returns",
"all",
"symbols",
"for",
"a",
"given",
"pattern",
"as",
"an",
"array",
"of",
"FeatureGroup"
] | 96858e837a07c08e08dbba1c6751abdec9a85433 | https://github.com/bbecquet/Leaflet.PolylineDecorator/blob/96858e837a07c08e08dbba1c6751abdec9a85433/src/L.PolylineDecorator.js#L152-L160 | |
17,518 | bbecquet/Leaflet.PolylineDecorator | src/L.PolylineDecorator.js | function () {
this._patterns
.map(pattern => this._getPatternLayers(pattern))
.forEach(layers => { this.addLayer(L.featureGroup(layers)); });
} | javascript | function () {
this._patterns
.map(pattern => this._getPatternLayers(pattern))
.forEach(layers => { this.addLayer(L.featureGroup(layers)); });
} | [
"function",
"(",
")",
"{",
"this",
".",
"_patterns",
".",
"map",
"(",
"pattern",
"=>",
"this",
".",
"_getPatternLayers",
"(",
"pattern",
")",
")",
".",
"forEach",
"(",
"layers",
"=>",
"{",
"this",
".",
"addLayer",
"(",
"L",
".",
"featureGroup",
"(",
... | Draw all patterns | [
"Draw",
"all",
"patterns"
] | 96858e837a07c08e08dbba1c6751abdec9a85433 | https://github.com/bbecquet/Leaflet.PolylineDecorator/blob/96858e837a07c08e08dbba1c6751abdec9a85433/src/L.PolylineDecorator.js#L165-L169 | |
17,519 | AndiDittrich/NodeMCU-Tool | lib/cli/nodemcu-tool.js | getConnection | async function getConnection(){
// already connected ?
if (_nodeMcuConnector.isConnected()){
return;
}
// create new connector
try{
const msg = await _nodeMcuConnector.connect(_options.device, _options.baudrate, true, _options.connectionDelay);
// status message
_lo... | javascript | async function getConnection(){
// already connected ?
if (_nodeMcuConnector.isConnected()){
return;
}
// create new connector
try{
const msg = await _nodeMcuConnector.connect(_options.device, _options.baudrate, true, _options.connectionDelay);
// status message
_lo... | [
"async",
"function",
"getConnection",
"(",
")",
"{",
"// already connected ?",
"if",
"(",
"_nodeMcuConnector",
".",
"isConnected",
"(",
")",
")",
"{",
"return",
";",
"}",
"// create new connector",
"try",
"{",
"const",
"msg",
"=",
"await",
"_nodeMcuConnector",
"... | helper function to create a NodeMCU Tool Connection | [
"helper",
"function",
"to",
"create",
"a",
"NodeMCU",
"Tool",
"Connection"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/nodemcu-tool.js#L38-L56 |
17,520 | AndiDittrich/NodeMCU-Tool | lib/cli/nodemcu-tool.js | fsinfo | async function fsinfo(format){
// try to establish a connection to the module
await getConnection();
const {metadata, files} = await _nodeMcuConnector.fsinfo();
// json output - third party applications
if (format == 'json') {
writeOutput(JSON.stringify({
files: files,
... | javascript | async function fsinfo(format){
// try to establish a connection to the module
await getConnection();
const {metadata, files} = await _nodeMcuConnector.fsinfo();
// json output - third party applications
if (format == 'json') {
writeOutput(JSON.stringify({
files: files,
... | [
"async",
"function",
"fsinfo",
"(",
"format",
")",
"{",
"// try to establish a connection to the module",
"await",
"getConnection",
"(",
")",
";",
"const",
"{",
"metadata",
",",
"files",
"}",
"=",
"await",
"_nodeMcuConnector",
".",
"fsinfo",
"(",
")",
";",
"// j... | show file-system info | [
"show",
"file",
"-",
"system",
"info"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/nodemcu-tool.js#L63-L99 |
17,521 | AndiDittrich/NodeMCU-Tool | lib/cli/nodemcu-tool.js | upload | async function upload(localFiles, options, onProgess){
// the index of the current uploaded file
let fileUploadIndex = 0;
async function uploadFile(localFile, remoteFilename){
// increment upload index
fileUploadIndex++;
// get file stats
try{
const stats = aw... | javascript | async function upload(localFiles, options, onProgess){
// the index of the current uploaded file
let fileUploadIndex = 0;
async function uploadFile(localFile, remoteFilename){
// increment upload index
fileUploadIndex++;
// get file stats
try{
const stats = aw... | [
"async",
"function",
"upload",
"(",
"localFiles",
",",
"options",
",",
"onProgess",
")",
"{",
"// the index of the current uploaded file",
"let",
"fileUploadIndex",
"=",
"0",
";",
"async",
"function",
"uploadFile",
"(",
"localFile",
",",
"remoteFilename",
")",
"{",
... | upload a local file to nodemcu | [
"upload",
"a",
"local",
"file",
"to",
"nodemcu"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/nodemcu-tool.js#L117-L213 |
17,522 | AndiDittrich/NodeMCU-Tool | lib/cli/nodemcu-tool.js | download | async function download(remoteFile){
// strip path
let localFilename = _path.basename(remoteFile);
// local file with same name already available ?
if (await _fs.exists(remoteFile)){
// change filename
localFilename += '.' + (new Date().getTime());
_logger.log('Local file "' + ... | javascript | async function download(remoteFile){
// strip path
let localFilename = _path.basename(remoteFile);
// local file with same name already available ?
if (await _fs.exists(remoteFile)){
// change filename
localFilename += '.' + (new Date().getTime());
_logger.log('Local file "' + ... | [
"async",
"function",
"download",
"(",
"remoteFile",
")",
"{",
"// strip path",
"let",
"localFilename",
"=",
"_path",
".",
"basename",
"(",
"remoteFile",
")",
";",
"// local file with same name already available ?",
"if",
"(",
"await",
"_fs",
".",
"exists",
"(",
"r... | download a remote file from nodemcu | [
"download",
"a",
"remote",
"file",
"from",
"nodemcu"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/nodemcu-tool.js#L216-L253 |
17,523 | AndiDittrich/NodeMCU-Tool | lib/cli/nodemcu-tool.js | remove | async function remove(filename){
// try to establish a connection to the module
await getConnection();
// remove the file
await _nodeMcuConnector.remove(filename);
// just show complete message (no feedback from nodemcu)
_mculogger.log('File "' + filename + '" removed!');
} | javascript | async function remove(filename){
// try to establish a connection to the module
await getConnection();
// remove the file
await _nodeMcuConnector.remove(filename);
// just show complete message (no feedback from nodemcu)
_mculogger.log('File "' + filename + '" removed!');
} | [
"async",
"function",
"remove",
"(",
"filename",
")",
"{",
"// try to establish a connection to the module",
"await",
"getConnection",
"(",
")",
";",
"// remove the file",
"await",
"_nodeMcuConnector",
".",
"remove",
"(",
"filename",
")",
";",
"// just show complete messag... | removes a file from NodeMCU | [
"removes",
"a",
"file",
"from",
"NodeMCU"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/nodemcu-tool.js#L256-L266 |
17,524 | AndiDittrich/NodeMCU-Tool | lib/cli/nodemcu-tool.js | mkfs | async function mkfs(){
// try to establish a connection to the module
await getConnection();
_mculogger.log('Formatting the file system...this will take around ~30s');
try{
const response = await _nodeMcuConnector.format();
// just show complete message
_mculogger.log('File S... | javascript | async function mkfs(){
// try to establish a connection to the module
await getConnection();
_mculogger.log('Formatting the file system...this will take around ~30s');
try{
const response = await _nodeMcuConnector.format();
// just show complete message
_mculogger.log('File S... | [
"async",
"function",
"mkfs",
"(",
")",
"{",
"// try to establish a connection to the module",
"await",
"getConnection",
"(",
")",
";",
"_mculogger",
".",
"log",
"(",
"'Formatting the file system...this will take around ~30s'",
")",
";",
"try",
"{",
"const",
"response",
... | format the file system | [
"format",
"the",
"file",
"system"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/nodemcu-tool.js#L269-L285 |
17,525 | AndiDittrich/NodeMCU-Tool | lib/cli/nodemcu-tool.js | devices | async function devices(showAll, jsonOutput){
try{
const serialDevices = await _nodeMcuConnector.listDevices(showAll);
if (jsonOutput){
writeOutput(JSON.stringify(serialDevices));
}else{
// just show complete message
if (serialDevices.length == 0){
... | javascript | async function devices(showAll, jsonOutput){
try{
const serialDevices = await _nodeMcuConnector.listDevices(showAll);
if (jsonOutput){
writeOutput(JSON.stringify(serialDevices));
}else{
// just show complete message
if (serialDevices.length == 0){
... | [
"async",
"function",
"devices",
"(",
"showAll",
",",
"jsonOutput",
")",
"{",
"try",
"{",
"const",
"serialDevices",
"=",
"await",
"_nodeMcuConnector",
".",
"listDevices",
"(",
"showAll",
")",
";",
"if",
"(",
"jsonOutput",
")",
"{",
"writeOutput",
"(",
"JSON",... | show serial devices connected to the system | [
"show",
"serial",
"devices",
"connected",
"to",
"the",
"system"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/nodemcu-tool.js#L321-L346 |
17,526 | AndiDittrich/NodeMCU-Tool | lib/cli/nodemcu-tool.js | function(opt){
// merge with default options
Object.keys(_options).forEach(function(key){
_options[key] = opt[key] || _options[key];
});
} | javascript | function(opt){
// merge with default options
Object.keys(_options).forEach(function(key){
_options[key] = opt[key] || _options[key];
});
} | [
"function",
"(",
"opt",
")",
"{",
"// merge with default options",
"Object",
".",
"keys",
"(",
"_options",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"_options",
"[",
"key",
"]",
"=",
"opt",
"[",
"key",
"]",
"||",
"_options",
"[",
"key... | set connector options | [
"set",
"connector",
"options"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/nodemcu-tool.js#L359-L364 | |
17,527 | AndiDittrich/NodeMCU-Tool | lib/lua/command-builder.js | luaPrepare | function luaPrepare(commandName, args){
// get command by name
let command = _esp8266_commands[commandName] || null;
// valid command name provided ?
if (command == null){
return null;
}
// replace all placeholders with given args
args.forEach(function(arg){
// simple escap... | javascript | function luaPrepare(commandName, args){
// get command by name
let command = _esp8266_commands[commandName] || null;
// valid command name provided ?
if (command == null){
return null;
}
// replace all placeholders with given args
args.forEach(function(arg){
// simple escap... | [
"function",
"luaPrepare",
"(",
"commandName",
",",
"args",
")",
"{",
"// get command by name",
"let",
"command",
"=",
"_esp8266_commands",
"[",
"commandName",
"]",
"||",
"null",
";",
"// valid command name provided ?",
"if",
"(",
"command",
"==",
"null",
")",
"{",... | prepare command be escaping args | [
"prepare",
"command",
"be",
"escaping",
"args"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/lua/command-builder.js#L4-L23 |
17,528 | AndiDittrich/NodeMCU-Tool | lib/cli/prompt.js | prompt | function prompt(menu){
return new Promise(function(resolve, reject){
// user confirmation required!
_prompt.start();
_prompt.message = '';
_prompt.delimiter = '';
_prompt.colors = false;
_prompt.get(menu, function (err, result){
if (err){
... | javascript | function prompt(menu){
return new Promise(function(resolve, reject){
// user confirmation required!
_prompt.start();
_prompt.message = '';
_prompt.delimiter = '';
_prompt.colors = false;
_prompt.get(menu, function (err, result){
if (err){
... | [
"function",
"prompt",
"(",
"menu",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// user confirmation required!",
"_prompt",
".",
"start",
"(",
")",
";",
"_prompt",
".",
"message",
"=",
"''",
";",
"_prompt... | async prompt wrapper | [
"async",
"prompt",
"wrapper"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/prompt.js#L4-L22 |
17,529 | AndiDittrich/NodeMCU-Tool | lib/connector/device-info.js | fetchDeviceInfo | async function fetchDeviceInfo(){
// run the node.info() command
let {response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command.nodeInfo);
// replace whitespaces with single delimiter
const p = response.replace(/\s+/gi, '-').split('-');
// 8 elements found ? nodemcu on esp8266
... | javascript | async function fetchDeviceInfo(){
// run the node.info() command
let {response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command.nodeInfo);
// replace whitespaces with single delimiter
const p = response.replace(/\s+/gi, '-').split('-');
// 8 elements found ? nodemcu on esp8266
... | [
"async",
"function",
"fetchDeviceInfo",
"(",
")",
"{",
"// run the node.info() command",
"let",
"{",
"response",
"}",
"=",
"await",
"_virtualTerminal",
".",
"executeCommand",
"(",
"_luaCommandBuilder",
".",
"command",
".",
"nodeInfo",
")",
";",
"// replace whitespaces... | fetch nodemcu device info | [
"fetch",
"nodemcu",
"device",
"info"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/connector/device-info.js#L6-L52 |
17,530 | AndiDittrich/NodeMCU-Tool | lib/connector/fsinfo.js | fsinfo | async function fsinfo(){
// get file system info (size)
let {response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command.fsInfo);
// extract size (remaining, used, total)
response = response.replace(/\s+/gi, '-').split('-');
const meta = {
remaining: toKB(response[0]),
... | javascript | async function fsinfo(){
// get file system info (size)
let {response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command.fsInfo);
// extract size (remaining, used, total)
response = response.replace(/\s+/gi, '-').split('-');
const meta = {
remaining: toKB(response[0]),
... | [
"async",
"function",
"fsinfo",
"(",
")",
"{",
"// get file system info (size)",
"let",
"{",
"response",
"}",
"=",
"await",
"_virtualTerminal",
".",
"executeCommand",
"(",
"_luaCommandBuilder",
".",
"command",
".",
"fsInfo",
")",
";",
"// extract size (remaining, used,... | show filesystem information | [
"show",
"filesystem",
"information"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/connector/fsinfo.js#L9-L51 |
17,531 | AndiDittrich/NodeMCU-Tool | lib/connector/format.js | format | async function format(){
// create new filesystem
const {response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command.fsFormat);
return response;
} | javascript | async function format(){
// create new filesystem
const {response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command.fsFormat);
return response;
} | [
"async",
"function",
"format",
"(",
")",
"{",
"// create new filesystem",
"const",
"{",
"response",
"}",
"=",
"await",
"_virtualTerminal",
".",
"executeCommand",
"(",
"_luaCommandBuilder",
".",
"command",
".",
"fsFormat",
")",
";",
"return",
"response",
";",
"}"... | format the filesystem | [
"format",
"the",
"filesystem"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/connector/format.js#L5-L10 |
17,532 | AndiDittrich/NodeMCU-Tool | lib/connector/compile.js | compile | async function compile(remoteName){
// run the lua compiler/interpreter to cache the file as bytecode
const {response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.prepare('compile', [remoteName]));
return response;
} | javascript | async function compile(remoteName){
// run the lua compiler/interpreter to cache the file as bytecode
const {response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.prepare('compile', [remoteName]));
return response;
} | [
"async",
"function",
"compile",
"(",
"remoteName",
")",
"{",
"// run the lua compiler/interpreter to cache the file as bytecode",
"const",
"{",
"response",
"}",
"=",
"await",
"_virtualTerminal",
".",
"executeCommand",
"(",
"_luaCommandBuilder",
".",
"prepare",
"(",
"'comp... | compile a remote file | [
"compile",
"a",
"remote",
"file"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/connector/compile.js#L5-L10 |
17,533 | AndiDittrich/NodeMCU-Tool | lib/transport/scriptable-serial-terminal.js | onData | function onData(rawData){
// strip delimiter sequence from array
const input = rawData.toString(_encoding);
// response data object - default no response data
const data = {
echo: input,
response: null
};
// response found ? split echo and respo... | javascript | function onData(rawData){
// strip delimiter sequence from array
const input = rawData.toString(_encoding);
// response data object - default no response data
const data = {
echo: input,
response: null
};
// response found ? split echo and respo... | [
"function",
"onData",
"(",
"rawData",
")",
"{",
"// strip delimiter sequence from array",
"const",
"input",
"=",
"rawData",
".",
"toString",
"(",
"_encoding",
")",
";",
"// response data object - default no response data",
"const",
"data",
"=",
"{",
"echo",
":",
"inpu... | listen on incoming data | [
"listen",
"on",
"incoming",
"data"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/transport/scriptable-serial-terminal.js#L33-L59 |
17,534 | AndiDittrich/NodeMCU-Tool | lib/transport/scriptable-serial-terminal.js | getNextResponse | function getNextResponse(){
if (_waitingForInput !== null){
throw new Error('concurreny error - receive listener already in-queue');
}
return new Promise(function(resolve){
// data received ?
if (_inputbuffer.length > 0){
resolve(_inputbuffer.shift());
}else{
... | javascript | function getNextResponse(){
if (_waitingForInput !== null){
throw new Error('concurreny error - receive listener already in-queue');
}
return new Promise(function(resolve){
// data received ?
if (_inputbuffer.length > 0){
resolve(_inputbuffer.shift());
}else{
... | [
"function",
"getNextResponse",
"(",
")",
"{",
"if",
"(",
"_waitingForInput",
"!==",
"null",
")",
"{",
"throw",
"new",
"Error",
"(",
"'concurreny error - receive listener already in-queue'",
")",
";",
"}",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve"... | wait for next echo + response line | [
"wait",
"for",
"next",
"echo",
"+",
"response",
"line"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/transport/scriptable-serial-terminal.js#L71-L85 |
17,535 | AndiDittrich/NodeMCU-Tool | lib/transport/scriptable-serial-terminal.js | write | async function write(data){
await _serialport.write(data);
await _serialport.drain();
} | javascript | async function write(data){
await _serialport.write(data);
await _serialport.drain();
} | [
"async",
"function",
"write",
"(",
"data",
")",
"{",
"await",
"_serialport",
".",
"write",
"(",
"data",
")",
";",
"await",
"_serialport",
".",
"drain",
"(",
")",
";",
"}"
] | write data to serial port and wait for transmission complete | [
"write",
"data",
"to",
"serial",
"port",
"and",
"wait",
"for",
"transmission",
"complete"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/transport/scriptable-serial-terminal.js#L88-L91 |
17,536 | AndiDittrich/NodeMCU-Tool | lib/connector/upload.js | startTransfer | async function startTransfer(rawContent, localName, remoteName, progressCb){
// convert buffer to hex or base64
const content = rawContent.toString(_transferEncoding);
// get absolute filesize
const absoluteFilesize = content.length;
// split file content into chunks
const chunks = content.mat... | javascript | async function startTransfer(rawContent, localName, remoteName, progressCb){
// convert buffer to hex or base64
const content = rawContent.toString(_transferEncoding);
// get absolute filesize
const absoluteFilesize = content.length;
// split file content into chunks
const chunks = content.mat... | [
"async",
"function",
"startTransfer",
"(",
"rawContent",
",",
"localName",
",",
"remoteName",
",",
"progressCb",
")",
"{",
"// convert buffer to hex or base64",
"const",
"content",
"=",
"rawContent",
".",
"toString",
"(",
"_transferEncoding",
")",
";",
"// get absolut... | utility function to handle the file transfer | [
"utility",
"function",
"to",
"handle",
"the",
"file",
"transfer"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/connector/upload.js#L13-L84 |
17,537 | AndiDittrich/NodeMCU-Tool | lib/connector/upload.js | writeChunk | async function writeChunk(){
if (chunks.length > 0){
// get first element
const l = chunks.shift();
// increment size counter
currentUploadSize += l.length;
// write first element to file
try{
await _virtualTerminal.execut... | javascript | async function writeChunk(){
if (chunks.length > 0){
// get first element
const l = chunks.shift();
// increment size counter
currentUploadSize += l.length;
// write first element to file
try{
await _virtualTerminal.execut... | [
"async",
"function",
"writeChunk",
"(",
")",
"{",
"if",
"(",
"chunks",
".",
"length",
">",
"0",
")",
"{",
"// get first element",
"const",
"l",
"=",
"chunks",
".",
"shift",
"(",
")",
";",
"// increment size counter",
"currentUploadSize",
"+=",
"l",
".",
"l... | internal helper to write chunks | [
"internal",
"helper",
"to",
"write",
"chunks"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/connector/upload.js#L46-L80 |
17,538 | AndiDittrich/NodeMCU-Tool | lib/connector/upload.js | requireTransferHelper | async function requireTransferHelper(){
// hex write helper already uploaded within current session ?
// otherwise upload helper
if (_isTransferWriteHelperUploaded !== true){
let response = null;
try{
({response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command... | javascript | async function requireTransferHelper(){
// hex write helper already uploaded within current session ?
// otherwise upload helper
if (_isTransferWriteHelperUploaded !== true){
let response = null;
try{
({response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command... | [
"async",
"function",
"requireTransferHelper",
"(",
")",
"{",
"// hex write helper already uploaded within current session ?",
"// otherwise upload helper",
"if",
"(",
"_isTransferWriteHelperUploaded",
"!==",
"true",
")",
"{",
"let",
"response",
"=",
"null",
";",
"try",
"{",... | utility function to upload file transfer helper | [
"utility",
"function",
"to",
"upload",
"file",
"transfer",
"helper"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/connector/upload.js#L87-L116 |
17,539 | AndiDittrich/NodeMCU-Tool | lib/transport/serial-terminal.js | passthrough | function passthrough(devicename, baudrate, initialCommand=null){
return new Promise(function(resolve, reject){
// try to open the serial port
const _device = new _serialport(devicename, {
baudRate: parseInt(baudrate),
autoOpen: false
});
// new length parse... | javascript | function passthrough(devicename, baudrate, initialCommand=null){
return new Promise(function(resolve, reject){
// try to open the serial port
const _device = new _serialport(devicename, {
baudRate: parseInt(baudrate),
autoOpen: false
});
// new length parse... | [
"function",
"passthrough",
"(",
"devicename",
",",
"baudrate",
",",
"initialCommand",
"=",
"null",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// try to open the serial port",
"const",
"_device",
"=",
"new",
... | serial connection to stdout;stdin | [
"serial",
"connection",
"to",
"stdout",
";",
"stdin"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/transport/serial-terminal.js#L5-L62 |
17,540 | AndiDittrich/NodeMCU-Tool | bin/nodemcu-tool.js | asyncWrapper | function asyncWrapper(promise){
return function(...args){
// extract options (last argument)
_optionsManager.parse(args.pop())
// trigger command
.then(options => {
// re-merge
return promise(...args, options)
})
// tr... | javascript | function asyncWrapper(promise){
return function(...args){
// extract options (last argument)
_optionsManager.parse(args.pop())
// trigger command
.then(options => {
// re-merge
return promise(...args, options)
})
// tr... | [
"function",
"asyncWrapper",
"(",
"promise",
")",
"{",
"return",
"function",
"(",
"...",
"args",
")",
"{",
"// extract options (last argument)",
"_optionsManager",
".",
"parse",
"(",
"args",
".",
"pop",
"(",
")",
")",
"// trigger command",
".",
"then",
"(",
"op... | wrap async tasks | [
"wrap",
"async",
"tasks"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/bin/nodemcu-tool.js#L25-L57 |
17,541 | AndiDittrich/NodeMCU-Tool | lib/connector/check-connection.js | checkConnection | function checkConnection(){
return new Promise(function(resolve, reject){
// 1.5s connection timeout
const watchdog = setTimeout(function(){
// throw error
reject(new Error('Timeout, no response detected - is NodeMCU online and the Lua interpreter ready ?'));
}, 150... | javascript | function checkConnection(){
return new Promise(function(resolve, reject){
// 1.5s connection timeout
const watchdog = setTimeout(function(){
// throw error
reject(new Error('Timeout, no response detected - is NodeMCU online and the Lua interpreter ready ?'));
}, 150... | [
"function",
"checkConnection",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// 1.5s connection timeout",
"const",
"watchdog",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"// throw error",
"reject",
... | checks the node-mcu connection | [
"checks",
"the",
"node",
"-",
"mcu",
"connection"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/connector/check-connection.js#L6-L34 |
17,542 | AndiDittrich/NodeMCU-Tool | lib/connector/download.js | download | async function download(remoteName){
let response = null;
let data = null;
// transfer helper function to encode hex data
try{
({response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command.transferReadHelper));
}catch(e){
_logger.debug(e);
throw new Error('... | javascript | async function download(remoteName){
let response = null;
let data = null;
// transfer helper function to encode hex data
try{
({response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command.transferReadHelper));
}catch(e){
_logger.debug(e);
throw new Error('... | [
"async",
"function",
"download",
"(",
"remoteName",
")",
"{",
"let",
"response",
"=",
"null",
";",
"let",
"data",
"=",
"null",
";",
"// transfer helper function to encode hex data",
"try",
"{",
"(",
"{",
"response",
"}",
"=",
"await",
"_virtualTerminal",
".",
... | download a file from NodeMCU | [
"download",
"a",
"file",
"from",
"NodeMCU"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/connector/download.js#L6-L51 |
17,543 | AndiDittrich/NodeMCU-Tool | lib/connector/list-devices.js | listDevices | async function listDevices(showAll){
// get all available serial ports
const ports = (await _serialport.list()) || [];
// just pass-through
if (showAll){
return ports;
// filter by vendorIDs
}else{
return ports.filter(function(item){
//
return knownVendo... | javascript | async function listDevices(showAll){
// get all available serial ports
const ports = (await _serialport.list()) || [];
// just pass-through
if (showAll){
return ports;
// filter by vendorIDs
}else{
return ports.filter(function(item){
//
return knownVendo... | [
"async",
"function",
"listDevices",
"(",
"showAll",
")",
"{",
"// get all available serial ports",
"const",
"ports",
"=",
"(",
"await",
"_serialport",
".",
"list",
"(",
")",
")",
"||",
"[",
"]",
";",
"// just pass-through",
"if",
"(",
"showAll",
")",
"{",
"r... | show connected serial devices | [
"show",
"connected",
"serial",
"devices"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/connector/list-devices.js#L16-L30 |
17,544 | AndiDittrich/NodeMCU-Tool | lib/cli/options-manager.js | mergeOptions | function mergeOptions(...opt){
// extract default (last argument)
const result = opt.pop();
// try to find first match
while (opt.length > 0){
// extract first argument (priority)
const o = opt.shift();
// value set ?
if (typeof o !== 'un... | javascript | function mergeOptions(...opt){
// extract default (last argument)
const result = opt.pop();
// try to find first match
while (opt.length > 0){
// extract first argument (priority)
const o = opt.shift();
// value set ?
if (typeof o !== 'un... | [
"function",
"mergeOptions",
"(",
"...",
"opt",
")",
"{",
"// extract default (last argument)",
"const",
"result",
"=",
"opt",
".",
"pop",
"(",
")",
";",
"// try to find first match",
"while",
"(",
"opt",
".",
"length",
">",
"0",
")",
"{",
"// extract first argum... | utility function to merge different options cli args take presendence over config | [
"utility",
"function",
"to",
"merge",
"different",
"options",
"cli",
"args",
"take",
"presendence",
"over",
"config"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/options-manager.js#L54-L70 |
17,545 | AndiDittrich/NodeMCU-Tool | lib/cli/options-manager.js | storeOptions | async function storeOptions(options){
await _fs.writeFile(_configFilename, JSON.stringify(options, null, 4));
} | javascript | async function storeOptions(options){
await _fs.writeFile(_configFilename, JSON.stringify(options, null, 4));
} | [
"async",
"function",
"storeOptions",
"(",
"options",
")",
"{",
"await",
"_fs",
".",
"writeFile",
"(",
"_configFilename",
",",
"JSON",
".",
"stringify",
"(",
"options",
",",
"null",
",",
"4",
")",
")",
";",
"}"
] | write options to file | [
"write",
"options",
"to",
"file"
] | 93670a062d38dd65e868295b0b071be503714b7c | https://github.com/AndiDittrich/NodeMCU-Tool/blob/93670a062d38dd65e868295b0b071be503714b7c/lib/cli/options-manager.js#L107-L109 |
17,546 | Diokuz/baron | src/autoUpdate.js | startWatch | function startWatch() {
if (watcher) return
watcher = setInterval(function() {
if (self.root[self.origin.offset]) {
stopWatch()
self.update()
}
}, 300) // is it good enought for you?)
} | javascript | function startWatch() {
if (watcher) return
watcher = setInterval(function() {
if (self.root[self.origin.offset]) {
stopWatch()
self.update()
}
}, 300) // is it good enought for you?)
} | [
"function",
"startWatch",
"(",
")",
"{",
"if",
"(",
"watcher",
")",
"return",
"watcher",
"=",
"setInterval",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"self",
".",
"root",
"[",
"self",
".",
"origin",
".",
"offset",
"]",
")",
"{",
"stopWatch",
"(",
... | Set interval timeout for watching when root node will be visible | [
"Set",
"interval",
"timeout",
"for",
"watching",
"when",
"root",
"node",
"will",
"be",
"visible"
] | 2403ec98582c624da7671fff6c44b864a64caf5f | https://github.com/Diokuz/baron/blob/2403ec98582c624da7671fff6c44b864a64caf5f/src/autoUpdate.js#L22-L31 |
17,547 | Diokuz/baron | src/core.js | baron | function baron(user) {
var withParams = !!user
var tryNode = (user && user[0]) || user
var isNode = typeof user == 'string' || tryNode instanceof HTMLElement
var params = isNode ? { root: user } : clone(user)
var jQueryMode
var rootNode
var defaultParams = {
direction: 'v',
b... | javascript | function baron(user) {
var withParams = !!user
var tryNode = (user && user[0]) || user
var isNode = typeof user == 'string' || tryNode instanceof HTMLElement
var params = isNode ? { root: user } : clone(user)
var jQueryMode
var rootNode
var defaultParams = {
direction: 'v',
b... | [
"function",
"baron",
"(",
"user",
")",
"{",
"var",
"withParams",
"=",
"!",
"!",
"user",
"var",
"tryNode",
"=",
"(",
"user",
"&&",
"user",
"[",
"0",
"]",
")",
"||",
"user",
"var",
"isNode",
"=",
"typeof",
"user",
"==",
"'string'",
"||",
"tryNode",
"... | window.baron and jQuery.fn.baron points to this function | [
"window",
".",
"baron",
"and",
"jQuery",
".",
"fn",
".",
"baron",
"points",
"to",
"this",
"function"
] | 2403ec98582c624da7671fff6c44b864a64caf5f | https://github.com/Diokuz/baron/blob/2403ec98582c624da7671fff6c44b864a64caf5f/src/core.js#L61-L160 |
17,548 | Diokuz/baron | src/core.js | manageAttr | function manageAttr(node, direction, mode, id) {
var attrName = 'data-baron-' + direction + '-id'
if (mode == 'on') {
node.setAttribute(attrName, id)
} else if (mode == 'off') {
node.removeAttribute(attrName)
}
return node.getAttribute(attrName)
} | javascript | function manageAttr(node, direction, mode, id) {
var attrName = 'data-baron-' + direction + '-id'
if (mode == 'on') {
node.setAttribute(attrName, id)
} else if (mode == 'off') {
node.removeAttribute(attrName)
}
return node.getAttribute(attrName)
} | [
"function",
"manageAttr",
"(",
"node",
",",
"direction",
",",
"mode",
",",
"id",
")",
"{",
"var",
"attrName",
"=",
"'data-baron-'",
"+",
"direction",
"+",
"'-id'",
"if",
"(",
"mode",
"==",
"'on'",
")",
"{",
"node",
".",
"setAttribute",
"(",
"attrName",
... | set, remove or read baron-specific id-attribute @returns {String|null} - id node value, or null, if there is no attr | [
"set",
"remove",
"or",
"read",
"baron",
"-",
"specific",
"id",
"-",
"attribute"
] | 2403ec98582c624da7671fff6c44b864a64caf5f | https://github.com/Diokuz/baron/blob/2403ec98582c624da7671fff6c44b864a64caf5f/src/core.js#L326-L336 |
17,549 | Diokuz/baron | src/core.js | function(func, wait) {
var self = this,
timeout,
// args, // right now there is no need for arguments
// context, // and for context
timestamp
// result // and for result
var later = function() {
if (self._disposed) {
... | javascript | function(func, wait) {
var self = this,
timeout,
// args, // right now there is no need for arguments
// context, // and for context
timestamp
// result // and for result
var later = function() {
if (self._disposed) {
... | [
"function",
"(",
"func",
",",
"wait",
")",
"{",
"var",
"self",
"=",
"this",
",",
"timeout",
",",
"// args, // right now there is no need for arguments",
"// context, // and for context",
"timestamp",
"// result // and for result",
"var",
"later",
"=",
"function",
"(",
"... | underscore.js realization used in autoUpdate plugin | [
"underscore",
".",
"js",
"realization",
"used",
"in",
"autoUpdate",
"plugin"
] | 2403ec98582c624da7671fff6c44b864a64caf5f | https://github.com/Diokuz/baron/blob/2403ec98582c624da7671fff6c44b864a64caf5f/src/core.js#L385-L423 | |
17,550 | Diokuz/baron | src/core.js | setBarSize | function setBarSize(_size) {
var barMinSize = this.barMinSize || 20
var size = _size
if (size > 0 && size < barMinSize) {
size = barMinSize
}
if (this.bar) {
css(this.bar, this.origin.size, parseInt(size, 10) + 'px')
... | javascript | function setBarSize(_size) {
var barMinSize = this.barMinSize || 20
var size = _size
if (size > 0 && size < barMinSize) {
size = barMinSize
}
if (this.bar) {
css(this.bar, this.origin.size, parseInt(size, 10) + 'px')
... | [
"function",
"setBarSize",
"(",
"_size",
")",
"{",
"var",
"barMinSize",
"=",
"this",
".",
"barMinSize",
"||",
"20",
"var",
"size",
"=",
"_size",
"if",
"(",
"size",
">",
"0",
"&&",
"size",
"<",
"barMinSize",
")",
"{",
"size",
"=",
"barMinSize",
"}",
"i... | Updating height or width of bar | [
"Updating",
"height",
"or",
"width",
"of",
"bar"
] | 2403ec98582c624da7671fff6c44b864a64caf5f | https://github.com/Diokuz/baron/blob/2403ec98582c624da7671fff6c44b864a64caf5f/src/core.js#L472-L483 |
17,551 | Diokuz/baron | src/core.js | posBar | function posBar(_pos) {
if (this.bar) {
var was = css(this.bar, this.origin.pos),
will = +_pos + 'px'
if (will && will != was) {
css(this.bar, this.origin.pos, will)
}
}
} | javascript | function posBar(_pos) {
if (this.bar) {
var was = css(this.bar, this.origin.pos),
will = +_pos + 'px'
if (will && will != was) {
css(this.bar, this.origin.pos, will)
}
}
} | [
"function",
"posBar",
"(",
"_pos",
")",
"{",
"if",
"(",
"this",
".",
"bar",
")",
"{",
"var",
"was",
"=",
"css",
"(",
"this",
".",
"bar",
",",
"this",
".",
"origin",
".",
"pos",
")",
",",
"will",
"=",
"+",
"_pos",
"+",
"'px'",
"if",
"(",
"will... | Updating top or left bar position | [
"Updating",
"top",
"or",
"left",
"bar",
"position"
] | 2403ec98582c624da7671fff6c44b864a64caf5f | https://github.com/Diokuz/baron/blob/2403ec98582c624da7671fff6c44b864a64caf5f/src/core.js#L486-L495 |
17,552 | Diokuz/baron | src/core.js | function(params) {
if (process.env.NODE_ENV !== 'production') {
if (this._disposed) {
log('error', [
'Update on disposed baron instance detected.',
'You should clear your stored baron value for this instance:',
this
... | javascript | function(params) {
if (process.env.NODE_ENV !== 'production') {
if (this._disposed) {
log('error', [
'Update on disposed baron instance detected.',
'You should clear your stored baron value for this instance:',
this
... | [
"function",
"(",
"params",
")",
"{",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
")",
"{",
"if",
"(",
"this",
".",
"_disposed",
")",
"{",
"log",
"(",
"'error'",
",",
"[",
"'Update on disposed baron instance detected.'",
",",
"... | fires on any update and on init | [
"fires",
"on",
"any",
"update",
"and",
"on",
"init"
] | 2403ec98582c624da7671fff6c44b864a64caf5f | https://github.com/Diokuz/baron/blob/2403ec98582c624da7671fff6c44b864a64caf5f/src/core.js#L790-L807 | |
17,553 | HelloFax/hellosign-nodejs-sdk | lib/HelloSignResource.js | HelloSignResource | function HelloSignResource(hellosign, urlData) {
this._hellosign = hellosign;
this._urlData = urlData || {};
this.basePath = utils.makeURLInterpolator(hellosign.getApiField('basePath'));
this.path = utils.makeURLInterpolator(this.path);
if (this.includeBasic) {
this.includeBasic.forEach(f... | javascript | function HelloSignResource(hellosign, urlData) {
this._hellosign = hellosign;
this._urlData = urlData || {};
this.basePath = utils.makeURLInterpolator(hellosign.getApiField('basePath'));
this.path = utils.makeURLInterpolator(this.path);
if (this.includeBasic) {
this.includeBasic.forEach(f... | [
"function",
"HelloSignResource",
"(",
"hellosign",
",",
"urlData",
")",
"{",
"this",
".",
"_hellosign",
"=",
"hellosign",
";",
"this",
".",
"_urlData",
"=",
"urlData",
"||",
"{",
"}",
";",
"this",
".",
"basePath",
"=",
"utils",
".",
"makeURLInterpolator",
... | Encapsulates request logic for a HelloSign Resource | [
"Encapsulates",
"request",
"logic",
"for",
"a",
"HelloSign",
"Resource"
] | 5ab3e27896986602fa9613ccb3e7d2997f02539a | https://github.com/HelloFax/hellosign-nodejs-sdk/blob/5ab3e27896986602fa9613ccb3e7d2997f02539a/lib/HelloSignResource.js#L49-L65 |
17,554 | silas/node-consul | lib/agent.js | Agent | function Agent(consul) {
this.consul = consul;
this.check = new Agent.Check(consul);
this.service = new Agent.Service(consul);
} | javascript | function Agent(consul) {
this.consul = consul;
this.check = new Agent.Check(consul);
this.service = new Agent.Service(consul);
} | [
"function",
"Agent",
"(",
"consul",
")",
"{",
"this",
".",
"consul",
"=",
"consul",
";",
"this",
".",
"check",
"=",
"new",
"Agent",
".",
"Check",
"(",
"consul",
")",
";",
"this",
".",
"service",
"=",
"new",
"Agent",
".",
"Service",
"(",
"consul",
"... | Initialize a new `Agent` client. | [
"Initialize",
"a",
"new",
"Agent",
"client",
"."
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/agent.js#L20-L24 |
17,555 | silas/node-consul | lib/lock.js | Lock | function Lock(consul, opts) {
events.EventEmitter.call(this);
opts = utils.normalizeKeys(opts);
this.consul = consul;
this._opts = opts;
this._defaults = utils.defaultCommonOptions(opts);
if (opts.session) {
switch (typeof opts.session) {
case 'string':
opts.session = { id: opts.session... | javascript | function Lock(consul, opts) {
events.EventEmitter.call(this);
opts = utils.normalizeKeys(opts);
this.consul = consul;
this._opts = opts;
this._defaults = utils.defaultCommonOptions(opts);
if (opts.session) {
switch (typeof opts.session) {
case 'string':
opts.session = { id: opts.session... | [
"function",
"Lock",
"(",
"consul",
",",
"opts",
")",
"{",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"opts",
"=",
"utils",
".",
"normalizeKeys",
"(",
"opts",
")",
";",
"this",
".",
"consul",
"=",
"consul",
";",
"this",
".",
... | Initialize a new `Lock` instance. | [
"Initialize",
"a",
"new",
"Lock",
"instance",
"."
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/lock.js#L34-L63 |
17,556 | silas/node-consul | lib/utils.js | bodyItem | function bodyItem(request, next) {
if (request.err) return next(false, request.err, undefined, request.res);
if (request.res.body && request.res.body.length) {
return next(false, undefined, request.res.body[0], request.res);
}
next(false, undefined, undefined, request.res);
} | javascript | function bodyItem(request, next) {
if (request.err) return next(false, request.err, undefined, request.res);
if (request.res.body && request.res.body.length) {
return next(false, undefined, request.res.body[0], request.res);
}
next(false, undefined, undefined, request.res);
} | [
"function",
"bodyItem",
"(",
"request",
",",
"next",
")",
"{",
"if",
"(",
"request",
".",
"err",
")",
"return",
"next",
"(",
"false",
",",
"request",
".",
"err",
",",
"undefined",
",",
"request",
".",
"res",
")",
";",
"if",
"(",
"request",
".",
"re... | First item in body | [
"First",
"item",
"in",
"body"
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/utils.js#L27-L35 |
17,557 | silas/node-consul | lib/utils.js | defaultCommonOptions | function defaultCommonOptions(opts) {
opts = normalizeKeys(opts);
var defaults;
constants.DEFAULT_OPTIONS.forEach(function(key) {
if (!opts.hasOwnProperty(key)) return;
if (!defaults) defaults = {};
defaults[key] = opts[key];
});
return defaults;
} | javascript | function defaultCommonOptions(opts) {
opts = normalizeKeys(opts);
var defaults;
constants.DEFAULT_OPTIONS.forEach(function(key) {
if (!opts.hasOwnProperty(key)) return;
if (!defaults) defaults = {};
defaults[key] = opts[key];
});
return defaults;
} | [
"function",
"defaultCommonOptions",
"(",
"opts",
")",
"{",
"opts",
"=",
"normalizeKeys",
"(",
"opts",
")",
";",
"var",
"defaults",
";",
"constants",
".",
"DEFAULT_OPTIONS",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"!",
"opts",
".... | Default common options | [
"Default",
"common",
"options"
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/utils.js#L160-L171 |
17,558 | silas/node-consul | lib/utils.js | setTimeoutContext | function setTimeoutContext(fn, ctx, timeout) {
var id;
var cancel = function() {
clearTimeout(id);
};
id = setTimeout(function() {
ctx.removeListener('cancel', cancel);
fn();
}, timeout);
ctx.once('cancel', cancel);
} | javascript | function setTimeoutContext(fn, ctx, timeout) {
var id;
var cancel = function() {
clearTimeout(id);
};
id = setTimeout(function() {
ctx.removeListener('cancel', cancel);
fn();
}, timeout);
ctx.once('cancel', cancel);
} | [
"function",
"setTimeoutContext",
"(",
"fn",
",",
"ctx",
",",
"timeout",
")",
"{",
"var",
"id",
";",
"var",
"cancel",
"=",
"function",
"(",
")",
"{",
"clearTimeout",
"(",
"id",
")",
";",
"}",
";",
"id",
"=",
"setTimeout",
"(",
"function",
"(",
")",
... | Set timeout with cancel support | [
"Set",
"timeout",
"with",
"cancel",
"support"
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/utils.js#L204-L218 |
17,559 | silas/node-consul | lib/utils.js | setIntervalContext | function setIntervalContext(fn, ctx, timeout) {
var id;
var cancel = function() {
clearInterval(id);
};
id = setInterval(function() { fn(); }, timeout);
ctx.once('cancel', cancel);
} | javascript | function setIntervalContext(fn, ctx, timeout) {
var id;
var cancel = function() {
clearInterval(id);
};
id = setInterval(function() { fn(); }, timeout);
ctx.once('cancel', cancel);
} | [
"function",
"setIntervalContext",
"(",
"fn",
",",
"ctx",
",",
"timeout",
")",
"{",
"var",
"id",
";",
"var",
"cancel",
"=",
"function",
"(",
")",
"{",
"clearInterval",
"(",
"id",
")",
";",
"}",
";",
"id",
"=",
"setInterval",
"(",
"function",
"(",
")",... | Set interval with cancel support | [
"Set",
"interval",
"with",
"cancel",
"support"
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/utils.js#L224-L234 |
17,560 | silas/node-consul | lib/utils.js | hasIndexChanged | function hasIndexChanged(index, prevIndex) {
if (typeof index !== 'string' || !index) return false;
if (typeof prevIndex !== 'string' || !prevIndex) return true;
return index !== prevIndex;
} | javascript | function hasIndexChanged(index, prevIndex) {
if (typeof index !== 'string' || !index) return false;
if (typeof prevIndex !== 'string' || !prevIndex) return true;
return index !== prevIndex;
} | [
"function",
"hasIndexChanged",
"(",
"index",
",",
"prevIndex",
")",
"{",
"if",
"(",
"typeof",
"index",
"!==",
"'string'",
"||",
"!",
"index",
")",
"return",
"false",
";",
"if",
"(",
"typeof",
"prevIndex",
"!==",
"'string'",
"||",
"!",
"prevIndex",
")",
"... | Has the Consul index changed. | [
"Has",
"the",
"Consul",
"index",
"changed",
"."
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/utils.js#L316-L320 |
17,561 | silas/node-consul | lib/utils.js | parseQueryMeta | function parseQueryMeta(res) {
var meta = {};
if (res && res.headers) {
if (res.headers['x-consul-index']) {
meta.LastIndex = res.headers['x-consul-index'];
}
if (res.headers['x-consul-lastcontact']) {
meta.LastContact = parseInt(res.headers['x-consul-lastcontact'], 10);
}
if (res.h... | javascript | function parseQueryMeta(res) {
var meta = {};
if (res && res.headers) {
if (res.headers['x-consul-index']) {
meta.LastIndex = res.headers['x-consul-index'];
}
if (res.headers['x-consul-lastcontact']) {
meta.LastContact = parseInt(res.headers['x-consul-lastcontact'], 10);
}
if (res.h... | [
"function",
"parseQueryMeta",
"(",
"res",
")",
"{",
"var",
"meta",
"=",
"{",
"}",
";",
"if",
"(",
"res",
"&&",
"res",
".",
"headers",
")",
"{",
"if",
"(",
"res",
".",
"headers",
"[",
"'x-consul-index'",
"]",
")",
"{",
"meta",
".",
"LastIndex",
"=",... | Parse query meta | [
"Parse",
"query",
"meta"
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/utils.js#L326-L345 |
17,562 | silas/node-consul | lib/catalog.js | Catalog | function Catalog(consul) {
this.consul = consul;
this.connect = new Catalog.Connect(consul);
this.node = new Catalog.Node(consul);
this.service = new Catalog.Service(consul);
} | javascript | function Catalog(consul) {
this.consul = consul;
this.connect = new Catalog.Connect(consul);
this.node = new Catalog.Node(consul);
this.service = new Catalog.Service(consul);
} | [
"function",
"Catalog",
"(",
"consul",
")",
"{",
"this",
".",
"consul",
"=",
"consul",
";",
"this",
".",
"connect",
"=",
"new",
"Catalog",
".",
"Connect",
"(",
"consul",
")",
";",
"this",
".",
"node",
"=",
"new",
"Catalog",
".",
"Node",
"(",
"consul",... | Initialize a new `Catalog` client. | [
"Initialize",
"a",
"new",
"Catalog",
"client",
"."
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/catalog.js#L20-L25 |
17,563 | silas/node-consul | lib/consul.js | Consul | function Consul(opts) {
if (!(this instanceof Consul)) {
return new Consul(opts);
}
opts = utils.defaults({}, opts);
if (!opts.baseUrl) {
opts.baseUrl = (opts.secure ? 'https:' : 'http:') + '//' +
(opts.host || '127.0.0.1') + ':' +
(opts.port || 8500) + '/v1';
}
opts.name = 'consul';
... | javascript | function Consul(opts) {
if (!(this instanceof Consul)) {
return new Consul(opts);
}
opts = utils.defaults({}, opts);
if (!opts.baseUrl) {
opts.baseUrl = (opts.secure ? 'https:' : 'http:') + '//' +
(opts.host || '127.0.0.1') + ':' +
(opts.port || 8500) + '/v1';
}
opts.name = 'consul';
... | [
"function",
"Consul",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Consul",
")",
")",
"{",
"return",
"new",
"Consul",
"(",
"opts",
")",
";",
"}",
"opts",
"=",
"utils",
".",
"defaults",
"(",
"{",
"}",
",",
"opts",
")",
";",
... | Initialize a new `Consul` client. | [
"Initialize",
"a",
"new",
"Consul",
"client",
"."
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/consul.js#L31-L76 |
17,564 | silas/node-consul | lib/watch.js | Watch | function Watch(consul, opts) {
var self = this;
events.EventEmitter.call(self);
opts = utils.normalizeKeys(opts);
var options = utils.normalizeKeys(opts.options || {});
options = utils.defaults(options, consul._defaults);
options.wait = options.wait || '30s';
options.index = options.index || '0';
if... | javascript | function Watch(consul, opts) {
var self = this;
events.EventEmitter.call(self);
opts = utils.normalizeKeys(opts);
var options = utils.normalizeKeys(opts.options || {});
options = utils.defaults(options, consul._defaults);
options.wait = options.wait || '30s';
options.index = options.index || '0';
if... | [
"function",
"Watch",
"(",
"consul",
",",
"opts",
")",
"{",
"var",
"self",
"=",
"this",
";",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"self",
")",
";",
"opts",
"=",
"utils",
".",
"normalizeKeys",
"(",
"opts",
")",
";",
"var",
"options",
"=",
... | Initialize a new `Watch` instance. | [
"Initialize",
"a",
"new",
"Watch",
"instance",
"."
] | d009af5b05a1543fa7bd7aa58a6325d1aae93308 | https://github.com/silas/node-consul/blob/d009af5b05a1543fa7bd7aa58a6325d1aae93308/lib/watch.js#L21-L67 |
17,565 | pbojinov/request-ip | src/index.js | getClientIpFromXForwardedFor | function getClientIpFromXForwardedFor(value) {
if (!is.existy(value)) {
return null;
}
if (is.not.string(value)) {
throw new TypeError(`Expected a string, got "${typeof value}"`);
}
// x-forwarded-for may return multiple IP addresses in the format:
// "client IP, proxy 1 IP, pr... | javascript | function getClientIpFromXForwardedFor(value) {
if (!is.existy(value)) {
return null;
}
if (is.not.string(value)) {
throw new TypeError(`Expected a string, got "${typeof value}"`);
}
// x-forwarded-for may return multiple IP addresses in the format:
// "client IP, proxy 1 IP, pr... | [
"function",
"getClientIpFromXForwardedFor",
"(",
"value",
")",
"{",
"if",
"(",
"!",
"is",
".",
"existy",
"(",
"value",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is",
".",
"not",
".",
"string",
"(",
"value",
")",
")",
"{",
"throw",
"new... | Parse x-forwarded-for headers.
@param {string} value - The value to be parsed.
@return {string|null} First known IP address, if any. | [
"Parse",
"x",
"-",
"forwarded",
"-",
"for",
"headers",
"."
] | 915d984b46d262e4418a889abc7601c38d47f049 | https://github.com/pbojinov/request-ip/blob/915d984b46d262e4418a889abc7601c38d47f049/src/index.js#L9-L40 |
17,566 | pbojinov/request-ip | src/index.js | getClientIp | function getClientIp(req) {
// Server is probably behind a proxy.
if (req.headers) {
// Standard headers used by Amazon EC2, Heroku, and others.
if (is.ip(req.headers['x-client-ip'])) {
return req.headers['x-client-ip'];
}
// Load-balancers (AWS ELB) or pro... | javascript | function getClientIp(req) {
// Server is probably behind a proxy.
if (req.headers) {
// Standard headers used by Amazon EC2, Heroku, and others.
if (is.ip(req.headers['x-client-ip'])) {
return req.headers['x-client-ip'];
}
// Load-balancers (AWS ELB) or pro... | [
"function",
"getClientIp",
"(",
"req",
")",
"{",
"// Server is probably behind a proxy.",
"if",
"(",
"req",
".",
"headers",
")",
"{",
"// Standard headers used by Amazon EC2, Heroku, and others.",
"if",
"(",
"is",
".",
"ip",
"(",
"req",
".",
"headers",
"[",
"'x-clie... | Determine client IP address.
@param req
@returns {string} ip - The IP address if known, defaulting to empty string if unknown. | [
"Determine",
"client",
"IP",
"address",
"."
] | 915d984b46d262e4418a889abc7601c38d47f049 | https://github.com/pbojinov/request-ip/blob/915d984b46d262e4418a889abc7601c38d47f049/src/index.js#L48-L130 |
17,567 | pbojinov/request-ip | src/index.js | mw | function mw(options) {
// Defaults.
const configuration = is.not.existy(options) ? {} : options;
// Validation.
if (is.not.object(configuration)) {
throw new TypeError('Options must be an object!');
}
const attributeName = configuration.attributeName || 'clientIp';
return (req, res... | javascript | function mw(options) {
// Defaults.
const configuration = is.not.existy(options) ? {} : options;
// Validation.
if (is.not.object(configuration)) {
throw new TypeError('Options must be an object!');
}
const attributeName = configuration.attributeName || 'clientIp';
return (req, res... | [
"function",
"mw",
"(",
"options",
")",
"{",
"// Defaults.",
"const",
"configuration",
"=",
"is",
".",
"not",
".",
"existy",
"(",
"options",
")",
"?",
"{",
"}",
":",
"options",
";",
"// Validation.",
"if",
"(",
"is",
".",
"not",
".",
"object",
"(",
"c... | Expose request IP as a middleware.
@param {object} [options] - Configuration.
@param {string} [options.attributeName] - Name of attribute to augment request object with.
@return {*} | [
"Expose",
"request",
"IP",
"as",
"a",
"middleware",
"."
] | 915d984b46d262e4418a889abc7601c38d47f049 | https://github.com/pbojinov/request-ip/blob/915d984b46d262e4418a889abc7601c38d47f049/src/index.js#L139-L157 |
17,568 | anandthakker/doiuse | src/missing-support.js | missingSupport | function missingSupport (browserRequest, from) {
const browsers = new BrowserSelection(browserRequest, from)
let result = {}
Object.keys(features).forEach(function (feature) {
const featureData = caniuse.feature(caniuse.features[feature])
const lackData = filterStats(browsers, featureData.stats)
cons... | javascript | function missingSupport (browserRequest, from) {
const browsers = new BrowserSelection(browserRequest, from)
let result = {}
Object.keys(features).forEach(function (feature) {
const featureData = caniuse.feature(caniuse.features[feature])
const lackData = filterStats(browsers, featureData.stats)
cons... | [
"function",
"missingSupport",
"(",
"browserRequest",
",",
"from",
")",
"{",
"const",
"browsers",
"=",
"new",
"BrowserSelection",
"(",
"browserRequest",
",",
"from",
")",
"let",
"result",
"=",
"{",
"}",
"Object",
".",
"keys",
"(",
"features",
")",
".",
"for... | Get data on CSS features not supported by the given autoprefixer-like
browser selection.
@returns `{browsers, features}`, where `features` is an array of:
```
{
'feature-name': {
title: 'Title of feature'
missing: "IE (8), Chrome (31)"
missingData: {
// map of browser -> version -> (lack of)support code
ie: { '8': 'n'... | [
"Get",
"data",
"on",
"CSS",
"features",
"not",
"supported",
"by",
"the",
"given",
"autoprefixer",
"-",
"like",
"browser",
"selection",
"."
] | 7525e72dbc86914600e96710c1a5c34b8cb3f8ac | https://github.com/anandthakker/doiuse/blob/7525e72dbc86914600e96710c1a5c34b8cb3f8ac/src/missing-support.js#L76-L109 |
17,569 | joewalnes/filtrex | filtrex.js | removeErrorRecovery | function removeErrorRecovery (fn) {
var parseFn = String(fn);
try {
var JSONSelect = require("JSONSelect");
var Reflect = require("reflect");
var ast = Reflect.parse(parseFn);
var labeled = JSONSelect.match(':has(:root > .label > .name:val("_handle_error"))', ast);
label... | javascript | function removeErrorRecovery (fn) {
var parseFn = String(fn);
try {
var JSONSelect = require("JSONSelect");
var Reflect = require("reflect");
var ast = Reflect.parse(parseFn);
var labeled = JSONSelect.match(':has(:root > .label > .name:val("_handle_error"))', ast);
label... | [
"function",
"removeErrorRecovery",
"(",
"fn",
")",
"{",
"var",
"parseFn",
"=",
"String",
"(",
"fn",
")",
";",
"try",
"{",
"var",
"JSONSelect",
"=",
"require",
"(",
"\"JSONSelect\"",
")",
";",
"var",
"Reflect",
"=",
"require",
"(",
"\"reflect\"",
")",
";"... | returns parse function without error recovery code | [
"returns",
"parse",
"function",
"without",
"error",
"recovery",
"code"
] | 685f5796211353623269de02b43bb6bc68e556a0 | https://github.com/joewalnes/filtrex/blob/685f5796211353623269de02b43bb6bc68e556a0/filtrex.js#L1178-L1192 |
17,570 | joewalnes/filtrex | filtrex.js | layerMethod | function layerMethod(k, fun) {
var pos = k.match(position)[0],
key = k.replace(position, ''),
prop = this[key];
if (pos === 'after') {
this[key] = function () {
var ret = prop.apply(this, arguments);
var args = [].slice.call(arguments);
args.splice(0,... | javascript | function layerMethod(k, fun) {
var pos = k.match(position)[0],
key = k.replace(position, ''),
prop = this[key];
if (pos === 'after') {
this[key] = function () {
var ret = prop.apply(this, arguments);
var args = [].slice.call(arguments);
args.splice(0,... | [
"function",
"layerMethod",
"(",
"k",
",",
"fun",
")",
"{",
"var",
"pos",
"=",
"k",
".",
"match",
"(",
"position",
")",
"[",
"0",
"]",
",",
"key",
"=",
"k",
".",
"replace",
"(",
"position",
",",
"''",
")",
",",
"prop",
"=",
"this",
"[",
"key",
... | basic method layering always returns original method's return value | [
"basic",
"method",
"layering",
"always",
"returns",
"original",
"method",
"s",
"return",
"value"
] | 685f5796211353623269de02b43bb6bc68e556a0 | https://github.com/joewalnes/filtrex/blob/685f5796211353623269de02b43bb6bc68e556a0/filtrex.js#L2392-L2412 |
17,571 | joewalnes/filtrex | filtrex.js | typal_construct | function typal_construct() {
var o = typal_mix.apply(create(this), arguments);
var constructor = o.constructor;
var Klass = o.constructor = function () { return constructor.apply(this, arguments); };
Klass.prototype = o;
Klass.mix = typal_mix; // allow for easy singleton property... | javascript | function typal_construct() {
var o = typal_mix.apply(create(this), arguments);
var constructor = o.constructor;
var Klass = o.constructor = function () { return constructor.apply(this, arguments); };
Klass.prototype = o;
Klass.mix = typal_mix; // allow for easy singleton property... | [
"function",
"typal_construct",
"(",
")",
"{",
"var",
"o",
"=",
"typal_mix",
".",
"apply",
"(",
"create",
"(",
"this",
")",
",",
"arguments",
")",
";",
"var",
"constructor",
"=",
"o",
".",
"constructor",
";",
"var",
"Klass",
"=",
"o",
".",
"constructor"... | Creates a new Class function based on an object with a constructor method | [
"Creates",
"a",
"new",
"Class",
"function",
"based",
"on",
"an",
"object",
"with",
"a",
"constructor",
"method"
] | 685f5796211353623269de02b43bb6bc68e556a0 | https://github.com/joewalnes/filtrex/blob/685f5796211353623269de02b43bb6bc68e556a0/filtrex.js#L2450-L2457 |
17,572 | joewalnes/filtrex | example/highlight.js | buildTable | function buildTable(tbody, data) {
tbody.empty();
data.forEach(function(item) {
var row = $('<tr>').appendTo(tbody);
$('<td>').appendTo(row).text(item.price);
$('<td>').appendTo(row).text(item.weight);
$('<td>').appendTo(row).text(item.taste);
// Associate underlying data with row node so we ca... | javascript | function buildTable(tbody, data) {
tbody.empty();
data.forEach(function(item) {
var row = $('<tr>').appendTo(tbody);
$('<td>').appendTo(row).text(item.price);
$('<td>').appendTo(row).text(item.weight);
$('<td>').appendTo(row).text(item.taste);
// Associate underlying data with row node so we ca... | [
"function",
"buildTable",
"(",
"tbody",
",",
"data",
")",
"{",
"tbody",
".",
"empty",
"(",
")",
";",
"data",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"var",
"row",
"=",
"$",
"(",
"'<tr>'",
")",
".",
"appendTo",
"(",
"tbody",
")",
"... | Build table on page with items. | [
"Build",
"table",
"on",
"page",
"with",
"items",
"."
] | 685f5796211353623269de02b43bb6bc68e556a0 | https://github.com/joewalnes/filtrex/blob/685f5796211353623269de02b43bb6bc68e556a0/example/highlight.js#L27-L39 |
17,573 | joewalnes/filtrex | example/highlight.js | updateExpression | function updateExpression() {
// Default highlighter will not highlight anything
var nullHighlighter = function(item) { return false; }
var input = $('.expression');
var expression = input.val();
var highlighter;
if (!expression) {
// No expression specified. Don't highlight anything.
highlighter... | javascript | function updateExpression() {
// Default highlighter will not highlight anything
var nullHighlighter = function(item) { return false; }
var input = $('.expression');
var expression = input.val();
var highlighter;
if (!expression) {
// No expression specified. Don't highlight anything.
highlighter... | [
"function",
"updateExpression",
"(",
")",
"{",
"// Default highlighter will not highlight anything",
"var",
"nullHighlighter",
"=",
"function",
"(",
"item",
")",
"{",
"return",
"false",
";",
"}",
"var",
"input",
"=",
"$",
"(",
"'.expression'",
")",
";",
"var",
"... | When user entered expression changes, attempt to parse it
and apply highlights to rows that match filter. | [
"When",
"user",
"entered",
"expression",
"changes",
"attempt",
"to",
"parse",
"it",
"and",
"apply",
"highlights",
"to",
"rows",
"that",
"match",
"filter",
"."
] | 685f5796211353623269de02b43bb6bc68e556a0 | https://github.com/joewalnes/filtrex/blob/685f5796211353623269de02b43bb6bc68e556a0/example/highlight.js#L45-L71 |
17,574 | kristerkari/stylelint-scss | src/utils/sassValueParser/index.js | isInsideFunctionCall | function isInsideFunctionCall(string, index) {
const result = { is: false, fn: null };
const before = string.substring(0, index).trim();
const after = string.substring(index + 1).trim();
const beforeMatch = before.match(/([a-zA-Z_-][a-zA-Z0-9_-]*)\([^(){},]+$/);
if (beforeMatch && beforeMatch[0] && after.sea... | javascript | function isInsideFunctionCall(string, index) {
const result = { is: false, fn: null };
const before = string.substring(0, index).trim();
const after = string.substring(index + 1).trim();
const beforeMatch = before.match(/([a-zA-Z_-][a-zA-Z0-9_-]*)\([^(){},]+$/);
if (beforeMatch && beforeMatch[0] && after.sea... | [
"function",
"isInsideFunctionCall",
"(",
"string",
",",
"index",
")",
"{",
"const",
"result",
"=",
"{",
"is",
":",
"false",
",",
"fn",
":",
"null",
"}",
";",
"const",
"before",
"=",
"string",
".",
"substring",
"(",
"0",
",",
"index",
")",
".",
"trim"... | Checks if the character is inside a function agruments
@param {String} string - the input string
@param {Number} index - current character index
@return {Object} return
{Boolean} return.is - if inside a function arguments
{String} return.fn - function name | [
"Checks",
"if",
"the",
"character",
"is",
"inside",
"a",
"function",
"agruments"
] | c8a0f2ff85a588424b02a154be3811b16029ecc0 | https://github.com/kristerkari/stylelint-scss/blob/c8a0f2ff85a588424b02a154be3811b16029ecc0/src/utils/sassValueParser/index.js#L690-L702 |
17,575 | kristerkari/stylelint-scss | src/utils/sassValueParser/index.js | isStringBefore | function isStringBefore(before) {
const result = { is: false, opsBetween: false };
const stringOpsClipped = before.replace(/(\s*[+/*%]|\s+-)+$/, "");
if (stringOpsClipped !== before) {
result.opsBetween = true;
}
// If it is quoted
if (
stringOpsClipped[stringOpsClipped.length - 1] === '"' ||
... | javascript | function isStringBefore(before) {
const result = { is: false, opsBetween: false };
const stringOpsClipped = before.replace(/(\s*[+/*%]|\s+-)+$/, "");
if (stringOpsClipped !== before) {
result.opsBetween = true;
}
// If it is quoted
if (
stringOpsClipped[stringOpsClipped.length - 1] === '"' ||
... | [
"function",
"isStringBefore",
"(",
"before",
")",
"{",
"const",
"result",
"=",
"{",
"is",
":",
"false",
",",
"opsBetween",
":",
"false",
"}",
";",
"const",
"stringOpsClipped",
"=",
"before",
".",
"replace",
"(",
"/",
"(\\s*[+/*%]|\\s+-)+$",
"/",
",",
"\"\"... | Checks if there is a string before the character.
Also checks if there is a math operator in between
@param {String} before - the input string that preceses the character
@return {Object} return
{Boolean} return.is - if there is a string
{String} return.opsBetween - if there are operators in between | [
"Checks",
"if",
"there",
"is",
"a",
"string",
"before",
"the",
"character",
".",
"Also",
"checks",
"if",
"there",
"is",
"a",
"math",
"operator",
"in",
"between"
] | c8a0f2ff85a588424b02a154be3811b16029ecc0 | https://github.com/kristerkari/stylelint-scss/blob/c8a0f2ff85a588424b02a154be3811b16029ecc0/src/utils/sassValueParser/index.js#L713-L737 |
17,576 | kristerkari/stylelint-scss | src/utils/sassValueParser/index.js | isInterpolationBefore | function isInterpolationBefore(before) {
const result = { is: false, opsBetween: false };
// Removing preceding operators if any
const beforeOpsClipped = before.replace(/(\s*[+/*%-])+$/, "");
if (beforeOpsClipped !== before) {
result.opsBetween = true;
}
if (beforeOpsClipped[beforeOpsClipped.length - ... | javascript | function isInterpolationBefore(before) {
const result = { is: false, opsBetween: false };
// Removing preceding operators if any
const beforeOpsClipped = before.replace(/(\s*[+/*%-])+$/, "");
if (beforeOpsClipped !== before) {
result.opsBetween = true;
}
if (beforeOpsClipped[beforeOpsClipped.length - ... | [
"function",
"isInterpolationBefore",
"(",
"before",
")",
"{",
"const",
"result",
"=",
"{",
"is",
":",
"false",
",",
"opsBetween",
":",
"false",
"}",
";",
"// Removing preceding operators if any",
"const",
"beforeOpsClipped",
"=",
"before",
".",
"replace",
"(",
"... | Checks if there is an interpolation before the character.
Also checks if there is a math operator in between
@param {String} before - the input string that preceses the character
@return {Object} return
{Boolean} return.is - if there is an interpolation
{String} return.opsBetween - if there are operators in between | [
"Checks",
"if",
"there",
"is",
"an",
"interpolation",
"before",
"the",
"character",
".",
"Also",
"checks",
"if",
"there",
"is",
"a",
"math",
"operator",
"in",
"between"
] | c8a0f2ff85a588424b02a154be3811b16029ecc0 | https://github.com/kristerkari/stylelint-scss/blob/c8a0f2ff85a588424b02a154be3811b16029ecc0/src/utils/sassValueParser/index.js#L803-L817 |
17,577 | elpheria/rpc-websockets | dist/lib/utils.js | createError | function createError(code, details) {
var error = {
code: code,
message: errors.get(code) || "Internal Server Error"
};
if (details) error["data"] = details;
return error;
} | javascript | function createError(code, details) {
var error = {
code: code,
message: errors.get(code) || "Internal Server Error"
};
if (details) error["data"] = details;
return error;
} | [
"function",
"createError",
"(",
"code",
",",
"details",
")",
"{",
"var",
"error",
"=",
"{",
"code",
":",
"code",
",",
"message",
":",
"errors",
".",
"get",
"(",
"code",
")",
"||",
"\"Internal Server Error\"",
"}",
";",
"if",
"(",
"details",
")",
"error... | Creates a JSON-RPC 2.0-compliant error.
@param {Number} code - error code
@param {String} details - error details
@return {Object} | [
"Creates",
"a",
"JSON",
"-",
"RPC",
"2",
".",
"0",
"-",
"compliant",
"error",
"."
] | b9430f04593d42161dd19b8ca7e01f877587497f | https://github.com/elpheria/rpc-websockets/blob/b9430f04593d42161dd19b8ca7e01f877587497f/dist/lib/utils.js#L22-L31 |
17,578 | filerjs/filer | src/filesystem/implementation.js | create_node_in_parent | function create_node_in_parent(error, parentDirectoryNode) {
if(error) {
callback(error);
} else if(parentDirectoryNode.type !== NODE_TYPE_DIRECTORY) {
callback(new Errors.ENOTDIR('a component of the path prefix is not a directory', path));
} else {
parentNode = parentDirectoryNode;
... | javascript | function create_node_in_parent(error, parentDirectoryNode) {
if(error) {
callback(error);
} else if(parentDirectoryNode.type !== NODE_TYPE_DIRECTORY) {
callback(new Errors.ENOTDIR('a component of the path prefix is not a directory', path));
} else {
parentNode = parentDirectoryNode;
... | [
"function",
"create_node_in_parent",
"(",
"error",
",",
"parentDirectoryNode",
")",
"{",
"if",
"(",
"error",
")",
"{",
"callback",
"(",
"error",
")",
";",
"}",
"else",
"if",
"(",
"parentDirectoryNode",
".",
"type",
"!==",
"NODE_TYPE_DIRECTORY",
")",
"{",
"ca... | Check if the parent node exists | [
"Check",
"if",
"the",
"parent",
"node",
"exists"
] | 4aae53839a8da2ca5da9f4e92c33eaab50094352 | https://github.com/filerjs/filer/blob/4aae53839a8da2ca5da9f4e92c33eaab50094352/src/filesystem/implementation.js#L106-L115 |
17,579 | filerjs/filer | src/filesystem/implementation.js | check_if_node_exists | function check_if_node_exists(error, result) {
if(!error && result) {
callback(new Errors.EEXIST('path name already exists', path));
} else if(error && !(error instanceof Errors.ENOENT)) {
callback(error);
} else {
context.getObject(parentNode.data, create_node);
}
} | javascript | function check_if_node_exists(error, result) {
if(!error && result) {
callback(new Errors.EEXIST('path name already exists', path));
} else if(error && !(error instanceof Errors.ENOENT)) {
callback(error);
} else {
context.getObject(parentNode.data, create_node);
}
} | [
"function",
"check_if_node_exists",
"(",
"error",
",",
"result",
")",
"{",
"if",
"(",
"!",
"error",
"&&",
"result",
")",
"{",
"callback",
"(",
"new",
"Errors",
".",
"EEXIST",
"(",
"'path name already exists'",
",",
"path",
")",
")",
";",
"}",
"else",
"if... | Check if the node to be created already exists | [
"Check",
"if",
"the",
"node",
"to",
"be",
"created",
"already",
"exists"
] | 4aae53839a8da2ca5da9f4e92c33eaab50094352 | https://github.com/filerjs/filer/blob/4aae53839a8da2ca5da9f4e92c33eaab50094352/src/filesystem/implementation.js#L118-L126 |
17,580 | filerjs/filer | src/filesystem/implementation.js | create_node | function create_node(error, result) {
if(error) {
callback(error);
} else {
parentNodeData = result;
Node.create({
guid: context.guid,
type: type
}, function(error, result) {
if(error) {
callback(error);
return;
}
node = result;... | javascript | function create_node(error, result) {
if(error) {
callback(error);
} else {
parentNodeData = result;
Node.create({
guid: context.guid,
type: type
}, function(error, result) {
if(error) {
callback(error);
return;
}
node = result;... | [
"function",
"create_node",
"(",
"error",
",",
"result",
")",
"{",
"if",
"(",
"error",
")",
"{",
"callback",
"(",
"error",
")",
";",
"}",
"else",
"{",
"parentNodeData",
"=",
"result",
";",
"Node",
".",
"create",
"(",
"{",
"guid",
":",
"context",
".",
... | Create the new node | [
"Create",
"the",
"new",
"node"
] | 4aae53839a8da2ca5da9f4e92c33eaab50094352 | https://github.com/filerjs/filer/blob/4aae53839a8da2ca5da9f4e92c33eaab50094352/src/filesystem/implementation.js#L129-L147 |
17,581 | filerjs/filer | src/filesystem/implementation.js | update_parent_node_data | function update_parent_node_data(error) {
if(error) {
callback(error);
} else {
parentNodeData[name] = new DirectoryEntry(node.id, type);
context.putObject(parentNode.data, parentNodeData, update_time);
}
} | javascript | function update_parent_node_data(error) {
if(error) {
callback(error);
} else {
parentNodeData[name] = new DirectoryEntry(node.id, type);
context.putObject(parentNode.data, parentNodeData, update_time);
}
} | [
"function",
"update_parent_node_data",
"(",
"error",
")",
"{",
"if",
"(",
"error",
")",
"{",
"callback",
"(",
"error",
")",
";",
"}",
"else",
"{",
"parentNodeData",
"[",
"name",
"]",
"=",
"new",
"DirectoryEntry",
"(",
"node",
".",
"id",
",",
"type",
")... | Update the parent nodes data | [
"Update",
"the",
"parent",
"nodes",
"data"
] | 4aae53839a8da2ca5da9f4e92c33eaab50094352 | https://github.com/filerjs/filer/blob/4aae53839a8da2ca5da9f4e92c33eaab50094352/src/filesystem/implementation.js#L160-L167 |
17,582 | filerjs/filer | src/filesystem/implementation.js | ensure_root_directory | function ensure_root_directory(context, callback) {
var superNode;
var directoryNode;
var directoryData;
function ensure_super_node(error, existingNode) {
if(!error && existingNode) {
// Another instance has beat us and already created the super node.
callback();
} else if(error && !(error ... | javascript | function ensure_root_directory(context, callback) {
var superNode;
var directoryNode;
var directoryData;
function ensure_super_node(error, existingNode) {
if(!error && existingNode) {
// Another instance has beat us and already created the super node.
callback();
} else if(error && !(error ... | [
"function",
"ensure_root_directory",
"(",
"context",
",",
"callback",
")",
"{",
"var",
"superNode",
";",
"var",
"directoryNode",
";",
"var",
"directoryData",
";",
"function",
"ensure_super_node",
"(",
"error",
",",
"existingNode",
")",
"{",
"if",
"(",
"!",
"er... | ensure_root_directory. Creates a root node if necessary.
Note: this should only be invoked when formatting a new file system.
Multiple invocations of this by separate instances will still result
in only a single super node. | [
"ensure_root_directory",
".",
"Creates",
"a",
"root",
"node",
"if",
"necessary",
"."
] | 4aae53839a8da2ca5da9f4e92c33eaab50094352 | https://github.com/filerjs/filer/blob/4aae53839a8da2ca5da9f4e92c33eaab50094352/src/filesystem/implementation.js#L315-L368 |
17,583 | filerjs/filer | src/node.js | ensureID | function ensureID(options, prop, callback) {
if(options[prop]) {
return callback();
}
options.guid(function(err, id) {
if(err) {
return callback(err);
}
options[prop] = id;
callback();
});
} | javascript | function ensureID(options, prop, callback) {
if(options[prop]) {
return callback();
}
options.guid(function(err, id) {
if(err) {
return callback(err);
}
options[prop] = id;
callback();
});
} | [
"function",
"ensureID",
"(",
"options",
",",
"prop",
",",
"callback",
")",
"{",
"if",
"(",
"options",
"[",
"prop",
"]",
")",
"{",
"return",
"callback",
"(",
")",
";",
"}",
"options",
".",
"guid",
"(",
"function",
"(",
"err",
",",
"id",
")",
"{",
... | Make sure the options object has an id on property,
either from caller or one we generate using supplied guid fn. | [
"Make",
"sure",
"the",
"options",
"object",
"has",
"an",
"id",
"on",
"property",
"either",
"from",
"caller",
"or",
"one",
"we",
"generate",
"using",
"supplied",
"guid",
"fn",
"."
] | 4aae53839a8da2ca5da9f4e92c33eaab50094352 | https://github.com/filerjs/filer/blob/4aae53839a8da2ca5da9f4e92c33eaab50094352/src/node.js#L18-L30 |
17,584 | filerjs/filer | src/filesystem/interface.js | wrappedGuidFn | function wrappedGuidFn(context) {
return function (callback) {
// Skip the duplicate ID check if asked to
if (flags.includes(FS_NODUPEIDCHECK)) {
callback(null, guid());
return;
}
// Otherwise (default) make sure this id is unused first
function guidWithCheck(callback)... | javascript | function wrappedGuidFn(context) {
return function (callback) {
// Skip the duplicate ID check if asked to
if (flags.includes(FS_NODUPEIDCHECK)) {
callback(null, guid());
return;
}
// Otherwise (default) make sure this id is unused first
function guidWithCheck(callback)... | [
"function",
"wrappedGuidFn",
"(",
"context",
")",
"{",
"return",
"function",
"(",
"callback",
")",
"{",
"// Skip the duplicate ID check if asked to",
"if",
"(",
"flags",
".",
"includes",
"(",
"FS_NODUPEIDCHECK",
")",
")",
"{",
"callback",
"(",
"null",
",",
"guid... | Deal with various approaches to node ID creation | [
"Deal",
"with",
"various",
"approaches",
"to",
"node",
"ID",
"creation"
] | 4aae53839a8da2ca5da9f4e92c33eaab50094352 | https://github.com/filerjs/filer/blob/4aae53839a8da2ca5da9f4e92c33eaab50094352/src/filesystem/interface.js#L210-L237 |
17,585 | country-regions/country-region-selector | source/source-jquery.crs.js | function (countries, preferred, preferredDelim) {
var preferredShortCodes = preferred.split(',').reverse();
var preferredMap = {};
var foundPreferred = false;
var updatedCountries = countries.filter(function (c) {
if (preferredShortCodes.indexOf(c[1]) !== -1) {
... | javascript | function (countries, preferred, preferredDelim) {
var preferredShortCodes = preferred.split(',').reverse();
var preferredMap = {};
var foundPreferred = false;
var updatedCountries = countries.filter(function (c) {
if (preferredShortCodes.indexOf(c[1]) !== -1) {
... | [
"function",
"(",
"countries",
",",
"preferred",
",",
"preferredDelim",
")",
"{",
"var",
"preferredShortCodes",
"=",
"preferred",
".",
"split",
"(",
"','",
")",
".",
"reverse",
"(",
")",
";",
"var",
"preferredMap",
"=",
"{",
"}",
";",
"var",
"foundPreferred... | in 0.5.0 we added the option for "preferred" countries that get listed first. This just causes the preferred countries to get listed at the top of the list with an optional delimiter row following them | [
"in",
"0",
".",
"5",
".",
"0",
"we",
"added",
"the",
"option",
"for",
"preferred",
"countries",
"that",
"get",
"listed",
"first",
".",
"This",
"just",
"causes",
"the",
"preferred",
"countries",
"to",
"get",
"listed",
"at",
"the",
"top",
"of",
"the",
"l... | 619110c162b6b68e427798b8c049135802ebf0c5 | https://github.com/country-regions/country-region-selector/blob/619110c162b6b68e427798b8c049135802ebf0c5/source/source-jquery.crs.js#L229-L254 | |
17,586 | country-regions/country-region-selector | gruntfile.js | getCountryList | function getCountryList() {
var countries = grunt.option("countries");
if (!countries) {
grunt.fail.fatal("Country list not passed. Example usage: `grunt customBuild --countries=Canada,United States`");
}
// countries may contain commas in their names. Bit ugly, but simple. ... | javascript | function getCountryList() {
var countries = grunt.option("countries");
if (!countries) {
grunt.fail.fatal("Country list not passed. Example usage: `grunt customBuild --countries=Canada,United States`");
}
// countries may contain commas in their names. Bit ugly, but simple. ... | [
"function",
"getCountryList",
"(",
")",
"{",
"var",
"countries",
"=",
"grunt",
".",
"option",
"(",
"\"countries\"",
")",
";",
"if",
"(",
"!",
"countries",
")",
"{",
"grunt",
".",
"fail",
".",
"fatal",
"(",
"\"Country list not passed. Example usage: `grunt custom... | used for the customBuild target. This generates a custom build of CRS with the list of countries specified by the user | [
"used",
"for",
"the",
"customBuild",
"target",
".",
"This",
"generates",
"a",
"custom",
"build",
"of",
"CRS",
"with",
"the",
"list",
"of",
"countries",
"specified",
"by",
"the",
"user"
] | 619110c162b6b68e427798b8c049135802ebf0c5 | https://github.com/country-regions/country-region-selector/blob/619110c162b6b68e427798b8c049135802ebf0c5/gruntfile.js#L15-L58 |
17,587 | country-regions/country-region-selector | gruntfile.js | minifyJSON | function minifyJSON(json) {
var js = [];
json.forEach(function (countryData) {
var pairs = [];
countryData.regions.forEach(function (info) {
if (_.has(info, 'shortCode')) {
pairs.push(info.name + '~' + info.shortCode);
} else {... | javascript | function minifyJSON(json) {
var js = [];
json.forEach(function (countryData) {
var pairs = [];
countryData.regions.forEach(function (info) {
if (_.has(info, 'shortCode')) {
pairs.push(info.name + '~' + info.shortCode);
} else {... | [
"function",
"minifyJSON",
"(",
"json",
")",
"{",
"var",
"js",
"=",
"[",
"]",
";",
"json",
".",
"forEach",
"(",
"function",
"(",
"countryData",
")",
"{",
"var",
"pairs",
"=",
"[",
"]",
";",
"countryData",
".",
"regions",
".",
"forEach",
"(",
"function... | converts the data.json content from the country-region-data | [
"converts",
"the",
"data",
".",
"json",
"content",
"from",
"the",
"country",
"-",
"region",
"-",
"data"
] | 619110c162b6b68e427798b8c049135802ebf0c5 | https://github.com/country-regions/country-region-selector/blob/619110c162b6b68e427798b8c049135802ebf0c5/gruntfile.js#L62-L84 |
17,588 | Mikhus/domurl | url.js | urlConfig | function urlConfig (url) {
var config = {
path: true,
query: true,
hash: true
};
if (!url) {
return config;
}
if (RX_PROTOCOL.test(url)) {
config.protocol = true;
config.host = true;
if (RX_POR... | javascript | function urlConfig (url) {
var config = {
path: true,
query: true,
hash: true
};
if (!url) {
return config;
}
if (RX_PROTOCOL.test(url)) {
config.protocol = true;
config.host = true;
if (RX_POR... | [
"function",
"urlConfig",
"(",
"url",
")",
"{",
"var",
"config",
"=",
"{",
"path",
":",
"true",
",",
"query",
":",
"true",
",",
"hash",
":",
"true",
"}",
";",
"if",
"(",
"!",
"url",
")",
"{",
"return",
"config",
";",
"}",
"if",
"(",
"RX_PROTOCOL",... | configure given url options | [
"configure",
"given",
"url",
"options"
] | 6da9d172cfed40b126a7f53f87645e85124814a8 | https://github.com/Mikhus/domurl/blob/6da9d172cfed40b126a7f53f87645e85124814a8/url.js#L32-L58 |
17,589 | medialab/artoo | src/artoo.writers.js | keysIndex | function keysIndex(a) {
var keys = [],
l,
k,
i;
for (i = 0, l = a.length; i < l; i++)
for (k in a[i])
if (!~keys.indexOf(k))
keys.push(k);
return keys;
} | javascript | function keysIndex(a) {
var keys = [],
l,
k,
i;
for (i = 0, l = a.length; i < l; i++)
for (k in a[i])
if (!~keys.indexOf(k))
keys.push(k);
return keys;
} | [
"function",
"keysIndex",
"(",
"a",
")",
"{",
"var",
"keys",
"=",
"[",
"]",
",",
"l",
",",
"k",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
",",
"l",
"=",
"a",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"for",
"(",
"k",
"in",
... | Retrieve an index of keys present in an array of objects | [
"Retrieve",
"an",
"index",
"of",
"keys",
"present",
"in",
"an",
"array",
"of",
"objects"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.writers.js#L40-L52 |
17,590 | medialab/artoo | src/artoo.writers.js | toCSVString | function toCSVString(data, params) {
if (data.length === 0) {
return '';
}
params = params || {};
var header = params.headers || [],
plainObject = isPlainObject(data[0]),
keys = plainObject && (params.order || keysIndex(data)),
oData,
i;
// Defaults
var es... | javascript | function toCSVString(data, params) {
if (data.length === 0) {
return '';
}
params = params || {};
var header = params.headers || [],
plainObject = isPlainObject(data[0]),
keys = plainObject && (params.order || keysIndex(data)),
oData,
i;
// Defaults
var es... | [
"function",
"toCSVString",
"(",
"data",
",",
"params",
")",
"{",
"if",
"(",
"data",
".",
"length",
"===",
"0",
")",
"{",
"return",
"''",
";",
"}",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"var",
"header",
"=",
"params",
".",
"headers",
"||",
... | Converting an array of arrays into a CSV string | [
"Converting",
"an",
"array",
"of",
"arrays",
"into",
"a",
"CSV",
"string"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.writers.js#L60-L104 |
17,591 | medialab/artoo | src/artoo.writers.js | repeatString | function repeatString(string, nb) {
var s = string,
l,
i;
if (nb <= 0)
return '';
for (i = 1, l = nb | 0; i < l; i++)
s += string;
return s;
} | javascript | function repeatString(string, nb) {
var s = string,
l,
i;
if (nb <= 0)
return '';
for (i = 1, l = nb | 0; i < l; i++)
s += string;
return s;
} | [
"function",
"repeatString",
"(",
"string",
",",
"nb",
")",
"{",
"var",
"s",
"=",
"string",
",",
"l",
",",
"i",
";",
"if",
"(",
"nb",
"<=",
"0",
")",
"return",
"''",
";",
"for",
"(",
"i",
"=",
"1",
",",
"l",
"=",
"nb",
"|",
"0",
";",
"i",
... | Creating repeating sequences | [
"Creating",
"repeating",
"sequences"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.writers.js#L119-L130 |
17,592 | medialab/artoo | src/artoo.writers.js | processYAMLVariable | function processYAMLVariable(v, lvl, indent) {
// Scalars
if (typeof v === 'string')
return yml.string(v);
else if (typeof v === 'number')
return yml.number(v);
else if (typeof v === 'boolean')
return yml.boolean(v);
else if (typeof v === 'undefined' || v === null || isRealNaN(v))... | javascript | function processYAMLVariable(v, lvl, indent) {
// Scalars
if (typeof v === 'string')
return yml.string(v);
else if (typeof v === 'number')
return yml.number(v);
else if (typeof v === 'boolean')
return yml.boolean(v);
else if (typeof v === 'undefined' || v === null || isRealNaN(v))... | [
"function",
"processYAMLVariable",
"(",
"v",
",",
"lvl",
",",
"indent",
")",
"{",
"// Scalars",
"if",
"(",
"typeof",
"v",
"===",
"'string'",
")",
"return",
"yml",
".",
"string",
"(",
"v",
")",
";",
"else",
"if",
"(",
"typeof",
"v",
"===",
"'number'",
... | Get the correct handler corresponding to variable type | [
"Get",
"the",
"correct",
"handler",
"corresponding",
"to",
"variable",
"type"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.writers.js#L204-L227 |
17,593 | medialab/artoo | src/artoo.helpers.js | extend | function extend() {
var i,
k,
res = {},
l = arguments.length;
for (i = l - 1; i >= 0; i--)
for (k in arguments[i])
if (res[k] && isPlainObject(arguments[i][k]))
res[k] = extend(arguments[i][k], res[k]);
else
res[k] = arguments[i][k];
return... | javascript | function extend() {
var i,
k,
res = {},
l = arguments.length;
for (i = l - 1; i >= 0; i--)
for (k in arguments[i])
if (res[k] && isPlainObject(arguments[i][k]))
res[k] = extend(arguments[i][k], res[k]);
else
res[k] = arguments[i][k];
return... | [
"function",
"extend",
"(",
")",
"{",
"var",
"i",
",",
"k",
",",
"res",
"=",
"{",
"}",
",",
"l",
"=",
"arguments",
".",
"length",
";",
"for",
"(",
"i",
"=",
"l",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"for",
"(",
"k",
"in",
... | Recursively extend objects | [
"Recursively",
"extend",
"objects"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.helpers.js#L41-L55 |
17,594 | medialab/artoo | src/artoo.helpers.js | first | function first(a, fn, scope) {
for (var i = 0, l = a.length; i < l; i++) {
if (fn.call(scope || null, a[i]))
return a[i];
}
return;
} | javascript | function first(a, fn, scope) {
for (var i = 0, l = a.length; i < l; i++) {
if (fn.call(scope || null, a[i]))
return a[i];
}
return;
} | [
"function",
"first",
"(",
"a",
",",
"fn",
",",
"scope",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"a",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"if",
"(",
"fn",
".",
"call",
"(",
"scope",
"||",
"null",... | Get first item of array returning true to given function | [
"Get",
"first",
"item",
"of",
"array",
"returning",
"true",
"to",
"given",
"function"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.helpers.js#L90-L96 |
17,595 | medialab/artoo | src/artoo.helpers.js | getExtension | function getExtension(url) {
var a = url.split('.');
if (a.length === 1 || (a[0] === '' && a.length === 2))
return '';
return a.pop();
} | javascript | function getExtension(url) {
var a = url.split('.');
if (a.length === 1 || (a[0] === '' && a.length === 2))
return '';
return a.pop();
} | [
"function",
"getExtension",
"(",
"url",
")",
"{",
"var",
"a",
"=",
"url",
".",
"split",
"(",
"'.'",
")",
";",
"if",
"(",
"a",
".",
"length",
"===",
"1",
"||",
"(",
"a",
"[",
"0",
"]",
"===",
"''",
"&&",
"a",
".",
"length",
"===",
"2",
")",
... | Retrieve a file extenstion from filename or url | [
"Retrieve",
"a",
"file",
"extenstion",
"from",
"filename",
"or",
"url"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.helpers.js#L108-L114 |
17,596 | medialab/artoo | src/artoo.helpers.js | createDocument | function createDocument(root, namespace) {
if (!root)
return document.implementation.createHTMLDocument();
else
return document.implementation.createDocument(
namespace || null,
root,
null
);
} | javascript | function createDocument(root, namespace) {
if (!root)
return document.implementation.createHTMLDocument();
else
return document.implementation.createDocument(
namespace || null,
root,
null
);
} | [
"function",
"createDocument",
"(",
"root",
",",
"namespace",
")",
"{",
"if",
"(",
"!",
"root",
")",
"return",
"document",
".",
"implementation",
".",
"createHTMLDocument",
"(",
")",
";",
"else",
"return",
"document",
".",
"implementation",
".",
"createDocument... | Creating an HTML or XML document | [
"Creating",
"an",
"HTML",
"or",
"XML",
"document"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.helpers.js#L146-L155 |
17,597 | medialab/artoo | src/artoo.helpers.js | getScript | function getScript(url, async, cb) {
if (typeof async === 'function') {
cb = async;
async = false;
}
var el = document.createElement('script');
// Script attributes
el.type = 'text/javascript';
el.src = url;
// Should the script be loaded asynchronously?
if (async)
e... | javascript | function getScript(url, async, cb) {
if (typeof async === 'function') {
cb = async;
async = false;
}
var el = document.createElement('script');
// Script attributes
el.type = 'text/javascript';
el.src = url;
// Should the script be loaded asynchronously?
if (async)
e... | [
"function",
"getScript",
"(",
"url",
",",
"async",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"async",
"===",
"'function'",
")",
"{",
"cb",
"=",
"async",
";",
"async",
"=",
"false",
";",
"}",
"var",
"el",
"=",
"document",
".",
"createElement",
"(",
... | Loading an external file the same way the browser would load it from page | [
"Loading",
"an",
"external",
"file",
"the",
"same",
"way",
"the",
"browser",
"would",
"load",
"it",
"from",
"page"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.helpers.js#L158-L191 |
17,598 | medialab/artoo | src/artoo.helpers.js | getStylesheet | function getStylesheet(data, isUrl, cb) {
var el = document.createElement(isUrl ? 'link' : 'style'),
head = document.getElementsByTagName('head')[0];
el.type = 'text/css';
if (isUrl) {
el.href = data;
el.rel = 'stylesheet';
// Waiting for script to load
el.onload = el.onre... | javascript | function getStylesheet(data, isUrl, cb) {
var el = document.createElement(isUrl ? 'link' : 'style'),
head = document.getElementsByTagName('head')[0];
el.type = 'text/css';
if (isUrl) {
el.href = data;
el.rel = 'stylesheet';
// Waiting for script to load
el.onload = el.onre... | [
"function",
"getStylesheet",
"(",
"data",
",",
"isUrl",
",",
"cb",
")",
"{",
"var",
"el",
"=",
"document",
".",
"createElement",
"(",
"isUrl",
"?",
"'link'",
":",
"'style'",
")",
",",
"head",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'head'",
"... | Loading an external stylesheet | [
"Loading",
"an",
"external",
"stylesheet"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.helpers.js#L194-L222 |
17,599 | medialab/artoo | src/artoo.helpers.js | async | function async() {
var args = Array.prototype.slice.call(arguments);
return setTimeout.apply(null, [args[0], 0].concat(args.slice(1)));
} | javascript | function async() {
var args = Array.prototype.slice.call(arguments);
return setTimeout.apply(null, [args[0], 0].concat(args.slice(1)));
} | [
"function",
"async",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"return",
"setTimeout",
".",
"apply",
"(",
"null",
",",
"[",
"args",
"[",
"0",
"]",
",",
"0",
"]",
".",
"con... | Dispatch asynchronous function | [
"Dispatch",
"asynchronous",
"function"
] | 89fe334cb2c2ec38b16012edfab2977822e1ecda | https://github.com/medialab/artoo/blob/89fe334cb2c2ec38b16012edfab2977822e1ecda/src/artoo.helpers.js#L318-L321 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.