repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | createTableLayout | function createTableLayout(){
var tableItem = {
type: 'component',
componentName: 'Table'
};
var stackItem = myLayout.root.getItemsById('stack-topleft')[0];
stackItem.addChild(tableItem);
// get focus on the search tab
stackItem.setActiveContentItem(myLayout.root.getItemsById('n... | javascript | function createTableLayout(){
var tableItem = {
type: 'component',
componentName: 'Table'
};
var stackItem = myLayout.root.getItemsById('stack-topleft')[0];
stackItem.addChild(tableItem);
// get focus on the search tab
stackItem.setActiveContentItem(myLayout.root.getItemsById('n... | [
"function",
"createTableLayout",
"(",
")",
"{",
"var",
"tableItem",
"=",
"{",
"type",
":",
"'component'",
",",
"componentName",
":",
"'Table'",
"}",
";",
"var",
"stackItem",
"=",
"myLayout",
".",
"root",
".",
"getItemsById",
"(",
"'stack-topleft'",
")",
"[",... | Creates a golden-layout component for SlickGrid and initializes it | [
"Creates",
"a",
"golden",
"-",
"layout",
"component",
"for",
"SlickGrid",
"and",
"initializes",
"it"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L360-L371 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | initJQueryEvents | function initJQueryEvents(){
$('#searchDiv').parent().scroll(function() {
if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight - 100) {
globalFunc.addNodesInList();
}
});
$('#toggleLayout').click(function() {
toggleLayout();
});
$("#sliderTe... | javascript | function initJQueryEvents(){
$('#searchDiv').parent().scroll(function() {
if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight - 100) {
globalFunc.addNodesInList();
}
});
$('#toggleLayout').click(function() {
toggleLayout();
});
$("#sliderTe... | [
"function",
"initJQueryEvents",
"(",
")",
"{",
"$",
"(",
"'#searchDiv'",
")",
".",
"parent",
"(",
")",
".",
"scroll",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"$",
"(",
"this",
")",
".",
"scrollTop",
"(",
")",
"+",
"$",
"(",
"this",
")",
".",
... | Initializes the necessary events | [
"Initializes",
"the",
"necessary",
"events"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L376-L403 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | panToNode | function panToNode(node) {
var pos = layout.getNodePosition(node._id);
renderer.moveTo(pos.x, pos.y);
highlightNodeWebGL(node);
} | javascript | function panToNode(node) {
var pos = layout.getNodePosition(node._id);
renderer.moveTo(pos.x, pos.y);
highlightNodeWebGL(node);
} | [
"function",
"panToNode",
"(",
"node",
")",
"{",
"var",
"pos",
"=",
"layout",
".",
"getNodePosition",
"(",
"node",
".",
"_id",
")",
";",
"renderer",
".",
"moveTo",
"(",
"pos",
".",
"x",
",",
"pos",
".",
"y",
")",
";",
"highlightNodeWebGL",
"(",
"node"... | Center the focus on the node with nodeId, then highlight it
@param node | [
"Center",
"the",
"focus",
"on",
"the",
"node",
"with",
"nodeId",
"then",
"highlight",
"it"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L409-L414 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | highlightNodeWebGL | function highlightNodeWebGL(node) {
var ui = graphics.getNodeUI(node._id);
if (prevNodeUI){
prevNodeUI.size = NODE_SIZE;
//prevNodeUI.color = hexColorToWebGLColor(colorsByNodeType[node._type]);
}
prevNodeUI = ui;
ui.size = NODE_SIZE * 4;
//ui.color = 0xFFA500FF; //orange
if ... | javascript | function highlightNodeWebGL(node) {
var ui = graphics.getNodeUI(node._id);
if (prevNodeUI){
prevNodeUI.size = NODE_SIZE;
//prevNodeUI.color = hexColorToWebGLColor(colorsByNodeType[node._type]);
}
prevNodeUI = ui;
ui.size = NODE_SIZE * 4;
//ui.color = 0xFFA500FF; //orange
if ... | [
"function",
"highlightNodeWebGL",
"(",
"node",
")",
"{",
"var",
"ui",
"=",
"graphics",
".",
"getNodeUI",
"(",
"node",
".",
"_id",
")",
";",
"if",
"(",
"prevNodeUI",
")",
"{",
"prevNodeUI",
".",
"size",
"=",
"NODE_SIZE",
";",
"//prevNodeUI.color = hexColorToW... | Highlight function especially for WebGL
@param node | [
"Highlight",
"function",
"especially",
"for",
"WebGL"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L420-L433 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | addToGlobalNodes | function addToGlobalNodes(node){
var nodeToAdd = {
"_id": node.id(),
"_world": node.world(),
"_time": node.time(),
"_type": (node.nodeTypeName() ? node.nodeTypeName() : "default")
};
var containsRel = false;
// add all the attributes of the node to the JSON
graph.res... | javascript | function addToGlobalNodes(node){
var nodeToAdd = {
"_id": node.id(),
"_world": node.world(),
"_time": node.time(),
"_type": (node.nodeTypeName() ? node.nodeTypeName() : "default")
};
var containsRel = false;
// add all the attributes of the node to the JSON
graph.res... | [
"function",
"addToGlobalNodes",
"(",
"node",
")",
"{",
"var",
"nodeToAdd",
"=",
"{",
"\"_id\"",
":",
"node",
".",
"id",
"(",
")",
",",
"\"_world\"",
":",
"node",
".",
"world",
"(",
")",
",",
"\"_time\"",
":",
"node",
".",
"time",
"(",
")",
",",
"\"... | Transform every node from mwg and add them to a global var
@param node | [
"Transform",
"every",
"node",
"from",
"mwg",
"and",
"add",
"them",
"to",
"a",
"global",
"var"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L439-L486 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | addNodeToGraph | function addNodeToGraph(node){
gNodesDisplayed.push(node);
g.addNode(node._id, node);
if (contains(childrenNodes, node._id)){
var parentNode = getNodeFromId(nodesToBeLinked[node._id].from);
if (contains(gNodesDisplayed, parentNode)){
addLinkToParent(node._id, parentNode._id);
... | javascript | function addNodeToGraph(node){
gNodesDisplayed.push(node);
g.addNode(node._id, node);
if (contains(childrenNodes, node._id)){
var parentNode = getNodeFromId(nodesToBeLinked[node._id].from);
if (contains(gNodesDisplayed, parentNode)){
addLinkToParent(node._id, parentNode._id);
... | [
"function",
"addNodeToGraph",
"(",
"node",
")",
"{",
"gNodesDisplayed",
".",
"push",
"(",
"node",
")",
";",
"g",
".",
"addNode",
"(",
"node",
".",
"_id",
",",
"node",
")",
";",
"if",
"(",
"contains",
"(",
"childrenNodes",
",",
"node",
".",
"_id",
")"... | Add the node in param to the graph
@param node | [
"Add",
"the",
"node",
"in",
"param",
"to",
"the",
"graph"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L492-L504 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | addRelToGraph | function addRelToGraph(node){
var children = [];
for (var prop in node){
if(node.hasOwnProperty(prop)){
if (typeof node[prop] === 'object') {
var linkedNodes = node[prop];
// same for links
if (colorsByLinkType[prop] == null) {
... | javascript | function addRelToGraph(node){
var children = [];
for (var prop in node){
if(node.hasOwnProperty(prop)){
if (typeof node[prop] === 'object') {
var linkedNodes = node[prop];
// same for links
if (colorsByLinkType[prop] == null) {
... | [
"function",
"addRelToGraph",
"(",
"node",
")",
"{",
"var",
"children",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"prop",
"in",
"node",
")",
"{",
"if",
"(",
"node",
".",
"hasOwnProperty",
"(",
"prop",
")",
")",
"{",
"if",
"(",
"typeof",
"node",
"[",
... | Add the necessary nodes and the relationships to the graph
@param node | [
"Add",
"the",
"necessary",
"nodes",
"and",
"the",
"relationships",
"to",
"the",
"graph"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L510-L541 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | getNodeFromId | function getNodeFromId(nodeId){
var res = $.grep(gAllNodes, function(e) {
return e._id === nodeId;
});
return res[0];
} | javascript | function getNodeFromId(nodeId){
var res = $.grep(gAllNodes, function(e) {
return e._id === nodeId;
});
return res[0];
} | [
"function",
"getNodeFromId",
"(",
"nodeId",
")",
"{",
"var",
"res",
"=",
"$",
".",
"grep",
"(",
"gAllNodes",
",",
"function",
"(",
"e",
")",
"{",
"return",
"e",
".",
"_id",
"===",
"nodeId",
";",
"}",
")",
";",
"return",
"res",
"[",
"0",
"]",
";",... | Function that will return the node from the id in parameter
@param nodeId
@returns {*} | [
"Function",
"that",
"will",
"return",
"the",
"node",
"from",
"the",
"id",
"in",
"parameter"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L548-L553 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | delayLinkCreation | function delayLinkCreation(idParent, idChild, relationName){
childrenNodes.push(idChild);
return {
from: idParent,
name: relationName
};
} | javascript | function delayLinkCreation(idParent, idChild, relationName){
childrenNodes.push(idChild);
return {
from: idParent,
name: relationName
};
} | [
"function",
"delayLinkCreation",
"(",
"idParent",
",",
"idChild",
",",
"relationName",
")",
"{",
"childrenNodes",
".",
"push",
"(",
"idChild",
")",
";",
"return",
"{",
"from",
":",
"idParent",
",",
"name",
":",
"relationName",
"}",
";",
"}"
] | Handle the links that need to be created by keeping the nodes id and the relationship name
@param idParent
@param idChild
@param relationName
@returns {{from: *, to: *, name: *}} | [
"Handle",
"the",
"links",
"that",
"need",
"to",
"be",
"created",
"by",
"keeping",
"the",
"nodes",
"id",
"and",
"the",
"relationship",
"name"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L561-L567 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | addLinkToParent | function addLinkToParent(idNode, idParentNode){
g.addLink(idParentNode, idNode, nodesToBeLinked[idNode].name);
delete nodesToBeLinked[idNode];
//we remove the node from childrenNodes
var index = childrenNodes.indexOf(idNode);
if (index > -1) {
childrenNodes.splice(index, 1);
}
} | javascript | function addLinkToParent(idNode, idParentNode){
g.addLink(idParentNode, idNode, nodesToBeLinked[idNode].name);
delete nodesToBeLinked[idNode];
//we remove the node from childrenNodes
var index = childrenNodes.indexOf(idNode);
if (index > -1) {
childrenNodes.splice(index, 1);
}
} | [
"function",
"addLinkToParent",
"(",
"idNode",
",",
"idParentNode",
")",
"{",
"g",
".",
"addLink",
"(",
"idParentNode",
",",
"idNode",
",",
"nodesToBeLinked",
"[",
"idNode",
"]",
".",
"name",
")",
";",
"delete",
"nodesToBeLinked",
"[",
"idNode",
"]",
";",
"... | Add a link to the graph between the node and its parent
@param idNode
@param idParentNode | [
"Add",
"a",
"link",
"to",
"the",
"graph",
"between",
"the",
"node",
"and",
"its",
"parent"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L574-L583 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/demo_vivagraph.js | toggleLayout | function toggleLayout() {
$('.nodeLabel').remove();
isPaused = !isPaused;
if (isPaused) {
$('#toggleLayout').html('<i class="fa fa-play"></i>Resume layout');
renderer.pause();
} else {
$('#toggleLayout').html('<i class="fa fa-pause"></i>Pause layout');
renderer.resume();
... | javascript | function toggleLayout() {
$('.nodeLabel').remove();
isPaused = !isPaused;
if (isPaused) {
$('#toggleLayout').html('<i class="fa fa-play"></i>Resume layout');
renderer.pause();
} else {
$('#toggleLayout').html('<i class="fa fa-pause"></i>Pause layout');
renderer.resume();
... | [
"function",
"toggleLayout",
"(",
")",
"{",
"$",
"(",
"'.nodeLabel'",
")",
".",
"remove",
"(",
")",
";",
"isPaused",
"=",
"!",
"isPaused",
";",
"if",
"(",
"isPaused",
")",
"{",
"$",
"(",
"'#toggleLayout'",
")",
".",
"html",
"(",
"'<i class=\"fa fa-play\">... | Allows the rendering to be paused or resumed
@returns {boolean} | [
"Allows",
"the",
"rendering",
"to",
"be",
"paused",
"or",
"resumed"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/demo_vivagraph.js#L589-L600 | train |
datathings/greycat | plugins/incub/benchmark/src/main/resources/static/c3.js | splitTickText | function splitTickText(d, maxWidth) {
var tickText = textFormatted(d),
subtext, spaceIndex, textWidth, splitted = [];
if (Object.prototype.toString.call(tickText) === "[object Array]") {
return tickText;
}
... | javascript | function splitTickText(d, maxWidth) {
var tickText = textFormatted(d),
subtext, spaceIndex, textWidth, splitted = [];
if (Object.prototype.toString.call(tickText) === "[object Array]") {
return tickText;
}
... | [
"function",
"splitTickText",
"(",
"d",
",",
"maxWidth",
")",
"{",
"var",
"tickText",
"=",
"textFormatted",
"(",
"d",
")",
",",
"subtext",
",",
"spaceIndex",
",",
"textWidth",
",",
"splitted",
"=",
"[",
"]",
";",
"if",
"(",
"Object",
".",
"prototype",
"... | this should be called only when category axis | [
"this",
"should",
"be",
"called",
"only",
"when",
"category",
"axis"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/benchmark/src/main/resources/static/c3.js#L7126-L7158 | train |
datathings/greycat | plugins/incub/visualizer/old/src/js/react_layout.js | createColumnsFromProperties | function createColumnsFromProperties(){
var res = [];
for (var i = 0; i < nodeProperties.length; ++i){
var prop = nodeProperties[i];
var obj = {
id: prop,
name: prop,
field: prop
};
res.push(obj);
}
return res;
} | javascript | function createColumnsFromProperties(){
var res = [];
for (var i = 0; i < nodeProperties.length; ++i){
var prop = nodeProperties[i];
var obj = {
id: prop,
name: prop,
field: prop
};
res.push(obj);
}
return res;
} | [
"function",
"createColumnsFromProperties",
"(",
")",
"{",
"var",
"res",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"nodeProperties",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"prop",
"=",
"nodeProperties",
"[",
"i",
... | Create columns for the slickgrid from the properties of the nodes
@returns {Array} | [
"Create",
"columns",
"for",
"the",
"slickgrid",
"from",
"the",
"properties",
"of",
"the",
"nodes"
] | 602243bdd50e1f869bb19e3ac2991c540ea7af79 | https://github.com/datathings/greycat/blob/602243bdd50e1f869bb19e3ac2991c540ea7af79/plugins/incub/visualizer/old/src/js/react_layout.js#L683-L695 | train |
GoogleChromeLabs/imagecapture-polyfill | docs/index.js | gotMedia | function gotMedia(mediaStream) {
// Extract video track.
videoDevice = mediaStream.getVideoTracks()[0];
log('Using camera', videoDevice.label);
const captureDevice = new ImageCapture(videoDevice, mediaStream);
interval = setInterval(function () {
captureDevice.grabFrame().then(processFrame).catch(error =... | javascript | function gotMedia(mediaStream) {
// Extract video track.
videoDevice = mediaStream.getVideoTracks()[0];
log('Using camera', videoDevice.label);
const captureDevice = new ImageCapture(videoDevice, mediaStream);
interval = setInterval(function () {
captureDevice.grabFrame().then(processFrame).catch(error =... | [
"function",
"gotMedia",
"(",
"mediaStream",
")",
"{",
"// Extract video track.",
"videoDevice",
"=",
"mediaStream",
".",
"getVideoTracks",
"(",
")",
"[",
"0",
"]",
";",
"log",
"(",
"'Using camera'",
",",
"videoDevice",
".",
"label",
")",
";",
"const",
"capture... | We have a video capture device. Exercise various capturing modes.
@param {MediaStream} mediaStream | [
"We",
"have",
"a",
"video",
"capture",
"device",
".",
"Exercise",
"various",
"capturing",
"modes",
"."
] | 18e7db21ac97d350c9c51f7502d2d0822d8bf2ae | https://github.com/GoogleChromeLabs/imagecapture-polyfill/blob/18e7db21ac97d350c9c51f7502d2d0822d8bf2ae/docs/index.js#L69-L84 | train |
jesseditson/fs-router | index.js | findRoutes | function findRoutes (dir, fileExtensions) {
let files = fs.readdirSync(dir)
let resolve = f => path.join(dir, f)
let routes = files.filter(f => fileExtensions.indexOf(path.extname(f)) !== -1).map(resolve)
let dirs = files.filter(f => fs.statSync(path.join(dir, f)).isDirectory()).map(resolve)
return routes.con... | javascript | function findRoutes (dir, fileExtensions) {
let files = fs.readdirSync(dir)
let resolve = f => path.join(dir, f)
let routes = files.filter(f => fileExtensions.indexOf(path.extname(f)) !== -1).map(resolve)
let dirs = files.filter(f => fs.statSync(path.join(dir, f)).isDirectory()).map(resolve)
return routes.con... | [
"function",
"findRoutes",
"(",
"dir",
",",
"fileExtensions",
")",
"{",
"let",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
"let",
"resolve",
"=",
"f",
"=>",
"path",
".",
"join",
"(",
"dir",
",",
"f",
")",
"let",
"routes",
"=",
"files",
... | recursively searches for all js files inside a directory tree, and returns their full paths | [
"recursively",
"searches",
"for",
"all",
"js",
"files",
"inside",
"a",
"directory",
"tree",
"and",
"returns",
"their",
"full",
"paths"
] | 5f174888ce578908713a6b8b490d4c5b24997296 | https://github.com/jesseditson/fs-router/blob/5f174888ce578908713a6b8b490d4c5b24997296/index.js#L41-L47 | train |
ysmood/yaku | src/yaku.aplus.js | scheduleHandler | function scheduleHandler (p1, p2) {
return setTimeout(function () {
var x, handler = p1._s ? p2._onFulfilled : p2._onRejected;
// 2.2.7.3
// 2.2.7.4
if (handler === void 0) {
settlePromise(p2, p1._s, p1._v);
return;
}
... | javascript | function scheduleHandler (p1, p2) {
return setTimeout(function () {
var x, handler = p1._s ? p2._onFulfilled : p2._onRejected;
// 2.2.7.3
// 2.2.7.4
if (handler === void 0) {
settlePromise(p2, p1._s, p1._v);
return;
}
... | [
"function",
"scheduleHandler",
"(",
"p1",
",",
"p2",
")",
"{",
"return",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"x",
",",
"handler",
"=",
"p1",
".",
"_s",
"?",
"p2",
".",
"_onFulfilled",
":",
"p2",
".",
"_onRejected",
";",
"// 2.2.7.3",
... | Resolve the value returned by onFulfilled or onRejected.
@private
@param {Yaku} p1
@param {Yaku} p2 | [
"Resolve",
"the",
"value",
"returned",
"by",
"onFulfilled",
"or",
"onRejected",
"."
] | f0fb064d23dfada832751832800f2199de566e22 | https://github.com/ysmood/yaku/blob/f0fb064d23dfada832751832800f2199de566e22/src/yaku.aplus.js#L116-L139 | train |
ysmood/yaku | src/yaku.aplus.js | settleWithX | function settleWithX (p, x) {
// 2.3.1
if (x === p && x) {
settlePromise(p, $rejected, new TypeError('promise_circular_chain'));
return;
}
// 2.3.2
// 2.3.3
var xthen, type = typeof x;
if (x !== null && (type === 'function' || type === 'ob... | javascript | function settleWithX (p, x) {
// 2.3.1
if (x === p && x) {
settlePromise(p, $rejected, new TypeError('promise_circular_chain'));
return;
}
// 2.3.2
// 2.3.3
var xthen, type = typeof x;
if (x !== null && (type === 'function' || type === 'ob... | [
"function",
"settleWithX",
"(",
"p",
",",
"x",
")",
"{",
"// 2.3.1",
"if",
"(",
"x",
"===",
"p",
"&&",
"x",
")",
"{",
"settlePromise",
"(",
"p",
",",
"$rejected",
",",
"new",
"TypeError",
"(",
"'promise_circular_chain'",
")",
")",
";",
"return",
";",
... | Resolve or reject primise with value x. The x can also be a thenable.
@private
@param {Yaku} p
@param {Any | Thenable} x A normal value or a thenable. | [
"Resolve",
"or",
"reject",
"primise",
"with",
"value",
"x",
".",
"The",
"x",
"can",
"also",
"be",
"a",
"thenable",
"."
] | f0fb064d23dfada832751832800f2199de566e22 | https://github.com/ysmood/yaku/blob/f0fb064d23dfada832751832800f2199de566e22/src/yaku.aplus.js#L177-L207 | train |
ysmood/yaku | src/Observable.js | function (onNext, onError) {
var self = this, subscriber = new Observable();
subscriber._onNext = onNext;
subscriber._onError = onError;
subscriber._nextErr = genNextErr(subscriber.next);
subscriber.publisher = self;
self.subscribers.push(subscriber);
return sub... | javascript | function (onNext, onError) {
var self = this, subscriber = new Observable();
subscriber._onNext = onNext;
subscriber._onError = onError;
subscriber._nextErr = genNextErr(subscriber.next);
subscriber.publisher = self;
self.subscribers.push(subscriber);
return sub... | [
"function",
"(",
"onNext",
",",
"onError",
")",
"{",
"var",
"self",
"=",
"this",
",",
"subscriber",
"=",
"new",
"Observable",
"(",
")",
";",
"subscriber",
".",
"_onNext",
"=",
"onNext",
";",
"subscriber",
".",
"_onError",
"=",
"onError",
";",
"subscriber... | It will create a new Observable, like promise.
@param {Function} onNext
@param {Function} onError
@return {Observable} | [
"It",
"will",
"create",
"a",
"new",
"Observable",
"like",
"promise",
"."
] | f0fb064d23dfada832751832800f2199de566e22 | https://github.com/ysmood/yaku/blob/f0fb064d23dfada832751832800f2199de566e22/src/Observable.js#L103-L113 | train | |
ysmood/yaku | src/yaku.core.js | genScheduler | function genScheduler (initQueueSize, fn) {
/**
* All async promise will be scheduled in
* here, so that they can be execute on the next tick.
* @private
*/
var fnQueue = Arr(initQueueSize)
, fnQueueLen = 0;
/**
* Run all queued functions... | javascript | function genScheduler (initQueueSize, fn) {
/**
* All async promise will be scheduled in
* here, so that they can be execute on the next tick.
* @private
*/
var fnQueue = Arr(initQueueSize)
, fnQueueLen = 0;
/**
* Run all queued functions... | [
"function",
"genScheduler",
"(",
"initQueueSize",
",",
"fn",
")",
"{",
"/**\n * All async promise will be scheduled in\n * here, so that they can be execute on the next tick.\n * @private\n */",
"var",
"fnQueue",
"=",
"Arr",
"(",
"initQueueSize",
")",
... | Generate a scheduler.
@private
@param {Integer} initQueueSize
@param {Function} fn `(Yaku, Value) ->` The schedule handler.
@return {Function} `(Yaku, Value) ->` The scheduler. | [
"Generate",
"a",
"scheduler",
"."
] | f0fb064d23dfada832751832800f2199de566e22 | https://github.com/ysmood/yaku/blob/f0fb064d23dfada832751832800f2199de566e22/src/yaku.core.js#L389-L420 | train |
ysmood/yaku | src/yaku.core.js | flush | function flush () {
var i = 0;
while (i < fnQueueLen) {
fn(fnQueue[i], fnQueue[i + 1]);
fnQueue[i++] = $undefined;
fnQueue[i++] = $undefined;
}
fnQueueLen = 0;
if (fnQueue.length > initQueueSize) fnQueue.length ... | javascript | function flush () {
var i = 0;
while (i < fnQueueLen) {
fn(fnQueue[i], fnQueue[i + 1]);
fnQueue[i++] = $undefined;
fnQueue[i++] = $undefined;
}
fnQueueLen = 0;
if (fnQueue.length > initQueueSize) fnQueue.length ... | [
"function",
"flush",
"(",
")",
"{",
"var",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"fnQueueLen",
")",
"{",
"fn",
"(",
"fnQueue",
"[",
"i",
"]",
",",
"fnQueue",
"[",
"i",
"+",
"1",
"]",
")",
";",
"fnQueue",
"[",
"i",
"++",
"]",
"=",
"$un... | Run all queued functions.
@private | [
"Run",
"all",
"queued",
"functions",
"."
] | f0fb064d23dfada832751832800f2199de566e22 | https://github.com/ysmood/yaku/blob/f0fb064d23dfada832751832800f2199de566e22/src/yaku.core.js#L402-L412 | train |
ysmood/yaku | src/yaku.core.js | settleWithX | function settleWithX (p, x) {
// 2.3.1
if (x === p && x) {
settlePromise(p, $rejected, genTypeError($promiseCircularChain));
return p;
}
// 2.3.2
// 2.3.3
if (x !== $null && (isFunction(x) || isObject(x))) {
// 2.3.2.1
var ... | javascript | function settleWithX (p, x) {
// 2.3.1
if (x === p && x) {
settlePromise(p, $rejected, genTypeError($promiseCircularChain));
return p;
}
// 2.3.2
// 2.3.3
if (x !== $null && (isFunction(x) || isObject(x))) {
// 2.3.2.1
var ... | [
"function",
"settleWithX",
"(",
"p",
",",
"x",
")",
"{",
"// 2.3.1",
"if",
"(",
"x",
"===",
"p",
"&&",
"x",
")",
"{",
"settlePromise",
"(",
"p",
",",
"$rejected",
",",
"genTypeError",
"(",
"$promiseCircularChain",
")",
")",
";",
"return",
"p",
";",
"... | Resolve or reject promise with value x. The x can also be a thenable.
@private
@param {Yaku} p
@param {Any | Thenable} x A normal value or a thenable. | [
"Resolve",
"or",
"reject",
"promise",
"with",
"value",
"x",
".",
"The",
"x",
"can",
"also",
"be",
"a",
"thenable",
"."
] | f0fb064d23dfada832751832800f2199de566e22 | https://github.com/ysmood/yaku/blob/f0fb064d23dfada832751832800f2199de566e22/src/yaku.core.js#L653-L688 | train |
uploadcare/uploadcare-widget | scripts/serve.js | saveUrl | function saveUrl(url) {
fs.writeFile('serve-url.log', url, error => {
if (error) {
return console.log(error)
}
console.log('serve-url.log updated!')
})
} | javascript | function saveUrl(url) {
fs.writeFile('serve-url.log', url, error => {
if (error) {
return console.log(error)
}
console.log('serve-url.log updated!')
})
} | [
"function",
"saveUrl",
"(",
"url",
")",
"{",
"fs",
".",
"writeFile",
"(",
"'serve-url.log'",
",",
"url",
",",
"error",
"=>",
"{",
"if",
"(",
"error",
")",
"{",
"return",
"console",
".",
"log",
"(",
"error",
")",
"}",
"console",
".",
"log",
"(",
"'s... | Save url generated by ngrok to file
@param url | [
"Save",
"url",
"generated",
"by",
"ngrok",
"to",
"file"
] | 19f9d6424df2b94e83c088e33a155d87dc06ea0a | https://github.com/uploadcare/uploadcare-widget/blob/19f9d6424df2b94e83c088e33a155d87dc06ea0a/scripts/serve.js#L18-L26 | train |
uploadcare/uploadcare-widget | app/assets/javascripts/uploadcare/vendor/pusher.js | connectionDelay | function connectionDelay() {
var delay = self.connectionWait;
if (delay === 0) {
if (self.connectedAt) {
var t = 1000;
var connectedFor = new Date().getTime() - self.connectedAt;
if (connectedFor < t) {
delay = t - connectedFor;
}
}
}... | javascript | function connectionDelay() {
var delay = self.connectionWait;
if (delay === 0) {
if (self.connectedAt) {
var t = 1000;
var connectedFor = new Date().getTime() - self.connectedAt;
if (connectedFor < t) {
delay = t - connectedFor;
}
}
}... | [
"function",
"connectionDelay",
"(",
")",
"{",
"var",
"delay",
"=",
"self",
".",
"connectionWait",
";",
"if",
"(",
"delay",
"===",
"0",
")",
"{",
"if",
"(",
"self",
".",
"connectedAt",
")",
"{",
"var",
"t",
"=",
"1000",
";",
"var",
"connectedFor",
"="... | Returns the delay before the next connection attempt should be made This function guards against attempting to connect more frequently than once every second | [
"Returns",
"the",
"delay",
"before",
"the",
"next",
"connection",
"attempt",
"should",
"be",
"made",
"This",
"function",
"guards",
"against",
"attempting",
"to",
"connect",
"more",
"frequently",
"than",
"once",
"every",
"second"
] | 19f9d6424df2b94e83c088e33a155d87dc06ea0a | https://github.com/uploadcare/uploadcare-widget/blob/19f9d6424df2b94e83c088e33a155d87dc06ea0a/app/assets/javascripts/uploadcare/vendor/pusher.js#L710-L722 | train |
uploadcare/uploadcare-widget | app/assets/javascripts/uploadcare/vendor/pusher.js | parseWebSocketEvent | function parseWebSocketEvent(event) {
try {
var params = JSON.parse(event.data);
if (typeof params.data === 'string') {
try {
params.data = JSON.parse(params.data);
} catch (e) {
if (!(e instanceof SyntaxError)) {
throw e;
}
... | javascript | function parseWebSocketEvent(event) {
try {
var params = JSON.parse(event.data);
if (typeof params.data === 'string') {
try {
params.data = JSON.parse(params.data);
} catch (e) {
if (!(e instanceof SyntaxError)) {
throw e;
}
... | [
"function",
"parseWebSocketEvent",
"(",
"event",
")",
"{",
"try",
"{",
"var",
"params",
"=",
"JSON",
".",
"parse",
"(",
"event",
".",
"data",
")",
";",
"if",
"(",
"typeof",
"params",
".",
"data",
"===",
"'string'",
")",
"{",
"try",
"{",
"params",
"."... | Parses an event from the WebSocket to get
the JSON payload that we require
@param {MessageEvent} event The event from the WebSocket.onmessage handler. | [
"Parses",
"an",
"event",
"from",
"the",
"WebSocket",
"to",
"get",
"the",
"JSON",
"payload",
"that",
"we",
"require"
] | 19f9d6424df2b94e83c088e33a155d87dc06ea0a | https://github.com/uploadcare/uploadcare-widget/blob/19f9d6424df2b94e83c088e33a155d87dc06ea0a/app/assets/javascripts/uploadcare/vendor/pusher.js#L798-L816 | train |
uploadcare/uploadcare-widget | app/assets/javascripts/uploadcare/vendor/pusher.js | updateState | function updateState(newState, data) {
var prevState = self.state;
self.state = newState;
// Only emit when the state changes
if (prevState !== newState) {
Pusher.debug('State changed', prevState + ' -> ' + newState);
self.emit('state_change', {previous: prevState, current: newS... | javascript | function updateState(newState, data) {
var prevState = self.state;
self.state = newState;
// Only emit when the state changes
if (prevState !== newState) {
Pusher.debug('State changed', prevState + ' -> ' + newState);
self.emit('state_change', {previous: prevState, current: newS... | [
"function",
"updateState",
"(",
"newState",
",",
"data",
")",
"{",
"var",
"prevState",
"=",
"self",
".",
"state",
";",
"self",
".",
"state",
"=",
"newState",
";",
"// Only emit when the state changes",
"if",
"(",
"prevState",
"!==",
"newState",
")",
"{",
"Pu... | Updates the public state information exposed by connection This is distinct from the internal state information used by _machine to manage the connection | [
"Updates",
"the",
"public",
"state",
"information",
"exposed",
"by",
"connection",
"This",
"is",
"distinct",
"from",
"the",
"internal",
"state",
"information",
"used",
"by",
"_machine",
"to",
"manage",
"the",
"connection"
] | 19f9d6424df2b94e83c088e33a155d87dc06ea0a | https://github.com/uploadcare/uploadcare-widget/blob/19f9d6424df2b94e83c088e33a155d87dc06ea0a/app/assets/javascripts/uploadcare/vendor/pusher.js#L832-L842 | train |
TooTallNate/node-spotify-web | lib/spotify.js | Spotify | function Spotify () {
if (!(this instanceof Spotify)) return new Spotify();
EventEmitter.call(this);
this.seq = 0;
this.heartbeatInterval = 18E4; // 180s, from "spotify.web.client.js"
this.agent = superagent.agent();
this.connected = false; // true after the WebSocket "connect" message is sent
this._call... | javascript | function Spotify () {
if (!(this instanceof Spotify)) return new Spotify();
EventEmitter.call(this);
this.seq = 0;
this.heartbeatInterval = 18E4; // 180s, from "spotify.web.client.js"
this.agent = superagent.agent();
this.connected = false; // true after the WebSocket "connect" message is sent
this._call... | [
"function",
"Spotify",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Spotify",
")",
")",
"return",
"new",
"Spotify",
"(",
")",
";",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"seq",
"=",
"0",
";",
"this",
".",
"... | Spotify Web base class.
@api public | [
"Spotify",
"Web",
"base",
"class",
"."
] | 9ace59c486d32f194bb01fb578b2f0ddfabbe9a9 | https://github.com/TooTallNate/node-spotify-web/blob/9ace59c486d32f194bb01fb578b2f0ddfabbe9a9/lib/spotify.js#L76-L125 | train |
TooTallNate/node-spotify-web | lib/spotify.js | function(schema, dontRecurse) {
if ('string' === typeof schema) {
var schemaName = schema.split("#");
schema = schemas.build(schemaName[0], schemaName[1]);
if (!schema)
throw new Error('Could not load schema: ' + schemaName.join('#'));
} else if (schema && !dontRecurse && (!schema.hasO... | javascript | function(schema, dontRecurse) {
if ('string' === typeof schema) {
var schemaName = schema.split("#");
schema = schemas.build(schemaName[0], schemaName[1]);
if (!schema)
throw new Error('Could not load schema: ' + schemaName.join('#'));
} else if (schema && !dontRecurse && (!schema.hasO... | [
"function",
"(",
"schema",
",",
"dontRecurse",
")",
"{",
"if",
"(",
"'string'",
"===",
"typeof",
"schema",
")",
"{",
"var",
"schemaName",
"=",
"schema",
".",
"split",
"(",
"\"#\"",
")",
";",
"schema",
"=",
"schemas",
".",
"build",
"(",
"schemaName",
"[... | load payload and response schemas | [
"load",
"payload",
"and",
"response",
"schemas"
] | 9ace59c486d32f194bb01fb578b2f0ddfabbe9a9 | https://github.com/TooTallNate/node-spotify-web/blob/9ace59c486d32f194bb01fb578b2f0ddfabbe9a9/lib/spotify.js#L553-L566 | train | |
TooTallNate/node-spotify-web | lib/error.js | SpotifyError | function SpotifyError (err) {
this.domain = err[0] || 0;
this.code = err[1] || 0;
this.description = err[2] || '';
this.data = err[3] || null;
// Error impl
this.name = domains[this.domain];
var msg = codes[this.code];
if (this.description) msg += ' (' + this.description + ')';
this.message = msg;
... | javascript | function SpotifyError (err) {
this.domain = err[0] || 0;
this.code = err[1] || 0;
this.description = err[2] || '';
this.data = err[3] || null;
// Error impl
this.name = domains[this.domain];
var msg = codes[this.code];
if (this.description) msg += ' (' + this.description + ')';
this.message = msg;
... | [
"function",
"SpotifyError",
"(",
"err",
")",
"{",
"this",
".",
"domain",
"=",
"err",
"[",
"0",
"]",
"||",
"0",
";",
"this",
".",
"code",
"=",
"err",
"[",
"1",
"]",
"||",
"0",
";",
"this",
".",
"description",
"=",
"err",
"[",
"2",
"]",
"||",
"... | Spotify error class.
Sample `err` objects:
[ 11, 1, 'Invalid user' ]
[ 12, 8, '' ]
[ 14, 408, '' ]
[ 14, 429, '' ] | [
"Spotify",
"error",
"class",
"."
] | 9ace59c486d32f194bb01fb578b2f0ddfabbe9a9 | https://github.com/TooTallNate/node-spotify-web/blob/9ace59c486d32f194bb01fb578b2f0ddfabbe9a9/lib/error.js#L48-L60 | train |
MazeMap/Leaflet.TileLayer.PouchDBCached | L.TileLayer.PouchDBCached.js | function(coords, done) {
var tile = document.createElement("img");
tile.onerror = L.bind(this._tileOnError, this, done, tile);
if (this.options.crossOrigin) {
tile.crossOrigin = "";
}
/*
Alt tag is *set to empty string to keep screen readers from reading URL and for compliance reasons
http://www.w... | javascript | function(coords, done) {
var tile = document.createElement("img");
tile.onerror = L.bind(this._tileOnError, this, done, tile);
if (this.options.crossOrigin) {
tile.crossOrigin = "";
}
/*
Alt tag is *set to empty string to keep screen readers from reading URL and for compliance reasons
http://www.w... | [
"function",
"(",
"coords",
",",
"done",
")",
"{",
"var",
"tile",
"=",
"document",
".",
"createElement",
"(",
"\"img\"",
")",
";",
"tile",
".",
"onerror",
"=",
"L",
".",
"bind",
"(",
"this",
".",
"_tileOnError",
",",
"this",
",",
"done",
",",
"tile",
... | Overwrites L.TileLayer.prototype.createTile | [
"Overwrites",
"L",
".",
"TileLayer",
".",
"prototype",
".",
"createTile"
] | ca83b60dcdd276d7cd7f9c4f24eb1fd1138b2c72 | https://github.com/MazeMap/Leaflet.TileLayer.PouchDBCached/blob/ca83b60dcdd276d7cd7f9c4f24eb1fd1138b2c72/L.TileLayer.PouchDBCached.js#L56-L86 | train | |
MazeMap/Leaflet.TileLayer.PouchDBCached | L.TileLayer.PouchDBCached.js | function(coords) {
var zoom = coords.z;
if (this.options.zoomReverse) {
zoom = this.options.maxZoom - zoom;
}
zoom += this.options.zoomOffset;
return L.Util.template(
this._url,
L.extend(
{
r:
this.options.detectRetina &&
L.Browser.retina &&
this.options.maxZoom > 0
... | javascript | function(coords) {
var zoom = coords.z;
if (this.options.zoomReverse) {
zoom = this.options.maxZoom - zoom;
}
zoom += this.options.zoomOffset;
return L.Util.template(
this._url,
L.extend(
{
r:
this.options.detectRetina &&
L.Browser.retina &&
this.options.maxZoom > 0
... | [
"function",
"(",
"coords",
")",
"{",
"var",
"zoom",
"=",
"coords",
".",
"z",
";",
"if",
"(",
"this",
".",
"options",
".",
"zoomReverse",
")",
"{",
"zoom",
"=",
"this",
".",
"options",
".",
"maxZoom",
"-",
"zoom",
";",
"}",
"zoom",
"+=",
"this",
"... | Modified L.TileLayer.getTileUrl, this will use the zoom given by the parameter coords instead of the maps current zoomlevel. | [
"Modified",
"L",
".",
"TileLayer",
".",
"getTileUrl",
"this",
"will",
"use",
"the",
"zoom",
"given",
"by",
"the",
"parameter",
"coords",
"instead",
"of",
"the",
"maps",
"current",
"zoomlevel",
"."
] | ca83b60dcdd276d7cd7f9c4f24eb1fd1138b2c72 | https://github.com/MazeMap/Leaflet.TileLayer.PouchDBCached/blob/ca83b60dcdd276d7cd7f9c4f24eb1fd1138b2c72/L.TileLayer.PouchDBCached.js#L276-L304 | train | |
MazeMap/Leaflet.TileLayer.PouchDBCached | L.TileLayer.PouchDBCached.js | function(tile, remaining, seedData) {
if (!remaining.length) {
this.fire("seedend", seedData);
return;
}
this.fire("seedprogress", {
bbox: seedData.bbox,
minZoom: seedData.minZoom,
maxZoom: seedData.maxZoom,
queueLength: seedData.queueLength,
remainingLength: remaining.length,
});
var ur... | javascript | function(tile, remaining, seedData) {
if (!remaining.length) {
this.fire("seedend", seedData);
return;
}
this.fire("seedprogress", {
bbox: seedData.bbox,
minZoom: seedData.minZoom,
maxZoom: seedData.maxZoom,
queueLength: seedData.queueLength,
remainingLength: remaining.length,
});
var ur... | [
"function",
"(",
"tile",
",",
"remaining",
",",
"seedData",
")",
"{",
"if",
"(",
"!",
"remaining",
".",
"length",
")",
"{",
"this",
".",
"fire",
"(",
"\"seedend\"",
",",
"seedData",
")",
";",
"return",
";",
"}",
"this",
".",
"fire",
"(",
"\"seedprogr... | Uses a defined tile to eat through one item in the queue and asynchronously recursively call itself when the tile has finished loading. | [
"Uses",
"a",
"defined",
"tile",
"to",
"eat",
"through",
"one",
"item",
"in",
"the",
"queue",
"and",
"asynchronously",
"recursively",
"call",
"itself",
"when",
"the",
"tile",
"has",
"finished",
"loading",
"."
] | ca83b60dcdd276d7cd7f9c4f24eb1fd1138b2c72 | https://github.com/MazeMap/Leaflet.TileLayer.PouchDBCached/blob/ca83b60dcdd276d7cd7f9c4f24eb1fd1138b2c72/L.TileLayer.PouchDBCached.js#L309-L340 | train | |
antoniogarrote/rdfstore-js | src/query_plan.js | function(left, right, cost, identifier, allVars, joinVars) {
this.left = left;
this.right = right;
this.cost = cost;
this.i = identifier;
this.vars = allVars;
this.join = joinVars;
} | javascript | function(left, right, cost, identifier, allVars, joinVars) {
this.left = left;
this.right = right;
this.cost = cost;
this.i = identifier;
this.vars = allVars;
this.join = joinVars;
} | [
"function",
"(",
"left",
",",
"right",
",",
"cost",
",",
"identifier",
",",
"allVars",
",",
"joinVars",
")",
"{",
"this",
".",
"left",
"=",
"left",
";",
"this",
".",
"right",
"=",
"right",
";",
"this",
".",
"cost",
"=",
"cost",
";",
"this",
".",
... | A new query plan object
@param left
@param right
@param cost
@param identifier
@param allVars
@param joinVars
@constructor | [
"A",
"new",
"query",
"plan",
"object"
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/src/query_plan.js#L14-L23 | train | |
antoniogarrote/rdfstore-js | src/query_plan.js | function(vars, groupVars) {
for(var j=0; j<vars.length; j++) {
var thisVar = "/"+vars[j]+"/";
if(groupVars.indexOf(thisVar) != -1) {
return true;
}
}
return false;
} | javascript | function(vars, groupVars) {
for(var j=0; j<vars.length; j++) {
var thisVar = "/"+vars[j]+"/";
if(groupVars.indexOf(thisVar) != -1) {
return true;
}
}
return false;
} | [
"function",
"(",
"vars",
",",
"groupVars",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"vars",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"thisVar",
"=",
"\"/\"",
"+",
"vars",
"[",
"j",
"]",
"+",
"\"/\"",
";",
"if",
"(",
... | Returns true if the any of the passed vars are in the vars associated to the group. | [
"Returns",
"true",
"if",
"the",
"any",
"of",
"the",
"passed",
"vars",
"are",
"in",
"the",
"vars",
"associated",
"to",
"the",
"group",
"."
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/src/query_plan.js#L118-L128 | train | |
antoniogarrote/rdfstore-js | src/query_plan.js | function(bgp, toJoin, newGroups, newGroupVars) {
var acumGroups = [];
var acumId = "";
var acumVars = "";
for(var gid in toJoin) {
acumId = acumId+gid; // new group id
acumGroups = acumGroups.concat(groups[gid]);
acumVars = acumVars + groupVars[gid]; /... | javascript | function(bgp, toJoin, newGroups, newGroupVars) {
var acumGroups = [];
var acumId = "";
var acumVars = "";
for(var gid in toJoin) {
acumId = acumId+gid; // new group id
acumGroups = acumGroups.concat(groups[gid]);
acumVars = acumVars + groupVars[gid]; /... | [
"function",
"(",
"bgp",
",",
"toJoin",
",",
"newGroups",
",",
"newGroupVars",
")",
"{",
"var",
"acumGroups",
"=",
"[",
"]",
";",
"var",
"acumId",
"=",
"\"\"",
";",
"var",
"acumVars",
"=",
"\"\"",
";",
"for",
"(",
"var",
"gid",
"in",
"toJoin",
")",
... | Creates a new group merging the vars and the groups | [
"Creates",
"a",
"new",
"group",
"merging",
"the",
"vars",
"and",
"the",
"groups"
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/src/query_plan.js#L131-L146 | train | |
antoniogarrote/rdfstore-js | frontend/js/rdfquery.js | function (absolute) {
var aPath, bPath, i = 0, j, resultPath = [], result = '';
if (typeof absolute === 'string') {
absolute = $.uri(absolute, {});
}
if (absolute.scheme !== this.scheme ||
absolute.authority !== this.authority) {
return absolute.toString();
}
... | javascript | function (absolute) {
var aPath, bPath, i = 0, j, resultPath = [], result = '';
if (typeof absolute === 'string') {
absolute = $.uri(absolute, {});
}
if (absolute.scheme !== this.scheme ||
absolute.authority !== this.authority) {
return absolute.toString();
}
... | [
"function",
"(",
"absolute",
")",
"{",
"var",
"aPath",
",",
"bPath",
",",
"i",
"=",
"0",
",",
"j",
",",
"resultPath",
"=",
"[",
"]",
",",
"result",
"=",
"''",
";",
"if",
"(",
"typeof",
"absolute",
"===",
"'string'",
")",
"{",
"absolute",
"=",
"$"... | Creates a relative URI giving the path from this URI to the absolute URI passed as a parameter
@param {String|jQuery.uri} absolute
@returns String | [
"Creates",
"a",
"relative",
"URI",
"giving",
"the",
"path",
"from",
"this",
"URI",
"to",
"the",
"absolute",
"URI",
"passed",
"as",
"a",
"parameter"
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/frontend/js/rdfquery.js#L174-L212 | train | |
antoniogarrote/rdfstore-js | frontend/js/rdfquery.js | function () {
var result = '';
if (this._string) {
return this._string;
} else {
result = this.scheme === undefined ? result : (result + this.scheme + ':');
result = this.authority === undefined ? result : (result + '//' + this.authority);
result = result + this.path;
... | javascript | function () {
var result = '';
if (this._string) {
return this._string;
} else {
result = this.scheme === undefined ? result : (result + this.scheme + ':');
result = this.authority === undefined ? result : (result + '//' + this.authority);
result = result + this.path;
... | [
"function",
"(",
")",
"{",
"var",
"result",
"=",
"''",
";",
"if",
"(",
"this",
".",
"_string",
")",
"{",
"return",
"this",
".",
"_string",
";",
"}",
"else",
"{",
"result",
"=",
"this",
".",
"scheme",
"===",
"undefined",
"?",
"result",
":",
"(",
"... | Returns the URI as an absolute string
@returns String | [
"Returns",
"the",
"URI",
"as",
"an",
"absolute",
"string"
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/frontend/js/rdfquery.js#L218-L231 | train | |
antoniogarrote/rdfstore-js | frontend/js/rdfquery.js | function (options) {
options = $.extend({ namespaces: this.namespaces, base: this.base }, options || {});
return $.rdf.dump(this.triples(), options);
} | javascript | function (options) {
options = $.extend({ namespaces: this.namespaces, base: this.base }, options || {});
return $.rdf.dump(this.triples(), options);
} | [
"function",
"(",
"options",
")",
"{",
"options",
"=",
"$",
".",
"extend",
"(",
"{",
"namespaces",
":",
"this",
".",
"namespaces",
",",
"base",
":",
"this",
".",
"base",
"}",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"$",
".",
"rdf",
"."... | Dumps the triples in the databank into a format that can be shown to the user or sent to a server.
@param {Object} [options] Options that control the formatting of the triples. See {@link jQuery.rdf.dump} for details.
@returns {Object|Node|String}
@see jQuery.rdf.dump | [
"Dumps",
"the",
"triples",
"in",
"the",
"databank",
"into",
"a",
"format",
"that",
"can",
"be",
"shown",
"to",
"the",
"user",
"or",
"sent",
"to",
"a",
"server",
"."
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/frontend/js/rdfquery.js#L2792-L2795 | train | |
antoniogarrote/rdfstore-js | frontend/js/rdfquery.js | function (triple) {
var binding = {};
binding = testResource(triple.subject, this.subject, binding);
if (binding === null) {
return null;
}
binding = testResource(triple.property, this.property, binding);
if (binding === null) {
return null;
}
binding = te... | javascript | function (triple) {
var binding = {};
binding = testResource(triple.subject, this.subject, binding);
if (binding === null) {
return null;
}
binding = testResource(triple.property, this.property, binding);
if (binding === null) {
return null;
}
binding = te... | [
"function",
"(",
"triple",
")",
"{",
"var",
"binding",
"=",
"{",
"}",
";",
"binding",
"=",
"testResource",
"(",
"triple",
".",
"subject",
",",
"this",
".",
"subject",
",",
"binding",
")",
";",
"if",
"(",
"binding",
"===",
"null",
")",
"{",
"return",
... | Creates a new Object holding variable bindings by matching the passed triple against this pattern.
@param {jQuery.rdf.triple} triple A {@link jQuery.rdf.triple} for this pattern to match against.
@returns {null|Object} An object containing the bindings of variables (as specified in this pattern) to values (as specified... | [
"Creates",
"a",
"new",
"Object",
"holding",
"variable",
"bindings",
"by",
"matching",
"the",
"passed",
"triple",
"against",
"this",
"pattern",
"."
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/frontend/js/rdfquery.js#L3020-L3032 | train | |
antoniogarrote/rdfstore-js | frontend/js/rdfquery.js | function (bindings) {
var t = this;
if (!this.isFixed()) {
t = this.fill(bindings);
}
if (t.isFixed()) {
return $.rdf.triple(t.subject, t.property, t.object, { source: this.toString() });
} else {
return null;
}
} | javascript | function (bindings) {
var t = this;
if (!this.isFixed()) {
t = this.fill(bindings);
}
if (t.isFixed()) {
return $.rdf.triple(t.subject, t.property, t.object, { source: this.toString() });
} else {
return null;
}
} | [
"function",
"(",
"bindings",
")",
"{",
"var",
"t",
"=",
"this",
";",
"if",
"(",
"!",
"this",
".",
"isFixed",
"(",
")",
")",
"{",
"t",
"=",
"this",
".",
"fill",
"(",
"bindings",
")",
";",
"}",
"if",
"(",
"t",
".",
"isFixed",
"(",
")",
")",
"... | Creates a new triple based on the bindings passed to the pattern, if possible.
@param {Object} bindings An object holding the variable bindings to be used to replace any placeholders in the pattern. These bindings are of the type held by the {@link jQuery.rdf} object.
@returns {null|jQuery.rdf.triple} A new {@link jQue... | [
"Creates",
"a",
"new",
"triple",
"based",
"on",
"the",
"bindings",
"passed",
"to",
"the",
"pattern",
"if",
"possible",
"."
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/frontend/js/rdfquery.js#L3059-L3069 | train | |
antoniogarrote/rdfstore-js | src/utils.js | function(term) {
try {
if(term == null) {
return "";
} if(term.token==='uri') {
return "u"+term.value;
} else if(term.token === 'blank') {
return "b"+term.value;
} else if(term.token === 'literal') {
var l = "l"+term.value;
... | javascript | function(term) {
try {
if(term == null) {
return "";
} if(term.token==='uri') {
return "u"+term.value;
} else if(term.token === 'blank') {
return "b"+term.value;
} else if(term.token === 'literal') {
var l = "l"+term.value;
... | [
"function",
"(",
"term",
")",
"{",
"try",
"{",
"if",
"(",
"term",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"term",
".",
"token",
"===",
"'uri'",
")",
"{",
"return",
"\"u\"",
"+",
"term",
".",
"value",
";",
"}",
"else",
"if... | Function that generates a hash key for a bound term.
@param term
@returns {*} | [
"Function",
"that",
"generates",
"a",
"hash",
"key",
"for",
"a",
"bound",
"term",
"."
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/src/utils.js#L34-L60 | train | |
antoniogarrote/rdfstore-js | lubm/browser/server.js | function(filename, charset, callback) {
fs.readFile(filename, function (err, data) {
if (err) throw err;
zlib.gzip(data, function(err, result) {
callback(result);
});
});
} | javascript | function(filename, charset, callback) {
fs.readFile(filename, function (err, data) {
if (err) throw err;
zlib.gzip(data, function(err, result) {
callback(result);
});
});
} | [
"function",
"(",
"filename",
",",
"charset",
",",
"callback",
")",
"{",
"fs",
".",
"readFile",
"(",
"filename",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"throw",
"err",
";",
"zlib",
".",
"gzip",
"(",
"data",
",",
... | gzip file. | [
"gzip",
"file",
"."
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/lubm/browser/server.js#L35-L45 | train | |
antoniogarrote/rdfstore-js | src/store.js | function(){
if(arguments.length == 1) {
return new Store(arguments[0]);
} else if(arguments.length == 2) {
return new Store(arguments[0], arguments[1]);
} else {
return new Store();
};
} | javascript | function(){
if(arguments.length == 1) {
return new Store(arguments[0]);
} else if(arguments.length == 2) {
return new Store(arguments[0], arguments[1]);
} else {
return new Store();
};
} | [
"function",
"(",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"==",
"1",
")",
"{",
"return",
"new",
"Store",
"(",
"arguments",
"[",
"0",
"]",
")",
";",
"}",
"else",
"if",
"(",
"arguments",
".",
"length",
"==",
"2",
")",
"{",
"return",
"new",
... | Creates a new instance of the store.
The function accepts two optional arguments.
<br/>
If only one argument is passed it must be a
callback function that will be invoked when the
store had been created.<br/>
<br/>
If two arguments are passed the first one must
be a map of configuration parameters for the
store, and t... | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"store",
"."
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/src/store.js#L909-L917 | train | |
antoniogarrote/rdfstore-js | spec/browser/nodeunit.js | function (callback) {
return function (new_method, assert_method, arity) {
return function () {
var message = arguments[arity - 1];
var a = exports.assertion({method: new_method, message: message});
try {
assert[assert_method].apply(null, arguments);
... | javascript | function (callback) {
return function (new_method, assert_method, arity) {
return function () {
var message = arguments[arity - 1];
var a = exports.assertion({method: new_method, message: message});
try {
assert[assert_method].apply(null, arguments);
... | [
"function",
"(",
"callback",
")",
"{",
"return",
"function",
"(",
"new_method",
",",
"assert_method",
",",
"arity",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"message",
"=",
"arguments",
"[",
"arity",
"-",
"1",
"]",
";",
"var",
"a",
"=",
... | Create a wrapper function for assert module methods. Executes a callback
after the it's complete with an assertion object representing the result.
@param {Function} callback
@api private | [
"Create",
"a",
"wrapper",
"function",
"for",
"assert",
"module",
"methods",
".",
"Executes",
"a",
"callback",
"after",
"the",
"it",
"s",
"complete",
"with",
"an",
"assertion",
"object",
"representing",
"the",
"result",
"."
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/spec/browser/nodeunit.js#L1515-L1529 | train | |
antoniogarrote/rdfstore-js | spec/browser/nodeunit.js | function (setUp, tearDown, fn) {
return function (test) {
var context = {};
if (tearDown) {
var done = test.done;
test.done = function (err) {
try {
tearDown.call(context, function (err2) {
if (err && err2) {
... | javascript | function (setUp, tearDown, fn) {
return function (test) {
var context = {};
if (tearDown) {
var done = test.done;
test.done = function (err) {
try {
tearDown.call(context, function (err2) {
if (err && err2) {
... | [
"function",
"(",
"setUp",
",",
"tearDown",
",",
"fn",
")",
"{",
"return",
"function",
"(",
"test",
")",
"{",
"var",
"context",
"=",
"{",
"}",
";",
"if",
"(",
"tearDown",
")",
"{",
"var",
"done",
"=",
"test",
".",
"done",
";",
"test",
".",
"done",... | Wraps a test function with setUp and tearDown functions.
Used by testCase.
@param {Function} setUp
@param {Function} tearDown
@param {Function} fn
@api private | [
"Wraps",
"a",
"test",
"function",
"with",
"setUp",
"and",
"tearDown",
"functions",
".",
"Used",
"by",
"testCase",
"."
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/spec/browser/nodeunit.js#L1822-L1856 | train | |
antoniogarrote/rdfstore-js | spec/browser/nodeunit.js | function (setUp, tearDown, group) {
var tests = {};
var keys = _keys(group);
for (var i = 0; i < keys.length; i += 1) {
var k = keys[i];
if (typeof group[k] === 'function') {
tests[k] = wrapTest(setUp, tearDown, group[k]);
}
else if (typeof group[k] === 'object') ... | javascript | function (setUp, tearDown, group) {
var tests = {};
var keys = _keys(group);
for (var i = 0; i < keys.length; i += 1) {
var k = keys[i];
if (typeof group[k] === 'function') {
tests[k] = wrapTest(setUp, tearDown, group[k]);
}
else if (typeof group[k] === 'object') ... | [
"function",
"(",
"setUp",
",",
"tearDown",
",",
"group",
")",
"{",
"var",
"tests",
"=",
"{",
"}",
";",
"var",
"keys",
"=",
"_keys",
"(",
"group",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"+="... | Wraps a group of tests with setUp and tearDown functions.
Used by testCase.
@param {Function} setUp
@param {Function} tearDown
@param {Object} group
@api private | [
"Wraps",
"a",
"group",
"of",
"tests",
"with",
"setUp",
"and",
"tearDown",
"functions",
".",
"Used",
"by",
"testCase",
"."
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/spec/browser/nodeunit.js#L1869-L1882 | train | |
antoniogarrote/rdfstore-js | src/rvn3_parser.js | convertEntity | function convertEntity(entity) {
switch (entity[0]) {
case '"': {
if(entity.indexOf("^^") > 0) {
var parts = entity.split("^^");
return {literal: parts[0] + "^^<" + parts[1] + ">" };
} else {
return { literal: entity };
}
... | javascript | function convertEntity(entity) {
switch (entity[0]) {
case '"': {
if(entity.indexOf("^^") > 0) {
var parts = entity.split("^^");
return {literal: parts[0] + "^^<" + parts[1] + ">" };
} else {
return { literal: entity };
}
... | [
"function",
"convertEntity",
"(",
"entity",
")",
"{",
"switch",
"(",
"entity",
"[",
"0",
"]",
")",
"{",
"case",
"'\"'",
":",
"{",
"if",
"(",
"entity",
".",
"indexOf",
"(",
"\"^^\"",
")",
">",
"0",
")",
"{",
"var",
"parts",
"=",
"entity",
".",
"sp... | Converts an entity in N3.js representation to this library's representation | [
"Converts",
"an",
"entity",
"in",
"N3",
".",
"js",
"representation",
"to",
"this",
"library",
"s",
"representation"
] | 1b19a61ede04ba19605ca3b7dc331c990ab7336f | https://github.com/antoniogarrote/rdfstore-js/blob/1b19a61ede04ba19605ca3b7dc331c990ab7336f/src/rvn3_parser.js#L47-L60 | train |
mozilla/fxa-shared | oauth/scopes.js | coerce | function coerce(scopes) {
if (scopes instanceof ScopeSet) {
return scopes;
}
// If we receive a string, assume it's a single scope.
// We deliberately do not attempt to split the string on whitespace here,
// because we want to force callers to explicitly choose between
// exports.fromString() or export... | javascript | function coerce(scopes) {
if (scopes instanceof ScopeSet) {
return scopes;
}
// If we receive a string, assume it's a single scope.
// We deliberately do not attempt to split the string on whitespace here,
// because we want to force callers to explicitly choose between
// exports.fromString() or export... | [
"function",
"coerce",
"(",
"scopes",
")",
"{",
"if",
"(",
"scopes",
"instanceof",
"ScopeSet",
")",
"{",
"return",
"scopes",
";",
"}",
"// If we receive a string, assume it's a single scope.",
"// We deliberately do not attempt to split the string on whitespace here,",
"// becau... | A little helper function for coercing different
kinds of input data into a `ScopeSet` instance. | [
"A",
"little",
"helper",
"function",
"for",
"coercing",
"different",
"kinds",
"of",
"input",
"data",
"into",
"a",
"ScopeSet",
"instance",
"."
] | e95c36400472642311554dab53dde8068f973c59 | https://github.com/mozilla/fxa-shared/blob/e95c36400472642311554dab53dde8068f973c59/oauth/scopes.js#L437-L450 | train |
mozilla/fxa-shared | feature-flags/index.js | initialise | function initialise (config, log, defaults) {
const { interval, redis: redisConfig } = config;
if (! (interval > 0 && interval < Infinity)) {
throw new TypeError('Invalid interval');
}
if (! log) {
throw new TypeError('Missing log argument');
}
const redis = require('../redis')({
...redisConf... | javascript | function initialise (config, log, defaults) {
const { interval, redis: redisConfig } = config;
if (! (interval > 0 && interval < Infinity)) {
throw new TypeError('Invalid interval');
}
if (! log) {
throw new TypeError('Missing log argument');
}
const redis = require('../redis')({
...redisConf... | [
"function",
"initialise",
"(",
"config",
",",
"log",
",",
"defaults",
")",
"{",
"const",
"{",
"interval",
",",
"redis",
":",
"redisConfig",
"}",
"=",
"config",
";",
"if",
"(",
"!",
"(",
"interval",
">",
"0",
"&&",
"interval",
"<",
"Infinity",
")",
")... | Initialise the feature-flag module.
@param {Object} config - Configuration object.
@param {Object} config.interval - Refresh interval.
@param {Object} [config.redis] - Redis config.
@param {String} [config.redis.host] - Redis host name or IP address.
@param {Number} [config.redis.port] - Redis port.
@param {Number} [c... | [
"Initialise",
"the",
"feature",
"-",
"flag",
"module",
"."
] | e95c36400472642311554dab53dde8068f973c59 | https://github.com/mozilla/fxa-shared/blob/e95c36400472642311554dab53dde8068f973c59/feature-flags/index.js#L31-L118 | train |
kentcdodds/webpack-config-utils | src/get-if-utils.js | getIfUtils | function getIfUtils(env, vars = ['production', 'prod', 'test', 'development', 'dev']) {
env = typeof env === 'string' ? {[env]: true} : env
if (typeof env !== 'object') {
throw new Error(
`webpack-config-utils:getIfUtils: env passed should be a string/Object. Was ${JSON.stringify(env)}`
)
}
return... | javascript | function getIfUtils(env, vars = ['production', 'prod', 'test', 'development', 'dev']) {
env = typeof env === 'string' ? {[env]: true} : env
if (typeof env !== 'object') {
throw new Error(
`webpack-config-utils:getIfUtils: env passed should be a string/Object. Was ${JSON.stringify(env)}`
)
}
return... | [
"function",
"getIfUtils",
"(",
"env",
",",
"vars",
"=",
"[",
"'production'",
",",
"'prod'",
",",
"'test'",
",",
"'development'",
",",
"'dev'",
"]",
")",
"{",
"env",
"=",
"typeof",
"env",
"===",
"'string'",
"?",
"{",
"[",
"env",
"]",
":",
"true",
"}",... | The object returned from getIfUtils
@typedef {Object} IfUtils
@property {function} ifProduction - a wrapper around `propIf` function that returns the given `value` if the
environment is `"production"` or the `alternate` if not
@property {function} ifNotProduction, - a wrapper around `propIf` function that returns the g... | [
"The",
"object",
"returned",
"from",
"getIfUtils"
] | 816ac556f1b9a88c07ba2bc31d312948a653b057 | https://github.com/kentcdodds/webpack-config-utils/blob/816ac556f1b9a88c07ba2bc31d312948a653b057/src/get-if-utils.js#L37-L55 | train |
eddyerburgh/avoriaz | dist/avoriaz.amd.js | ListCache | function ListCache(entries) {
var this$1 = this;
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this$1.set(entry[0], entry[1]);
}
} | javascript | function ListCache(entries) {
var this$1 = this;
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this$1.set(entry[0], entry[1]);
}
} | [
"function",
"ListCache",
"(",
"entries",
")",
"{",
"var",
"this$1",
"=",
"this",
";",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"entries",
"==",
"null",
"?",
"0",
":",
"entries",
".",
"length",
";",
"this",
".",
"clear",
"(",
")",
";",
"... | Creates an list cache object.
@private
@constructor
@param {Array} [entries] The key-value pairs to cache. | [
"Creates",
"an",
"list",
"cache",
"object",
"."
] | 4070f017bf1d0175c54ab383f880ef815cc887c6 | https://github.com/eddyerburgh/avoriaz/blob/4070f017bf1d0175c54ab383f880ef815cc887c6/dist/avoriaz.amd.js#L176-L187 | train |
olov/ng-annotate | lut.js | findNodeFromPos | function findNodeFromPos(pos) {
const lut = this.begins;
assert(is.finitenumber(pos) && pos >= 0);
let left = 0;
let right = lut.length - 1;
while (left < right) {
const mid = Math.floor((left + right) / 2);
assert(mid >= 0 && mid < lut.length);
if (pos > lut[mid].range[0]) ... | javascript | function findNodeFromPos(pos) {
const lut = this.begins;
assert(is.finitenumber(pos) && pos >= 0);
let left = 0;
let right = lut.length - 1;
while (left < right) {
const mid = Math.floor((left + right) / 2);
assert(mid >= 0 && mid < lut.length);
if (pos > lut[mid].range[0]) ... | [
"function",
"findNodeFromPos",
"(",
"pos",
")",
"{",
"const",
"lut",
"=",
"this",
".",
"begins",
";",
"assert",
"(",
"is",
".",
"finitenumber",
"(",
"pos",
")",
"&&",
"pos",
">=",
"0",
")",
";",
"let",
"left",
"=",
"0",
";",
"let",
"right",
"=",
... | binary search lut to find node beginning at pos or as close after pos as possible. null if none | [
"binary",
"search",
"lut",
"to",
"find",
"node",
"beginning",
"at",
"pos",
"or",
"as",
"close",
"after",
"pos",
"as",
"possible",
".",
"null",
"if",
"none"
] | f5c709c682c99afe9e1413d9081734a62e3e5cdf | https://github.com/olov/ng-annotate/blob/f5c709c682c99afe9e1413d9081734a62e3e5cdf/lut.js#L56-L86 | train |
olov/ng-annotate | ng-annotate-main.js | replaceNodeWith | function replaceNodeWith(node, newNode) {
let done = false;
const parent = node.$parent;
const keys = Object.keys(parent);
keys.forEach(function(key) {
if (parent[key] === node) {
parent[key] = newNode;
done = true;
}
});
if (done) {
return;
}... | javascript | function replaceNodeWith(node, newNode) {
let done = false;
const parent = node.$parent;
const keys = Object.keys(parent);
keys.forEach(function(key) {
if (parent[key] === node) {
parent[key] = newNode;
done = true;
}
});
if (done) {
return;
}... | [
"function",
"replaceNodeWith",
"(",
"node",
",",
"newNode",
")",
"{",
"let",
"done",
"=",
"false",
";",
"const",
"parent",
"=",
"node",
".",
"$parent",
";",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"parent",
")",
";",
"keys",
".",
"forEach",
... | stand-in for not having a jsshaper-style ref's | [
"stand",
"-",
"in",
"for",
"not",
"having",
"a",
"jsshaper",
"-",
"style",
"ref",
"s"
] | f5c709c682c99afe9e1413d9081734a62e3e5cdf | https://github.com/olov/ng-annotate/blob/f5c709c682c99afe9e1413d9081734a62e3e5cdf/ng-annotate-main.js#L451-L480 | train |
kurttheviking/html2plaintext | index.js | _escapeHtml | function _escapeHtml (input) {
return String(input)
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
} | javascript | function _escapeHtml (input) {
return String(input)
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
} | [
"function",
"_escapeHtml",
"(",
"input",
")",
"{",
"return",
"String",
"(",
"input",
")",
".",
"replace",
"(",
"/",
"&",
"/",
"g",
",",
"'&'",
")",
".",
"replace",
"(",
"/",
"<",
"/",
"g",
",",
"'<'",
")",
".",
"replace",
"(",
"/",
">",
... | "private" helper for ensuring html entities are properly escaped | [
"private",
"helper",
"for",
"ensuring",
"html",
"entities",
"are",
"properly",
"escaped"
] | dbb7104a7fb87a790cf7ac294e0b9ca13dc67982 | https://github.com/kurttheviking/html2plaintext/blob/dbb7104a7fb87a790cf7ac294e0b9ca13dc67982/index.js#L6-L13 | train |
kurttheviking/html2plaintext | index.js | _list | function _list (str, isOrdered) {
if (!str) return str;
var $ = cheerio.load(str);
var listEl = isOrdered ? 'ol' : 'ul';
$(listEl).each(function (i, el) {
var $out = cheerio.load('<p></p>');
var $el = $(el);
$el.find('li').each(function (j, li) {
var tick = isOrdered ? String(j + 1) + '.' :... | javascript | function _list (str, isOrdered) {
if (!str) return str;
var $ = cheerio.load(str);
var listEl = isOrdered ? 'ol' : 'ul';
$(listEl).each(function (i, el) {
var $out = cheerio.load('<p></p>');
var $el = $(el);
$el.find('li').each(function (j, li) {
var tick = isOrdered ? String(j + 1) + '.' :... | [
"function",
"_list",
"(",
"str",
",",
"isOrdered",
")",
"{",
"if",
"(",
"!",
"str",
")",
"return",
"str",
";",
"var",
"$",
"=",
"cheerio",
".",
"load",
"(",
"str",
")",
";",
"var",
"listEl",
"=",
"isOrdered",
"?",
"'ol'",
":",
"'ul'",
";",
"$",
... | "private" helper for list processing into plaintext | [
"private",
"helper",
"for",
"list",
"processing",
"into",
"plaintext"
] | dbb7104a7fb87a790cf7ac294e0b9ca13dc67982 | https://github.com/kurttheviking/html2plaintext/blob/dbb7104a7fb87a790cf7ac294e0b9ca13dc67982/index.js#L16-L40 | train |
uber/express-statsd | lib/express-statsd.js | sendStats | function sendStats() {
var key = req[options.requestKey];
key = key ? key + '.' : '';
// Status Code
var statusCode = res.statusCode || 'unknown_status';
client.increment(key + 'status_code.' + statusCode);
// Response Time
var duration = new Date().getTime() - startTime;
... | javascript | function sendStats() {
var key = req[options.requestKey];
key = key ? key + '.' : '';
// Status Code
var statusCode = res.statusCode || 'unknown_status';
client.increment(key + 'status_code.' + statusCode);
// Response Time
var duration = new Date().getTime() - startTime;
... | [
"function",
"sendStats",
"(",
")",
"{",
"var",
"key",
"=",
"req",
"[",
"options",
".",
"requestKey",
"]",
";",
"key",
"=",
"key",
"?",
"key",
"+",
"'.'",
":",
"''",
";",
"// Status Code",
"var",
"statusCode",
"=",
"res",
".",
"statusCode",
"||",
"'un... | Function called on response finish that sends stats to statsd | [
"Function",
"called",
"on",
"response",
"finish",
"that",
"sends",
"stats",
"to",
"statsd"
] | 4e3ee7dd68c2bcebaa1718d4310b1b32a8b66e47 | https://github.com/uber/express-statsd/blob/4e3ee7dd68c2bcebaa1718d4310b1b32a8b66e47/lib/express-statsd.js#L20-L33 | train |
chartshq/datamodel | src/converter/auto-resolver.js | Auto | function Auto (data, options) {
const converters = { FlatJSON, DSVStr, DSVArr };
const dataFormat = detectDataFormat(data);
if (!dataFormat) {
throw new Error('Couldn\'t detect the data format');
}
return converters[dataFormat](data, options);
} | javascript | function Auto (data, options) {
const converters = { FlatJSON, DSVStr, DSVArr };
const dataFormat = detectDataFormat(data);
if (!dataFormat) {
throw new Error('Couldn\'t detect the data format');
}
return converters[dataFormat](data, options);
} | [
"function",
"Auto",
"(",
"data",
",",
"options",
")",
"{",
"const",
"converters",
"=",
"{",
"FlatJSON",
",",
"DSVStr",
",",
"DSVArr",
"}",
";",
"const",
"dataFormat",
"=",
"detectDataFormat",
"(",
"data",
")",
";",
"if",
"(",
"!",
"dataFormat",
")",
"{... | Parses the input data and detect the format automatically.
@param {string|Array} data - The input data.
@param {Object} options - An optional config specific to data format.
@return {Array.<Object>} Returns an array of headers and column major data. | [
"Parses",
"the",
"input",
"data",
"and",
"detect",
"the",
"format",
"automatically",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/converter/auto-resolver.js#L13-L22 | train |
chartshq/datamodel | src/converter/dsv-str.js | DSVStr | function DSVStr (str, options) {
const defaultOption = {
firstRowHeader: true,
fieldSeparator: ','
};
options = Object.assign({}, defaultOption, options);
const dsv = d3Dsv(options.fieldSeparator);
return DSVArr(dsv.parseRows(str), options);
} | javascript | function DSVStr (str, options) {
const defaultOption = {
firstRowHeader: true,
fieldSeparator: ','
};
options = Object.assign({}, defaultOption, options);
const dsv = d3Dsv(options.fieldSeparator);
return DSVArr(dsv.parseRows(str), options);
} | [
"function",
"DSVStr",
"(",
"str",
",",
"options",
")",
"{",
"const",
"defaultOption",
"=",
"{",
"firstRowHeader",
":",
"true",
",",
"fieldSeparator",
":",
"','",
"}",
";",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"defaultOption",
",",... | Parses and converts data formatted in DSV string to a manageable internal format.
@todo Support to be given for https://tools.ietf.org/html/rfc4180.
@todo Sample implementation https://github.com/knrz/CSV.js/.
@param {string} str - The input DSV string.
@param {Object} options - Option to control the behaviour of the... | [
"Parses",
"and",
"converts",
"data",
"formatted",
"in",
"DSV",
"string",
"to",
"a",
"manageable",
"internal",
"format",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/converter/dsv-str.js#L25-L34 | train |
chartshq/datamodel | src/field-creator.js | createUnitField | function createUnitField(data, schema) {
data = data || [];
let partialField;
switch (schema.type) {
case FieldType.MEASURE:
switch (schema.subtype) {
case MeasureSubtype.CONTINUOUS:
partialField = new PartialField(schema.name, data, schema, new ContinuousParser());
... | javascript | function createUnitField(data, schema) {
data = data || [];
let partialField;
switch (schema.type) {
case FieldType.MEASURE:
switch (schema.subtype) {
case MeasureSubtype.CONTINUOUS:
partialField = new PartialField(schema.name, data, schema, new ContinuousParser());
... | [
"function",
"createUnitField",
"(",
"data",
",",
"schema",
")",
"{",
"data",
"=",
"data",
"||",
"[",
"]",
";",
"let",
"partialField",
";",
"switch",
"(",
"schema",
".",
"type",
")",
"{",
"case",
"FieldType",
".",
"MEASURE",
":",
"switch",
"(",
"schema"... | Creates a field instance according to the provided data and schema.
@param {Array} data - The field data array.
@param {Object} schema - The field schema object.
@return {Field} Returns the newly created field instance. | [
"Creates",
"a",
"field",
"instance",
"according",
"to",
"the",
"provided",
"data",
"and",
"schema",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/field-creator.js#L21-L54 | train |
chartshq/datamodel | plugins/md.js | generateNestedMap | function generateNestedMap(objArray) {
let mainMap = new Map();
objArray.forEach((obj) => {
let params = obj.name.split('.');
let i = 0;
let k = mainMap;
while (k.has(params[i])) {
k = k.get(params[i]);
i++;
}
let kk = new Map();
k... | javascript | function generateNestedMap(objArray) {
let mainMap = new Map();
objArray.forEach((obj) => {
let params = obj.name.split('.');
let i = 0;
let k = mainMap;
while (k.has(params[i])) {
k = k.get(params[i]);
i++;
}
let kk = new Map();
k... | [
"function",
"generateNestedMap",
"(",
"objArray",
")",
"{",
"let",
"mainMap",
"=",
"new",
"Map",
"(",
")",
";",
"objArray",
".",
"forEach",
"(",
"(",
"obj",
")",
"=>",
"{",
"let",
"params",
"=",
"obj",
".",
"name",
".",
"split",
"(",
"'.'",
")",
";... | This method generates a nested hashmap for the parameters table
@param {Object} objArray the Array structure containing the parameters | [
"This",
"method",
"generates",
"a",
"nested",
"hashmap",
"for",
"the",
"parameters",
"table"
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/plugins/md.js#L12-L29 | train |
chartshq/datamodel | src/operator/group-by-function.js | sum | function sum (arr) {
if (isArray(arr) && !(arr[0] instanceof Array)) {
const filteredNumber = getFilteredValues(arr);
const totalSum = filteredNumber.length ?
filteredNumber.reduce((acc, curr) => acc + curr, 0)
: InvalidAwareTypes.NULL;
... | javascript | function sum (arr) {
if (isArray(arr) && !(arr[0] instanceof Array)) {
const filteredNumber = getFilteredValues(arr);
const totalSum = filteredNumber.length ?
filteredNumber.reduce((acc, curr) => acc + curr, 0)
: InvalidAwareTypes.NULL;
... | [
"function",
"sum",
"(",
"arr",
")",
"{",
"if",
"(",
"isArray",
"(",
"arr",
")",
"&&",
"!",
"(",
"arr",
"[",
"0",
"]",
"instanceof",
"Array",
")",
")",
"{",
"const",
"filteredNumber",
"=",
"getFilteredValues",
"(",
"arr",
")",
";",
"const",
"totalSum"... | Reducer function that returns the sum of all the values.
@public
@param {Array.<number>} arr - The input array.
@return {number} Returns the sum of the array. | [
"Reducer",
"function",
"that",
"returns",
"the",
"sum",
"of",
"all",
"the",
"values",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/group-by-function.js#L17-L26 | train |
chartshq/datamodel | src/operator/group-by-function.js | avg | function avg (arr) {
if (isArray(arr) && !(arr[0] instanceof Array)) {
const totalSum = sum(arr);
const len = arr.length || 1;
return (Number.isNaN(totalSum) || totalSum instanceof InvalidAwareTypes) ?
InvalidAwareTypes.NULL : totalSum / len;
}
return InvalidAwareTyp... | javascript | function avg (arr) {
if (isArray(arr) && !(arr[0] instanceof Array)) {
const totalSum = sum(arr);
const len = arr.length || 1;
return (Number.isNaN(totalSum) || totalSum instanceof InvalidAwareTypes) ?
InvalidAwareTypes.NULL : totalSum / len;
}
return InvalidAwareTyp... | [
"function",
"avg",
"(",
"arr",
")",
"{",
"if",
"(",
"isArray",
"(",
"arr",
")",
"&&",
"!",
"(",
"arr",
"[",
"0",
"]",
"instanceof",
"Array",
")",
")",
"{",
"const",
"totalSum",
"=",
"sum",
"(",
"arr",
")",
";",
"const",
"len",
"=",
"arr",
".",
... | Reducer function that returns the average of all the values.
@public
@param {Array.<number>} arr - The input array.
@return {number} Returns the mean value of the array. | [
"Reducer",
"function",
"that",
"returns",
"the",
"average",
"of",
"all",
"the",
"values",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/group-by-function.js#L35-L43 | train |
chartshq/datamodel | src/operator/group-by-function.js | min | function min (arr) {
if (isArray(arr) && !(arr[0] instanceof Array)) {
// Filter out undefined, null and NaN values
const filteredValues = getFilteredValues(arr);
return (filteredValues.length) ? Math.min(...filteredValues) : InvalidAwareTypes.NULL;
}
return InvalidAwareTypes.NULL;
... | javascript | function min (arr) {
if (isArray(arr) && !(arr[0] instanceof Array)) {
// Filter out undefined, null and NaN values
const filteredValues = getFilteredValues(arr);
return (filteredValues.length) ? Math.min(...filteredValues) : InvalidAwareTypes.NULL;
}
return InvalidAwareTypes.NULL;
... | [
"function",
"min",
"(",
"arr",
")",
"{",
"if",
"(",
"isArray",
"(",
"arr",
")",
"&&",
"!",
"(",
"arr",
"[",
"0",
"]",
"instanceof",
"Array",
")",
")",
"{",
"// Filter out undefined, null and NaN values",
"const",
"filteredValues",
"=",
"getFilteredValues",
"... | Reducer function that gives the min value amongst all the values.
@public
@param {Array.<number>} arr - The input array.
@return {number} Returns the minimum value of the array. | [
"Reducer",
"function",
"that",
"gives",
"the",
"min",
"value",
"amongst",
"all",
"the",
"values",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/group-by-function.js#L52-L60 | train |
chartshq/datamodel | src/operator/group-by-function.js | variance | function variance (arr) {
let mean = avg(arr);
return avg(arr.map(num => (num - mean) ** 2));
} | javascript | function variance (arr) {
let mean = avg(arr);
return avg(arr.map(num => (num - mean) ** 2));
} | [
"function",
"variance",
"(",
"arr",
")",
"{",
"let",
"mean",
"=",
"avg",
"(",
"arr",
")",
";",
"return",
"avg",
"(",
"arr",
".",
"map",
"(",
"num",
"=>",
"(",
"num",
"-",
"mean",
")",
"**",
"2",
")",
")",
";",
"}"
] | Calculates the variance of the input array.
@param {Array.<number>} arr - The input array.
@return {number} Returns the variance of the input array. | [
"Calculates",
"the",
"variance",
"of",
"the",
"input",
"array",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/group-by-function.js#L121-L124 | train |
chartshq/datamodel | src/operator/data-builder.js | getSortFn | function getSortFn (dataType, sortType, index) {
let retFunc;
switch (dataType) {
case MeasureSubtype.CONTINUOUS:
case DimensionSubtype.TEMPORAL:
if (sortType === 'desc') {
retFunc = (a, b) => b[index] - a[index];
} else {
retFunc = (a, b) => a[index] - b[index];
... | javascript | function getSortFn (dataType, sortType, index) {
let retFunc;
switch (dataType) {
case MeasureSubtype.CONTINUOUS:
case DimensionSubtype.TEMPORAL:
if (sortType === 'desc') {
retFunc = (a, b) => b[index] - a[index];
} else {
retFunc = (a, b) => a[index] - b[index];
... | [
"function",
"getSortFn",
"(",
"dataType",
",",
"sortType",
",",
"index",
")",
"{",
"let",
"retFunc",
";",
"switch",
"(",
"dataType",
")",
"{",
"case",
"MeasureSubtype",
".",
"CONTINUOUS",
":",
"case",
"DimensionSubtype",
".",
"TEMPORAL",
":",
"if",
"(",
"s... | Generates the sorting functions to sort the data of a DataModel instance
according to the input data type.
@param {string} dataType - The data type e.g. 'measure', 'datetime' etc.
@param {string} sortType - The sorting order i.e. 'asc' or 'desc'.
@param {integer} index - The index of the data which will be sorted.
@re... | [
"Generates",
"the",
"sorting",
"functions",
"to",
"sort",
"the",
"data",
"of",
"a",
"DataModel",
"instance",
"according",
"to",
"the",
"input",
"data",
"type",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/data-builder.js#L15-L40 | train |
chartshq/datamodel | src/operator/data-builder.js | groupData | function groupData(data, fieldIndex) {
const hashMap = new Map();
const groupedData = [];
data.forEach((datum) => {
const fieldVal = datum[fieldIndex];
if (hashMap.has(fieldVal)) {
groupedData[hashMap.get(fieldVal)][1].push(datum);
} else {
groupedData.push([... | javascript | function groupData(data, fieldIndex) {
const hashMap = new Map();
const groupedData = [];
data.forEach((datum) => {
const fieldVal = datum[fieldIndex];
if (hashMap.has(fieldVal)) {
groupedData[hashMap.get(fieldVal)][1].push(datum);
} else {
groupedData.push([... | [
"function",
"groupData",
"(",
"data",
",",
"fieldIndex",
")",
"{",
"const",
"hashMap",
"=",
"new",
"Map",
"(",
")",
";",
"const",
"groupedData",
"=",
"[",
"]",
";",
"data",
".",
"forEach",
"(",
"(",
"datum",
")",
"=>",
"{",
"const",
"fieldVal",
"=",
... | Groups the data according to the specified target field.
@param {Array} data - The input data array.
@param {number} fieldIndex - The target field index within schema array.
@return {Array} Returns an array containing the grouped data. | [
"Groups",
"the",
"data",
"according",
"to",
"the",
"specified",
"target",
"field",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/data-builder.js#L49-L64 | train |
chartshq/datamodel | src/operator/data-builder.js | createSortingFnArg | function createSortingFnArg(groupedDatum, targetFields, targetFieldDetails) {
const arg = {
label: groupedDatum[0]
};
targetFields.reduce((acc, next, idx) => {
acc[next] = groupedDatum[1].map(datum => datum[targetFieldDetails[idx].index]);
return acc;
}, arg);
return arg;
} | javascript | function createSortingFnArg(groupedDatum, targetFields, targetFieldDetails) {
const arg = {
label: groupedDatum[0]
};
targetFields.reduce((acc, next, idx) => {
acc[next] = groupedDatum[1].map(datum => datum[targetFieldDetails[idx].index]);
return acc;
}, arg);
return arg;
} | [
"function",
"createSortingFnArg",
"(",
"groupedDatum",
",",
"targetFields",
",",
"targetFieldDetails",
")",
"{",
"const",
"arg",
"=",
"{",
"label",
":",
"groupedDatum",
"[",
"0",
"]",
"}",
";",
"targetFields",
".",
"reduce",
"(",
"(",
"acc",
",",
"next",
"... | Creates the argument value used for sorting function when sort is done
with another fields.
@param {Array} groupedDatum - The grouped datum for a single dimension field value.
@param {Array} targetFields - An array of the sorting fields.
@param {Array} targetFieldDetails - An array of the sorting field details in sche... | [
"Creates",
"the",
"argument",
"value",
"used",
"for",
"sorting",
"function",
"when",
"sort",
"is",
"done",
"with",
"another",
"fields",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/data-builder.js#L75-L86 | train |
chartshq/datamodel | src/operator/data-builder.js | sortData | function sortData(dataObj, sortingDetails) {
const { data, schema } = dataObj;
let fieldName;
let sortMeta;
let fDetails;
let i = sortingDetails.length - 1;
for (; i >= 0; i--) {
fieldName = sortingDetails[i][0];
sortMeta = sortingDetails[i][1];
fDetails = fieldInSchema(... | javascript | function sortData(dataObj, sortingDetails) {
const { data, schema } = dataObj;
let fieldName;
let sortMeta;
let fDetails;
let i = sortingDetails.length - 1;
for (; i >= 0; i--) {
fieldName = sortingDetails[i][0];
sortMeta = sortingDetails[i][1];
fDetails = fieldInSchema(... | [
"function",
"sortData",
"(",
"dataObj",
",",
"sortingDetails",
")",
"{",
"const",
"{",
"data",
",",
"schema",
"}",
"=",
"dataObj",
";",
"let",
"fieldName",
";",
"let",
"sortMeta",
";",
"let",
"fDetails",
";",
"let",
"i",
"=",
"sortingDetails",
".",
"leng... | Sorts the data before return in dataBuilder.
@param {Object} dataObj - An object containing the data and schema.
@param {Array} sortingDetails - An array containing the sorting configs. | [
"Sorts",
"the",
"data",
"before",
"return",
"in",
"dataBuilder",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/data-builder.js#L94-L145 | train |
chartshq/datamodel | src/operator/merge-sort.js | defSortFn | function defSortFn (a, b) {
const a1 = `${a}`;
const b1 = `${b}`;
if (a1 < b1) {
return -1;
}
if (a1 > b1) {
return 1;
}
return 0;
} | javascript | function defSortFn (a, b) {
const a1 = `${a}`;
const b1 = `${b}`;
if (a1 < b1) {
return -1;
}
if (a1 > b1) {
return 1;
}
return 0;
} | [
"function",
"defSortFn",
"(",
"a",
",",
"b",
")",
"{",
"const",
"a1",
"=",
"`",
"${",
"a",
"}",
"`",
";",
"const",
"b1",
"=",
"`",
"${",
"b",
"}",
"`",
";",
"if",
"(",
"a1",
"<",
"b1",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
... | The default sort function.
@param {*} a - The first value.
@param {*} b - The second value.
@return {number} Returns the comparison result e.g. 1 or 0 or -1. | [
"The",
"default",
"sort",
"function",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/merge-sort.js#L8-L18 | train |
chartshq/datamodel | src/operator/merge-sort.js | merge | function merge (arr, lo, mid, hi, sortFn) {
const mainArr = arr;
const auxArr = [];
for (let i = lo; i <= hi; i += 1) {
auxArr[i] = mainArr[i];
}
let a = lo;
let b = mid + 1;
for (let i = lo; i <= hi; i += 1) {
if (a > mid) {
mainArr[i] = auxArr[b];
b... | javascript | function merge (arr, lo, mid, hi, sortFn) {
const mainArr = arr;
const auxArr = [];
for (let i = lo; i <= hi; i += 1) {
auxArr[i] = mainArr[i];
}
let a = lo;
let b = mid + 1;
for (let i = lo; i <= hi; i += 1) {
if (a > mid) {
mainArr[i] = auxArr[b];
b... | [
"function",
"merge",
"(",
"arr",
",",
"lo",
",",
"mid",
",",
"hi",
",",
"sortFn",
")",
"{",
"const",
"mainArr",
"=",
"arr",
";",
"const",
"auxArr",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"lo",
";",
"i",
"<=",
"hi",
";",
"i",
"+=",
... | The helper function for merge sort which creates the sorted array
from the two halves of the input array.
@param {Array} arr - The target array which needs to be merged.
@param {number} lo - The starting index of the first array half.
@param {number} mid - The ending index of the first array half.
@param {number} hi -... | [
"The",
"helper",
"function",
"for",
"merge",
"sort",
"which",
"creates",
"the",
"sorted",
"array",
"from",
"the",
"two",
"halves",
"of",
"the",
"input",
"array",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/merge-sort.js#L30-L54 | train |
chartshq/datamodel | src/operator/merge-sort.js | sort | function sort (arr, lo, hi, sortFn) {
if (hi === lo) { return arr; }
const mid = lo + Math.floor((hi - lo) / 2);
sort(arr, lo, mid, sortFn);
sort(arr, mid + 1, hi, sortFn);
merge(arr, lo, mid, hi, sortFn);
return arr;
} | javascript | function sort (arr, lo, hi, sortFn) {
if (hi === lo) { return arr; }
const mid = lo + Math.floor((hi - lo) / 2);
sort(arr, lo, mid, sortFn);
sort(arr, mid + 1, hi, sortFn);
merge(arr, lo, mid, hi, sortFn);
return arr;
} | [
"function",
"sort",
"(",
"arr",
",",
"lo",
",",
"hi",
",",
"sortFn",
")",
"{",
"if",
"(",
"hi",
"===",
"lo",
")",
"{",
"return",
"arr",
";",
"}",
"const",
"mid",
"=",
"lo",
"+",
"Math",
".",
"floor",
"(",
"(",
"hi",
"-",
"lo",
")",
"/",
"2"... | The helper function for merge sort which would be called
recursively for sorting the array halves.
@param {Array} arr - The target array which needs to be sorted.
@param {number} lo - The starting index of the array half.
@param {number} hi - The ending index of the array half.
@param {Function} sortFn - The sort func... | [
"The",
"helper",
"function",
"for",
"merge",
"sort",
"which",
"would",
"be",
"called",
"recursively",
"for",
"sorting",
"the",
"array",
"halves",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/merge-sort.js#L66-L75 | train |
chartshq/datamodel | src/operator/group-by.js | getFieldArr | function getFieldArr (dataModel, fieldArr) {
const retArr = [];
const fieldStore = dataModel.getFieldspace();
const dimensions = fieldStore.getDimension();
Object.entries(dimensions).forEach(([key]) => {
if (fieldArr && fieldArr.length) {
if (fieldArr.indexOf(key) !== -1) {
... | javascript | function getFieldArr (dataModel, fieldArr) {
const retArr = [];
const fieldStore = dataModel.getFieldspace();
const dimensions = fieldStore.getDimension();
Object.entries(dimensions).forEach(([key]) => {
if (fieldArr && fieldArr.length) {
if (fieldArr.indexOf(key) !== -1) {
... | [
"function",
"getFieldArr",
"(",
"dataModel",
",",
"fieldArr",
")",
"{",
"const",
"retArr",
"=",
"[",
"]",
";",
"const",
"fieldStore",
"=",
"dataModel",
".",
"getFieldspace",
"(",
")",
";",
"const",
"dimensions",
"=",
"fieldStore",
".",
"getDimension",
"(",
... | This function sanitize the user given field and return a common Array structure field
list
@param {DataModel} dataModel the dataModel operating on
@param {Array} fieldArr user input of field Array
@return {Array} arrays of field name | [
"This",
"function",
"sanitize",
"the",
"user",
"given",
"field",
"and",
"return",
"a",
"common",
"Array",
"structure",
"field",
"list"
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/group-by.js#L15-L31 | train |
chartshq/datamodel | src/operator/group-by.js | getReducerObj | function getReducerObj (dataModel, reducers = {}) {
const retObj = {};
const fieldStore = dataModel.getFieldspace();
const measures = fieldStore.getMeasure();
const defReducer = reducerStore.defaultReducer();
Object.keys(measures).forEach((measureName) => {
if (typeof reducers[measureName] ... | javascript | function getReducerObj (dataModel, reducers = {}) {
const retObj = {};
const fieldStore = dataModel.getFieldspace();
const measures = fieldStore.getMeasure();
const defReducer = reducerStore.defaultReducer();
Object.keys(measures).forEach((measureName) => {
if (typeof reducers[measureName] ... | [
"function",
"getReducerObj",
"(",
"dataModel",
",",
"reducers",
"=",
"{",
"}",
")",
"{",
"const",
"retObj",
"=",
"{",
"}",
";",
"const",
"fieldStore",
"=",
"dataModel",
".",
"getFieldspace",
"(",
")",
";",
"const",
"measures",
"=",
"fieldStore",
".",
"ge... | This sanitize the reducer provide by the user and create a common type of object.
user can give function Also
@param {DataModel} dataModel dataModel to worked on
@param {Object|function} [reducers={}] reducer provided by the users
@return {Object} object containing reducer function for every measure | [
"This",
"sanitize",
"the",
"reducer",
"provide",
"by",
"the",
"user",
"and",
"create",
"a",
"common",
"type",
"of",
"object",
".",
"user",
"can",
"give",
"function",
"Also"
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/group-by.js#L40-L59 | train |
chartshq/datamodel | src/operator/group-by.js | groupBy | function groupBy (dataModel, fieldArr, reducers, existingDataModel) {
const sFieldArr = getFieldArr(dataModel, fieldArr);
const reducerObj = getReducerObj(dataModel, reducers);
const fieldStore = dataModel.getFieldspace();
const fieldStoreObj = fieldStore.fieldsObj();
const dbName = fieldStore.name;... | javascript | function groupBy (dataModel, fieldArr, reducers, existingDataModel) {
const sFieldArr = getFieldArr(dataModel, fieldArr);
const reducerObj = getReducerObj(dataModel, reducers);
const fieldStore = dataModel.getFieldspace();
const fieldStoreObj = fieldStore.fieldsObj();
const dbName = fieldStore.name;... | [
"function",
"groupBy",
"(",
"dataModel",
",",
"fieldArr",
",",
"reducers",
",",
"existingDataModel",
")",
"{",
"const",
"sFieldArr",
"=",
"getFieldArr",
"(",
"dataModel",
",",
"fieldArr",
")",
";",
"const",
"reducerObj",
"=",
"getReducerObj",
"(",
"dataModel",
... | main function which perform the group-by operations which reduce the measures value is the
fields are common according to the reducer function provided
@param {DataModel} dataModel the dataModel to worked
@param {Array} fieldArr fields according to which the groupby should be worked
@param {Object|Function} reducer... | [
"main",
"function",
"which",
"perform",
"the",
"group",
"-",
"by",
"operations",
"which",
"reduce",
"the",
"measures",
"value",
"is",
"the",
"fields",
"are",
"common",
"according",
"to",
"the",
"reducer",
"function",
"provided"
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/operator/group-by.js#L70-L139 | train |
chartshq/datamodel | src/converter/flat-json.js | FlatJSON | function FlatJSON (arr) {
const header = {};
let i = 0;
let insertionIndex;
const columns = [];
const push = columnMajor(columns);
arr.forEach((item) => {
const fields = [];
for (let key in item) {
if (key in header) {
insertionIndex = header[key];
... | javascript | function FlatJSON (arr) {
const header = {};
let i = 0;
let insertionIndex;
const columns = [];
const push = columnMajor(columns);
arr.forEach((item) => {
const fields = [];
for (let key in item) {
if (key in header) {
insertionIndex = header[key];
... | [
"function",
"FlatJSON",
"(",
"arr",
")",
"{",
"const",
"header",
"=",
"{",
"}",
";",
"let",
"i",
"=",
"0",
";",
"let",
"insertionIndex",
";",
"const",
"columns",
"=",
"[",
"]",
";",
"const",
"push",
"=",
"columnMajor",
"(",
"columns",
")",
";",
"ar... | Parses and converts data formatted in JSON to a manageable internal format.
@param {Array.<Object>} arr - The input data formatted in JSON.
@return {Array.<Object>} Returns an array of headers and column major data.
@example
// Sample input data:
const data = [
{
"a": 1,
"b": 2,
"c": 3
},
{
"a": 4,
"b": 5,
"c": 6
},
... | [
"Parses",
"and",
"converts",
"data",
"formatted",
"in",
"JSON",
"to",
"a",
"manageable",
"internal",
"format",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/converter/flat-json.js#L29-L51 | train |
chartshq/datamodel | src/helper.js | prepareSelectionData | function prepareSelectionData (fields, i) {
const resp = {};
for (let field of fields) {
resp[field.name()] = new Value(field.partialField.data[i], field);
}
return resp;
} | javascript | function prepareSelectionData (fields, i) {
const resp = {};
for (let field of fields) {
resp[field.name()] = new Value(field.partialField.data[i], field);
}
return resp;
} | [
"function",
"prepareSelectionData",
"(",
"fields",
",",
"i",
")",
"{",
"const",
"resp",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"field",
"of",
"fields",
")",
"{",
"resp",
"[",
"field",
".",
"name",
"(",
")",
"]",
"=",
"new",
"Value",
"(",
"field",
... | Prepares the selection data. | [
"Prepares",
"the",
"selection",
"data",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/helper.js#L16-L22 | train |
chartshq/datamodel | src/converter/dsv-arr.js | DSVArr | function DSVArr (arr, options) {
const defaultOption = {
firstRowHeader: true,
};
options = Object.assign({}, defaultOption, options);
let header;
const columns = [];
const push = columnMajor(columns);
if (options.firstRowHeader) {
// If header present then mutate the array... | javascript | function DSVArr (arr, options) {
const defaultOption = {
firstRowHeader: true,
};
options = Object.assign({}, defaultOption, options);
let header;
const columns = [];
const push = columnMajor(columns);
if (options.firstRowHeader) {
// If header present then mutate the array... | [
"function",
"DSVArr",
"(",
"arr",
",",
"options",
")",
"{",
"const",
"defaultOption",
"=",
"{",
"firstRowHeader",
":",
"true",
",",
"}",
";",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"defaultOption",
",",
"options",
")",
";",
"let",... | Parses and converts data formatted in DSV array to a manageable internal format.
@param {Array.<Array>} arr - A 2D array containing of the DSV data.
@param {Object} options - Option to control the behaviour of the parsing.
@param {boolean} [options.firstRowHeader=true] - Whether the first row of the dsv data is header... | [
"Parses",
"and",
"converts",
"data",
"formatted",
"in",
"DSV",
"array",
"to",
"a",
"manageable",
"internal",
"format",
"."
] | cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e | https://github.com/chartshq/datamodel/blob/cb2c3df2c31cdbfbcc22ddf3856c61178bbcc28e/src/converter/dsv-arr.js#L20-L41 | train |
pelias/whosonfirst | src/components/extractFields.js | getLanguages | function getLanguages(properties) {
if (!Array.isArray(properties['wof:lang_x_official'])) {
return [];
}
return properties['wof:lang_x_official']
.filter(l => (typeof l === 'string' && l.length === 3))
.map(l => l.toLowerCase());
} | javascript | function getLanguages(properties) {
if (!Array.isArray(properties['wof:lang_x_official'])) {
return [];
}
return properties['wof:lang_x_official']
.filter(l => (typeof l === 'string' && l.length === 3))
.map(l => l.toLowerCase());
} | [
"function",
"getLanguages",
"(",
"properties",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"properties",
"[",
"'wof:lang_x_official'",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"properties",
"[",
"'wof:lang_x_official'",
"]",
... | get an array of language codes spoken at this location | [
"get",
"an",
"array",
"of",
"language",
"codes",
"spoken",
"at",
"this",
"location"
] | 56fdb2f00ad0c97510ea44166aaee5d8b0cc334a | https://github.com/pelias/whosonfirst/blob/56fdb2f00ad0c97510ea44166aaee5d8b0cc334a/src/components/extractFields.js#L71-L78 | train |
pelias/whosonfirst | src/components/extractFields.js | concatArrayFields | function concatArrayFields(properties, fields){
let arr = [];
fields.forEach(field => {
if (Array.isArray(properties[field]) && properties[field].length) {
arr = arr.concat(properties[field]);
}
});
// dedupe array
return arr.filter((item, pos, self) => self.indexOf(item) === pos);
} | javascript | function concatArrayFields(properties, fields){
let arr = [];
fields.forEach(field => {
if (Array.isArray(properties[field]) && properties[field].length) {
arr = arr.concat(properties[field]);
}
});
// dedupe array
return arr.filter((item, pos, self) => self.indexOf(item) === pos);
} | [
"function",
"concatArrayFields",
"(",
"properties",
",",
"fields",
")",
"{",
"let",
"arr",
"=",
"[",
"]",
";",
"fields",
".",
"forEach",
"(",
"field",
"=>",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"properties",
"[",
"field",
"]",
")",
"&&",
"pr... | convenience function to safely concat array fields | [
"convenience",
"function",
"to",
"safely",
"concat",
"array",
"fields"
] | 56fdb2f00ad0c97510ea44166aaee5d8b0cc334a | https://github.com/pelias/whosonfirst/blob/56fdb2f00ad0c97510ea44166aaee5d8b0cc334a/src/components/extractFields.js#L81-L90 | train |
pelias/whosonfirst | utils/sqlite_extract_data.js | extractDB | function extractDB( dbpath ){
let targetWofIds = Array.isArray(config.importPlace) ? config.importPlace: [config.importPlace];
// connect to sql db
let db = new Sqlite3( dbpath, { readonly: true } );
// convert ids to integers and remove any which fail to convert
let cleanIds = targetWofIds.map(id... | javascript | function extractDB( dbpath ){
let targetWofIds = Array.isArray(config.importPlace) ? config.importPlace: [config.importPlace];
// connect to sql db
let db = new Sqlite3( dbpath, { readonly: true } );
// convert ids to integers and remove any which fail to convert
let cleanIds = targetWofIds.map(id... | [
"function",
"extractDB",
"(",
"dbpath",
")",
"{",
"let",
"targetWofIds",
"=",
"Array",
".",
"isArray",
"(",
"config",
".",
"importPlace",
")",
"?",
"config",
".",
"importPlace",
":",
"[",
"config",
".",
"importPlace",
"]",
";",
"// connect to sql db",
"let",... | extract from a single db file | [
"extract",
"from",
"a",
"single",
"db",
"file"
] | 56fdb2f00ad0c97510ea44166aaee5d8b0cc334a | https://github.com/pelias/whosonfirst/blob/56fdb2f00ad0c97510ea44166aaee5d8b0cc334a/utils/sqlite_extract_data.js#L103-L145 | train |
pelias/whosonfirst | utils/sqlite_extract_data.js | findSubdivisions | function findSubdivisions( filename ){
// load configuration variables
const config = require('pelias-config').generate(require('../schema')).imports.whosonfirst;
const sqliteDir = path.join(config.datapath, 'sqlite');
let targetWofIds = Array.isArray(config.importPlace) ? config.importPlace: [config.importPla... | javascript | function findSubdivisions( filename ){
// load configuration variables
const config = require('pelias-config').generate(require('../schema')).imports.whosonfirst;
const sqliteDir = path.join(config.datapath, 'sqlite');
let targetWofIds = Array.isArray(config.importPlace) ? config.importPlace: [config.importPla... | [
"function",
"findSubdivisions",
"(",
"filename",
")",
"{",
"// load configuration variables",
"const",
"config",
"=",
"require",
"(",
"'pelias-config'",
")",
".",
"generate",
"(",
"require",
"(",
"'../schema'",
")",
")",
".",
"imports",
".",
"whosonfirst",
";",
... | return all distinct subdivisions of the data | [
"return",
"all",
"distinct",
"subdivisions",
"of",
"the",
"data"
] | 56fdb2f00ad0c97510ea44166aaee5d8b0cc334a | https://github.com/pelias/whosonfirst/blob/56fdb2f00ad0c97510ea44166aaee5d8b0cc334a/utils/sqlite_extract_data.js#L187-L209 | train |
pelias/whosonfirst | src/peliasDocGenerators.js | setupDocument | function setupDocument(record, hierarchy) {
var wofDoc = new Document( 'whosonfirst', record.place_type, record.id );
if (record.name) {
wofDoc.setName('default', record.name);
// index a version of postcode which doesn't contain whitespace
if (record.place_type === 'postalcode' && typeof record.name ... | javascript | function setupDocument(record, hierarchy) {
var wofDoc = new Document( 'whosonfirst', record.place_type, record.id );
if (record.name) {
wofDoc.setName('default', record.name);
// index a version of postcode which doesn't contain whitespace
if (record.place_type === 'postalcode' && typeof record.name ... | [
"function",
"setupDocument",
"(",
"record",
",",
"hierarchy",
")",
"{",
"var",
"wofDoc",
"=",
"new",
"Document",
"(",
"'whosonfirst'",
",",
"record",
".",
"place_type",
",",
"record",
".",
"id",
")",
";",
"if",
"(",
"record",
".",
"name",
")",
"{",
"wo... | method that extracts the logic for Document creation. `hierarchy` is optional | [
"method",
"that",
"extracts",
"the",
"logic",
"for",
"Document",
"creation",
".",
"hierarchy",
"is",
"optional"
] | 56fdb2f00ad0c97510ea44166aaee5d8b0cc334a | https://github.com/pelias/whosonfirst/blob/56fdb2f00ad0c97510ea44166aaee5d8b0cc334a/src/peliasDocGenerators.js#L61-L128 | train |
pelias/whosonfirst | src/wofIdToPath.js | wofIdToPath | function wofIdToPath( id ){
let strId = id.toString();
let parts = [];
while( strId.length ){
let part = strId.substr(0, 3);
parts.push(part);
strId = strId.substr(3);
}
return parts;
} | javascript | function wofIdToPath( id ){
let strId = id.toString();
let parts = [];
while( strId.length ){
let part = strId.substr(0, 3);
parts.push(part);
strId = strId.substr(3);
}
return parts;
} | [
"function",
"wofIdToPath",
"(",
"id",
")",
"{",
"let",
"strId",
"=",
"id",
".",
"toString",
"(",
")",
";",
"let",
"parts",
"=",
"[",
"]",
";",
"while",
"(",
"strId",
".",
"length",
")",
"{",
"let",
"part",
"=",
"strId",
".",
"substr",
"(",
"0",
... | convert wofid integer to array of path components | [
"convert",
"wofid",
"integer",
"to",
"array",
"of",
"path",
"components"
] | 56fdb2f00ad0c97510ea44166aaee5d8b0cc334a | https://github.com/pelias/whosonfirst/blob/56fdb2f00ad0c97510ea44166aaee5d8b0cc334a/src/wofIdToPath.js#L4-L13 | train |
pencil-js/pencil.js | modules/text/text.js | formatString | function formatString (string) {
const separator = "\n";
return Array.isArray(string) ?
string.reduce((acc, line) => acc.concat(line.split(separator)), []) :
string.split(separator);
} | javascript | function formatString (string) {
const separator = "\n";
return Array.isArray(string) ?
string.reduce((acc, line) => acc.concat(line.split(separator)), []) :
string.split(separator);
} | [
"function",
"formatString",
"(",
"string",
")",
"{",
"const",
"separator",
"=",
"\"\\n\"",
";",
"return",
"Array",
".",
"isArray",
"(",
"string",
")",
"?",
"string",
".",
"reduce",
"(",
"(",
"acc",
",",
"line",
")",
"=>",
"acc",
".",
"concat",
"(",
"... | Reformat passed arguments into an array of line string
@param {String|Array<String>} string -
@return {Array<String>} | [
"Reformat",
"passed",
"arguments",
"into",
"an",
"array",
"of",
"line",
"string"
] | faa58f24946fd6b08ac920d26d735ca0d3a31861 | https://github.com/pencil-js/pencil.js/blob/faa58f24946fd6b08ac920d26d735ca0d3a31861/modules/text/text.js#L12-L17 | train |
pencil-js/pencil.js | modules/pencil.js/pencil.js | from | function from (json) {
const instance = exportableClasses[json.constructor].from(json);
if (json.children) {
instance.add(...json.children.map(child => from(child)));
}
return instance;
} | javascript | function from (json) {
const instance = exportableClasses[json.constructor].from(json);
if (json.children) {
instance.add(...json.children.map(child => from(child)));
}
return instance;
} | [
"function",
"from",
"(",
"json",
")",
"{",
"const",
"instance",
"=",
"exportableClasses",
"[",
"json",
".",
"constructor",
"]",
".",
"from",
"(",
"json",
")",
";",
"if",
"(",
"json",
".",
"children",
")",
"{",
"instance",
".",
"add",
"(",
"...",
"jso... | Construct Pencil objects from a JSON
@param {Object} json - Valid JSON
@return {*} | [
"Construct",
"Pencil",
"objects",
"from",
"a",
"JSON"
] | faa58f24946fd6b08ac920d26d735ca0d3a31861 | https://github.com/pencil-js/pencil.js/blob/faa58f24946fd6b08ac920d26d735ca0d3a31861/modules/pencil.js/pencil.js#L89-L95 | train |
pencil-js/pencil.js | modules/vector/vector.js | sanitizeParameters | function sanitizeParameters (definition) {
let scalar;
try {
// eslint-disable-next-line no-use-before-define
const vector = Vector.from(definition);
scalar = vector.getDelta();
}
catch (e) {
scalar = definition.getDelta ? definition.getDelta() : definition;
}
ret... | javascript | function sanitizeParameters (definition) {
let scalar;
try {
// eslint-disable-next-line no-use-before-define
const vector = Vector.from(definition);
scalar = vector.getDelta();
}
catch (e) {
scalar = definition.getDelta ? definition.getDelta() : definition;
}
ret... | [
"function",
"sanitizeParameters",
"(",
"definition",
")",
"{",
"let",
"scalar",
";",
"try",
"{",
"// eslint-disable-next-line no-use-before-define",
"const",
"vector",
"=",
"Vector",
".",
"from",
"(",
"definition",
")",
";",
"scalar",
"=",
"vector",
".",
"getDelta... | Accept all kind of type and return only Number or Position
@param {VectorDefinition|PositionDefinition|Number} definition - Value definition
@return {Position|Number} | [
"Accept",
"all",
"kind",
"of",
"type",
"and",
"return",
"only",
"Number",
"or",
"Position"
] | faa58f24946fd6b08ac920d26d735ca0d3a31861 | https://github.com/pencil-js/pencil.js/blob/faa58f24946fd6b08ac920d26d735ca0d3a31861/modules/vector/vector.js#L8-L19 | train |
js-data/js-data-angular | dist/js-data-angular.js | logResponse | function logResponse(data, isRejection) {
data = data || {};
// examine the data object
if (data instanceof Error) {
// log the Error object
_this.defaults.error('FAILED: ' + (data.message || 'Unknown Error'), data);
return DSUtils.Promise.reject(data);
... | javascript | function logResponse(data, isRejection) {
data = data || {};
// examine the data object
if (data instanceof Error) {
// log the Error object
_this.defaults.error('FAILED: ' + (data.message || 'Unknown Error'), data);
return DSUtils.Promise.reject(data);
... | [
"function",
"logResponse",
"(",
"data",
",",
"isRejection",
")",
"{",
"data",
"=",
"data",
"||",
"{",
"}",
";",
"// examine the data object",
"if",
"(",
"data",
"instanceof",
"Error",
")",
"{",
"// log the Error object",
"_this",
".",
"defaults",
".",
"error",... | logs the HTTP response | [
"logs",
"the",
"HTTP",
"response"
] | 2890d89a5951c225a3870b7711b65b4889042170 | https://github.com/js-data/js-data-angular/blob/2890d89a5951c225a3870b7711b65b4889042170/dist/js-data-angular.js#L530-L556 | train |
syntax-tree/mdast-util-toc | lib/search.js | isClosingHeading | function isClosingHeading(node, depth) {
return depth && node && node.type === HEADING && node.depth <= depth
} | javascript | function isClosingHeading(node, depth) {
return depth && node && node.type === HEADING && node.depth <= depth
} | [
"function",
"isClosingHeading",
"(",
"node",
",",
"depth",
")",
"{",
"return",
"depth",
"&&",
"node",
"&&",
"node",
".",
"type",
"===",
"HEADING",
"&&",
"node",
".",
"depth",
"<=",
"depth",
"}"
] | Check if `node` is the next heading. | [
"Check",
"if",
"node",
"is",
"the",
"next",
"heading",
"."
] | 32d2a8fd91c3c0cfb2c568cc11ed457cd9386cd8 | https://github.com/syntax-tree/mdast-util-toc/blob/32d2a8fd91c3c0cfb2c568cc11ed457cd9386cd8/lib/search.js#L82-L84 | train |
segmentio/analytics.js-core | lib/analytics.js | pickPrefix | function pickPrefix(prefix, object) {
var length = prefix.length;
var sub;
return foldl(
function(acc, val, key) {
if (key.substr(0, length) === prefix) {
sub = key.substr(length);
acc[sub] = val;
}
return acc;
},
{},
object
);
} | javascript | function pickPrefix(prefix, object) {
var length = prefix.length;
var sub;
return foldl(
function(acc, val, key) {
if (key.substr(0, length) === prefix) {
sub = key.substr(length);
acc[sub] = val;
}
return acc;
},
{},
object
);
} | [
"function",
"pickPrefix",
"(",
"prefix",
",",
"object",
")",
"{",
"var",
"length",
"=",
"prefix",
".",
"length",
";",
"var",
"sub",
";",
"return",
"foldl",
"(",
"function",
"(",
"acc",
",",
"val",
",",
"key",
")",
"{",
"if",
"(",
"key",
".",
"subst... | Create a shallow copy of an input object containing only the properties
whose keys are specified by a prefix, stripped of that prefix
@param {String} prefix
@param {Object} object
@return {Object}
@api private | [
"Create",
"a",
"shallow",
"copy",
"of",
"an",
"input",
"object",
"containing",
"only",
"the",
"properties",
"whose",
"keys",
"are",
"specified",
"by",
"a",
"prefix",
"stripped",
"of",
"that",
"prefix"
] | 2facc5f327b84513ebbede2e5392483ea654f117 | https://github.com/segmentio/analytics.js-core/blob/2facc5f327b84513ebbede2e5392483ea654f117/lib/analytics.js#L769-L783 | train |
segmentio/analytics.js-core | lib/normalize.js | normalize | function normalize(msg, list) {
var lower = map(function(s) {
return s.toLowerCase();
}, list);
var opts = msg.options || {};
var integrations = opts.integrations || {};
var providers = opts.providers || {};
var context = opts.context || {};
var ret = {};
debug('<-', msg);
// integrations.
each... | javascript | function normalize(msg, list) {
var lower = map(function(s) {
return s.toLowerCase();
}, list);
var opts = msg.options || {};
var integrations = opts.integrations || {};
var providers = opts.providers || {};
var context = opts.context || {};
var ret = {};
debug('<-', msg);
// integrations.
each... | [
"function",
"normalize",
"(",
"msg",
",",
"list",
")",
"{",
"var",
"lower",
"=",
"map",
"(",
"function",
"(",
"s",
")",
"{",
"return",
"s",
".",
"toLowerCase",
"(",
")",
";",
"}",
",",
"list",
")",
";",
"var",
"opts",
"=",
"msg",
".",
"options",
... | Normalize `msg` based on integrations `list`.
@param {Object} msg
@param {Array} list
@return {Function} | [
"Normalize",
"msg",
"based",
"on",
"integrations",
"list",
"."
] | 2facc5f327b84513ebbede2e5392483ea654f117 | https://github.com/segmentio/analytics.js-core/blob/2facc5f327b84513ebbede2e5392483ea654f117/lib/normalize.js#L43-L99 | train |
sebelga/gstore-node | lib/entity.js | convertGeoPoints | function convertGeoPoints() {
if (!{}.hasOwnProperty.call(this.schema.__meta, 'geoPointsProps')) {
return;
}
this.schema.__meta.geoPointsProps.forEach((property) => {
if ({}.hasOwnProperty.call(_this.entityData, property)
... | javascript | function convertGeoPoints() {
if (!{}.hasOwnProperty.call(this.schema.__meta, 'geoPointsProps')) {
return;
}
this.schema.__meta.geoPointsProps.forEach((property) => {
if ({}.hasOwnProperty.call(_this.entityData, property)
... | [
"function",
"convertGeoPoints",
"(",
")",
"{",
"if",
"(",
"!",
"{",
"}",
".",
"hasOwnProperty",
".",
"call",
"(",
"this",
".",
"schema",
".",
"__meta",
",",
"'geoPointsProps'",
")",
")",
"{",
"return",
";",
"}",
"this",
".",
"schema",
".",
"__meta",
... | If the entityData has some property of type 'geoPoint'
and its value is an js object with "latitude" and "longitude"
we convert it to a datastore GeoPoint. | [
"If",
"the",
"entityData",
"has",
"some",
"property",
"of",
"type",
"geoPoint",
"and",
"its",
"value",
"is",
"an",
"js",
"object",
"with",
"latitude",
"and",
"longitude",
"we",
"convert",
"it",
"to",
"a",
"datastore",
"GeoPoint",
"."
] | 349ffe9f284d3315307a2e0f88e3fb5c01d3eac5 | https://github.com/sebelga/gstore-node/blob/349ffe9f284d3315307a2e0f88e3fb5c01d3eac5/lib/entity.js#L168-L180 | train |
sebelga/gstore-node | lib/model.js | metaData | function metaData() {
const meta = {};
Object.keys(schema.paths).forEach((k) => {
switch (schema.paths[k].type) {
case 'geoPoint':
// This allows us to automatically convert valid lng/lat objects
// to Datastore... | javascript | function metaData() {
const meta = {};
Object.keys(schema.paths).forEach((k) => {
switch (schema.paths[k].type) {
case 'geoPoint':
// This allows us to automatically convert valid lng/lat objects
// to Datastore... | [
"function",
"metaData",
"(",
")",
"{",
"const",
"meta",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"schema",
".",
"paths",
")",
".",
"forEach",
"(",
"(",
"k",
")",
"=>",
"{",
"switch",
"(",
"schema",
".",
"paths",
"[",
"k",
"]",
".",
"type... | To improve performance and avoid looping over and over the entityData or Schema we keep here some meta data to be used later in models and entities methods | [
"To",
"improve",
"performance",
"and",
"avoid",
"looping",
"over",
"and",
"over",
"the",
"entityData",
"or",
"Schema",
"we",
"keep",
"here",
"some",
"meta",
"data",
"to",
"be",
"used",
"later",
"in",
"models",
"and",
"entities",
"methods"
] | 349ffe9f284d3315307a2e0f88e3fb5c01d3eac5 | https://github.com/sebelga/gstore-node/blob/349ffe9f284d3315307a2e0f88e3fb5c01d3eac5/lib/model.js#L75-L95 | train |
sebelga/gstore-node | lib/model.js | applyMethods | function applyMethods(entity, schema) {
Object.keys(schema.methods).forEach((method) => {
entity[method] = schema.methods[method];
});
return entity;
} | javascript | function applyMethods(entity, schema) {
Object.keys(schema.methods).forEach((method) => {
entity[method] = schema.methods[method];
});
return entity;
} | [
"function",
"applyMethods",
"(",
"entity",
",",
"schema",
")",
"{",
"Object",
".",
"keys",
"(",
"schema",
".",
"methods",
")",
".",
"forEach",
"(",
"(",
"method",
")",
"=>",
"{",
"entity",
"[",
"method",
"]",
"=",
"schema",
".",
"methods",
"[",
"meth... | Add custom methods declared on the Schema to the Entity Class
@param {Entity} entity Model.prototype
@param {any} schema Model Schema
@returns Model.prototype | [
"Add",
"custom",
"methods",
"declared",
"on",
"the",
"Schema",
"to",
"the",
"Entity",
"Class"
] | 349ffe9f284d3315307a2e0f88e3fb5c01d3eac5 | https://github.com/sebelga/gstore-node/blob/349ffe9f284d3315307a2e0f88e3fb5c01d3eac5/lib/model.js#L961-L966 | train |
sebelga/gstore-node | lib/schema.js | defaultOptions | function defaultOptions(options) {
const optionsDefault = {
validateBeforeSave: true,
explicitOnly: true,
queries: {
readAll: false,
format: queries.formats.JSON,
},
};
options = extend(true, {}, optionsDefault, options);
if (options.joi) {
... | javascript | function defaultOptions(options) {
const optionsDefault = {
validateBeforeSave: true,
explicitOnly: true,
queries: {
readAll: false,
format: queries.formats.JSON,
},
};
options = extend(true, {}, optionsDefault, options);
if (options.joi) {
... | [
"function",
"defaultOptions",
"(",
"options",
")",
"{",
"const",
"optionsDefault",
"=",
"{",
"validateBeforeSave",
":",
"true",
",",
"explicitOnly",
":",
"true",
",",
"queries",
":",
"{",
"readAll",
":",
"false",
",",
"format",
":",
"queries",
".",
"formats"... | Merge options passed with the default option for Schemas
@param options | [
"Merge",
"options",
"passed",
"with",
"the",
"default",
"option",
"for",
"Schemas"
] | 349ffe9f284d3315307a2e0f88e3fb5c01d3eac5 | https://github.com/sebelga/gstore-node/blob/349ffe9f284d3315307a2e0f88e3fb5c01d3eac5/lib/schema.js#L201-L227 | train |
sebelga/gstore-node | lib/dataloader.js | createDataLoader | function createDataLoader(ds) {
ds = typeof ds !== 'undefined' ? ds : this && this.ds;
if (!ds) {
throw new Error('A Datastore instance has to be passed');
}
return new DataLoader(keys => (
ds.get(keys).then(([res]) => {
// When providing an Array with 1 Key item, google-da... | javascript | function createDataLoader(ds) {
ds = typeof ds !== 'undefined' ? ds : this && this.ds;
if (!ds) {
throw new Error('A Datastore instance has to be passed');
}
return new DataLoader(keys => (
ds.get(keys).then(([res]) => {
// When providing an Array with 1 Key item, google-da... | [
"function",
"createDataLoader",
"(",
"ds",
")",
"{",
"ds",
"=",
"typeof",
"ds",
"!==",
"'undefined'",
"?",
"ds",
":",
"this",
"&&",
"this",
".",
"ds",
";",
"if",
"(",
"!",
"ds",
")",
"{",
"throw",
"new",
"Error",
"(",
"'A Datastore instance has to be pas... | Create a DataLoader instance
@param {Datastore} ds @google-cloud Datastore instance | [
"Create",
"a",
"DataLoader",
"instance"
] | 349ffe9f284d3315307a2e0f88e3fb5c01d3eac5 | https://github.com/sebelga/gstore-node/blob/349ffe9f284d3315307a2e0f88e3fb5c01d3eac5/lib/dataloader.js#L16-L41 | train |
caolan/forms | lib/widgets.js | function (type) {
return function (opts) {
var opt = opts || {};
var userAttrs = getUserAttrs(opt);
var w = {
classes: opt.classes,
type: type,
formatValue: function (value) {
return (value || value === 0) ? value : null;
}
... | javascript | function (type) {
return function (opts) {
var opt = opts || {};
var userAttrs = getUserAttrs(opt);
var w = {
classes: opt.classes,
type: type,
formatValue: function (value) {
return (value || value === 0) ? value : null;
}
... | [
"function",
"(",
"type",
")",
"{",
"return",
"function",
"(",
"opts",
")",
"{",
"var",
"opt",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"userAttrs",
"=",
"getUserAttrs",
"(",
"opt",
")",
";",
"var",
"w",
"=",
"{",
"classes",
":",
"opt",
".",
"clas... | used to generate different input elements varying only by type attribute | [
"used",
"to",
"generate",
"different",
"input",
"elements",
"varying",
"only",
"by",
"type",
"attribute"
] | 748976ad38fd653873504cc776e73c8d47199a9c | https://github.com/caolan/forms/blob/748976ad38fd653873504cc776e73c8d47199a9c/lib/widgets.js#L22-L46 | train | |
instana/nodejs-sensor | packages/collector/src/agentConnection.js | sendRequestsSync | function sendRequestsSync(requests) {
// only try to require optional dependency netlinkwrapper once
if (!netLinkHasBeenRequired) {
netLinkHasBeenRequired = true;
try {
netLink = require('netlinkwrapper')();
} catch (requireNetlinkError) {
logger.warn(
'Failed to require optional dep... | javascript | function sendRequestsSync(requests) {
// only try to require optional dependency netlinkwrapper once
if (!netLinkHasBeenRequired) {
netLinkHasBeenRequired = true;
try {
netLink = require('netlinkwrapper')();
} catch (requireNetlinkError) {
logger.warn(
'Failed to require optional dep... | [
"function",
"sendRequestsSync",
"(",
"requests",
")",
"{",
"// only try to require optional dependency netlinkwrapper once",
"if",
"(",
"!",
"netLinkHasBeenRequired",
")",
"{",
"netLinkHasBeenRequired",
"=",
"true",
";",
"try",
"{",
"netLink",
"=",
"require",
"(",
"'net... | Sends multiple HTTP POST requests to the agent. This function is synchronous, that is, it blocks the event loop!
YOU MUST NOT USE THIS FUNCTION, except for the one use case where it is actually required to block the event loop
(reporting an uncaught exception tot the agent in the process.on('uncaughtException') handle... | [
"Sends",
"multiple",
"HTTP",
"POST",
"requests",
"to",
"the",
"agent",
".",
"This",
"function",
"is",
"synchronous",
"that",
"is",
"it",
"blocks",
"the",
"event",
"loop!"
] | 7e42fd64e1b38e9704a4f73a4c64ef5fac54e722 | https://github.com/instana/nodejs-sensor/blob/7e42fd64e1b38e9704a4f73a4c64ef5fac54e722/packages/collector/src/agentConnection.js#L301-L342 | train |
instana/nodejs-sensor | packages/collector/src/agentConnection.js | sendHttpPostRequestSync | function sendHttpPostRequestSync(port, path, data) {
logger.debug({ payload: data }, 'Sending payload synchronously to %s', path);
try {
var payload = JSON.stringify(data);
var payloadLength = buffer.fromString(payload, 'utf8').length;
} catch (payloadSerializationError) {
logger.warn('Could not seria... | javascript | function sendHttpPostRequestSync(port, path, data) {
logger.debug({ payload: data }, 'Sending payload synchronously to %s', path);
try {
var payload = JSON.stringify(data);
var payloadLength = buffer.fromString(payload, 'utf8').length;
} catch (payloadSerializationError) {
logger.warn('Could not seria... | [
"function",
"sendHttpPostRequestSync",
"(",
"port",
",",
"path",
",",
"data",
")",
"{",
"logger",
".",
"debug",
"(",
"{",
"payload",
":",
"data",
"}",
",",
"'Sending payload synchronously to %s'",
",",
"path",
")",
";",
"try",
"{",
"var",
"payload",
"=",
"... | Sends a single, synchronous HTTP POST request to the agent. This function is synchronous, that is, it blocks the
event loop!
YOU MUST NOT USE THIS FUNCTION, except for the one use case where it is actually required to block the event loop
(reporting an uncaught exception tot the agent in the process.on('uncaughtExcept... | [
"Sends",
"a",
"single",
"synchronous",
"HTTP",
"POST",
"request",
"to",
"the",
"agent",
".",
"This",
"function",
"is",
"synchronous",
"that",
"is",
"it",
"blocks",
"the",
"event",
"loop!"
] | 7e42fd64e1b38e9704a4f73a4c64ef5fac54e722 | https://github.com/instana/nodejs-sensor/blob/7e42fd64e1b38e9704a4f73a4c64ef5fac54e722/packages/collector/src/agentConnection.js#L351-L372 | train |
instana/nodejs-sensor | packages/core/src/tracing/instrumentation/frameworks/fastify.js | instrument | function instrument(build) {
if (typeof build !== 'function') {
return build;
}
// copy further exported properties
Object.keys(build).forEach(function(k) {
overwrittenBuild[k] = build[k];
});
return overwrittenBuild;
function overwrittenBuild() {
var app = build.apply(this, arguments);
... | javascript | function instrument(build) {
if (typeof build !== 'function') {
return build;
}
// copy further exported properties
Object.keys(build).forEach(function(k) {
overwrittenBuild[k] = build[k];
});
return overwrittenBuild;
function overwrittenBuild() {
var app = build.apply(this, arguments);
... | [
"function",
"instrument",
"(",
"build",
")",
"{",
"if",
"(",
"typeof",
"build",
"!==",
"'function'",
")",
"{",
"return",
"build",
";",
"}",
"// copy further exported properties",
"Object",
".",
"keys",
"(",
"build",
")",
".",
"forEach",
"(",
"function",
"(",... | Fastify exposes a function as its module's export. We are replacing this exposed function so that we gain access to the created fastify object. This is necessary so that we can overwrite the fastify.route method. fastify.route is the central routing registration method to which all other functions delegate. We overwri... | [
"Fastify",
"exposes",
"a",
"function",
"as",
"its",
"module",
"s",
"export",
".",
"We",
"are",
"replacing",
"this",
"exposed",
"function",
"so",
"that",
"we",
"gain",
"access",
"to",
"the",
"created",
"fastify",
"object",
".",
"This",
"is",
"necessary",
"s... | 7e42fd64e1b38e9704a4f73a4c64ef5fac54e722 | https://github.com/instana/nodejs-sensor/blob/7e42fd64e1b38e9704a4f73a4c64ef5fac54e722/packages/core/src/tracing/instrumentation/frameworks/fastify.js#L30-L70 | train |
FGRibreau/node-request-retry | index.js | makePromise | function makePromise(requestInstance, promiseFactoryFn) {
// Resolver function wich assigns the promise (resolve, reject) functions
// to the requestInstance
function Resolver(resolve, reject) {
this._resolve = resolve;
this._reject = reject;
}
return promiseFactoryFn(Resolver.bind(requestInstance))... | javascript | function makePromise(requestInstance, promiseFactoryFn) {
// Resolver function wich assigns the promise (resolve, reject) functions
// to the requestInstance
function Resolver(resolve, reject) {
this._resolve = resolve;
this._reject = reject;
}
return promiseFactoryFn(Resolver.bind(requestInstance))... | [
"function",
"makePromise",
"(",
"requestInstance",
",",
"promiseFactoryFn",
")",
"{",
"// Resolver function wich assigns the promise (resolve, reject) functions",
"// to the requestInstance",
"function",
"Resolver",
"(",
"resolve",
",",
"reject",
")",
"{",
"this",
".",
"_reso... | It calls the promiseFactory function passing it the resolver for the promise
@param {Object} requestInstance - The Request Retry instance
@param {Function} promiseFactoryFn - The Request Retry instance
@return {Object} - The promise instance | [
"It",
"calls",
"the",
"promiseFactory",
"function",
"passing",
"it",
"the",
"resolver",
"for",
"the",
"promise"
] | 0c6fb14d271b09a15f53ff44f3a16d640a914677 | https://github.com/FGRibreau/node-request-retry/blob/0c6fb14d271b09a15f53ff44f3a16d640a914677/index.js#L35-L45 | train |
FGRibreau/node-request-retry | index.js | makeHelper | function makeHelper(obj, verb) {
obj[verb] = function helper(url, options, f) {
// ('url')
if(_.isString(url)){
// ('url', f)
if(_.isFunction(options)){
f = options;
}
if(!_.isObject(options)){
options = {};
}
// ('url', {object})
options.url = url;
... | javascript | function makeHelper(obj, verb) {
obj[verb] = function helper(url, options, f) {
// ('url')
if(_.isString(url)){
// ('url', f)
if(_.isFunction(options)){
f = options;
}
if(!_.isObject(options)){
options = {};
}
// ('url', {object})
options.url = url;
... | [
"function",
"makeHelper",
"(",
"obj",
",",
"verb",
")",
"{",
"obj",
"[",
"verb",
"]",
"=",
"function",
"helper",
"(",
"url",
",",
"options",
",",
"f",
")",
"{",
"// ('url')",
"if",
"(",
"_",
".",
"isString",
"(",
"url",
")",
")",
"{",
"// ('url', f... | adds a helper for HTTP method `verb` to object `obj` | [
"adds",
"a",
"helper",
"for",
"HTTP",
"method",
"verb",
"to",
"object",
"obj"
] | 0c6fb14d271b09a15f53ff44f3a16d640a914677 | https://github.com/FGRibreau/node-request-retry/blob/0c6fb14d271b09a15f53ff44f3a16d640a914677/index.js#L183-L210 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.