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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
knownasilya/ember-leaflet-cartodb | vendor/ember-leaflet-cartodb/cartodb_noleaflet.js | PointView | function PointView(geometryModel) {
var self = this;
// events to link
var events = [
'click',
'dblclick',
'mousedown',
'mouseover',
'mouseout',
'dragstart',
'drag',
'dragend'
];
this._eventHandlers = {};
this.model = geometryModel;
this.points = [];
var style = _.clone... | javascript | function PointView(geometryModel) {
var self = this;
// events to link
var events = [
'click',
'dblclick',
'mousedown',
'mouseover',
'mouseout',
'dragstart',
'drag',
'dragend'
];
this._eventHandlers = {};
this.model = geometryModel;
this.points = [];
var style = _.clone... | [
"function",
"PointView",
"(",
"geometryModel",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// events to link",
"var",
"events",
"=",
"[",
"'click'",
",",
"'dblclick'",
",",
"'mousedown'",
",",
"'mouseover'",
",",
"'mouseout'",
",",
"'dragstart'",
",",
"'drag'"... | view for markers | [
"view",
"for",
"markers"
] | 61d11c6268d59343746809639e0d23419674ae87 | https://github.com/knownasilya/ember-leaflet-cartodb/blob/61d11c6268d59343746809639e0d23419674ae87/vendor/ember-leaflet-cartodb/cartodb_noleaflet.js#L27699-L27754 | train |
knownasilya/ember-leaflet-cartodb | vendor/ember-leaflet-cartodb/cartodb_noleaflet.js | function(index, columnName) {
var r = this.at(index);
if(!r) {
return null;
}
return r.get(columnName);
} | javascript | function(index, columnName) {
var r = this.at(index);
if(!r) {
return null;
}
return r.get(columnName);
} | [
"function",
"(",
"index",
",",
"columnName",
")",
"{",
"var",
"r",
"=",
"this",
".",
"at",
"(",
"index",
")",
";",
"if",
"(",
"!",
"r",
")",
"{",
"return",
"null",
";",
"}",
"return",
"r",
".",
"get",
"(",
"columnName",
")",
";",
"}"
] | get value for row index and columnName | [
"get",
"value",
"for",
"row",
"index",
"and",
"columnName"
] | 61d11c6268d59343746809639e0d23419674ae87 | https://github.com/knownasilya/ember-leaflet-cartodb/blob/61d11c6268d59343746809639e0d23419674ae87/vendor/ember-leaflet-cartodb/cartodb_noleaflet.js#L28762-L28768 | train | |
knownasilya/ember-leaflet-cartodb | vendor/ember-leaflet-cartodb/cartodb_noleaflet.js | function() {
this.$('tfoot').remove();
this.$('tr.noRows').remove();
// unbind rows before cleaning them when all are gonna be removed
var rowView = null;
while(rowView = this.rowViews.pop()) {
// this is a hack to avoid all the elements are removed one by one
rowView.unbind(null, null,... | javascript | function() {
this.$('tfoot').remove();
this.$('tr.noRows').remove();
// unbind rows before cleaning them when all are gonna be removed
var rowView = null;
while(rowView = this.rowViews.pop()) {
// this is a hack to avoid all the elements are removed one by one
rowView.unbind(null, null,... | [
"function",
"(",
")",
"{",
"this",
".",
"$",
"(",
"'tfoot'",
")",
".",
"remove",
"(",
")",
";",
"this",
".",
"$",
"(",
"'tr.noRows'",
")",
".",
"remove",
"(",
")",
";",
"// unbind rows before cleaning them when all are gonna be removed",
"var",
"rowView",
"=... | remove all rows | [
"remove",
"all",
"rows"
] | 61d11c6268d59343746809639e0d23419674ae87 | https://github.com/knownasilya/ember-leaflet-cartodb/blob/61d11c6268d59343746809639e0d23419674ae87/vendor/ember-leaflet-cartodb/cartodb_noleaflet.js#L28977-L28991 | train | |
knownasilya/ember-leaflet-cartodb | vendor/ember-leaflet-cartodb/cartodb_noleaflet.js | function() {
this.clear_rows();
if(! this.isEmptyTable()) {
if(this.dataModel.fetched) {
var self = this;
this.dataModel.each(function(row) {
self.addRow(row);
});
} else {
this._renderLoading();
}
} else {
this._renderEmpty();
}
} | javascript | function() {
this.clear_rows();
if(! this.isEmptyTable()) {
if(this.dataModel.fetched) {
var self = this;
this.dataModel.each(function(row) {
self.addRow(row);
});
} else {
this._renderLoading();
}
} else {
this._renderEmpty();
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"clear_rows",
"(",
")",
";",
"if",
"(",
"!",
"this",
".",
"isEmptyTable",
"(",
")",
")",
"{",
"if",
"(",
"this",
".",
"dataModel",
".",
"fetched",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"... | render only data rows | [
"render",
"only",
"data",
"rows"
] | 61d11c6268d59343746809639e0d23419674ae87 | https://github.com/knownasilya/ember-leaflet-cartodb/blob/61d11c6268d59343746809639e0d23419674ae87/vendor/ember-leaflet-cartodb/cartodb_noleaflet.js#L29099-L29115 | train | |
knownasilya/ember-leaflet-cartodb | vendor/ember-leaflet-cartodb/cartodb_noleaflet.js | function(type, vis, data) {
var t = Overlay._types[type];
if (!t) {
cdb.log.error("Overlay: " + type + " does not exist");
return;
}
data.options = typeof data.options === 'string' ? JSON.parse(data.options): data.options;
data.options = data.options || {}
var widget = t(data, vis)... | javascript | function(type, vis, data) {
var t = Overlay._types[type];
if (!t) {
cdb.log.error("Overlay: " + type + " does not exist");
return;
}
data.options = typeof data.options === 'string' ? JSON.parse(data.options): data.options;
data.options = data.options || {}
var widget = t(data, vis)... | [
"function",
"(",
"type",
",",
"vis",
",",
"data",
")",
"{",
"var",
"t",
"=",
"Overlay",
".",
"_types",
"[",
"type",
"]",
";",
"if",
"(",
"!",
"t",
")",
"{",
"cdb",
".",
"log",
".",
"error",
"(",
"\"Overlay: \"",
"+",
"type",
"+",
"\" does not exi... | create a type given the data raise an exception if the type does not exist | [
"create",
"a",
"type",
"given",
"the",
"data",
"raise",
"an",
"exception",
"if",
"the",
"type",
"does",
"not",
"exist"
] | 61d11c6268d59343746809639e0d23419674ae87 | https://github.com/knownasilya/ember-leaflet-cartodb/blob/61d11c6268d59343746809639e0d23419674ae87/vendor/ember-leaflet-cartodb/cartodb_noleaflet.js#L29344-L29362 | train | |
knownasilya/ember-leaflet-cartodb | vendor/ember-leaflet-cartodb/cartodb_noleaflet.js | function(layers) {
var mods = Layers.modulesForLayers(layers);
return _.every(_.map(mods, function(m) { return cartodb[m] !== undefined; }));
} | javascript | function(layers) {
var mods = Layers.modulesForLayers(layers);
return _.every(_.map(mods, function(m) { return cartodb[m] !== undefined; }));
} | [
"function",
"(",
"layers",
")",
"{",
"var",
"mods",
"=",
"Layers",
".",
"modulesForLayers",
"(",
"layers",
")",
";",
"return",
"_",
".",
"every",
"(",
"_",
".",
"map",
"(",
"mods",
",",
"function",
"(",
"m",
")",
"{",
"return",
"cartodb",
"[",
"m",... | check if all the modules needed to create layers are loaded | [
"check",
"if",
"all",
"the",
"modules",
"needed",
"to",
"create",
"layers",
"are",
"loaded"
] | 61d11c6268d59343746809639e0d23419674ae87 | https://github.com/knownasilya/ember-leaflet-cartodb/blob/61d11c6268d59343746809639e0d23419674ae87/vendor/ember-leaflet-cartodb/cartodb_noleaflet.js#L29454-L29457 | train | |
knownasilya/ember-leaflet-cartodb | vendor/ember-leaflet-cartodb/cartodb_noleaflet.js | function() {
var self = this;
return _.compact(this.map.layers.map(function(layer) {
return self.mapView.getLayerByCid(layer.cid);
}));
} | javascript | function() {
var self = this;
return _.compact(this.map.layers.map(function(layer) {
return self.mapView.getLayerByCid(layer.cid);
}));
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"return",
"_",
".",
"compact",
"(",
"this",
".",
"map",
".",
"layers",
".",
"map",
"(",
"function",
"(",
"layer",
")",
"{",
"return",
"self",
".",
"mapView",
".",
"getLayerByCid",
"(",
"la... | returns an array of layers | [
"returns",
"an",
"array",
"of",
"layers"
] | 61d11c6268d59343746809639e0d23419674ae87 | https://github.com/knownasilya/ember-leaflet-cartodb/blob/61d11c6268d59343746809639e0d23419674ae87/vendor/ember-leaflet-cartodb/cartodb_noleaflet.js#L30681-L30686 | train | |
knownasilya/ember-leaflet-cartodb | vendor/ember-leaflet-cartodb/cartodb_noleaflet.js | cartodbUrl | function cartodbUrl(opts) {
var host = opts.host || 'carto.com';
var protocol = opts.protocol || 'https';
return protocol + '://' + opts.user + '.' + host + '/api/v1/viz/' + opts.table + '/viz.json';
} | javascript | function cartodbUrl(opts) {
var host = opts.host || 'carto.com';
var protocol = opts.protocol || 'https';
return protocol + '://' + opts.user + '.' + host + '/api/v1/viz/' + opts.table + '/viz.json';
} | [
"function",
"cartodbUrl",
"(",
"opts",
")",
"{",
"var",
"host",
"=",
"opts",
".",
"host",
"||",
"'carto.com'",
";",
"var",
"protocol",
"=",
"opts",
".",
"protocol",
"||",
"'https'",
";",
"return",
"protocol",
"+",
"'://'",
"+",
"opts",
".",
"user",
"+"... | compose cartodb url | [
"compose",
"cartodb",
"url"
] | 61d11c6268d59343746809639e0d23419674ae87 | https://github.com/knownasilya/ember-leaflet-cartodb/blob/61d11c6268d59343746809639e0d23419674ae87/vendor/ember-leaflet-cartodb/cartodb_noleaflet.js#L32053-L32057 | train |
knownasilya/ember-leaflet-cartodb | vendor/ember-leaflet-cartodb/cartodb_noleaflet.js | _getLayerJson | function _getLayerJson(layer, callback) {
var url = null;
if(layer.layers !== undefined || ((layer.kind || layer.type) !== undefined)) {
// layer object contains the layer data
_.defer(function() { callback(layer); });
return;
} else if(layer.table !== undefined && layer.user !== undefined... | javascript | function _getLayerJson(layer, callback) {
var url = null;
if(layer.layers !== undefined || ((layer.kind || layer.type) !== undefined)) {
// layer object contains the layer data
_.defer(function() { callback(layer); });
return;
} else if(layer.table !== undefined && layer.user !== undefined... | [
"function",
"_getLayerJson",
"(",
"layer",
",",
"callback",
")",
"{",
"var",
"url",
"=",
"null",
";",
"if",
"(",
"layer",
".",
"layers",
"!==",
"undefined",
"||",
"(",
"(",
"layer",
".",
"kind",
"||",
"layer",
".",
"type",
")",
"!==",
"undefined",
")... | given layer params fetchs the layer json | [
"given",
"layer",
"params",
"fetchs",
"the",
"layer",
"json"
] | 61d11c6268d59343746809639e0d23419674ae87 | https://github.com/knownasilya/ember-leaflet-cartodb/blob/61d11c6268d59343746809639e0d23419674ae87/vendor/ember-leaflet-cartodb/cartodb_noleaflet.js#L32062-L32080 | train |
rtm/upward | src/Utl.js | seq | function seq(to, from = 0, step = 1) {
var result = [];
var count = 0;
if (to > from) for (let i = from; i < to; i += step) result[count++] = i;
else for (let i = from; i > to; i -= step) result[count++] = i;
return result;
} | javascript | function seq(to, from = 0, step = 1) {
var result = [];
var count = 0;
if (to > from) for (let i = from; i < to; i += step) result[count++] = i;
else for (let i = from; i > to; i -= step) result[count++] = i;
return result;
} | [
"function",
"seq",
"(",
"to",
",",
"from",
"=",
"0",
",",
"step",
"=",
"1",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"count",
"=",
"0",
";",
"if",
"(",
"to",
">",
"from",
")",
"for",
"(",
"let",
"i",
"=",
"from",
";",
"i",
"<... | Create an array of a sequence of integers. | [
"Create",
"an",
"array",
"of",
"a",
"sequence",
"of",
"integers",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L15-L22 | train |
rtm/upward | src/Utl.js | omit | function omit(a, elt) {
var index = a.indexOf(elt);
if (index !== -1) {
a.splice(index, 1);
}
return a;
} | javascript | function omit(a, elt) {
var index = a.indexOf(elt);
if (index !== -1) {
a.splice(index, 1);
}
return a;
} | [
"function",
"omit",
"(",
"a",
",",
"elt",
")",
"{",
"var",
"index",
"=",
"a",
".",
"indexOf",
"(",
"elt",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"a",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"return",
"a",
";"... | Omit elements from array destructively. | [
"Omit",
"elements",
"from",
"array",
"destructively",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L100-L106 | train |
rtm/upward | src/Utl.js | replace | function replace(a, elt1, elt2) {
var idx = a.indexOf(elt1);
if (idx !== -1) { a[idx] = elt2; }
return a;
} | javascript | function replace(a, elt1, elt2) {
var idx = a.indexOf(elt1);
if (idx !== -1) { a[idx] = elt2; }
return a;
} | [
"function",
"replace",
"(",
"a",
",",
"elt1",
",",
"elt2",
")",
"{",
"var",
"idx",
"=",
"a",
".",
"indexOf",
"(",
"elt1",
")",
";",
"if",
"(",
"idx",
"!==",
"-",
"1",
")",
"{",
"a",
"[",
"idx",
"]",
"=",
"elt2",
";",
"}",
"return",
"a",
";"... | Replace one element in an array with another. | [
"Replace",
"one",
"element",
"in",
"an",
"array",
"with",
"another",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L109-L113 | train |
rtm/upward | src/Utl.js | reverse | function reverse(a) {
var len = a.length;
for (var i = 0; i < Math.floor(len/2); i++) {
[a[i], a[len-i-1]] = [a[len-i-1], a[i]];
}
return a;
} | javascript | function reverse(a) {
var len = a.length;
for (var i = 0; i < Math.floor(len/2); i++) {
[a[i], a[len-i-1]] = [a[len-i-1], a[i]];
}
return a;
} | [
"function",
"reverse",
"(",
"a",
")",
"{",
"var",
"len",
"=",
"a",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"Math",
".",
"floor",
"(",
"len",
"/",
"2",
")",
";",
"i",
"++",
")",
"{",
"[",
"a",
"[",
"i",
"]",
... | reverse an array in place | [
"reverse",
"an",
"array",
"in",
"place"
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L116-L122 | train |
rtm/upward | src/Utl.js | flatten | function flatten(a) {
function _reduce(a) { return a.reduce(_flatten, []); }
function _flatten(a, b) {
return a.concat(Array.isArray(b) ? _reduce(b) : b);
}
return _reduce(a);
} | javascript | function flatten(a) {
function _reduce(a) { return a.reduce(_flatten, []); }
function _flatten(a, b) {
return a.concat(Array.isArray(b) ? _reduce(b) : b);
}
return _reduce(a);
} | [
"function",
"flatten",
"(",
"a",
")",
"{",
"function",
"_reduce",
"(",
"a",
")",
"{",
"return",
"a",
".",
"reduce",
"(",
"_flatten",
",",
"[",
"]",
")",
";",
"}",
"function",
"_flatten",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
".",
"concat",... | Flatten an array. | [
"Flatten",
"an",
"array",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L125-L133 | train |
rtm/upward | src/Utl.js | uniqueize | function uniqueize(a) {
return a.filter((elt, i) => a.indexOf(elt) === i);
} | javascript | function uniqueize(a) {
return a.filter((elt, i) => a.indexOf(elt) === i);
} | [
"function",
"uniqueize",
"(",
"a",
")",
"{",
"return",
"a",
".",
"filter",
"(",
"(",
"elt",
",",
"i",
")",
"=>",
"a",
".",
"indexOf",
"(",
"elt",
")",
"===",
"i",
")",
";",
"}"
] | Create an array of unique values. @TODO replace this logic using Set. | [
"Create",
"an",
"array",
"of",
"unique",
"values",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L189-L191 | train |
rtm/upward | src/Utl.js | indexesOf | function indexesOf(a, elt) {
var ret = [], index = 0;
while ((index = a.indexOf(elt, index)) !== -1) {
ret.push(index++);
}
return ret;
} | javascript | function indexesOf(a, elt) {
var ret = [], index = 0;
while ((index = a.indexOf(elt, index)) !== -1) {
ret.push(index++);
}
return ret;
} | [
"function",
"indexesOf",
"(",
"a",
",",
"elt",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
",",
"index",
"=",
"0",
";",
"while",
"(",
"(",
"index",
"=",
"a",
".",
"indexOf",
"(",
"elt",
",",
"index",
")",
")",
"!==",
"-",
"1",
")",
"{",
"ret",
"... | Find all occurrences of element in an array, return indices. @NOTUSED | [
"Find",
"all",
"occurrences",
"of",
"element",
"in",
"an",
"array",
"return",
"indices",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L195-L201 | train |
rtm/upward | src/Utl.js | runningMap | function runningMap(a, fn, init) {
return a.map(v => init = fn(v, init));
} | javascript | function runningMap(a, fn, init) {
return a.map(v => init = fn(v, init));
} | [
"function",
"runningMap",
"(",
"a",
",",
"fn",
",",
"init",
")",
"{",
"return",
"a",
".",
"map",
"(",
"v",
"=>",
"init",
"=",
"fn",
"(",
"v",
",",
"init",
")",
")",
";",
"}"
] | Create an array of running totals, etc. | [
"Create",
"an",
"array",
"of",
"running",
"totals",
"etc",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L209-L211 | train |
rtm/upward | src/Utl.js | chainPromises | function chainPromises(...fns) {
return [...fns].reduce(
(result, fn) => result.then(fn),
Promise.resolve()
);
} | javascript | function chainPromises(...fns) {
return [...fns].reduce(
(result, fn) => result.then(fn),
Promise.resolve()
);
} | [
"function",
"chainPromises",
"(",
"...",
"fns",
")",
"{",
"return",
"[",
"...",
"fns",
"]",
".",
"reduce",
"(",
"(",
"result",
",",
"fn",
")",
"=>",
"result",
".",
"then",
"(",
"fn",
")",
",",
"Promise",
".",
"resolve",
"(",
")",
")",
";",
"}"
] | Chain fns together using promises. | [
"Chain",
"fns",
"together",
"using",
"promises",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L229-L234 | train |
rtm/upward | src/Utl.js | makeCounterMap | function makeCounterMap() {
var map = new WeakMap();
return {
init(obj) { map.set(obj, 0); },
incr(obj) {
console.assert(map.has(obj), "Object must be in counter map.");
map.set(obj, map.get(obj) + 1);
},
get(obj) { return map.get(obj); }
};
} | javascript | function makeCounterMap() {
var map = new WeakMap();
return {
init(obj) { map.set(obj, 0); },
incr(obj) {
console.assert(map.has(obj), "Object must be in counter map.");
map.set(obj, map.get(obj) + 1);
},
get(obj) { return map.get(obj); }
};
} | [
"function",
"makeCounterMap",
"(",
")",
"{",
"var",
"map",
"=",
"new",
"WeakMap",
"(",
")",
";",
"return",
"{",
"init",
"(",
"obj",
")",
"{",
"map",
".",
"set",
"(",
"obj",
",",
"0",
")",
";",
"}",
",",
"incr",
"(",
"obj",
")",
"{",
"console",
... | Make a counter for occurrences of something on an object, using weak map. For example, used to count recomputations of "keepXXX" results. | [
"Make",
"a",
"counter",
"for",
"occurrences",
"of",
"something",
"on",
"an",
"object",
"using",
"weak",
"map",
".",
"For",
"example",
"used",
"to",
"count",
"recomputations",
"of",
"keepXXX",
"results",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L259-L269 | train |
rtm/upward | src/Utl.js | interleave | function interleave(...arrays) {
var more = true;
var n = 0;
var result = [];
while (more) {
more = false;
for (var array of arrays) {
if (n >= array.length) continue;
result.push(array[n]);
more = true;
}
n++;
}
return result;
} | javascript | function interleave(...arrays) {
var more = true;
var n = 0;
var result = [];
while (more) {
more = false;
for (var array of arrays) {
if (n >= array.length) continue;
result.push(array[n]);
more = true;
}
n++;
}
return result;
} | [
"function",
"interleave",
"(",
"...",
"arrays",
")",
"{",
"var",
"more",
"=",
"true",
";",
"var",
"n",
"=",
"0",
";",
"var",
"result",
"=",
"[",
"]",
";",
"while",
"(",
"more",
")",
"{",
"more",
"=",
"false",
";",
"for",
"(",
"var",
"array",
"o... | Interleave multiple arrays. | [
"Interleave",
"multiple",
"arrays",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Utl.js#L272-L286 | train |
thybzi/styledoc | styledoc.js | getUniqueItemId | function getUniqueItemId(selector) {
var base_id = selectorToId(selector),
id = base_id,
numeric_suffix = 0;
while (used_item_ids.indexOf(id) !== -1) {
id = base_id + "_" + ++numeric_suffix;
}
used_item_ids.push(id);
... | javascript | function getUniqueItemId(selector) {
var base_id = selectorToId(selector),
id = base_id,
numeric_suffix = 0;
while (used_item_ids.indexOf(id) !== -1) {
id = base_id + "_" + ++numeric_suffix;
}
used_item_ids.push(id);
... | [
"function",
"getUniqueItemId",
"(",
"selector",
")",
"{",
"var",
"base_id",
"=",
"selectorToId",
"(",
"selector",
")",
",",
"id",
"=",
"base_id",
",",
"numeric_suffix",
"=",
"0",
";",
"while",
"(",
"used_item_ids",
".",
"indexOf",
"(",
"id",
")",
"!==",
... | Converts selector to ID and assures it is unique
@param {string} selector
@returns {string}
@todo dry? | [
"Converts",
"selector",
"to",
"ID",
"and",
"assures",
"it",
"is",
"unique"
] | f478da33b66ffa10d1426ed2dd90a5f457fe5248 | https://github.com/thybzi/styledoc/blob/f478da33b66ffa10d1426ed2dd90a5f457fe5248/styledoc.js#L349-L361 | train |
thybzi/styledoc | styledoc.js | getUniqueSectionAnchor | function getUniqueSectionAnchor(anchor) {
var base_anchor = anchor,
numeric_suffix = 0;
while (used_section_anchors.indexOf(anchor) !== -1) {
anchor = base_anchor + "_" + ++numeric_suffix;
}
used_section_anchors.push(anchor);
... | javascript | function getUniqueSectionAnchor(anchor) {
var base_anchor = anchor,
numeric_suffix = 0;
while (used_section_anchors.indexOf(anchor) !== -1) {
anchor = base_anchor + "_" + ++numeric_suffix;
}
used_section_anchors.push(anchor);
... | [
"function",
"getUniqueSectionAnchor",
"(",
"anchor",
")",
"{",
"var",
"base_anchor",
"=",
"anchor",
",",
"numeric_suffix",
"=",
"0",
";",
"while",
"(",
"used_section_anchors",
".",
"indexOf",
"(",
"anchor",
")",
"!==",
"-",
"1",
")",
"{",
"anchor",
"=",
"b... | Assures section anchor to be unique
@param {string} anchor
@returns {string}
@todo dry? | [
"Assures",
"section",
"anchor",
"to",
"be",
"unique"
] | f478da33b66ffa10d1426ed2dd90a5f457fe5248 | https://github.com/thybzi/styledoc/blob/f478da33b66ffa10d1426ed2dd90a5f457fe5248/styledoc.js#L370-L381 | train |
thybzi/styledoc | styledoc.js | getPreviewContainerStyle | function getPreviewContainerStyle(options) {
var preview_container_style = "";
var padding_value = options.preview_padding;
if (typeof padding_value === "number") {
padding_value = [ padding_value ];
}
if (isArray(padding_value)) {
preview_container_style... | javascript | function getPreviewContainerStyle(options) {
var preview_container_style = "";
var padding_value = options.preview_padding;
if (typeof padding_value === "number") {
padding_value = [ padding_value ];
}
if (isArray(padding_value)) {
preview_container_style... | [
"function",
"getPreviewContainerStyle",
"(",
"options",
")",
"{",
"var",
"preview_container_style",
"=",
"\"\"",
";",
"var",
"padding_value",
"=",
"options",
".",
"preview_padding",
";",
"if",
"(",
"typeof",
"padding_value",
"===",
"\"number\"",
")",
"{",
"padding... | Generate value for the preview container "style" attribute
@param {object} options
@param {number|number[]} [options.preview_padding] Padding value(s) for preview container (4 or [4, 8], or [4, 0, 12, 8] etc.)
@param {string} [options.background_color] Background color CSS value for both main showcase page and preview ... | [
"Generate",
"value",
"for",
"the",
"preview",
"container",
"style",
"attribute"
] | f478da33b66ffa10d1426ed2dd90a5f457fe5248 | https://github.com/thybzi/styledoc/blob/f478da33b66ffa10d1426ed2dd90a5f457fe5248/styledoc.js#L1340-L1356 | train |
thybzi/styledoc | styledoc.js | selectorToId | function selectorToId(selector) {
var id = selector.replace(/[^a-z0-9_-]/ig, "_");
if (styledoc.item_id_trim_underscores) {
id = id.replace(/_{2,}/g, "_").replace(/^_/, "").replace(/_$/, "");
}
return id;
} | javascript | function selectorToId(selector) {
var id = selector.replace(/[^a-z0-9_-]/ig, "_");
if (styledoc.item_id_trim_underscores) {
id = id.replace(/_{2,}/g, "_").replace(/^_/, "").replace(/_$/, "");
}
return id;
} | [
"function",
"selectorToId",
"(",
"selector",
")",
"{",
"var",
"id",
"=",
"selector",
".",
"replace",
"(",
"/",
"[^a-z0-9_-]",
"/",
"ig",
",",
"\"_\"",
")",
";",
"if",
"(",
"styledoc",
".",
"item_id_trim_underscores",
")",
"{",
"id",
"=",
"id",
".",
"re... | Replace any char other than latin letters, digits, hyphens and underscores with underscore char
Also wipes out the first underscore char (@todo is it really good and safe idea?)
E.g.: .my-class => my-class
.my-class.subclass#id #otherid => my-class_subclass_id__otherid
@param {string} selector
@returns {string} | [
"Replace",
"any",
"char",
"other",
"than",
"latin",
"letters",
"digits",
"hyphens",
"and",
"underscores",
"with",
"underscore",
"char",
"Also",
"wipes",
"out",
"the",
"first",
"underscore",
"char",
"("
] | f478da33b66ffa10d1426ed2dd90a5f457fe5248 | https://github.com/thybzi/styledoc/blob/f478da33b66ffa10d1426ed2dd90a5f457fe5248/styledoc.js#L1367-L1375 | train |
flatiron/cortex.js | lib/cortex.js | on | function on(event, callback, context) {
var events = eventsplitter.test(event)
? event.split(eventsplitter)
: [event];
this.events = this.events || (this.events = {});
while (event = events.shift()) {
if (!event) continue;
(this.events[event] = this... | javascript | function on(event, callback, context) {
var events = eventsplitter.test(event)
? event.split(eventsplitter)
: [event];
this.events = this.events || (this.events = {});
while (event = events.shift()) {
if (!event) continue;
(this.events[event] = this... | [
"function",
"on",
"(",
"event",
",",
"callback",
",",
"context",
")",
"{",
"var",
"events",
"=",
"eventsplitter",
".",
"test",
"(",
"event",
")",
"?",
"event",
".",
"split",
"(",
"eventsplitter",
")",
":",
"[",
"event",
"]",
";",
"this",
".",
"events... | Adds an event listener.
@param {String} events space separated list of events to listen on
@param {Function} callback
@param {Mixed} context
@api public | [
"Adds",
"an",
"event",
"listener",
"."
] | d8fe3829513e36755a5380933a778758c4bf5892 | https://github.com/flatiron/cortex.js/blob/d8fe3829513e36755a5380933a778758c4bf5892/lib/cortex.js#L205-L222 | train |
flatiron/cortex.js | lib/cortex.js | remove | function remove(handle) {
return !(
handle.callback === callback
&& (!context ? true : handle.context === context)
);
} | javascript | function remove(handle) {
return !(
handle.callback === callback
&& (!context ? true : handle.context === context)
);
} | [
"function",
"remove",
"(",
"handle",
")",
"{",
"return",
"!",
"(",
"handle",
".",
"callback",
"===",
"callback",
"&&",
"(",
"!",
"context",
"?",
"true",
":",
"handle",
".",
"context",
"===",
"context",
")",
")",
";",
"}"
] | Helper function to filter out the `this.events` array
@param {Function} handle the callback of the event
@api private | [
"Helper",
"function",
"to",
"filter",
"out",
"the",
"this",
".",
"events",
"array"
] | d8fe3829513e36755a5380933a778758c4bf5892 | https://github.com/flatiron/cortex.js/blob/d8fe3829513e36755a5380933a778758c4bf5892/lib/cortex.js#L255-L260 | train |
flatiron/cortex.js | lib/cortex.js | call | function call(handle) {
handle.callback.apply(handle.context, args);
called = true;
} | javascript | function call(handle) {
handle.callback.apply(handle.context, args);
called = true;
} | [
"function",
"call",
"(",
"handle",
")",
"{",
"handle",
".",
"callback",
".",
"apply",
"(",
"handle",
".",
"context",
",",
"args",
")",
";",
"called",
"=",
"true",
";",
"}"
] | Helper function that is called on each iteration of matching events.
@param {Function} handle
@api private | [
"Helper",
"function",
"that",
"is",
"called",
"on",
"each",
"iteration",
"of",
"matching",
"events",
"."
] | d8fe3829513e36755a5380933a778758c4bf5892 | https://github.com/flatiron/cortex.js/blob/d8fe3829513e36755a5380933a778758c4bf5892/lib/cortex.js#L298-L301 | train |
flatiron/cortex.js | lib/cortex.js | get | function get(attr) {
if (!~attr.indexOf('.')) return this.attributes[attr];
var result = attr
, structure = this.attributes;
for (var paths = attr.split('.'), i = 0, length = paths.length; i < length && structure; i++) {
result = structure[+paths[i] || paths[i]];
... | javascript | function get(attr) {
if (!~attr.indexOf('.')) return this.attributes[attr];
var result = attr
, structure = this.attributes;
for (var paths = attr.split('.'), i = 0, length = paths.length; i < length && structure; i++) {
result = structure[+paths[i] || paths[i]];
... | [
"function",
"get",
"(",
"attr",
")",
"{",
"if",
"(",
"!",
"~",
"attr",
".",
"indexOf",
"(",
"'.'",
")",
")",
"return",
"this",
".",
"attributes",
"[",
"attr",
"]",
";",
"var",
"result",
"=",
"attr",
",",
"structure",
"=",
"this",
".",
"attributes",... | Get attributes from the structure
@param {String} attr
@returns {Mixed}
@api public | [
"Get",
"attributes",
"from",
"the",
"structure"
] | d8fe3829513e36755a5380933a778758c4bf5892 | https://github.com/flatiron/cortex.js/blob/d8fe3829513e36755a5380933a778758c4bf5892/lib/cortex.js#L408-L420 | train |
alexindigo/batcher | default_reporter.js | function(state)
{
console.log('# Started batch process\n');
console.log('## Initial State:\n');
console.log('```');
console.log(JSON.stringify(sortKeys(state), null, 2));
console.log('```');
console.log('\n## Execution\n');
} | javascript | function(state)
{
console.log('# Started batch process\n');
console.log('## Initial State:\n');
console.log('```');
console.log(JSON.stringify(sortKeys(state), null, 2));
console.log('```');
console.log('\n## Execution\n');
} | [
"function",
"(",
"state",
")",
"{",
"console",
".",
"log",
"(",
"'# Started batch process\\n'",
")",
";",
"console",
".",
"log",
"(",
"'## Initial State:\\n'",
")",
";",
"console",
".",
"log",
"(",
"'```'",
")",
";",
"console",
".",
"log",
"(",
"JSON",
"... | Handles initial state report
@param {object} state - current state
@returns {void} | [
"Handles",
"initial",
"state",
"report"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/default_reporter.js#L13-L21 | train | |
alexindigo/batcher | default_reporter.js | function(state, command, error)
{
console.log('> Failed to execute ``', command, '``' + withCmdPrefix(state) + ':');
console.log('```');
console.log(JSON.stringify(error, null, 2));
console.log('```');
} | javascript | function(state, command, error)
{
console.log('> Failed to execute ``', command, '``' + withCmdPrefix(state) + ':');
console.log('```');
console.log(JSON.stringify(error, null, 2));
console.log('```');
} | [
"function",
"(",
"state",
",",
"command",
",",
"error",
")",
"{",
"console",
".",
"log",
"(",
"'> Failed to execute ``'",
",",
"command",
",",
"'``'",
"+",
"withCmdPrefix",
"(",
"state",
")",
"+",
"':'",
")",
";",
"console",
".",
"log",
"(",
"'```'",
"... | Handles reports with command's errors
@param {object} state - current state
@param {string} command - string representation of the command
@param {object} error - error returned by the command's execution
@returns {void} | [
"Handles",
"reports",
"with",
"command",
"s",
"errors"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/default_reporter.js#L43-L49 | train | |
alexindigo/batcher | default_reporter.js | function(state, command, output)
{
console.log('> Finished execution of ``', command, '``' + withCmdPrefix(state) + ':');
if (!Array.isArray(output)) output = [output];
console.log('```');
console.log(output.map(format).join('\n'));
console.log('```');
} | javascript | function(state, command, output)
{
console.log('> Finished execution of ``', command, '``' + withCmdPrefix(state) + ':');
if (!Array.isArray(output)) output = [output];
console.log('```');
console.log(output.map(format).join('\n'));
console.log('```');
} | [
"function",
"(",
"state",
",",
"command",
",",
"output",
")",
"{",
"console",
".",
"log",
"(",
"'> Finished execution of ``'",
",",
"command",
",",
"'``'",
"+",
"withCmdPrefix",
"(",
"state",
")",
"+",
"':'",
")",
";",
"if",
"(",
"!",
"Array",
".",
"is... | Handles reports with command's output
@param {object} state - current state
@param {string} command - string representation of the command
@param {array|string|undefined} output - command's output
@returns {void} | [
"Handles",
"reports",
"with",
"command",
"s",
"output"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/default_reporter.js#L64-L71 | train | |
alexindigo/batcher | default_reporter.js | function(state, error)
{
if (error)
{
console.log('\n## Finished with errors:\n');
console.log('```');
console.log(JSON.stringify(error, null, 2));
console.log('```');
}
console.log('\n## Final State:\n');
console.log('```');
console.log(JSON.stringify(sortKeys(state),... | javascript | function(state, error)
{
if (error)
{
console.log('\n## Finished with errors:\n');
console.log('```');
console.log(JSON.stringify(error, null, 2));
console.log('```');
}
console.log('\n## Final State:\n');
console.log('```');
console.log(JSON.stringify(sortKeys(state),... | [
"function",
"(",
"state",
",",
"error",
")",
"{",
"if",
"(",
"error",
")",
"{",
"console",
".",
"log",
"(",
"'\\n## Finished with errors:\\n'",
")",
";",
"console",
".",
"log",
"(",
"'```'",
")",
";",
"console",
".",
"log",
"(",
"JSON",
".",
"stringify... | Handles reports with starting command's execution
@param {object} state - final state
@param {object|null} error - optional error object
@returns {void} | [
"Handles",
"reports",
"with",
"starting",
"command",
"s",
"execution"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/default_reporter.js#L93-L107 | train | |
alexindigo/batcher | default_reporter.js | sortKeys | function sortKeys(obj)
{
var sortedObj = {};
if (typeOf(obj) == 'object')
{
Object.keys(obj).sort().forEach(function(key)
{
sortedObj[key] = sortKeys(obj[key]);
});
obj = sortedObj;
}
return obj;
} | javascript | function sortKeys(obj)
{
var sortedObj = {};
if (typeOf(obj) == 'object')
{
Object.keys(obj).sort().forEach(function(key)
{
sortedObj[key] = sortKeys(obj[key]);
});
obj = sortedObj;
}
return obj;
} | [
"function",
"sortKeys",
"(",
"obj",
")",
"{",
"var",
"sortedObj",
"=",
"{",
"}",
";",
"if",
"(",
"typeOf",
"(",
"obj",
")",
"==",
"'object'",
")",
"{",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"sort",
"(",
")",
".",
"forEach",
"(",
"function"... | Tries really hard to sort object's keys alphabetically
@param {object} obj - object to sort
@returns {object} - sorted object | [
"Tries",
"really",
"hard",
"to",
"sort",
"object",
"s",
"keys",
"alphabetically"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/default_reporter.js#L116-L131 | train |
alexindigo/batcher | default_reporter.js | format | function format(obj)
{
var output;
if (typeOf(obj) == 'object' || typeOf(obj) == 'array' || typeOf(obj) == 'null')
{
output = JSON.stringify(obj);
}
else if (typeOf(obj) != 'undefined')
{
output = obj.toString();
}
else
{
output = '';
}
return output;
} | javascript | function format(obj)
{
var output;
if (typeOf(obj) == 'object' || typeOf(obj) == 'array' || typeOf(obj) == 'null')
{
output = JSON.stringify(obj);
}
else if (typeOf(obj) != 'undefined')
{
output = obj.toString();
}
else
{
output = '';
}
return output;
} | [
"function",
"format",
"(",
"obj",
")",
"{",
"var",
"output",
";",
"if",
"(",
"typeOf",
"(",
"obj",
")",
"==",
"'object'",
"||",
"typeOf",
"(",
"obj",
")",
"==",
"'array'",
"||",
"typeOf",
"(",
"obj",
")",
"==",
"'null'",
")",
"{",
"output",
"=",
... | Formats provided variable into a string, ready for console
@param {mixed} obj – object to format
@returns {string} - formatted string | [
"Formats",
"provided",
"variable",
"into",
"a",
"string",
"ready",
"for",
"console"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/default_reporter.js#L139-L157 | train |
alexindigo/batcher | default_reporter.js | withCmdPrefix | function withCmdPrefix(state)
{
var prefix;
if (state.options && state.options.cmdPrefix)
{
prefix = ' with ``' + state.options.cmdPrefix + '`` prefix';
}
return prefix || '';
} | javascript | function withCmdPrefix(state)
{
var prefix;
if (state.options && state.options.cmdPrefix)
{
prefix = ' with ``' + state.options.cmdPrefix + '`` prefix';
}
return prefix || '';
} | [
"function",
"withCmdPrefix",
"(",
"state",
")",
"{",
"var",
"prefix",
";",
"if",
"(",
"state",
".",
"options",
"&&",
"state",
".",
"options",
".",
"cmdPrefix",
")",
"{",
"prefix",
"=",
"' with ``'",
"+",
"state",
".",
"options",
".",
"cmdPrefix",
"+",
... | Generates command prefix line
@param {object} state - current state
@returns {string} - prefix line or empty string | [
"Generates",
"command",
"prefix",
"line"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/default_reporter.js#L165-L175 | train |
fczbkk/the-box | src/utilities/get-boxes-around.spec.js | isMatching | function isMatching(result, expectation) {
if (result.length !== expectation.length) {
return false;
}
// convert results and expectations to strings for easier comparison
result = result.map(item => item.toString());
expectation = expectation.map(item => getBox(item).toString());
const reduce_callbac... | javascript | function isMatching(result, expectation) {
if (result.length !== expectation.length) {
return false;
}
// convert results and expectations to strings for easier comparison
result = result.map(item => item.toString());
expectation = expectation.map(item => getBox(item).toString());
const reduce_callbac... | [
"function",
"isMatching",
"(",
"result",
",",
"expectation",
")",
"{",
"if",
"(",
"result",
".",
"length",
"!==",
"expectation",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"// convert results and expectations to strings for easier comparison",
"result",
"... | helper function that compares length and values of expectations | [
"helper",
"function",
"that",
"compares",
"length",
"and",
"values",
"of",
"expectations"
] | 337efc6bd00f92565dac8abffeb271b03caae2ba | https://github.com/fczbkk/the-box/blob/337efc6bd00f92565dac8abffeb271b03caae2ba/src/utilities/get-boxes-around.spec.js#L6-L20 | train |
mikesamuel/module-keys | index.js | selfContained | function selfContained(collection) {
const proto = getPrototypeOf(collection);
/* istanbul ignore if */
if (!proto || getPrototypeOf(proto) !== ObjectPrototype) {
// The loop below is insufficient.
throw new Error();
}
for (const key of getOwnPropertyNames(proto)) {
defineProperty(collection, key,... | javascript | function selfContained(collection) {
const proto = getPrototypeOf(collection);
/* istanbul ignore if */
if (!proto || getPrototypeOf(proto) !== ObjectPrototype) {
// The loop below is insufficient.
throw new Error();
}
for (const key of getOwnPropertyNames(proto)) {
defineProperty(collection, key,... | [
"function",
"selfContained",
"(",
"collection",
")",
"{",
"const",
"proto",
"=",
"getPrototypeOf",
"(",
"collection",
")",
";",
"/* istanbul ignore if */",
"if",
"(",
"!",
"proto",
"||",
"getPrototypeOf",
"(",
"proto",
")",
"!==",
"ObjectPrototype",
")",
"{",
... | eslint-disable-line no-unused-vars, init-declarations
Called before attacker-controlled code on an internal collections,
copies prototype members onto the instance directly, so that later
changes to prototypes cannot expose collection internals.
@param {!T} collection
@return {!T} collection
@template T | [
"eslint",
"-",
"disable",
"-",
"line",
"no",
"-",
"unused",
"-",
"vars",
"init",
"-",
"declarations",
"Called",
"before",
"attacker",
"-",
"controlled",
"code",
"on",
"an",
"internal",
"collections",
"copies",
"prototype",
"members",
"onto",
"the",
"instance",... | 39100b07d143af3f77a0bec519a92634d5173dd6 | https://github.com/mikesamuel/module-keys/blob/39100b07d143af3f77a0bec519a92634d5173dd6/index.js#L82-L93 | train |
mikesamuel/module-keys | index.js | makeModuleKeys | function makeModuleKeys(moduleIdentifier) {
// Allocate a public/private key pair.
function privateKey(fun) {
const previous = hidden;
hidden = privateKey;
try {
return fun();
} finally {
hidden = previous;
}
}
function publicKey() {
return hidden === privateKey;
}
publi... | javascript | function makeModuleKeys(moduleIdentifier) {
// Allocate a public/private key pair.
function privateKey(fun) {
const previous = hidden;
hidden = privateKey;
try {
return fun();
} finally {
hidden = previous;
}
}
function publicKey() {
return hidden === privateKey;
}
publi... | [
"function",
"makeModuleKeys",
"(",
"moduleIdentifier",
")",
"{",
"// Allocate a public/private key pair.",
"function",
"privateKey",
"(",
"fun",
")",
"{",
"const",
"previous",
"=",
"hidden",
";",
"hidden",
"=",
"privateKey",
";",
"try",
"{",
"return",
"fun",
"(",
... | Creates a bundle that should be available as a local variable to module code. | [
"Creates",
"a",
"bundle",
"that",
"should",
"be",
"available",
"as",
"a",
"local",
"variable",
"to",
"module",
"code",
"."
] | 39100b07d143af3f77a0bec519a92634d5173dd6 | https://github.com/mikesamuel/module-keys/blob/39100b07d143af3f77a0bec519a92634d5173dd6/index.js#L140-L266 | train |
mikesamuel/module-keys | index.js | box | function box(value, mayOpen) {
if (typeof mayOpen !== 'function') {
throw new TypeError(`Expected function not ${ mayOpen }`);
}
// Allocate an opaque token
const newBox = new Box();
boxes.set(
newBox,
freeze({ boxerPriv: privateKey, boxerPub: publicKey, value, mayOpen }));
ret... | javascript | function box(value, mayOpen) {
if (typeof mayOpen !== 'function') {
throw new TypeError(`Expected function not ${ mayOpen }`);
}
// Allocate an opaque token
const newBox = new Box();
boxes.set(
newBox,
freeze({ boxerPriv: privateKey, boxerPub: publicKey, value, mayOpen }));
ret... | [
"function",
"box",
"(",
"value",
",",
"mayOpen",
")",
"{",
"if",
"(",
"typeof",
"mayOpen",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"mayOpen",
"}",
"`",
")",
";",
"}",
"// Allocate an opaque token",
"const",
"newBox",
"... | Wraps a value in a box so that only an approved
opener may unbox it.
@param {*} value the value that will be given to
an approved unboxer.
@param {!function(function():boolean):boolean} mayOpen
receives the public key of the opener.
Should return `true` to allow.
This will be called in the context of the opener's
priv... | [
"Wraps",
"a",
"value",
"in",
"a",
"box",
"so",
"that",
"only",
"an",
"approved",
"opener",
"may",
"unbox",
"it",
"."
] | 39100b07d143af3f77a0bec519a92634d5173dd6 | https://github.com/mikesamuel/module-keys/blob/39100b07d143af3f77a0bec519a92634d5173dd6/index.js#L187-L197 | train |
mikesamuel/module-keys | index.js | unbox | function unbox(box, ifFrom, fallback) { // eslint-disable-line no-shadow
if (ifFrom == null) { // eslint-disable-line
ifFrom = () => true;
}
if (typeof ifFrom !== 'function') {
throw new TypeError(`Expected function not ${ ifFrom }`);
}
const boxData = boxes.get(box);
if (!boxData) {... | javascript | function unbox(box, ifFrom, fallback) { // eslint-disable-line no-shadow
if (ifFrom == null) { // eslint-disable-line
ifFrom = () => true;
}
if (typeof ifFrom !== 'function') {
throw new TypeError(`Expected function not ${ ifFrom }`);
}
const boxData = boxes.get(box);
if (!boxData) {... | [
"function",
"unbox",
"(",
"box",
",",
"ifFrom",
",",
"fallback",
")",
"{",
"// eslint-disable-line no-shadow",
"if",
"(",
"ifFrom",
"==",
"null",
")",
"{",
"// eslint-disable-line",
"ifFrom",
"=",
"(",
")",
"=>",
"true",
";",
"}",
"if",
"(",
"typeof",
"ifF... | Tries to open a box.
@param {*} box the box to unbox.
@param {?function(function():boolean):boolean} ifFrom
if the box may be opened by this unboxer's owner,
then ifFrom receives the publicKey of the box creator.
It should return true to allow unboxing to proceed.
@param {*} fallback a value to substitute if unboxing ... | [
"Tries",
"to",
"open",
"a",
"box",
"."
] | 39100b07d143af3f77a0bec519a92634d5173dd6 | https://github.com/mikesamuel/module-keys/blob/39100b07d143af3f77a0bec519a92634d5173dd6/index.js#L211-L231 | train |
mikesamuel/module-keys | index.js | unboxStrict | function unboxStrict(box, ifFrom) { // eslint-disable-line no-shadow
const result = unbox(box, ifFrom, neverBoxed);
if (result === neverBoxed) {
throw new Error('Could not unbox');
}
return result;
} | javascript | function unboxStrict(box, ifFrom) { // eslint-disable-line no-shadow
const result = unbox(box, ifFrom, neverBoxed);
if (result === neverBoxed) {
throw new Error('Could not unbox');
}
return result;
} | [
"function",
"unboxStrict",
"(",
"box",
",",
"ifFrom",
")",
"{",
"// eslint-disable-line no-shadow",
"const",
"result",
"=",
"unbox",
"(",
"box",
",",
"ifFrom",
",",
"neverBoxed",
")",
";",
"if",
"(",
"result",
"===",
"neverBoxed",
")",
"{",
"throw",
"new",
... | Like unbox but raises an exception if unboxing fails.
@param {*} box the box to unbox.
@param {?function(function():boolean):boolean} ifFrom
if the box may be opened by this unboxer's owner,
then ifFrom receives the publicKey of the box creator.
It should return true to allow unboxing to proceed.
@return {*} the value ... | [
"Like",
"unbox",
"but",
"raises",
"an",
"exception",
"if",
"unboxing",
"fails",
"."
] | 39100b07d143af3f77a0bec519a92634d5173dd6 | https://github.com/mikesamuel/module-keys/blob/39100b07d143af3f77a0bec519a92634d5173dd6/index.js#L243-L249 | train |
niallo/gumshoe | index.js | result | function result(rule) {
var r = {}
var reserved = ['filename', 'exists', 'grep', 'jsonKeyExists']
Object.keys(rule).forEach(function(key) {
if (reserved.indexOf(key) !== -1) return
r[key] = rule[key]
})
return r
} | javascript | function result(rule) {
var r = {}
var reserved = ['filename', 'exists', 'grep', 'jsonKeyExists']
Object.keys(rule).forEach(function(key) {
if (reserved.indexOf(key) !== -1) return
r[key] = rule[key]
})
return r
} | [
"function",
"result",
"(",
"rule",
")",
"{",
"var",
"r",
"=",
"{",
"}",
"var",
"reserved",
"=",
"[",
"'filename'",
",",
"'exists'",
",",
"'grep'",
",",
"'jsonKeyExists'",
"]",
"Object",
".",
"keys",
"(",
"rule",
")",
".",
"forEach",
"(",
"function",
... | Return an object created by removing all special properties from a rules object. | [
"Return",
"an",
"object",
"created",
"by",
"removing",
"all",
"special",
"properties",
"from",
"a",
"rules",
"object",
"."
] | eff4a8a59bd580536889c4771bb70ca4db2ed96d | https://github.com/niallo/gumshoe/blob/eff4a8a59bd580536889c4771bb70ca4db2ed96d/index.js#L10-L21 | train |
nicktindall/cyclon.p2p-rtc-client | lib/RedundantSignallingSocket.js | scheduleServerConnectivityChecks | function scheduleServerConnectivityChecks() {
if (connectivityIntervalId === null) {
connectivityIntervalId = asyncExecService.setInterval(function () {
updateRegistrations();
connectToServers();
}, INTERVAL_BETWEEN_SERVER_CONNECTIVITY_CHECKS);
}
... | javascript | function scheduleServerConnectivityChecks() {
if (connectivityIntervalId === null) {
connectivityIntervalId = asyncExecService.setInterval(function () {
updateRegistrations();
connectToServers();
}, INTERVAL_BETWEEN_SERVER_CONNECTIVITY_CHECKS);
}
... | [
"function",
"scheduleServerConnectivityChecks",
"(",
")",
"{",
"if",
"(",
"connectivityIntervalId",
"===",
"null",
")",
"{",
"connectivityIntervalId",
"=",
"asyncExecService",
".",
"setInterval",
"(",
"function",
"(",
")",
"{",
"updateRegistrations",
"(",
")",
";",
... | Schedule periodic server connectivity checks | [
"Schedule",
"periodic",
"server",
"connectivity",
"checks"
] | eb586ce288a6ad7e1b221280825037e855b03904 | https://github.com/nicktindall/cyclon.p2p-rtc-client/blob/eb586ce288a6ad7e1b221280825037e855b03904/lib/RedundantSignallingSocket.js#L54-L64 | train |
nicktindall/cyclon.p2p-rtc-client | lib/RedundantSignallingSocket.js | connectToServers | function connectToServers() {
var knownServers = signallingServerSelector.getServerSpecsInPriorityOrder();
for (var i = 0; i < knownServers.length; i++) {
var connectionsRemaining = signallingServerService.getPreferredNumberOfSockets() - Object.keys(connectedSockets).length;
//... | javascript | function connectToServers() {
var knownServers = signallingServerSelector.getServerSpecsInPriorityOrder();
for (var i = 0; i < knownServers.length; i++) {
var connectionsRemaining = signallingServerService.getPreferredNumberOfSockets() - Object.keys(connectedSockets).length;
//... | [
"function",
"connectToServers",
"(",
")",
"{",
"var",
"knownServers",
"=",
"signallingServerSelector",
".",
"getServerSpecsInPriorityOrder",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"knownServers",
".",
"length",
";",
"i",
"++",
")",
... | Connect to servers if we're not connected to enough | [
"Connect",
"to",
"servers",
"if",
"we",
"re",
"not",
"connected",
"to",
"enough"
] | eb586ce288a6ad7e1b221280825037e855b03904 | https://github.com/nicktindall/cyclon.p2p-rtc-client/blob/eb586ce288a6ad7e1b221280825037e855b03904/lib/RedundantSignallingSocket.js#L105-L141 | train |
nicktindall/cyclon.p2p-rtc-client | lib/RedundantSignallingSocket.js | storeSocket | function storeSocket(spec, socket) {
connectedSpecs[spec.signallingApiBase] = spec;
connectedSockets[spec.signallingApiBase] = socket;
} | javascript | function storeSocket(spec, socket) {
connectedSpecs[spec.signallingApiBase] = spec;
connectedSockets[spec.signallingApiBase] = socket;
} | [
"function",
"storeSocket",
"(",
"spec",
",",
"socket",
")",
"{",
"connectedSpecs",
"[",
"spec",
".",
"signallingApiBase",
"]",
"=",
"spec",
";",
"connectedSockets",
"[",
"spec",
".",
"signallingApiBase",
"]",
"=",
"socket",
";",
"}"
] | Delete a socket from the local store
@param spec
@param socket | [
"Delete",
"a",
"socket",
"from",
"the",
"local",
"store"
] | eb586ce288a6ad7e1b221280825037e855b03904 | https://github.com/nicktindall/cyclon.p2p-rtc-client/blob/eb586ce288a6ad7e1b221280825037e855b03904/lib/RedundantSignallingSocket.js#L169-L172 | train |
nicktindall/cyclon.p2p-rtc-client | lib/RedundantSignallingSocket.js | addListeners | function addListeners(socket, serverSpec) {
var apiBase = serverSpec.signallingApiBase;
var disposeFunction = disposeOfSocket(apiBase);
var registerFunction = register(socket);
// Register if we connect
socket.on("connect", registerFunction);
// Dispose if we disconnect... | javascript | function addListeners(socket, serverSpec) {
var apiBase = serverSpec.signallingApiBase;
var disposeFunction = disposeOfSocket(apiBase);
var registerFunction = register(socket);
// Register if we connect
socket.on("connect", registerFunction);
// Dispose if we disconnect... | [
"function",
"addListeners",
"(",
"socket",
",",
"serverSpec",
")",
"{",
"var",
"apiBase",
"=",
"serverSpec",
".",
"signallingApiBase",
";",
"var",
"disposeFunction",
"=",
"disposeOfSocket",
"(",
"apiBase",
")",
";",
"var",
"registerFunction",
"=",
"register",
"(... | Add listeners for a socket
@param socket
@param serverSpec | [
"Add",
"listeners",
"for",
"a",
"socket"
] | eb586ce288a6ad7e1b221280825037e855b03904 | https://github.com/nicktindall/cyclon.p2p-rtc-client/blob/eb586ce288a6ad7e1b221280825037e855b03904/lib/RedundantSignallingSocket.js#L191-L210 | train |
nicktindall/cyclon.p2p-rtc-client | lib/RedundantSignallingSocket.js | disposeOfSocket | function disposeOfSocket(apiBase) {
return function (error) {
loggingService.warn("Got disconnected from signalling server (" + apiBase + ")", error);
var socket = connectedSockets[apiBase];
if (socket) {
stopConnectivityChecks();
socket.remov... | javascript | function disposeOfSocket(apiBase) {
return function (error) {
loggingService.warn("Got disconnected from signalling server (" + apiBase + ")", error);
var socket = connectedSockets[apiBase];
if (socket) {
stopConnectivityChecks();
socket.remov... | [
"function",
"disposeOfSocket",
"(",
"apiBase",
")",
"{",
"return",
"function",
"(",
"error",
")",
"{",
"loggingService",
".",
"warn",
"(",
"\"Got disconnected from signalling server (\"",
"+",
"apiBase",
"+",
"\")\"",
",",
"error",
")",
";",
"var",
"socket",
"="... | Return a closure that will dispose of a socket
@param apiBase
@returns {Function} | [
"Return",
"a",
"closure",
"that",
"will",
"dispose",
"of",
"a",
"socket"
] | eb586ce288a6ad7e1b221280825037e855b03904 | https://github.com/nicktindall/cyclon.p2p-rtc-client/blob/eb586ce288a6ad7e1b221280825037e855b03904/lib/RedundantSignallingSocket.js#L218-L242 | train |
YuhangGe/node-freetype | lib/parse/glyf.js | parseGlyphCoordinate | function parseGlyphCoordinate(p, flag, previousValue, shortVectorBitMask, sameBitMask) {
var v;
if ((flag & shortVectorBitMask) > 0) {
// The coordinate is 1 byte long.
v = p.parseByte();
// The `same` bit is re-used for short values to signify the sign of the value.
if ((flag & ... | javascript | function parseGlyphCoordinate(p, flag, previousValue, shortVectorBitMask, sameBitMask) {
var v;
if ((flag & shortVectorBitMask) > 0) {
// The coordinate is 1 byte long.
v = p.parseByte();
// The `same` bit is re-used for short values to signify the sign of the value.
if ((flag & ... | [
"function",
"parseGlyphCoordinate",
"(",
"p",
",",
"flag",
",",
"previousValue",
",",
"shortVectorBitMask",
",",
"sameBitMask",
")",
"{",
"var",
"v",
";",
"if",
"(",
"(",
"flag",
"&",
"shortVectorBitMask",
")",
">",
"0",
")",
"{",
"// The coordinate is 1 byte ... | Parse the coordinate data for a glyph. | [
"Parse",
"the",
"coordinate",
"data",
"for",
"a",
"glyph",
"."
] | 4c8d2e2503f088ffbd61e613a23b9ff2e64d3489 | https://github.com/YuhangGe/node-freetype/blob/4c8d2e2503f088ffbd61e613a23b9ff2e64d3489/lib/parse/glyf.js#L10-L31 | train |
YuhangGe/node-freetype | lib/parse/glyf.js | transformPoints | function transformPoints(points, transform) {
var newPoints, i, pt, newPt;
newPoints = [];
for (i = 0; i < points.length; i += 1) {
pt = points[i];
newPt = {
x: transform.xScale * pt.x + transform.scale01 * pt.y + transform.dx,
y: transform.scale10 * pt.x + transform.... | javascript | function transformPoints(points, transform) {
var newPoints, i, pt, newPt;
newPoints = [];
for (i = 0; i < points.length; i += 1) {
pt = points[i];
newPt = {
x: transform.xScale * pt.x + transform.scale01 * pt.y + transform.dx,
y: transform.scale10 * pt.x + transform.... | [
"function",
"transformPoints",
"(",
"points",
",",
"transform",
")",
"{",
"var",
"newPoints",
",",
"i",
",",
"pt",
",",
"newPt",
";",
"newPoints",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"points",
".",
"length",
";",
"i",
"+... | Transform an array of points and return a new array. | [
"Transform",
"an",
"array",
"of",
"points",
"and",
"return",
"a",
"new",
"array",
"."
] | 4c8d2e2503f088ffbd61e613a23b9ff2e64d3489 | https://github.com/YuhangGe/node-freetype/blob/4c8d2e2503f088ffbd61e613a23b9ff2e64d3489/lib/parse/glyf.js#L160-L174 | train |
YuhangGe/node-freetype | lib/parse/glyf.js | getPath | function getPath(points) {
var p, contours, i, realFirstPoint, j, contour, pt, firstPt,
prevPt, midPt, curvePt, lastPt;
p = new path.Path();
if (!points) {
return p;
}
contours = getContours(points);
for (i = 0; i < contours.length; i += 1) {
contour = contours[i];
... | javascript | function getPath(points) {
var p, contours, i, realFirstPoint, j, contour, pt, firstPt,
prevPt, midPt, curvePt, lastPt;
p = new path.Path();
if (!points) {
return p;
}
contours = getContours(points);
for (i = 0; i < contours.length; i += 1) {
contour = contours[i];
... | [
"function",
"getPath",
"(",
"points",
")",
"{",
"var",
"p",
",",
"contours",
",",
"i",
",",
"realFirstPoint",
",",
"j",
",",
"contour",
",",
"pt",
",",
"firstPt",
",",
"prevPt",
",",
"midPt",
",",
"curvePt",
",",
"lastPt",
";",
"p",
"=",
"new",
"pa... | Convert the TrueType glyph outline to a Path. | [
"Convert",
"the",
"TrueType",
"glyph",
"outline",
"to",
"a",
"Path",
"."
] | 4c8d2e2503f088ffbd61e613a23b9ff2e64d3489 | https://github.com/YuhangGe/node-freetype/blob/4c8d2e2503f088ffbd61e613a23b9ff2e64d3489/lib/parse/glyf.js#L194-L257 | train |
YuhangGe/node-freetype | lib/parse/glyf.js | parseGlyfTable | function parseGlyfTable(data, start, loca) {
var glyphs, i, j, offset, nextOffset, glyph,
component, componentGlyph, transformedPoints;
glyphs = [];
// The last element of the loca table is invalid.
for (i = 0; i < loca.length - 1; i += 1) {
offset = loca[i];
nextOffset = loca[i ... | javascript | function parseGlyfTable(data, start, loca) {
var glyphs, i, j, offset, nextOffset, glyph,
component, componentGlyph, transformedPoints;
glyphs = [];
// The last element of the loca table is invalid.
for (i = 0; i < loca.length - 1; i += 1) {
offset = loca[i];
nextOffset = loca[i ... | [
"function",
"parseGlyfTable",
"(",
"data",
",",
"start",
",",
"loca",
")",
"{",
"var",
"glyphs",
",",
"i",
",",
"j",
",",
"offset",
",",
"nextOffset",
",",
"glyph",
",",
"component",
",",
"componentGlyph",
",",
"transformedPoints",
";",
"glyphs",
"=",
"[... | Parse all the glyphs according to the offsets from the `loca` table. | [
"Parse",
"all",
"the",
"glyphs",
"according",
"to",
"the",
"offsets",
"from",
"the",
"loca",
"table",
"."
] | 4c8d2e2503f088ffbd61e613a23b9ff2e64d3489 | https://github.com/YuhangGe/node-freetype/blob/4c8d2e2503f088ffbd61e613a23b9ff2e64d3489/lib/parse/glyf.js#L273-L305 | train |
oegea/soap_salesforce | salesforce.js | Salesforce | function Salesforce(username, password, token, wsdl) {
//Required NodeJS libraries
this.q = require("q");
this.soap = require("soap");
//Salesforce access data
this.username = username;
this.password = password;
this.token = token;
this.wsdl = wsdl || "./node_modules/soap_salesforce/ws... | javascript | function Salesforce(username, password, token, wsdl) {
//Required NodeJS libraries
this.q = require("q");
this.soap = require("soap");
//Salesforce access data
this.username = username;
this.password = password;
this.token = token;
this.wsdl = wsdl || "./node_modules/soap_salesforce/ws... | [
"function",
"Salesforce",
"(",
"username",
",",
"password",
",",
"token",
",",
"wsdl",
")",
"{",
"//Required NodeJS libraries",
"this",
".",
"q",
"=",
"require",
"(",
"\"q\"",
")",
";",
"this",
".",
"soap",
"=",
"require",
"(",
"\"soap\"",
")",
";",
"//S... | Salesforce connection library constructor. | [
"Salesforce",
"connection",
"library",
"constructor",
"."
] | 2cfe10234f6d86c404faf61b730e6ec03d79bce5 | https://github.com/oegea/soap_salesforce/blob/2cfe10234f6d86c404faf61b730e6ec03d79bce5/salesforce.js#L4-L19 | train |
digitalwm/cloudjs | modules/callbacks.js | AddCallback | function AddCallback(mesgId, callbackFunction, callbackTimeout) {
var callbackElement, now;
now = new Date().getTime();
callbackElement = {
id : mesgId,
func : callbackFunction,
timeout : now + callbackTimeout
};
callbackList.push(callbackElement);
} | javascript | function AddCallback(mesgId, callbackFunction, callbackTimeout) {
var callbackElement, now;
now = new Date().getTime();
callbackElement = {
id : mesgId,
func : callbackFunction,
timeout : now + callbackTimeout
};
callbackList.push(callbackElement);
} | [
"function",
"AddCallback",
"(",
"mesgId",
",",
"callbackFunction",
",",
"callbackTimeout",
")",
"{",
"var",
"callbackElement",
",",
"now",
";",
"now",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"callbackElement",
"=",
"{",
"id",
":",
"m... | Add a callback for a specific message ID
@param string mesgId
@param function callbackFunction
@param number callbackTimeout | [
"Add",
"a",
"callback",
"for",
"a",
"specific",
"message",
"ID"
] | 96f9394d939f8369c7a1acc03815f43e882adba2 | https://github.com/digitalwm/cloudjs/blob/96f9394d939f8369c7a1acc03815f43e882adba2/modules/callbacks.js#L47-L59 | train |
digitalwm/cloudjs | modules/callbacks.js | ParseReply | function ParseReply(mesgId, data, sid) {
var i;
for(i = 0 ; i < callbackList.length ; i++) {
if(callbackList[i].id.toString() === mesgId.toString() ) {
callbackList[i].func(data, sid);
}
}
} | javascript | function ParseReply(mesgId, data, sid) {
var i;
for(i = 0 ; i < callbackList.length ; i++) {
if(callbackList[i].id.toString() === mesgId.toString() ) {
callbackList[i].func(data, sid);
}
}
} | [
"function",
"ParseReply",
"(",
"mesgId",
",",
"data",
",",
"sid",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"callbackList",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"callbackList",
"[",
"i",
"]",
".",
"id",... | Calls all the saved callbacks for a specific message ID
@param string mesgId
@param object data | [
"Calls",
"all",
"the",
"saved",
"callbacks",
"for",
"a",
"specific",
"message",
"ID"
] | 96f9394d939f8369c7a1acc03815f43e882adba2 | https://github.com/digitalwm/cloudjs/blob/96f9394d939f8369c7a1acc03815f43e882adba2/modules/callbacks.js#L66-L74 | train |
digitalwm/cloudjs | modules/callbacks.js | GetOnEvent | function GetOnEvent(title) {
var retList, i;
retList = [];
for(i = 0 ; i < onList.length ; i++) {
if(onList[i].event.toString() === title.toString()) {
retList.push(onList[i].callback);
}
}
return retList;
} | javascript | function GetOnEvent(title) {
var retList, i;
retList = [];
for(i = 0 ; i < onList.length ; i++) {
if(onList[i].event.toString() === title.toString()) {
retList.push(onList[i].callback);
}
}
return retList;
} | [
"function",
"GetOnEvent",
"(",
"title",
")",
"{",
"var",
"retList",
",",
"i",
";",
"retList",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"onList",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"onList",
"[",
"i",
"]",... | Gets a list of callbacks for a requested event
@param string title
@return array | [
"Gets",
"a",
"list",
"of",
"callbacks",
"for",
"a",
"requested",
"event"
] | 96f9394d939f8369c7a1acc03815f43e882adba2 | https://github.com/digitalwm/cloudjs/blob/96f9394d939f8369c7a1acc03815f43e882adba2/modules/callbacks.js#L93-L103 | train |
BladeRunnerJS/topiarist | src/msg.js | msg | function msg(str) {
if (str == null) {
return null;
}
for (var i = 1, len = arguments.length; i < len; ++i) {
str = str.replace('{' + (i - 1) + '}', String(arguments[i]));
}
return str;
} | javascript | function msg(str) {
if (str == null) {
return null;
}
for (var i = 1, len = arguments.length; i < len; ++i) {
str = str.replace('{' + (i - 1) + '}', String(arguments[i]));
}
return str;
} | [
"function",
"msg",
"(",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"1",
",",
"len",
"=",
"arguments",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"s... | Interpolates a string with the arguments, used for error messages.
@private | [
"Interpolates",
"a",
"string",
"with",
"the",
"arguments",
"used",
"for",
"error",
"messages",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/msg.js#L7-L17 | train |
i5ting/tpl_apply | index.js | tpl_apply_with_register_helper | function tpl_apply_with_register_helper(Handlebars, template_path, data_obj, dest_file_path) {
var rs = fs.createReadStream(template_path, {bufferSize: 11});
var bufferHelper = new BufferHelper();
rs.on("data", function (trunk){
bufferHelper.concat(trunk);
});
rs.on("end", function () {
var source = buffer... | javascript | function tpl_apply_with_register_helper(Handlebars, template_path, data_obj, dest_file_path) {
var rs = fs.createReadStream(template_path, {bufferSize: 11});
var bufferHelper = new BufferHelper();
rs.on("data", function (trunk){
bufferHelper.concat(trunk);
});
rs.on("end", function () {
var source = buffer... | [
"function",
"tpl_apply_with_register_helper",
"(",
"Handlebars",
",",
"template_path",
",",
"data_obj",
",",
"dest_file_path",
")",
"{",
"var",
"rs",
"=",
"fs",
".",
"createReadStream",
"(",
"template_path",
",",
"{",
"bufferSize",
":",
"11",
"}",
")",
";",
"v... | Custom with helpers | [
"Custom",
"with",
"helpers"
] | eb2e0f91035f68a94e5fe049058f13d94b35710e | https://github.com/i5ting/tpl_apply/blob/eb2e0f91035f68a94e5fe049058f13d94b35710e/index.js#L22-L44 | train |
reelyactive/chickadee | lib/associationmanager.js | AssociationManager | function AssociationManager(options) {
var self = this;
self.associationsRootUrl = options.associationsRootUrl ||
SNIFFYPEDIA_ROOT_URL;
var datafolder = options.persistentDataFolder || DEFAULT_DATA_FOLDER;
var filename = ASSOCIATION_DB;
if(options.persistentDataFolder !== '') {
... | javascript | function AssociationManager(options) {
var self = this;
self.associationsRootUrl = options.associationsRootUrl ||
SNIFFYPEDIA_ROOT_URL;
var datafolder = options.persistentDataFolder || DEFAULT_DATA_FOLDER;
var filename = ASSOCIATION_DB;
if(options.persistentDataFolder !== '') {
... | [
"function",
"AssociationManager",
"(",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"associationsRootUrl",
"=",
"options",
".",
"associationsRootUrl",
"||",
"SNIFFYPEDIA_ROOT_URL",
";",
"var",
"datafolder",
"=",
"options",
".",
"persistentDat... | AssociationManager Class
Manages the association of identifiers with URLs
@param {Object} options The options as a JSON object.
@constructor | [
"AssociationManager",
"Class",
"Manages",
"the",
"association",
"of",
"identifiers",
"with",
"URLs"
] | 1f65c2d369694d93796aae63318fa76326275120 | https://github.com/reelyactive/chickadee/blob/1f65c2d369694d93796aae63318fa76326275120/lib/associationmanager.js#L36-L53 | train |
reelyactive/chickadee | lib/associationmanager.js | getAssociations | function getAssociations(instance, ids, callback) {
instance.db.find({ _id: { $in: ids } }, function(err, associations) {
for(var cAssociation = 0; cAssociation < associations.length;
cAssociation++) {
associations[cAssociation].deviceId = associations[cAssociation]._id;
}
callback(err, asso... | javascript | function getAssociations(instance, ids, callback) {
instance.db.find({ _id: { $in: ids } }, function(err, associations) {
for(var cAssociation = 0; cAssociation < associations.length;
cAssociation++) {
associations[cAssociation].deviceId = associations[cAssociation]._id;
}
callback(err, asso... | [
"function",
"getAssociations",
"(",
"instance",
",",
"ids",
",",
"callback",
")",
"{",
"instance",
".",
"db",
".",
"find",
"(",
"{",
"_id",
":",
"{",
"$in",
":",
"ids",
"}",
"}",
",",
"function",
"(",
"err",
",",
"associations",
")",
"{",
"for",
"(... | Retrieve from the database the associations of the given ids
@param {Object} instance The given Chickadee instance.
@param {Array} ids The given ids.
@param {function} callback Function to call on completion. | [
"Retrieve",
"from",
"the",
"database",
"the",
"associations",
"of",
"the",
"given",
"ids"
] | 1f65c2d369694d93796aae63318fa76326275120 | https://github.com/reelyactive/chickadee/blob/1f65c2d369694d93796aae63318fa76326275120/lib/associationmanager.js#L91-L99 | train |
reelyactive/chickadee | lib/associationmanager.js | extractRadioDecoders | function extractRadioDecoders(devices) {
var radioDecoders = {};
for(var deviceId in devices) {
var radioDecodings = devices[deviceId].radioDecodings || [];
for(var cDecoding = 0; cDecoding < radioDecodings.length; cDecoding++) {
var radioDecoder = radioDecodings[cDecoding].identifier;
var radi... | javascript | function extractRadioDecoders(devices) {
var radioDecoders = {};
for(var deviceId in devices) {
var radioDecodings = devices[deviceId].radioDecodings || [];
for(var cDecoding = 0; cDecoding < radioDecodings.length; cDecoding++) {
var radioDecoder = radioDecodings[cDecoding].identifier;
var radi... | [
"function",
"extractRadioDecoders",
"(",
"devices",
")",
"{",
"var",
"radioDecoders",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"deviceId",
"in",
"devices",
")",
"{",
"var",
"radioDecodings",
"=",
"devices",
"[",
"deviceId",
"]",
".",
"radioDecodings",
"||",
... | Extract the radio decoders from the given list of devices.
@param {Object} devices The given devices. | [
"Extract",
"the",
"radio",
"decoders",
"from",
"the",
"given",
"list",
"of",
"devices",
"."
] | 1f65c2d369694d93796aae63318fa76326275120 | https://github.com/reelyactive/chickadee/blob/1f65c2d369694d93796aae63318fa76326275120/lib/associationmanager.js#L502-L515 | train |
reelyactive/chickadee | lib/associationmanager.js | extractAssociationIds | function extractAssociationIds(devices) {
var associationIds = [];
for(var deviceId in devices) {
var device = devices[deviceId];
var hasAssociationIds = device.hasOwnProperty("associationIds");
if(!hasAssociationIds) {
device.associationIds = reelib.tiraid.getAssociationIds(device);
}
fo... | javascript | function extractAssociationIds(devices) {
var associationIds = [];
for(var deviceId in devices) {
var device = devices[deviceId];
var hasAssociationIds = device.hasOwnProperty("associationIds");
if(!hasAssociationIds) {
device.associationIds = reelib.tiraid.getAssociationIds(device);
}
fo... | [
"function",
"extractAssociationIds",
"(",
"devices",
")",
"{",
"var",
"associationIds",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"deviceId",
"in",
"devices",
")",
"{",
"var",
"device",
"=",
"devices",
"[",
"deviceId",
"]",
";",
"var",
"hasAssociationIds",
"=... | Extract all non-duplicate association ids from the given list of devices,
adding an assocationIds field to each device when absent.
@param {Object} devices The given devices.
@return {Array} Non-duplicate association identifiers. | [
"Extract",
"all",
"non",
"-",
"duplicate",
"association",
"ids",
"from",
"the",
"given",
"list",
"of",
"devices",
"adding",
"an",
"assocationIds",
"field",
"to",
"each",
"device",
"when",
"absent",
"."
] | 1f65c2d369694d93796aae63318fa76326275120 | https://github.com/reelyactive/chickadee/blob/1f65c2d369694d93796aae63318fa76326275120/lib/associationmanager.js#L524-L541 | train |
fibo/laplace-determinant | laplace-determinant.js | subMatrix | function subMatrix (data, numRows, numCols, row, col) {
var sub = []
for (var i = 0; i < numRows; i++) {
for (var j = 0; j < numCols; j++) {
if ((i !== row) && (j !== col)) {
sub.push(data[matrixToArrayIndex(i, j, numCols)])
}
}
}
return sub
} | javascript | function subMatrix (data, numRows, numCols, row, col) {
var sub = []
for (var i = 0; i < numRows; i++) {
for (var j = 0; j < numCols; j++) {
if ((i !== row) && (j !== col)) {
sub.push(data[matrixToArrayIndex(i, j, numCols)])
}
}
}
return sub
} | [
"function",
"subMatrix",
"(",
"data",
",",
"numRows",
",",
"numCols",
",",
"row",
",",
"col",
")",
"{",
"var",
"sub",
"=",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"numRows",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"j",... | Compute the sub-matrix formed by deleting the i-th row and j-th column
@function
@param {Array} data set
@param {Number} numRows
@param {Number} numCols
@param {Number} row index deleted
@param {Number} col index deleted
@returns {Array} sub data-set | [
"Compute",
"the",
"sub",
"-",
"matrix",
"formed",
"by",
"deleting",
"the",
"i",
"-",
"th",
"row",
"and",
"j",
"-",
"th",
"column"
] | b66ff70e932a7131639f8d6a57eaeb8c7eaf1d6f | https://github.com/fibo/laplace-determinant/blob/b66ff70e932a7131639f8d6a57eaeb8c7eaf1d6f/laplace-determinant.js#L32-L44 | train |
fibo/laplace-determinant | laplace-determinant.js | determinant | function determinant (data, scalar, order) {
// Recursion will stop here:
// the determinant of a 1x1 matrix is its only element.
if (data.length === 1) return data[0]
if (no(order)) order = Math.sqrt(data.length)
if (order % 1 !== 0) {
throw new TypeError('data.lenght must be a square')
}
// Defau... | javascript | function determinant (data, scalar, order) {
// Recursion will stop here:
// the determinant of a 1x1 matrix is its only element.
if (data.length === 1) return data[0]
if (no(order)) order = Math.sqrt(data.length)
if (order % 1 !== 0) {
throw new TypeError('data.lenght must be a square')
}
// Defau... | [
"function",
"determinant",
"(",
"data",
",",
"scalar",
",",
"order",
")",
"{",
"// Recursion will stop here:",
"// the determinant of a 1x1 matrix is its only element.",
"if",
"(",
"data",
".",
"length",
"===",
"1",
")",
"return",
"data",
"[",
"0",
"]",
"if",
"(",... | Computes the determinant of a matrix using Laplace's formula
See https://en.wikipedia.org/wiki/Laplace_expansion
@function
@param {Array} data, lenght must be a square.
@param {Object} [scalar]
@param {Function} [scalar.addition = (a, b) -> a + b ]
@param {Function} [scalar.multiplication = (a, b) -> a * b ]
@... | [
"Computes",
"the",
"determinant",
"of",
"a",
"matrix",
"using",
"Laplace",
"s",
"formula"
] | b66ff70e932a7131639f8d6a57eaeb8c7eaf1d6f | https://github.com/fibo/laplace-determinant/blob/b66ff70e932a7131639f8d6a57eaeb8c7eaf1d6f/laplace-determinant.js#L63-L113 | train |
rtm/upward | src/Acc.js | notifyAccess | function notifyAccess({object, name}) {
// Create an observer for changes in properties accessed during execution of this function.
function makeAccessedObserver() {
return Observer(object, function(changes) {
changes.forEach(({type, name}) => {
var {names} = accessEntry;
if (... | javascript | function notifyAccess({object, name}) {
// Create an observer for changes in properties accessed during execution of this function.
function makeAccessedObserver() {
return Observer(object, function(changes) {
changes.forEach(({type, name}) => {
var {names} = accessEntry;
if (... | [
"function",
"notifyAccess",
"(",
"{",
"object",
",",
"name",
"}",
")",
"{",
"// Create an observer for changes in properties accessed during execution of this function.",
"function",
"makeAccessedObserver",
"(",
")",
"{",
"return",
"Observer",
"(",
"object",
",",
"function"... | `notifyAccess` is the callback invoked by upwardables when a property is accessed. It records the access in the `accesses` map. | [
"notifyAccess",
"is",
"the",
"callback",
"invoked",
"by",
"upwardables",
"when",
"a",
"property",
"is",
"accessed",
".",
"It",
"records",
"the",
"access",
"in",
"the",
"accesses",
"map",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Acc.js#L68-L100 | train |
rtm/upward | src/Acc.js | makeAccessedObserver | function makeAccessedObserver() {
return Observer(object, function(changes) {
changes.forEach(({type, name}) => {
var {names} = accessEntry;
if (!names || type === 'update' && names.indexOf(name) !== -1)
rerun();
});
});
} | javascript | function makeAccessedObserver() {
return Observer(object, function(changes) {
changes.forEach(({type, name}) => {
var {names} = accessEntry;
if (!names || type === 'update' && names.indexOf(name) !== -1)
rerun();
});
});
} | [
"function",
"makeAccessedObserver",
"(",
")",
"{",
"return",
"Observer",
"(",
"object",
",",
"function",
"(",
"changes",
")",
"{",
"changes",
".",
"forEach",
"(",
"(",
"{",
"type",
",",
"name",
"}",
")",
"=>",
"{",
"var",
"{",
"names",
"}",
"=",
"acc... | Create an observer for changes in properties accessed during execution of this function. | [
"Create",
"an",
"observer",
"for",
"changes",
"in",
"properties",
"accessed",
"during",
"execution",
"of",
"this",
"function",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Acc.js#L71-L79 | train |
rtm/upward | src/Acc.js | makeAccessEntry | function makeAccessEntry() {
accesses.set(object, {
names: name ? [name] : null,
observer: makeAccessedObserver()
});
} | javascript | function makeAccessEntry() {
accesses.set(object, {
names: name ? [name] : null,
observer: makeAccessedObserver()
});
} | [
"function",
"makeAccessEntry",
"(",
")",
"{",
"accesses",
".",
"set",
"(",
"object",
",",
"{",
"names",
":",
"name",
"?",
"[",
"name",
"]",
":",
"null",
",",
"observer",
":",
"makeAccessedObserver",
"(",
")",
"}",
")",
";",
"}"
] | Make a new entry in the access table, containing initial property name if any and observer for properties accessed on the object. | [
"Make",
"a",
"new",
"entry",
"in",
"the",
"access",
"table",
"containing",
"initial",
"property",
"name",
"if",
"any",
"and",
"observer",
"for",
"properties",
"accessed",
"on",
"the",
"object",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Acc.js#L83-L88 | train |
rtm/upward | src/Acc.js | setAccessEntry | function setAccessEntry() {
if (name && accessEntry.names) accessEntry.names.push(name);
else accessEntry.names = null;
} | javascript | function setAccessEntry() {
if (name && accessEntry.names) accessEntry.names.push(name);
else accessEntry.names = null;
} | [
"function",
"setAccessEntry",
"(",
")",
"{",
"if",
"(",
"name",
"&&",
"accessEntry",
".",
"names",
")",
"accessEntry",
".",
"names",
".",
"push",
"(",
"name",
")",
";",
"else",
"accessEntry",
".",
"names",
"=",
"null",
";",
"}"
] | If properties on this object are already being watched, there is already an entry in the access table for it. Add a new property name to the existing entry. | [
"If",
"properties",
"on",
"this",
"object",
"are",
"already",
"being",
"watched",
"there",
"is",
"already",
"an",
"entry",
"in",
"the",
"access",
"table",
"for",
"it",
".",
"Add",
"a",
"new",
"property",
"name",
"to",
"the",
"existing",
"entry",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Acc.js#L92-L95 | train |
smartface/sf-component-calendar | scripts/services/StyleContext.js | fromSFComponent | function fromSFComponent(component, name, initialClassNameMap) {
var hooksList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var flatted = {};
function collect(component, name, initialClassNameMap) {
var newComp = makeStylable(component, initialClassNameMap(name), name, hooks(ho... | javascript | function fromSFComponent(component, name, initialClassNameMap) {
var hooksList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var flatted = {};
function collect(component, name, initialClassNameMap) {
var newComp = makeStylable(component, initialClassNameMap(name), name, hooks(ho... | [
"function",
"fromSFComponent",
"(",
"component",
",",
"name",
",",
"initialClassNameMap",
")",
"{",
"var",
"hooksList",
"=",
"arguments",
".",
"length",
">",
"3",
"&&",
"arguments",
"[",
"3",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"3",
"]",
":",
... | Create styleContext tree from a SF Component and flat component tree to create actors
@param {Object} component - A sf-core component
@param {string} name - component name
@param {function} initialClassNameMap - classNames mapping with specified component and children
@param {?function} hookList - callback function to... | [
"Create",
"styleContext",
"tree",
"from",
"a",
"SF",
"Component",
"and",
"flat",
"component",
"tree",
"to",
"create",
"actors"
] | d6c8310564ff551b9424ac6955efa5e8cf5f8dff | https://github.com/smartface/sf-component-calendar/blob/d6c8310564ff551b9424ac6955efa5e8cf5f8dff/scripts/services/StyleContext.js#L43-L61 | train |
lpinca/sauce-browsers | index.js | filterByVersion | function filterByVersion(browsers, version) {
version = String(version);
if (version === 'latest' || version === 'oldest') {
const filtered = numericVersions(browsers);
const i = version === 'latest' ? filtered.length - 1 : 0;
const value = filtered[i].short_version;
return filtered.filter((el) => ... | javascript | function filterByVersion(browsers, version) {
version = String(version);
if (version === 'latest' || version === 'oldest') {
const filtered = numericVersions(browsers);
const i = version === 'latest' ? filtered.length - 1 : 0;
const value = filtered[i].short_version;
return filtered.filter((el) => ... | [
"function",
"filterByVersion",
"(",
"browsers",
",",
"version",
")",
"{",
"version",
"=",
"String",
"(",
"version",
")",
";",
"if",
"(",
"version",
"===",
"'latest'",
"||",
"version",
"===",
"'oldest'",
")",
"{",
"const",
"filtered",
"=",
"numericVersions",
... | Filter out entries whose version does not match a given version from a
list of objects describing the OS and browser platforms on Sauce Labs.
@param {Array} browsers The array to filter
@param {(Number|String)} version The version to test against
@return {Array} The filtered array
@private | [
"Filter",
"out",
"entries",
"whose",
"version",
"does",
"not",
"match",
"a",
"given",
"version",
"from",
"a",
"list",
"of",
"objects",
"describing",
"the",
"OS",
"and",
"browser",
"platforms",
"on",
"Sauce",
"Labs",
"."
] | 3fe31c326971dd6cf025030664bbfb83ff9c9a3a | https://github.com/lpinca/sauce-browsers/blob/3fe31c326971dd6cf025030664bbfb83ff9c9a3a/index.js#L41-L78 | train |
lpinca/sauce-browsers | index.js | transform | function transform(wanted, available) {
const browsers = new Set();
wanted.forEach((browser) => {
const name = browser.name.toLowerCase();
if (!available.has(name)) {
throw new Error(`Browser ${name} is not available`);
}
let list = available.get(name).slice().sort(compare);
let platfor... | javascript | function transform(wanted, available) {
const browsers = new Set();
wanted.forEach((browser) => {
const name = browser.name.toLowerCase();
if (!available.has(name)) {
throw new Error(`Browser ${name} is not available`);
}
let list = available.get(name).slice().sort(compare);
let platfor... | [
"function",
"transform",
"(",
"wanted",
",",
"available",
")",
"{",
"const",
"browsers",
"=",
"new",
"Set",
"(",
")",
";",
"wanted",
".",
"forEach",
"(",
"(",
"browser",
")",
"=>",
"{",
"const",
"name",
"=",
"browser",
".",
"name",
".",
"toLowerCase",
... | Convert a list of platforms in "zuul" format to a list of platforms in
the same format returned by Sauce Labs REST API.
@param {Array} available The list of all supported platforms on Sauce Labs
@param {Array} wanted The list of platforms in "zuul" format
@return {Array} The transformed list
@private | [
"Convert",
"a",
"list",
"of",
"platforms",
"in",
"zuul",
"format",
"to",
"a",
"list",
"of",
"platforms",
"in",
"the",
"same",
"format",
"returned",
"by",
"Sauce",
"Labs",
"REST",
"API",
"."
] | 3fe31c326971dd6cf025030664bbfb83ff9c9a3a | https://github.com/lpinca/sauce-browsers/blob/3fe31c326971dd6cf025030664bbfb83ff9c9a3a/index.js#L89-L137 | train |
lpinca/sauce-browsers | index.js | aggregate | function aggregate(browsers) {
const map = new Map();
browsers.forEach((browser) => {
const name = browser.api_name.toLowerCase();
let value = map.get(name);
if (value === undefined) {
value = [];
map.set(name, value);
}
value.push(browser);
});
const ie = map.get('internet e... | javascript | function aggregate(browsers) {
const map = new Map();
browsers.forEach((browser) => {
const name = browser.api_name.toLowerCase();
let value = map.get(name);
if (value === undefined) {
value = [];
map.set(name, value);
}
value.push(browser);
});
const ie = map.get('internet e... | [
"function",
"aggregate",
"(",
"browsers",
")",
"{",
"const",
"map",
"=",
"new",
"Map",
"(",
")",
";",
"browsers",
".",
"forEach",
"(",
"(",
"browser",
")",
"=>",
"{",
"const",
"name",
"=",
"browser",
".",
"api_name",
".",
"toLowerCase",
"(",
")",
";"... | Aggregate a list of platforms by `api_name`.
@param {Array} browsers The list of platforms supported on Sauce Labs
@return {Map} Aggregated list
@private | [
"Aggregate",
"a",
"list",
"of",
"platforms",
"by",
"api_name",
"."
] | 3fe31c326971dd6cf025030664bbfb83ff9c9a3a | https://github.com/lpinca/sauce-browsers/blob/3fe31c326971dd6cf025030664bbfb83ff9c9a3a/index.js#L146-L167 | train |
lpinca/sauce-browsers | index.js | sauceBrowsers | function sauceBrowsers(wanted) {
return got({
path: '/rest/v1/info/platforms/webdriver',
hostname: 'saucelabs.com',
protocol: 'https:',
json: true
}).then((res) => {
if (wanted === undefined) return res.body;
return transform(wanted, aggregate(res.body));
});
} | javascript | function sauceBrowsers(wanted) {
return got({
path: '/rest/v1/info/platforms/webdriver',
hostname: 'saucelabs.com',
protocol: 'https:',
json: true
}).then((res) => {
if (wanted === undefined) return res.body;
return transform(wanted, aggregate(res.body));
});
} | [
"function",
"sauceBrowsers",
"(",
"wanted",
")",
"{",
"return",
"got",
"(",
"{",
"path",
":",
"'/rest/v1/info/platforms/webdriver'",
",",
"hostname",
":",
"'saucelabs.com'",
",",
"protocol",
":",
"'https:'",
",",
"json",
":",
"true",
"}",
")",
".",
"then",
"... | Get a list of objects describing the OS and browser platforms on Sauce Labs
using the "zuul" format.
@param {Array} wanted The list of wanted platforms in "zuul" format
@return {Promise} Promise which is fulfilled with the list
@public | [
"Get",
"a",
"list",
"of",
"objects",
"describing",
"the",
"OS",
"and",
"browser",
"platforms",
"on",
"Sauce",
"Labs",
"using",
"the",
"zuul",
"format",
"."
] | 3fe31c326971dd6cf025030664bbfb83ff9c9a3a | https://github.com/lpinca/sauce-browsers/blob/3fe31c326971dd6cf025030664bbfb83ff9c9a3a/index.js#L177-L188 | train |
oliversalzburg/absync | dist/development/absync.concat.js | AbsyncProvider | function AbsyncProvider( $provide, absyncCache ) {
var self = this;
// Store a reference to the provide provider.
self.__provide = $provide;
// Store a reference to the cache service constructor.
self.__absyncCache = absyncCache;
// A reference to the socket.io instance we're using to receive updates from t... | javascript | function AbsyncProvider( $provide, absyncCache ) {
var self = this;
// Store a reference to the provide provider.
self.__provide = $provide;
// Store a reference to the cache service constructor.
self.__absyncCache = absyncCache;
// A reference to the socket.io instance we're using to receive updates from t... | [
"function",
"AbsyncProvider",
"(",
"$provide",
",",
"absyncCache",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Store a reference to the provide provider.",
"self",
".",
"__provide",
"=",
"$provide",
";",
"// Store a reference to the cache service constructor.",
"self",
... | Retrieves the absync provider.
@param {angular.auto.IProvideService|Object} $provide The $provide provider.
@param {Function} absyncCache The AbsyncCache service constructor.
@constructor | [
"Retrieves",
"the",
"absync",
"provider",
"."
] | 13807648d513c77008951446cfa1b334a2ab2ccf | https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/dist/development/absync.concat.js#L42-L71 | train |
oliversalzburg/absync | dist/development/absync.concat.js | onCollectionReceived | function onCollectionReceived( serverResponse ) {
if( !serverResponse.data[ configuration.collectionName ] ) {
throw new Error( "The response from the server was not in the expected format. It should have a member named '" + configuration.collectionName + "'." );
}
self.__entityCacheRaw = serverResponse.d... | javascript | function onCollectionReceived( serverResponse ) {
if( !serverResponse.data[ configuration.collectionName ] ) {
throw new Error( "The response from the server was not in the expected format. It should have a member named '" + configuration.collectionName + "'." );
}
self.__entityCacheRaw = serverResponse.d... | [
"function",
"onCollectionReceived",
"(",
"serverResponse",
")",
"{",
"if",
"(",
"!",
"serverResponse",
".",
"data",
"[",
"configuration",
".",
"collectionName",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"The response from the server was not in the expected format. ... | Invoked when the collection was received from the server.
@param {angular.IHttpPromiseCallbackArg|Object} serverResponse The reply sent from the server. | [
"Invoked",
"when",
"the",
"collection",
"was",
"received",
"from",
"the",
"server",
"."
] | 13807648d513c77008951446cfa1b334a2ab2ccf | https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/dist/development/absync.concat.js#L699-L707 | train |
oliversalzburg/absync | dist/development/absync.concat.js | onCollectionRetrievalFailure | function onCollectionRetrievalFailure( serverResponse ) {
self.logInterface.error( self.logPrefix + "Unable to retrieve the collection from the server.",
serverResponse );
self.__entityCacheRaw = null;
self.scope.$emit( "absyncError", serverResponse );
if( self.throwFailures ) {
throw serverRespon... | javascript | function onCollectionRetrievalFailure( serverResponse ) {
self.logInterface.error( self.logPrefix + "Unable to retrieve the collection from the server.",
serverResponse );
self.__entityCacheRaw = null;
self.scope.$emit( "absyncError", serverResponse );
if( self.throwFailures ) {
throw serverRespon... | [
"function",
"onCollectionRetrievalFailure",
"(",
"serverResponse",
")",
"{",
"self",
".",
"logInterface",
".",
"error",
"(",
"self",
".",
"logPrefix",
"+",
"\"Unable to retrieve the collection from the server.\"",
",",
"serverResponse",
")",
";",
"self",
".",
"__entityC... | Invoked when there was an error while trying to retrieve the collection from the server.
@param {angular.IHttpPromiseCallbackArg|Object} serverResponse The reply sent from the server. | [
"Invoked",
"when",
"there",
"was",
"an",
"error",
"while",
"trying",
"to",
"retrieve",
"the",
"collection",
"from",
"the",
"server",
"."
] | 13807648d513c77008951446cfa1b334a2ab2ccf | https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/dist/development/absync.concat.js#L713-L723 | train |
oliversalzburg/absync | dist/development/absync.concat.js | onSingleEntityReceived | function onSingleEntityReceived( serverResponse ) {
if( !serverResponse.data[ configuration.entityName ] ) {
throw new Error( "The response from the server was not in the expected format. It should have a member named '" + configuration.entityName + "'." );
}
self.__entityCacheRaw = serverResponse.data;
... | javascript | function onSingleEntityReceived( serverResponse ) {
if( !serverResponse.data[ configuration.entityName ] ) {
throw new Error( "The response from the server was not in the expected format. It should have a member named '" + configuration.entityName + "'." );
}
self.__entityCacheRaw = serverResponse.data;
... | [
"function",
"onSingleEntityReceived",
"(",
"serverResponse",
")",
"{",
"if",
"(",
"!",
"serverResponse",
".",
"data",
"[",
"configuration",
".",
"entityName",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"The response from the server was not in the expected format. It... | Invoked when the entity was received from the server.
@param {angular.IHttpPromiseCallbackArg|Object} serverResponse The reply sent from the server. | [
"Invoked",
"when",
"the",
"entity",
"was",
"received",
"from",
"the",
"server",
"."
] | 13807648d513c77008951446cfa1b334a2ab2ccf | https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/dist/development/absync.concat.js#L729-L736 | train |
oliversalzburg/absync | dist/development/absync.concat.js | onEntityRetrieved | function onEntityRetrieved( serverResponse ) {
if( !serverResponse.data[ configuration.entityName ] ) {
throw new Error( "The response from the server was not in the expected format. It should have a member named '" + configuration.entityName + "'." );
}
var rawEntity = serverResponse.data[ configuration.... | javascript | function onEntityRetrieved( serverResponse ) {
if( !serverResponse.data[ configuration.entityName ] ) {
throw new Error( "The response from the server was not in the expected format. It should have a member named '" + configuration.entityName + "'." );
}
var rawEntity = serverResponse.data[ configuration.... | [
"function",
"onEntityRetrieved",
"(",
"serverResponse",
")",
"{",
"if",
"(",
"!",
"serverResponse",
".",
"data",
"[",
"configuration",
".",
"entityName",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"The response from the server was not in the expected format. It shou... | Invoked when the entity was retrieved from the server.
@param {angular.IHttpPromiseCallbackArg|Object} serverResponse The reply sent from the server. | [
"Invoked",
"when",
"the",
"entity",
"was",
"retrieved",
"from",
"the",
"server",
"."
] | 13807648d513c77008951446cfa1b334a2ab2ccf | https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/dist/development/absync.concat.js#L889-L910 | train |
oliversalzburg/absync | dist/development/absync.concat.js | onEntityRetrievalFailure | function onEntityRetrievalFailure( serverResponse ) {
self.logInterface.error( self.logPrefix + "Unable to retrieve entity with ID '" + id + "' from the server.",
serverResponse );
self.scope.$emit( "absyncError", serverResponse );
if( self.throwFailures ) {
throw serverResponse;
}
} | javascript | function onEntityRetrievalFailure( serverResponse ) {
self.logInterface.error( self.logPrefix + "Unable to retrieve entity with ID '" + id + "' from the server.",
serverResponse );
self.scope.$emit( "absyncError", serverResponse );
if( self.throwFailures ) {
throw serverResponse;
}
} | [
"function",
"onEntityRetrievalFailure",
"(",
"serverResponse",
")",
"{",
"self",
".",
"logInterface",
".",
"error",
"(",
"self",
".",
"logPrefix",
"+",
"\"Unable to retrieve entity with ID '\"",
"+",
"id",
"+",
"\"' from the server.\"",
",",
"serverResponse",
")",
";"... | Invoked when there was an error while trying to retrieve the entity from the server.
@param {angular.IHttpPromiseCallbackArg|Object} serverResponse The reply sent from the server. | [
"Invoked",
"when",
"there",
"was",
"an",
"error",
"while",
"trying",
"to",
"retrieve",
"the",
"entity",
"from",
"the",
"server",
"."
] | 13807648d513c77008951446cfa1b334a2ab2ccf | https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/dist/development/absync.concat.js#L916-L924 | train |
oliversalzburg/absync | dist/development/absync.concat.js | afterEntityStored | function afterEntityStored( returnResult, serverResponse ) {
var self = this;
// Writing an entity to the backend will usually invoke an update event to be
// broadcast over websockets, where we would also retrieve the updated record.
// We still put the updated record we receive here into the cache to ensure ... | javascript | function afterEntityStored( returnResult, serverResponse ) {
var self = this;
// Writing an entity to the backend will usually invoke an update event to be
// broadcast over websockets, where we would also retrieve the updated record.
// We still put the updated record we receive here into the cache to ensure ... | [
"function",
"afterEntityStored",
"(",
"returnResult",
",",
"serverResponse",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Writing an entity to the backend will usually invoke an update event to be",
"// broadcast over websockets, where we would also retrieve the updated record.",
"//... | Invoked when the entity was stored on the server.
@param {Boolean} returnResult Should we return the parsed entity that is contained in the response?
@param {angular.IHttpPromiseCallbackArg|Object} serverResponse The reply sent from the server. | [
"Invoked",
"when",
"the",
"entity",
"was",
"stored",
"on",
"the",
"server",
"."
] | 13807648d513c77008951446cfa1b334a2ab2ccf | https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/dist/development/absync.concat.js#L1033-L1058 | train |
oliversalzburg/absync | dist/development/absync.concat.js | onEntityStorageFailure | function onEntityStorageFailure( serverResponse ) {
var self = this;
self.logInterface.error( self.logPrefix + "Unable to store entity on the server.",
serverResponse );
self.logInterface.error( serverResponse );
self.scope.$emit( "absyncError", serverResponse );
if( self.throwFailures ) {
throw serve... | javascript | function onEntityStorageFailure( serverResponse ) {
var self = this;
self.logInterface.error( self.logPrefix + "Unable to store entity on the server.",
serverResponse );
self.logInterface.error( serverResponse );
self.scope.$emit( "absyncError", serverResponse );
if( self.throwFailures ) {
throw serve... | [
"function",
"onEntityStorageFailure",
"(",
"serverResponse",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"logInterface",
".",
"error",
"(",
"self",
".",
"logPrefix",
"+",
"\"Unable to store entity on the server.\"",
",",
"serverResponse",
")",
";",
"se... | Invoked when there was an error while trying to store the entity on the server.
@param {angular.IHttpPromiseCallbackArg|Object} serverResponse The reply sent from the server. | [
"Invoked",
"when",
"there",
"was",
"an",
"error",
"while",
"trying",
"to",
"store",
"the",
"entity",
"on",
"the",
"server",
"."
] | 13807648d513c77008951446cfa1b334a2ab2ccf | https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/dist/development/absync.concat.js#L1064-L1075 | train |
oliversalzburg/absync | dist/development/absync.concat.js | onEntityDeleted | function onEntityDeleted( serverResponse ) {
self.__cacheMaintain( self.__entityCacheRaw[ configuration.collectionName || configuration.entityName ],
entity,
"delete",
false );
return self.__removeEntityFromCache( entityId );
} | javascript | function onEntityDeleted( serverResponse ) {
self.__cacheMaintain( self.__entityCacheRaw[ configuration.collectionName || configuration.entityName ],
entity,
"delete",
false );
return self.__removeEntityFromCache( entityId );
} | [
"function",
"onEntityDeleted",
"(",
"serverResponse",
")",
"{",
"self",
".",
"__cacheMaintain",
"(",
"self",
".",
"__entityCacheRaw",
"[",
"configuration",
".",
"collectionName",
"||",
"configuration",
".",
"entityName",
"]",
",",
"entity",
",",
"\"delete\"",
",",... | Invoked when the entity was successfully deleted from the server.
@param {angular.IHttpPromiseCallbackArg|Object} serverResponse The reply sent from the server. | [
"Invoked",
"when",
"the",
"entity",
"was",
"successfully",
"deleted",
"from",
"the",
"server",
"."
] | 13807648d513c77008951446cfa1b334a2ab2ccf | https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/dist/development/absync.concat.js#L1094-L1101 | train |
oliversalzburg/absync | dist/development/absync.concat.js | onEntityDeletionFailed | function onEntityDeletionFailed( serverResponse ) {
self.logInterface.error( serverResponse.data );
self.scope.$emit( "absyncError", serverResponse );
if( self.throwFailures ) {
throw serverResponse;
}
} | javascript | function onEntityDeletionFailed( serverResponse ) {
self.logInterface.error( serverResponse.data );
self.scope.$emit( "absyncError", serverResponse );
if( self.throwFailures ) {
throw serverResponse;
}
} | [
"function",
"onEntityDeletionFailed",
"(",
"serverResponse",
")",
"{",
"self",
".",
"logInterface",
".",
"error",
"(",
"serverResponse",
".",
"data",
")",
";",
"self",
".",
"scope",
".",
"$emit",
"(",
"\"absyncError\"",
",",
"serverResponse",
")",
";",
"if",
... | Invoked when there was an error while trying to delete the entity from the server.
@param {angular.IHttpPromiseCallbackArg|Object} serverResponse The reply sent from the server. | [
"Invoked",
"when",
"there",
"was",
"an",
"error",
"while",
"trying",
"to",
"delete",
"the",
"entity",
"from",
"the",
"server",
"."
] | 13807648d513c77008951446cfa1b334a2ab2ccf | https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/dist/development/absync.concat.js#L1107-L1114 | train |
jhermsmeier/node-apple-data-compression | lib/decompress.js | decompress | function decompress( buffer ) {
var chunks = []
var chunkType = ADC.CHUNK_UNKNOWN
var position = 0
var length = 0
windowOffset = 0
while( position < buffer.length ) {
chunkType = ADC.getChunkType( buffer[ position ] )
length = ADC.getSequenceLength( buffer[ position ] )
switch( chunkType ) {
... | javascript | function decompress( buffer ) {
var chunks = []
var chunkType = ADC.CHUNK_UNKNOWN
var position = 0
var length = 0
windowOffset = 0
while( position < buffer.length ) {
chunkType = ADC.getChunkType( buffer[ position ] )
length = ADC.getSequenceLength( buffer[ position ] )
switch( chunkType ) {
... | [
"function",
"decompress",
"(",
"buffer",
")",
"{",
"var",
"chunks",
"=",
"[",
"]",
"var",
"chunkType",
"=",
"ADC",
".",
"CHUNK_UNKNOWN",
"var",
"position",
"=",
"0",
"var",
"length",
"=",
"0",
"windowOffset",
"=",
"0",
"while",
"(",
"position",
"<",
"b... | Decompress an ADC compressed buffer
@param {Buffer} buffer
@returns {Buffer} | [
"Decompress",
"an",
"ADC",
"compressed",
"buffer"
] | 914ad4625754d1c77b76345845b24227c8a55181 | https://github.com/jhermsmeier/node-apple-data-compression/blob/914ad4625754d1c77b76345845b24227c8a55181/lib/decompress.js#L65-L95 | train |
scttnlsn/mongoose-denormalize | lib/index.js | function(schema, from) {
return function(next) {
var self = this;
var funcs = [];
for (var key in from) {
var items = from[key];
var model = mongoose.model(schema.path(key).options.ref);
funcs.push(function(callback) {
model.f... | javascript | function(schema, from) {
return function(next) {
var self = this;
var funcs = [];
for (var key in from) {
var items = from[key];
var model = mongoose.model(schema.path(key).options.ref);
funcs.push(function(callback) {
model.f... | [
"function",
"(",
"schema",
",",
"from",
")",
"{",
"return",
"function",
"(",
"next",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"funcs",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"from",
")",
"{",
"var",
"items",
"=",
"from",
"... | Denormalize values from foreign refs into local model | [
"Denormalize",
"values",
"from",
"foreign",
"refs",
"into",
"local",
"model"
] | 81b7bf73412aff119bfc49020cf63be9933df547 | https://github.com/scttnlsn/mongoose-denormalize/blob/81b7bf73412aff119bfc49020cf63be9933df547/lib/index.js#L5-L32 | train | |
archilogic-com/instant-api | lib/json-rpc2-server.js | function (result) {
// don't send a second response
if (responseHasBeenSent) {
console.warn('JSON-RPC2 response has already been sent.')
return
}
// notifications should not send error responses (JSON-RPC2 specs)
if (!isMethodCall) {
logNotificationResponseWarning(... | javascript | function (result) {
// don't send a second response
if (responseHasBeenSent) {
console.warn('JSON-RPC2 response has already been sent.')
return
}
// notifications should not send error responses (JSON-RPC2 specs)
if (!isMethodCall) {
logNotificationResponseWarning(... | [
"function",
"(",
"result",
")",
"{",
"// don't send a second response",
"if",
"(",
"responseHasBeenSent",
")",
"{",
"console",
".",
"warn",
"(",
"'JSON-RPC2 response has already been sent.'",
")",
"return",
"}",
"// notifications should not send error responses (JSON-RPC2 specs... | create send result handler | [
"create",
"send",
"result",
"handler"
] | a47728312e283136a24933f250aabb0be867cb2f | https://github.com/archilogic-com/instant-api/blob/a47728312e283136a24933f250aabb0be867cb2f/lib/json-rpc2-server.js#L198-L227 | train | |
archilogic-com/instant-api | lib/json-rpc2-server.js | function (method, result) {
// result should not be undefined
if (result === undefined) {
console.warn('JSON-RPC2 response from method ' + methodName + ' should return a result. (JSON-RPC2 spec)')
result = ''
}
var rpcMessage = {
jsonrpc: '2.0',
result: result,
... | javascript | function (method, result) {
// result should not be undefined
if (result === undefined) {
console.warn('JSON-RPC2 response from method ' + methodName + ' should return a result. (JSON-RPC2 spec)')
result = ''
}
var rpcMessage = {
jsonrpc: '2.0',
result: result,
... | [
"function",
"(",
"method",
",",
"result",
")",
"{",
"// result should not be undefined",
"if",
"(",
"result",
"===",
"undefined",
")",
"{",
"console",
".",
"warn",
"(",
"'JSON-RPC2 response from method '",
"+",
"methodName",
"+",
"' should return a result. (JSON-RPC2 sp... | create send message method | [
"create",
"send",
"message",
"method"
] | a47728312e283136a24933f250aabb0be867cb2f | https://github.com/archilogic-com/instant-api/blob/a47728312e283136a24933f250aabb0be867cb2f/lib/json-rpc2-server.js#L230-L247 | train | |
archilogic-com/instant-api | lib/json-rpc2-server.js | function (error, type) {
// don't send a second response
if (responseHasBeenSent) {
console.warn('JSON-RPC2 response has already been sent.')
return
}
// notifications should not send error responses (JSON-RPC2 specs)
if (!isMethodCall) {
var message = (error && er... | javascript | function (error, type) {
// don't send a second response
if (responseHasBeenSent) {
console.warn('JSON-RPC2 response has already been sent.')
return
}
// notifications should not send error responses (JSON-RPC2 specs)
if (!isMethodCall) {
var message = (error && er... | [
"function",
"(",
"error",
",",
"type",
")",
"{",
"// don't send a second response",
"if",
"(",
"responseHasBeenSent",
")",
"{",
"console",
".",
"warn",
"(",
"'JSON-RPC2 response has already been sent.'",
")",
"return",
"}",
"// notifications should not send error responses ... | create send error handler | [
"create",
"send",
"error",
"handler"
] | a47728312e283136a24933f250aabb0be867cb2f | https://github.com/archilogic-com/instant-api/blob/a47728312e283136a24933f250aabb0be867cb2f/lib/json-rpc2-server.js#L250-L322 | train | |
e-picas/grunt-nunjucks-render | lib/lib.js | merge | function merge(obj1, obj2)
{
var obj3 = {}, index;
for (index in obj1) {
obj3[index] = obj1[index];
}
for (index in obj2) {
obj3[index] = obj2[index];
}
return obj3;
} | javascript | function merge(obj1, obj2)
{
var obj3 = {}, index;
for (index in obj1) {
obj3[index] = obj1[index];
}
for (index in obj2) {
obj3[index] = obj2[index];
}
return obj3;
} | [
"function",
"merge",
"(",
"obj1",
",",
"obj2",
")",
"{",
"var",
"obj3",
"=",
"{",
"}",
",",
"index",
";",
"for",
"(",
"index",
"in",
"obj1",
")",
"{",
"obj3",
"[",
"index",
"]",
"=",
"obj1",
"[",
"index",
"]",
";",
"}",
"for",
"(",
"index",
"... | merge two objects with priority on second | [
"merge",
"two",
"objects",
"with",
"priority",
"on",
"second"
] | eab88e5ef943755853c2250f4df68398401ed0ab | https://github.com/e-picas/grunt-nunjucks-render/blob/eab88e5ef943755853c2250f4df68398401ed0ab/lib/lib.js#L27-L37 | train |
e-picas/grunt-nunjucks-render | lib/lib.js | parseData | function parseData(data)
{
var tmp_data = {};
if (nlib.isString(data)) {
if (data.match(/\.json/i) && grunt.file.exists(data)) {
tmp_data = grunt.file.readJSON(data);
} else if (data.match(/\.ya?ml/i) && grunt.file.exists(data)) {
tmp_data = grunt.file.readYAML(data);
... | javascript | function parseData(data)
{
var tmp_data = {};
if (nlib.isString(data)) {
if (data.match(/\.json/i) && grunt.file.exists(data)) {
tmp_data = grunt.file.readJSON(data);
} else if (data.match(/\.ya?ml/i) && grunt.file.exists(data)) {
tmp_data = grunt.file.readYAML(data);
... | [
"function",
"parseData",
"(",
"data",
")",
"{",
"var",
"tmp_data",
"=",
"{",
"}",
";",
"if",
"(",
"nlib",
".",
"isString",
"(",
"data",
")",
")",
"{",
"if",
"(",
"data",
".",
"match",
"(",
"/",
"\\.json",
"/",
"i",
")",
"&&",
"grunt",
".",
"fil... | prepare data parsing JSON or YAML file if so | [
"prepare",
"data",
"parsing",
"JSON",
"or",
"YAML",
"file",
"if",
"so"
] | eab88e5ef943755853c2250f4df68398401ed0ab | https://github.com/e-picas/grunt-nunjucks-render/blob/eab88e5ef943755853c2250f4df68398401ed0ab/lib/lib.js#L41-L67 | train |
joneit/filter-tree | js/Conditionals.js | inOp | function inOp(a, b) {
return b
.trim() // remove leading and trailing space chars
.replace(/\s*,\s*/g, ',') // remove any white-space chars from around commas
.split(',') // put in an array
.indexOf((a + '')); // search array whole matches
} | javascript | function inOp(a, b) {
return b
.trim() // remove leading and trailing space chars
.replace(/\s*,\s*/g, ',') // remove any white-space chars from around commas
.split(',') // put in an array
.indexOf((a + '')); // search array whole matches
} | [
"function",
"inOp",
"(",
"a",
",",
"b",
")",
"{",
"return",
"b",
".",
"trim",
"(",
")",
"// remove leading and trailing space chars",
".",
"replace",
"(",
"/",
"\\s*,\\s*",
"/",
"g",
",",
"','",
")",
"// remove any white-space chars from around commas",
".",
"sp... | UNICODE 'NOT EQUAL TO' | [
"UNICODE",
"NOT",
"EQUAL",
"TO"
] | c070a4045fced3e4ab20ed2e0c706c9a5fd07d1e | https://github.com/joneit/filter-tree/blob/c070a4045fced3e4ab20ed2e0c706c9a5fd07d1e/js/Conditionals.js#L238-L244 | train |
adplabs/PigeonKeeper | lib/genericService.js | GenericService | function GenericService(serviceId)
{
var self = this;
var id = serviceId;
var data = {};
/**
* Method called by PK
*
* @param {Object} sharedData - Data object that gets passed-around by PK
*/
this.doStuff = function (sharedData)
{
console.log("In service #" + id + "... | javascript | function GenericService(serviceId)
{
var self = this;
var id = serviceId;
var data = {};
/**
* Method called by PK
*
* @param {Object} sharedData - Data object that gets passed-around by PK
*/
this.doStuff = function (sharedData)
{
console.log("In service #" + id + "... | [
"function",
"GenericService",
"(",
"serviceId",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"id",
"=",
"serviceId",
";",
"var",
"data",
"=",
"{",
"}",
";",
"/**\n * Method called by PK\n *\n * @param {Object} sharedData - Data object that gets passed-aro... | "3"
Event emitter; this code is to be used as a sample of how to implement an event emitter for use with PigeonKeeper
@constructor
@param {string} serviceId - ID of the service
@fires "success"
@fires "error" | [
"3",
"Event",
"emitter",
";",
"this",
"code",
"is",
"to",
"be",
"used",
"as",
"a",
"sample",
"of",
"how",
"to",
"implement",
"an",
"event",
"emitter",
"for",
"use",
"with",
"PigeonKeeper"
] | c0a92d2032415617c2b6f6bd49d00a2c59bfaa41 | https://github.com/adplabs/PigeonKeeper/blob/c0a92d2032415617c2b6f6bd49d00a2c59bfaa41/lib/genericService.js#L13-L73 | train |
Kurento/kurento-module-crowddetector-js | lib/complexTypes/RegionOfInterestConfig.js | RegionOfInterestConfig | function RegionOfInterestConfig(regionOfInterestConfigDict){
if(!(this instanceof RegionOfInterestConfig))
return new RegionOfInterestConfig(regionOfInterestConfigDict)
regionOfInterestConfigDict = regionOfInterestConfigDict || {}
// Check regionOfInterestConfigDict has the required fields
//
// checkT... | javascript | function RegionOfInterestConfig(regionOfInterestConfigDict){
if(!(this instanceof RegionOfInterestConfig))
return new RegionOfInterestConfig(regionOfInterestConfigDict)
regionOfInterestConfigDict = regionOfInterestConfigDict || {}
// Check regionOfInterestConfigDict has the required fields
//
// checkT... | [
"function",
"RegionOfInterestConfig",
"(",
"regionOfInterestConfigDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"RegionOfInterestConfig",
")",
")",
"return",
"new",
"RegionOfInterestConfig",
"(",
"regionOfInterestConfigDict",
")",
"regionOfInterestConfigDict",... | data structure for configuration of CrowdDetector regions of interest
@constructor module:crowddetector/complexTypes.RegionOfInterestConfig
@property {external:Integer} occupancyLevelMin
minimun occupancy percentage in the ROI to send occupancy events
@property {external:Integer} occupancyLevelMed
send occupancy leve... | [
"data",
"structure",
"for",
"configuration",
"of",
"CrowdDetector",
"regions",
"of",
"interest"
] | ae0a03c5d6bbc07a23d083fe8916017cb4a63855 | https://github.com/Kurento/kurento-module-crowddetector-js/blob/ae0a03c5d6bbc07a23d083fe8916017cb4a63855/lib/complexTypes/RegionOfInterestConfig.js#L74-L173 | train |
smartface/sf-component-calendar | scripts/components/CalendarCore.js | getInitialState | function getInitialState() {
return {
month: {},
day: {},
rangeSelection: null,
rangeSelectionMode: RangeSelection.IDLE,
selectedDays: [],
selectedDaysByIndex: [],
weekIndex: 0
};
} | javascript | function getInitialState() {
return {
month: {},
day: {},
rangeSelection: null,
rangeSelectionMode: RangeSelection.IDLE,
selectedDays: [],
selectedDaysByIndex: [],
weekIndex: 0
};
} | [
"function",
"getInitialState",
"(",
")",
"{",
"return",
"{",
"month",
":",
"{",
"}",
",",
"day",
":",
"{",
"}",
",",
"rangeSelection",
":",
"null",
",",
"rangeSelectionMode",
":",
"RangeSelection",
".",
"IDLE",
",",
"selectedDays",
":",
"[",
"]",
",",
... | Returns initial state
@returns {object} | [
"Returns",
"initial",
"state"
] | d6c8310564ff551b9424ac6955efa5e8cf5f8dff | https://github.com/smartface/sf-component-calendar/blob/d6c8310564ff551b9424ac6955efa5e8cf5f8dff/scripts/components/CalendarCore.js#L16-L26 | train |
smartface/sf-component-calendar | scripts/components/CalendarCore.js | calculateDatePos | function calculateDatePos(startDayOfMonth, day) {
const start = startDayOfMonth - 1;
day = day - 1;
const weekDayIndex = (start + day) % WEEKDAYS;
const weekIndex = Math.ceil((start + day + 1) / WEEKDAYS) - 1;
return {
weekIndex,
weekDayIndex
};
} | javascript | function calculateDatePos(startDayOfMonth, day) {
const start = startDayOfMonth - 1;
day = day - 1;
const weekDayIndex = (start + day) % WEEKDAYS;
const weekIndex = Math.ceil((start + day + 1) / WEEKDAYS) - 1;
return {
weekIndex,
weekDayIndex
};
} | [
"function",
"calculateDatePos",
"(",
"startDayOfMonth",
",",
"day",
")",
"{",
"const",
"start",
"=",
"startDayOfMonth",
"-",
"1",
";",
"day",
"=",
"day",
"-",
"1",
";",
"const",
"weekDayIndex",
"=",
"(",
"start",
"+",
"day",
")",
"%",
"WEEKDAYS",
";",
... | Calcucalte given day's week and weekday index
@param {number} startDayOfMonth
@param {number} day | [
"Calcucalte",
"given",
"day",
"s",
"week",
"and",
"weekday",
"index"
] | d6c8310564ff551b9424ac6955efa5e8cf5f8dff | https://github.com/smartface/sf-component-calendar/blob/d6c8310564ff551b9424ac6955efa5e8cf5f8dff/scripts/components/CalendarCore.js#L59-L68 | train |
smartface/sf-component-calendar | scripts/components/CalendarCore.js | getDateData | function getDateData(date, month) {
const pos = getDatePos(date, month);
if (pos === null) {
throw new TypeError(JSON.stringify(date) + " is invalid format.");
}
return getDayData(pos.weekIndex, pos.weekDayIndex, month);
} | javascript | function getDateData(date, month) {
const pos = getDatePos(date, month);
if (pos === null) {
throw new TypeError(JSON.stringify(date) + " is invalid format.");
}
return getDayData(pos.weekIndex, pos.weekDayIndex, month);
} | [
"function",
"getDateData",
"(",
"date",
",",
"month",
")",
"{",
"const",
"pos",
"=",
"getDatePos",
"(",
"date",
",",
"month",
")",
";",
"if",
"(",
"pos",
"===",
"null",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"JSON",
".",
"stringify",
"(",
"date"... | Gets specified date's info data in specified month.
@param {object} date
@param {object} month
@throw {TypeError}
@returns {Calendar~DateInfo} | [
"Gets",
"specified",
"date",
"s",
"info",
"data",
"in",
"specified",
"month",
"."
] | d6c8310564ff551b9424ac6955efa5e8cf5f8dff | https://github.com/smartface/sf-component-calendar/blob/d6c8310564ff551b9424ac6955efa5e8cf5f8dff/scripts/components/CalendarCore.js#L107-L115 | train |
smartface/sf-component-calendar | scripts/components/CalendarCore.js | getDayData | function getDayData(weekIndex, weekDayIndex, currentMonth) {
const dayData = {};
if (!currentMonth || !currentMonth.days || currentMonth.days[weekIndex] === undefined) {
throw new TypeError("WeekIndex : " + weekIndex + ", weekDayIndex " + weekDayIndex + " selected day cannot be undefined");
}
const selectedDay ... | javascript | function getDayData(weekIndex, weekDayIndex, currentMonth) {
const dayData = {};
if (!currentMonth || !currentMonth.days || currentMonth.days[weekIndex] === undefined) {
throw new TypeError("WeekIndex : " + weekIndex + ", weekDayIndex " + weekDayIndex + " selected day cannot be undefined");
}
const selectedDay ... | [
"function",
"getDayData",
"(",
"weekIndex",
",",
"weekDayIndex",
",",
"currentMonth",
")",
"{",
"const",
"dayData",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"currentMonth",
"||",
"!",
"currentMonth",
".",
"days",
"||",
"currentMonth",
".",
"days",
"[",
"weekInd... | Select specified day
@private | [
"Select",
"specified",
"day"
] | d6c8310564ff551b9424ac6955efa5e8cf5f8dff | https://github.com/smartface/sf-component-calendar/blob/d6c8310564ff551b9424ac6955efa5e8cf5f8dff/scripts/components/CalendarCore.js#L123-L191 | train |
smartface/sf-component-calendar | scripts/components/CalendarCore.js | getDatePos | function getDatePos(date, month, notValue = null) {
const monthPos = (date.month === month.date.month && 'current') ||
(date.month === month.nextMonth.date.month && 'next') ||
(date.month === month.previousMonth.date.month && 'prev');
switch (monthPos) {
case 'current':
return calculateDatePos(month.start... | javascript | function getDatePos(date, month, notValue = null) {
const monthPos = (date.month === month.date.month && 'current') ||
(date.month === month.nextMonth.date.month && 'next') ||
(date.month === month.previousMonth.date.month && 'prev');
switch (monthPos) {
case 'current':
return calculateDatePos(month.start... | [
"function",
"getDatePos",
"(",
"date",
",",
"month",
",",
"notValue",
"=",
"null",
")",
"{",
"const",
"monthPos",
"=",
"(",
"date",
".",
"month",
"===",
"month",
".",
"date",
".",
"month",
"&&",
"'current'",
")",
"||",
"(",
"date",
".",
"month",
"===... | Calculates week and weekday indexes in the month
@param {object} date
@param {object} month
@param {object} notValue
@returns {({weekIndex:number, weekDayIndex:number}|*)} | [
"Calculates",
"week",
"and",
"weekday",
"indexes",
"in",
"the",
"month"
] | d6c8310564ff551b9424ac6955efa5e8cf5f8dff | https://github.com/smartface/sf-component-calendar/blob/d6c8310564ff551b9424ac6955efa5e8cf5f8dff/scripts/components/CalendarCore.js#L201-L227 | train |
areslabs/babel-plugin-import-css | src/index.js | devHandler | function devHandler(curPath, importPath, jsFilename) {
var absPath = resolve(importPath, jsFilename)
var projectDir = path.resolve(require.resolve('./index.js'), '..', '..', '..', '..', '..')
absPath = absPath.replace(projectDir, '@areslabs/babel-plugin-import-css/rncsscache')
curPath.node.source.valu... | javascript | function devHandler(curPath, importPath, jsFilename) {
var absPath = resolve(importPath, jsFilename)
var projectDir = path.resolve(require.resolve('./index.js'), '..', '..', '..', '..', '..')
absPath = absPath.replace(projectDir, '@areslabs/babel-plugin-import-css/rncsscache')
curPath.node.source.valu... | [
"function",
"devHandler",
"(",
"curPath",
",",
"importPath",
",",
"jsFilename",
")",
"{",
"var",
"absPath",
"=",
"resolve",
"(",
"importPath",
",",
"jsFilename",
")",
"var",
"projectDir",
"=",
"path",
".",
"resolve",
"(",
"require",
".",
"resolve",
"(",
"'... | In development, we just modify the import path, target file will be generated by 'cssWatch'
@param curPath
@param importPath
@param jsFilename | [
"In",
"development",
"we",
"just",
"modify",
"the",
"import",
"path",
"target",
"file",
"will",
"be",
"generated",
"by",
"cssWatch"
] | b90d3a4ec3a644edcaa1c803314e2c39de1d29c9 | https://github.com/areslabs/babel-plugin-import-css/blob/b90d3a4ec3a644edcaa1c803314e2c39de1d29c9/src/index.js#L61-L68 | train |
areslabs/babel-plugin-import-css | src/index.js | prodHandler | function prodHandler(curPath, opts, importPath, jsFilename, template, t){
var absPath = resolve(importPath, jsFilename)
const cssStr = fse.readFileSync(absPath).toString()
const {styles: obj} = createStylefromCode(cssStr, absPath)
const cssObj = convertStylesToRNCSS(obj)
var defautIdenti = curPath... | javascript | function prodHandler(curPath, opts, importPath, jsFilename, template, t){
var absPath = resolve(importPath, jsFilename)
const cssStr = fse.readFileSync(absPath).toString()
const {styles: obj} = createStylefromCode(cssStr, absPath)
const cssObj = convertStylesToRNCSS(obj)
var defautIdenti = curPath... | [
"function",
"prodHandler",
"(",
"curPath",
",",
"opts",
",",
"importPath",
",",
"jsFilename",
",",
"template",
",",
"t",
")",
"{",
"var",
"absPath",
"=",
"resolve",
"(",
"importPath",
",",
"jsFilename",
")",
"const",
"cssStr",
"=",
"fse",
".",
"readFileSyn... | In prod, the js's object which is generated by the ralated css file will write directly in the js file.
@param curPath
@param opts
@param importPath
@param jsFilename
@param template
@param t | [
"In",
"prod",
"the",
"js",
"s",
"object",
"which",
"is",
"generated",
"by",
"the",
"ralated",
"css",
"file",
"will",
"write",
"directly",
"in",
"the",
"js",
"file",
"."
] | b90d3a4ec3a644edcaa1c803314e2c39de1d29c9 | https://github.com/areslabs/babel-plugin-import-css/blob/b90d3a4ec3a644edcaa1c803314e2c39de1d29c9/src/index.js#L79-L94 | train |
luminous-patterns/angular-environment-config | Gruntfile.js | gruntPrepareRelease | function gruntPrepareRelease () {
var bower = grunt.file.readJSON('bower.json');
var version = bower.version;
if (version !== grunt.config('pkg.version')) {
throw new Error('Version mismatch in bower.json');
}
function searchForExistingTag () {
return e... | javascript | function gruntPrepareRelease () {
var bower = grunt.file.readJSON('bower.json');
var version = bower.version;
if (version !== grunt.config('pkg.version')) {
throw new Error('Version mismatch in bower.json');
}
function searchForExistingTag () {
return e... | [
"function",
"gruntPrepareRelease",
"(",
")",
"{",
"var",
"bower",
"=",
"grunt",
".",
"file",
".",
"readJSON",
"(",
"'bower.json'",
")",
";",
"var",
"version",
"=",
"bower",
".",
"version",
";",
"if",
"(",
"version",
"!==",
"grunt",
".",
"config",
"(",
... | Grunt Task Functions | [
"Grunt",
"Task",
"Functions"
] | 081bda487e16da8f0991699031cd9297c2464bc6 | https://github.com/luminous-patterns/angular-environment-config/blob/081bda487e16da8f0991699031cd9297c2464bc6/Gruntfile.js#L213-L248 | 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.