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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
repetere/modelscript | build/modelscript.umd.js | function(startPoint, endPoint) {
startPoint = vector.create(startPoint).to3D();
endPoint = vector.create(endPoint).to3D();
if (startPoint === null || endPoint === null) { return null; }
this.line = line.create(startPoint, endPoint.subtract(startPoint));
... | javascript | function(startPoint, endPoint) {
startPoint = vector.create(startPoint).to3D();
endPoint = vector.create(endPoint).to3D();
if (startPoint === null || endPoint === null) { return null; }
this.line = line.create(startPoint, endPoint.subtract(startPoint));
... | [
"function",
"(",
"startPoint",
",",
"endPoint",
")",
"{",
"startPoint",
"=",
"vector",
".",
"create",
"(",
"startPoint",
")",
".",
"to3D",
"(",
")",
";",
"endPoint",
"=",
"vector",
".",
"create",
"(",
"endPoint",
")",
".",
"to3D",
"(",
")",
";",
"if"... | Set the start and end-points of the segment | [
"Set",
"the",
"start",
"and",
"end",
"-",
"points",
"of",
"the",
"segment"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L76073-L76081 | train | |
repetere/modelscript | build/modelscript.umd.js | createCentroids | function createCentroids(k) {
var Centroid = [];
var maxes = this.Observations.maxColumns();
//console.log(maxes);
for(var i = 1; i <= k; i++) {
var centroid = [];
for(var j = 1; j <= this.Observations.cols(); j++) ... | javascript | function createCentroids(k) {
var Centroid = [];
var maxes = this.Observations.maxColumns();
//console.log(maxes);
for(var i = 1; i <= k; i++) {
var centroid = [];
for(var j = 1; j <= this.Observations.cols(); j++) ... | [
"function",
"createCentroids",
"(",
"k",
")",
"{",
"var",
"Centroid",
"=",
"[",
"]",
";",
"var",
"maxes",
"=",
"this",
".",
"Observations",
".",
"maxColumns",
"(",
")",
";",
"//console.log(maxes);",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<=",
"... | create an initial centroid matrix with initial values between 0 and the max of feature data X. | [
"create",
"an",
"initial",
"centroid",
"matrix",
"with",
"initial",
"values",
"between",
"0",
"and",
"the",
"max",
"of",
"feature",
"data",
"X",
"."
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L76337-L76354 | train |
repetere/modelscript | build/modelscript.umd.js | distanceFrom | function distanceFrom(Centroids) {
var distances = [];
for(var i = 1; i <= this.Observations.rows(); i++) {
var distance = [];
for(var j = 1; j <= Centroids.rows(); j++) {
distance.push(this.Observations.row(i).distanceFro... | javascript | function distanceFrom(Centroids) {
var distances = [];
for(var i = 1; i <= this.Observations.rows(); i++) {
var distance = [];
for(var j = 1; j <= Centroids.rows(); j++) {
distance.push(this.Observations.row(i).distanceFro... | [
"function",
"distanceFrom",
"(",
"Centroids",
")",
"{",
"var",
"distances",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<=",
"this",
".",
"Observations",
".",
"rows",
"(",
")",
";",
"i",
"++",
")",
"{",
"var",
"distance",
"="... | get the euclidian distance between the feature data X and a given centroid matrix C. | [
"get",
"the",
"euclidian",
"distance",
"between",
"the",
"feature",
"data",
"X",
"and",
"a",
"given",
"centroid",
"matrix",
"C",
"."
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L76358-L76372 | train |
repetere/modelscript | build/modelscript.umd.js | cluster | function cluster(k) {
var Centroids = this.createCentroids(k);
var LastDistances = Matrix$d.Zero(this.Observations.rows(), this.Observations.cols());
var Distances = this.distanceFrom(Centroids);
var Groups;
while(!(LastDistances.eql(Dista... | javascript | function cluster(k) {
var Centroids = this.createCentroids(k);
var LastDistances = Matrix$d.Zero(this.Observations.rows(), this.Observations.cols());
var Distances = this.distanceFrom(Centroids);
var Groups;
while(!(LastDistances.eql(Dista... | [
"function",
"cluster",
"(",
"k",
")",
"{",
"var",
"Centroids",
"=",
"this",
".",
"createCentroids",
"(",
"k",
")",
";",
"var",
"LastDistances",
"=",
"Matrix$d",
".",
"Zero",
"(",
"this",
".",
"Observations",
".",
"rows",
"(",
")",
",",
"this",
".",
"... | categorize the feature data X into k clusters. return a vector containing the results. | [
"categorize",
"the",
"feature",
"data",
"X",
"into",
"k",
"clusters",
".",
"return",
"a",
"vector",
"containing",
"the",
"results",
"."
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L76376-L76413 | train |
repetere/modelscript | build/modelscript.umd.js | function (str) {
var allPairs = [], pairs;
var words = str.split(/\s+/);
for (var i = 0; i < words.length; i++) {
pairs = letterPairs(words[i]);
allPairs.push.apply(allPairs, pairs);
}
return allPairs;
} | javascript | function (str) {
var allPairs = [], pairs;
var words = str.split(/\s+/);
for (var i = 0; i < words.length; i++) {
pairs = letterPairs(words[i]);
allPairs.push.apply(allPairs, pairs);
}
return allPairs;
} | [
"function",
"(",
"str",
")",
"{",
"var",
"allPairs",
"=",
"[",
"]",
",",
"pairs",
";",
"var",
"words",
"=",
"str",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"words",
".",
"length",
";",
... | Get all of the pairs in all of the words for a string | [
"Get",
"all",
"of",
"the",
"pairs",
"in",
"all",
"of",
"the",
"words",
"for",
"a",
"string"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L79378-L79386 | train | |
repetere/modelscript | build/modelscript.umd.js | function (str1, str2) {
var sanitized_str1 = sanitize(str1);
var sanitized_str2 = sanitize(str2);
var pairs1 = wordLetterPairs(sanitized_str1);
var pairs2 = wordLetterPairs(sanitized_str2);
var intersection = 0, union = pairs1.length + pairs2.length;... | javascript | function (str1, str2) {
var sanitized_str1 = sanitize(str1);
var sanitized_str2 = sanitize(str2);
var pairs1 = wordLetterPairs(sanitized_str1);
var pairs2 = wordLetterPairs(sanitized_str2);
var intersection = 0, union = pairs1.length + pairs2.length;... | [
"function",
"(",
"str1",
",",
"str2",
")",
"{",
"var",
"sanitized_str1",
"=",
"sanitize",
"(",
"str1",
")",
";",
"var",
"sanitized_str2",
"=",
"sanitize",
"(",
"str2",
")",
";",
"var",
"pairs1",
"=",
"wordLetterPairs",
"(",
"sanitized_str1",
")",
";",
"v... | Compare two strings, and spit out a number from 0-1 | [
"Compare",
"two",
"strings",
"and",
"spit",
"out",
"a",
"number",
"from",
"0",
"-",
"1"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L79394-L79421 | train | |
repetere/modelscript | build/modelscript.umd.js | function(tokens) {
if(typeof tokens === "string") {
tokens = [tokens];
}
var results = [];
var rule_count = rules$3.length;
var num_tokens = tokens.length;
var i, token, r, rule;
... | javascript | function(tokens) {
if(typeof tokens === "string") {
tokens = [tokens];
}
var results = [];
var rule_count = rules$3.length;
var num_tokens = tokens.length;
var i, token, r, rule;
... | [
"function",
"(",
"tokens",
")",
"{",
"if",
"(",
"typeof",
"tokens",
"===",
"\"string\"",
")",
"{",
"tokens",
"=",
"[",
"tokens",
"]",
";",
"}",
"var",
"results",
"=",
"[",
"]",
";",
"var",
"rule_count",
"=",
"rules$3",
".",
"length",
";",
"var",
"n... | Accepts a list of tokens to expand. | [
"Accepts",
"a",
"list",
"of",
"tokens",
"to",
"expand",
"."
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L79443-L79477 | train | |
repetere/modelscript | build/modelscript.cjs.js | StandardScalerTransforms | function StandardScalerTransforms(vector = [], nan_value = -1, return_nan=false) {
const average = avg(vector);
const standard_dev = sd(vector);
const maximum = max(vector);
const minimum = min(vector);
const scale = (z) => {
const scaledValue = (z - average) / standard_dev;
if (isNaN(scaledVal... | javascript | function StandardScalerTransforms(vector = [], nan_value = -1, return_nan=false) {
const average = avg(vector);
const standard_dev = sd(vector);
const maximum = max(vector);
const minimum = min(vector);
const scale = (z) => {
const scaledValue = (z - average) / standard_dev;
if (isNaN(scaledVal... | [
"function",
"StandardScalerTransforms",
"(",
"vector",
"=",
"[",
"]",
",",
"nan_value",
"=",
"-",
"1",
",",
"return_nan",
"=",
"false",
")",
"{",
"const",
"average",
"=",
"avg",
"(",
"vector",
")",
";",
"const",
"standard_dev",
"=",
"sd",
"(",
"vector",
... | This function returns two functions that can standard scale new inputs and reverse scale new outputs
@param {Number[]} values - array of numbers
@returns {Object} - {scale[ Function ], descale[ Function ]} | [
"This",
"function",
"returns",
"two",
"functions",
"that",
"can",
"standard",
"scale",
"new",
"inputs",
"and",
"reverse",
"scale",
"new",
"outputs"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.cjs.js#L377-L410 | train |
repetere/modelscript | build/modelscript.cjs.js | assocationRuleLearning | function assocationRuleLearning(transactions =[], options) {
return new Promise((resolve, reject) => {
try {
const config = Object.assign({}, {
support: 0.4,
minLength: 2,
summary: true,
valuesMap: new Map(),
}, options);
const fpgrowth = new FPGrowth(con... | javascript | function assocationRuleLearning(transactions =[], options) {
return new Promise((resolve, reject) => {
try {
const config = Object.assign({}, {
support: 0.4,
minLength: 2,
summary: true,
valuesMap: new Map(),
}, options);
const fpgrowth = new FPGrowth(con... | [
"function",
"assocationRuleLearning",
"(",
"transactions",
"=",
"[",
"]",
",",
"options",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"try",
"{",
"const",
"config",
"=",
"Object",
".",
"assign",
"(",
"{",
"... | returns association rule learning results
@memberOf calc
@see {@link https://github.com/alexisfacques/Node-FPGrowth}
@param {Array} transactions - sparse matrix of transactions
@param {Object} options
@param {Number} [options.support=0.4] - support level
@param {Number} [options.minLength=2] - minimum assocation array ... | [
"returns",
"association",
"rule",
"learning",
"results"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.cjs.js#L742-L775 | train |
repetere/modelscript | build/modelscript.cjs.js | cross_validate_score | function cross_validate_score(options = {}) {
const config = Object.assign({}, {
// classifier,
// regression,
// dataset,
// testingset,
dependentFeatures: [['X', ], ],
independentFeatures: [['Y', ], ],
// random_state,
folds: 10,
accuracy: 'standardError',
use_trai... | javascript | function cross_validate_score(options = {}) {
const config = Object.assign({}, {
// classifier,
// regression,
// dataset,
// testingset,
dependentFeatures: [['X', ], ],
independentFeatures: [['Y', ], ],
// random_state,
folds: 10,
accuracy: 'standardError',
use_trai... | [
"function",
"cross_validate_score",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"config",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"{",
"// classifier,\r",
"// regression,\r",
"// dataset,\r",
"// testingset,\r",
"dependentFeatures",
":",
"[",
"["... | Used to test variance and bias of a prediction
@memberOf cross_validation
@param {object} options
@param {function} options.classifier - instance of classification model used for training, or function to train a model. e.g. new DecisionTreeClassifier({ gainFunction: 'gini', }) or ml.KNN
@param {function} options.regres... | [
"Used",
"to",
"test",
"variance",
"and",
"bias",
"of",
"a",
"prediction"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.cjs.js#L2316-L2392 | train |
repetere/modelscript | build/modelscript.cjs.js | grid_search | function grid_search(options = {}) {
const config = Object.assign({}, {
return_parameters: false,
compare_score:'mean',
sortAccuracyScore:'desc',
parameters: {},
}, options);
const regressor = config.regression;
const classification = config.classifier;
const sortAccuracyScore = (!opt... | javascript | function grid_search(options = {}) {
const config = Object.assign({}, {
return_parameters: false,
compare_score:'mean',
sortAccuracyScore:'desc',
parameters: {},
}, options);
const regressor = config.regression;
const classification = config.classifier;
const sortAccuracyScore = (!opt... | [
"function",
"grid_search",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"config",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"{",
"return_parameters",
":",
"false",
",",
"compare_score",
":",
"'mean'",
",",
"sortAccuracyScore",
":",
"'desc'",
... | Used to test variance and bias of a prediction with parameter tuning
@memberOf cross_validation
@param {object} options
@param {function} options.classifier - instance of classification model used for training, or function to train a model. e.g. new DecisionTreeClassifier({ gainFunction: 'gini', }) or ml.KNN
@param {fu... | [
"Used",
"to",
"test",
"variance",
"and",
"bias",
"of",
"a",
"prediction",
"with",
"parameter",
"tuning"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.cjs.js#L2402-L2439 | train |
jhotmann/node-rename-cli | bin.js | epipeError | function epipeError(err) {
if (err.code === 'EPIPE' || err.errno === 32) return process.exit;
if (process.stdout.listeners('error').length <= 1) {
process.stdout.removeAllListeners();
process.stdout.emit('error', err);
process.stdout.on('error', epipeError);
}
} | javascript | function epipeError(err) {
if (err.code === 'EPIPE' || err.errno === 32) return process.exit;
if (process.stdout.listeners('error').length <= 1) {
process.stdout.removeAllListeners();
process.stdout.emit('error', err);
process.stdout.on('error', epipeError);
}
} | [
"function",
"epipeError",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
"code",
"===",
"'EPIPE'",
"||",
"err",
".",
"errno",
"===",
"32",
")",
"return",
"process",
".",
"exit",
";",
"if",
"(",
"process",
".",
"stdout",
".",
"listeners",
"(",
"'error'"... | Handle EPIPE errors when user doesn't put quotes around output file name with parameters | [
"Handle",
"EPIPE",
"errors",
"when",
"user",
"doesn",
"t",
"put",
"quotes",
"around",
"output",
"file",
"name",
"with",
"parameters"
] | 5d75fdcfc774796efd6a5f830cad9815f6323f20 | https://github.com/jhotmann/node-rename-cli/blob/5d75fdcfc774796efd6a5f830cad9815f6323f20/bin.js#L3-L11 | train |
FormidableLabs/builder-support | lib/dev.js | function (source, target, isExternal) {
// Clone source
var pkg = JSON.parse(JSON.stringify(source));
// Validation of source package.
["name", "description"].forEach(function (name) {
if (!pkg[name]) {
throw new Error("Source object missing field: " + name);
}
});
var nameRe = new RegExp("(... | javascript | function (source, target, isExternal) {
// Clone source
var pkg = JSON.parse(JSON.stringify(source));
// Validation of source package.
["name", "description"].forEach(function (name) {
if (!pkg[name]) {
throw new Error("Source object missing field: " + name);
}
});
var nameRe = new RegExp("(... | [
"function",
"(",
"source",
",",
"target",
",",
"isExternal",
")",
"{",
"// Clone source",
"var",
"pkg",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"source",
")",
")",
";",
"// Validation of source package.",
"[",
"\"name\"",
",",
"\"descr... | Update `target` JSON structure with fields from `source`.
@param {Object} source Source JSON object
@param {Object} target Target JSON object
@param {Boolean} isExternal Is external (`../NAME-dev`) dev package.
@returns {Object} Updated JSON object | [
"Update",
"target",
"JSON",
"structure",
"with",
"fields",
"from",
"source",
"."
] | 675ef7c1243f02f1243bfee0c68ecd3c167f548d | https://github.com/FormidableLabs/builder-support/blob/675ef7c1243f02f1243bfee0c68ecd3c167f548d/lib/dev.js#L44-L101 | train | |
soundar24/roundSlider | src/roundslider.js | function (value) {
var o = this.options, min = o.min, max = o.max;
this.bar.children().attr({ "aria-valuenow": value });
if (o.sliderType == "range") {
var handles = this._handles();
handles.eq(0).attr({ "aria-valuemin": min });
h... | javascript | function (value) {
var o = this.options, min = o.min, max = o.max;
this.bar.children().attr({ "aria-valuenow": value });
if (o.sliderType == "range") {
var handles = this._handles();
handles.eq(0).attr({ "aria-valuemin": min });
h... | [
"function",
"(",
"value",
")",
"{",
"var",
"o",
"=",
"this",
".",
"options",
",",
"min",
"=",
"o",
".",
"min",
",",
"max",
"=",
"o",
".",
"max",
";",
"this",
".",
"bar",
".",
"children",
"(",
")",
".",
"attr",
"(",
"{",
"\"aria-valuenow\"",
":"... | WAI-ARIA support | [
"WAI",
"-",
"ARIA",
"support"
] | b58cd164a894339a4047b568a2202f99dfaa49b8 | https://github.com/soundar24/roundSlider/blob/b58cd164a894339a4047b568a2202f99dfaa49b8/src/roundslider.js#L609-L621 | train | |
soundar24/roundSlider | src/roundslider.js | function () {
var _data = this._dataElement().data("bind");
if (typeof _data == "string" && typeof ko == "object") {
var _vm = ko.dataFor(this._dataElement()[0]);
if (typeof _vm == "undefined") return true;
var _all = _data.split(","), _handle... | javascript | function () {
var _data = this._dataElement().data("bind");
if (typeof _data == "string" && typeof ko == "object") {
var _vm = ko.dataFor(this._dataElement()[0]);
if (typeof _vm == "undefined") return true;
var _all = _data.split(","), _handle... | [
"function",
"(",
")",
"{",
"var",
"_data",
"=",
"this",
".",
"_dataElement",
"(",
")",
".",
"data",
"(",
"\"bind\"",
")",
";",
"if",
"(",
"typeof",
"_data",
"==",
"\"string\"",
"&&",
"typeof",
"ko",
"==",
"\"object\"",
")",
"{",
"var",
"_vm",
"=",
... | Listener for KO binding | [
"Listener",
"for",
"KO",
"binding"
] | b58cd164a894339a4047b568a2202f99dfaa49b8 | https://github.com/soundar24/roundSlider/blob/b58cd164a894339a4047b568a2202f99dfaa49b8/src/roundslider.js#L623-L641 | train | |
soundar24/roundSlider | src/roundslider.js | function () {
if (typeof angular == "object" && typeof angular.element == "function") {
this._ngName = this._dataElement().attr("ng-model");
if (typeof this._ngName == "string") {
this._isAngular = true; var that = this;
this._scop... | javascript | function () {
if (typeof angular == "object" && typeof angular.element == "function") {
this._ngName = this._dataElement().attr("ng-model");
if (typeof this._ngName == "string") {
this._isAngular = true; var that = this;
this._scop... | [
"function",
"(",
")",
"{",
"if",
"(",
"typeof",
"angular",
"==",
"\"object\"",
"&&",
"typeof",
"angular",
".",
"element",
"==",
"\"function\"",
")",
"{",
"this",
".",
"_ngName",
"=",
"this",
".",
"_dataElement",
"(",
")",
".",
"attr",
"(",
"\"ng-model\""... | Listener for Angular binding | [
"Listener",
"for",
"Angular",
"binding"
] | b58cd164a894339a4047b568a2202f99dfaa49b8 | https://github.com/soundar24/roundSlider/blob/b58cd164a894339a4047b568a2202f99dfaa49b8/src/roundslider.js#L643-L651 | train | |
soundar24/roundSlider | src/roundslider.js | CreateRoundSlider | function CreateRoundSlider(options, args) {
for (var i = 0; i < this.length; i++) {
var that = this[i], instance = $.data(that, pluginName);
if (!instance) {
var _this = new RoundSlider(that, options);
_this._saveInstanceOnElement();
... | javascript | function CreateRoundSlider(options, args) {
for (var i = 0; i < this.length; i++) {
var that = this[i], instance = $.data(that, pluginName);
if (!instance) {
var _this = new RoundSlider(that, options);
_this._saveInstanceOnElement();
... | [
"function",
"CreateRoundSlider",
"(",
"options",
",",
"args",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"that",
"=",
"this",
"[",
"i",
"]",
",",
"instance",
"=",
"$",
".",... | The plugin wrapper, prevents multiple instantiations | [
"The",
"plugin",
"wrapper",
"prevents",
"multiple",
"instantiations"
] | b58cd164a894339a4047b568a2202f99dfaa49b8 | https://github.com/soundar24/roundSlider/blob/b58cd164a894339a4047b568a2202f99dfaa49b8/src/roundslider.js#L1215-L1246 | train |
sematext/sematable | src/selectors.js | filter | function filter(rows = [], filters = [], filterText, columns) {
let filteredRows = rows.slice(0);
if (filters.length === 0 && !filterText) {
return filteredRows;
}
const textFilters = [
...(filterText ? [filterText.toLowerCase()] : []),
...filters.filter(f => f.textFilter).map(f => f.value),
];
... | javascript | function filter(rows = [], filters = [], filterText, columns) {
let filteredRows = rows.slice(0);
if (filters.length === 0 && !filterText) {
return filteredRows;
}
const textFilters = [
...(filterText ? [filterText.toLowerCase()] : []),
...filters.filter(f => f.textFilter).map(f => f.value),
];
... | [
"function",
"filter",
"(",
"rows",
"=",
"[",
"]",
",",
"filters",
"=",
"[",
"]",
",",
"filterText",
",",
"columns",
")",
"{",
"let",
"filteredRows",
"=",
"rows",
".",
"slice",
"(",
"0",
")",
";",
"if",
"(",
"filters",
".",
"length",
"===",
"0",
"... | rows - original data
filters - list of selected filters
filterText - currently entered text in filter input
columns - column definitions | [
"rows",
"-",
"original",
"data",
"filters",
"-",
"list",
"of",
"selected",
"filters",
"filterText",
"-",
"currently",
"entered",
"text",
"in",
"filter",
"input",
"columns",
"-",
"column",
"definitions"
] | 1572a90fb2a29ccb2626a451b951413491379fbe | https://github.com/sematext/sematable/blob/1572a90fb2a29ccb2626a451b951413491379fbe/src/selectors.js#L21-L58 | train |
MazeMap/Leaflet.LayerGroup.Collision | src/Leaflet.LayerGroup.Collision.js | function (el) {
if (isMSIE8) {
// Fallback for MSIE8, will most probably fail on edge cases
return [ 0, 0, el.offsetWidth, el.offsetHeight];
}
var styles = window.getComputedStyle(el);
// getComputedStyle() should return values already in pixels, so using parseInt()
// is not as much as a hack as i... | javascript | function (el) {
if (isMSIE8) {
// Fallback for MSIE8, will most probably fail on edge cases
return [ 0, 0, el.offsetWidth, el.offsetHeight];
}
var styles = window.getComputedStyle(el);
// getComputedStyle() should return values already in pixels, so using parseInt()
// is not as much as a hack as i... | [
"function",
"(",
"el",
")",
"{",
"if",
"(",
"isMSIE8",
")",
"{",
"// Fallback for MSIE8, will most probably fail on edge cases",
"return",
"[",
"0",
",",
"0",
",",
"el",
".",
"offsetWidth",
",",
"el",
".",
"offsetHeight",
"]",
";",
"}",
"var",
"styles",
"=",... | Returns a plain array with the relative dimensions of a L.Icon, based on the computed values from iconSize and iconAnchor. | [
"Returns",
"a",
"plain",
"array",
"with",
"the",
"relative",
"dimensions",
"of",
"a",
"L",
".",
"Icon",
"based",
"on",
"the",
"computed",
"values",
"from",
"iconSize",
"and",
"iconAnchor",
"."
] | 9543cab71dd2494f930d4ddce464e7742404cc28 | https://github.com/MazeMap/Leaflet.LayerGroup.Collision/blob/9543cab71dd2494f930d4ddce464e7742404cc28/src/Leaflet.LayerGroup.Collision.js#L122-L140 | train | |
npm/npmconf | lib/load-uid.js | loadUid | function loadUid (cb) {
// if we're not in unsafe-perm mode, then figure out who
// to run stuff as. Do this first, to support `npm update npm -g`
if (!this.get("unsafe-perm")) {
getUid(this.get("user"), this.get("group"), cb)
} else {
process.nextTick(cb)
}
} | javascript | function loadUid (cb) {
// if we're not in unsafe-perm mode, then figure out who
// to run stuff as. Do this first, to support `npm update npm -g`
if (!this.get("unsafe-perm")) {
getUid(this.get("user"), this.get("group"), cb)
} else {
process.nextTick(cb)
}
} | [
"function",
"loadUid",
"(",
"cb",
")",
"{",
"// if we're not in unsafe-perm mode, then figure out who",
"// to run stuff as. Do this first, to support `npm update npm -g`",
"if",
"(",
"!",
"this",
".",
"get",
"(",
"\"unsafe-perm\"",
")",
")",
"{",
"getUid",
"(",
"this",
... | Call in the context of a npmconf object | [
"Call",
"in",
"the",
"context",
"of",
"a",
"npmconf",
"object"
] | 22827e4038d6eebaafeb5c13ed2b92cf97b8fb82 | https://github.com/npm/npmconf/blob/22827e4038d6eebaafeb5c13ed2b92cf97b8fb82/lib/load-uid.js#L7-L15 | train |
Alex1990/tiny-cookie | src/util.js | computeExpires | function computeExpires(str) {
const lastCh = str.charAt(str.length - 1);
const value = parseInt(str, 10);
let expires = new Date();
switch (lastCh) {
case 'Y': expires.setFullYear(expires.getFullYear() + value); break;
case 'M': expires.setMonth(expires.getMonth() + value); break;
case 'D': expire... | javascript | function computeExpires(str) {
const lastCh = str.charAt(str.length - 1);
const value = parseInt(str, 10);
let expires = new Date();
switch (lastCh) {
case 'Y': expires.setFullYear(expires.getFullYear() + value); break;
case 'M': expires.setMonth(expires.getMonth() + value); break;
case 'D': expire... | [
"function",
"computeExpires",
"(",
"str",
")",
"{",
"const",
"lastCh",
"=",
"str",
".",
"charAt",
"(",
"str",
".",
"length",
"-",
"1",
")",
";",
"const",
"value",
"=",
"parseInt",
"(",
"str",
",",
"10",
")",
";",
"let",
"expires",
"=",
"new",
"Date... | Return a future date by the given string. | [
"Return",
"a",
"future",
"date",
"by",
"the",
"given",
"string",
"."
] | 6fcecdb044465cf35fe0653b7ab6a495c697c3cc | https://github.com/Alex1990/tiny-cookie/blob/6fcecdb044465cf35fe0653b7ab6a495c697c3cc/src/util.js#L11-L27 | train |
Alex1990/tiny-cookie | src/util.js | convert | function convert(opts) {
let res = '';
// eslint-disable-next-line
for (const key in opts) {
if (hasOwn(opts, key)) {
if (/^expires$/i.test(key)) {
let expires = opts[key];
if (typeof expires !== 'object') {
expires += typeof expires === 'number' ? 'D' : '';
expires... | javascript | function convert(opts) {
let res = '';
// eslint-disable-next-line
for (const key in opts) {
if (hasOwn(opts, key)) {
if (/^expires$/i.test(key)) {
let expires = opts[key];
if (typeof expires !== 'object') {
expires += typeof expires === 'number' ? 'D' : '';
expires... | [
"function",
"convert",
"(",
"opts",
")",
"{",
"let",
"res",
"=",
"''",
";",
"// eslint-disable-next-line",
"for",
"(",
"const",
"key",
"in",
"opts",
")",
"{",
"if",
"(",
"hasOwn",
"(",
"opts",
",",
"key",
")",
")",
"{",
"if",
"(",
"/",
"^expires$",
... | Convert an object to a cookie option string. | [
"Convert",
"an",
"object",
"to",
"a",
"cookie",
"option",
"string",
"."
] | 6fcecdb044465cf35fe0653b7ab6a495c697c3cc | https://github.com/Alex1990/tiny-cookie/blob/6fcecdb044465cf35fe0653b7ab6a495c697c3cc/src/util.js#L30-L59 | train |
Alex1990/tiny-cookie | src/index.js | isEnabled | function isEnabled() {
const key = '@key@';
const value = '1';
const re = new RegExp(`(?:^|; )${key}=${value}(?:;|$)`);
document.cookie = `${key}=${value}`;
const enabled = re.test(document.cookie);
if (enabled) {
// eslint-disable-next-line
remove(key);
}
return enabled;
} | javascript | function isEnabled() {
const key = '@key@';
const value = '1';
const re = new RegExp(`(?:^|; )${key}=${value}(?:;|$)`);
document.cookie = `${key}=${value}`;
const enabled = re.test(document.cookie);
if (enabled) {
// eslint-disable-next-line
remove(key);
}
return enabled;
} | [
"function",
"isEnabled",
"(",
")",
"{",
"const",
"key",
"=",
"'@key@'",
";",
"const",
"value",
"=",
"'1'",
";",
"const",
"re",
"=",
"new",
"RegExp",
"(",
"`",
"${",
"key",
"}",
"${",
"value",
"}",
"`",
")",
";",
"document",
".",
"cookie",
"=",
"`... | Check if the browser cookie is enabled. | [
"Check",
"if",
"the",
"browser",
"cookie",
"is",
"enabled",
"."
] | 6fcecdb044465cf35fe0653b7ab6a495c697c3cc | https://github.com/Alex1990/tiny-cookie/blob/6fcecdb044465cf35fe0653b7ab6a495c697c3cc/src/index.js#L4-L19 | train |
Alex1990/tiny-cookie | src/index.js | get | function get(key, decoder = decodeURIComponent) {
if ((typeof key !== 'string') || !key) {
return null;
}
const reKey = new RegExp(`(?:^|; )${escapeRe(key)}(?:=([^;]*))?(?:;|$)`);
const match = reKey.exec(document.cookie);
if (match === null) {
return null;
}
return typeof decoder === 'function... | javascript | function get(key, decoder = decodeURIComponent) {
if ((typeof key !== 'string') || !key) {
return null;
}
const reKey = new RegExp(`(?:^|; )${escapeRe(key)}(?:=([^;]*))?(?:;|$)`);
const match = reKey.exec(document.cookie);
if (match === null) {
return null;
}
return typeof decoder === 'function... | [
"function",
"get",
"(",
"key",
",",
"decoder",
"=",
"decodeURIComponent",
")",
"{",
"if",
"(",
"(",
"typeof",
"key",
"!==",
"'string'",
")",
"||",
"!",
"key",
")",
"{",
"return",
"null",
";",
"}",
"const",
"reKey",
"=",
"new",
"RegExp",
"(",
"`",
"... | Get the cookie value by key. | [
"Get",
"the",
"cookie",
"value",
"by",
"key",
"."
] | 6fcecdb044465cf35fe0653b7ab6a495c697c3cc | https://github.com/Alex1990/tiny-cookie/blob/6fcecdb044465cf35fe0653b7ab6a495c697c3cc/src/index.js#L22-L35 | train |
Alex1990/tiny-cookie | src/index.js | getAll | function getAll(decoder = decodeURIComponent) {
const reKey = /(?:^|; )([^=]+?)(?:=([^;]*))?(?:;|$)/g;
const cookies = {};
let match;
/* eslint-disable no-cond-assign */
while ((match = reKey.exec(document.cookie))) {
reKey.lastIndex = (match.index + match.length) - 1;
cookies[match[1]] = typeof deco... | javascript | function getAll(decoder = decodeURIComponent) {
const reKey = /(?:^|; )([^=]+?)(?:=([^;]*))?(?:;|$)/g;
const cookies = {};
let match;
/* eslint-disable no-cond-assign */
while ((match = reKey.exec(document.cookie))) {
reKey.lastIndex = (match.index + match.length) - 1;
cookies[match[1]] = typeof deco... | [
"function",
"getAll",
"(",
"decoder",
"=",
"decodeURIComponent",
")",
"{",
"const",
"reKey",
"=",
"/",
"(?:^|; )([^=]+?)(?:=([^;]*))?(?:;|$)",
"/",
"g",
";",
"const",
"cookies",
"=",
"{",
"}",
";",
"let",
"match",
";",
"/* eslint-disable no-cond-assign */",
"while... | The all cookies | [
"The",
"all",
"cookies"
] | 6fcecdb044465cf35fe0653b7ab6a495c697c3cc | https://github.com/Alex1990/tiny-cookie/blob/6fcecdb044465cf35fe0653b7ab6a495c697c3cc/src/index.js#L38-L50 | train |
Alex1990/tiny-cookie | src/index.js | remove | function remove(key, options) {
let opts = { expires: -1 };
if (options) {
opts = { ...options, ...opts };
}
return set(key, 'a', opts);
} | javascript | function remove(key, options) {
let opts = { expires: -1 };
if (options) {
opts = { ...options, ...opts };
}
return set(key, 'a', opts);
} | [
"function",
"remove",
"(",
"key",
",",
"options",
")",
"{",
"let",
"opts",
"=",
"{",
"expires",
":",
"-",
"1",
"}",
";",
"if",
"(",
"options",
")",
"{",
"opts",
"=",
"{",
"...",
"options",
",",
"...",
"opts",
"}",
";",
"}",
"return",
"set",
"("... | Remove a cookie by the specified key. | [
"Remove",
"a",
"cookie",
"by",
"the",
"specified",
"key",
"."
] | 6fcecdb044465cf35fe0653b7ab6a495c697c3cc | https://github.com/Alex1990/tiny-cookie/blob/6fcecdb044465cf35fe0653b7ab6a495c697c3cc/src/index.js#L67-L75 | train |
helior/react-highlighter | lib/highlighter.js | function(subject) {
if (this.isScalar() && this.hasSearch()) {
var search = this.getSearch();
return this.highlightChildren(subject, search);
}
return this.props.children;
} | javascript | function(subject) {
if (this.isScalar() && this.hasSearch()) {
var search = this.getSearch();
return this.highlightChildren(subject, search);
}
return this.props.children;
} | [
"function",
"(",
"subject",
")",
"{",
"if",
"(",
"this",
".",
"isScalar",
"(",
")",
"&&",
"this",
".",
"hasSearch",
"(",
")",
")",
"{",
"var",
"search",
"=",
"this",
".",
"getSearch",
"(",
")",
";",
"return",
"this",
".",
"highlightChildren",
"(",
... | A wrapper to the highlight method to determine when the highlighting
process should occur.
@param {string} subject
The body of text that will be searched for highlighted words.
@return {Array}
An array of ReactElements | [
"A",
"wrapper",
"to",
"the",
"highlight",
"method",
"to",
"determine",
"when",
"the",
"highlighting",
"process",
"should",
"occur",
"."
] | 9c59bfe8a19bc8df1fa02cb2298a94a6bbb13b3f | https://github.com/helior/react-highlighter/blob/9c59bfe8a19bc8df1fa02cb2298a94a6bbb13b3f/lib/highlighter.js#L72-L79 | train | |
helior/react-highlighter | lib/highlighter.js | function() {
if (this.props.search instanceof RegExp) {
return this.props.search;
}
var flags = '';
if (!this.props.caseSensitive) {
flags +='i';
}
var search = this.props.search;
if (typeof this.props.search === 'string') {
search = escapeStringRegexp(search);
}
... | javascript | function() {
if (this.props.search instanceof RegExp) {
return this.props.search;
}
var flags = '';
if (!this.props.caseSensitive) {
flags +='i';
}
var search = this.props.search;
if (typeof this.props.search === 'string') {
search = escapeStringRegexp(search);
}
... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"props",
".",
"search",
"instanceof",
"RegExp",
")",
"{",
"return",
"this",
".",
"props",
".",
"search",
";",
"}",
"var",
"flags",
"=",
"''",
";",
"if",
"(",
"!",
"this",
".",
"props",
".",
"case... | Get the search prop, but always in the form of a regular expression. Use
this as a proxy to this.props.search for consistency.
@return {RegExp} | [
"Get",
"the",
"search",
"prop",
"but",
"always",
"in",
"the",
"form",
"of",
"a",
"regular",
"expression",
".",
"Use",
"this",
"as",
"a",
"proxy",
"to",
"this",
".",
"props",
".",
"search",
"for",
"consistency",
"."
] | 9c59bfe8a19bc8df1fa02cb2298a94a6bbb13b3f | https://github.com/helior/react-highlighter/blob/9c59bfe8a19bc8df1fa02cb2298a94a6bbb13b3f/lib/highlighter.js#L105-L125 | train | |
helior/react-highlighter | lib/highlighter.js | function(subject, search) {
var matches = search.exec(subject);
if (matches) {
return {
first: matches.index,
last: matches.index + matches[0].length
};
}
} | javascript | function(subject, search) {
var matches = search.exec(subject);
if (matches) {
return {
first: matches.index,
last: matches.index + matches[0].length
};
}
} | [
"function",
"(",
"subject",
",",
"search",
")",
"{",
"var",
"matches",
"=",
"search",
".",
"exec",
"(",
"subject",
")",
";",
"if",
"(",
"matches",
")",
"{",
"return",
"{",
"first",
":",
"matches",
".",
"index",
",",
"last",
":",
"matches",
".",
"in... | Get the indexes of the first and last characters of the matched string.
@param {string} subject
The string to search against.
@param {RegExp} search
The regex search query.
@return {Object}
An object consisting of "first" and "last" properties representing the
indexes of the first and last characters of a matching... | [
"Get",
"the",
"indexes",
"of",
"the",
"first",
"and",
"last",
"characters",
"of",
"the",
"matched",
"string",
"."
] | 9c59bfe8a19bc8df1fa02cb2298a94a6bbb13b3f | https://github.com/helior/react-highlighter/blob/9c59bfe8a19bc8df1fa02cb2298a94a6bbb13b3f/lib/highlighter.js#L140-L148 | train | |
helior/react-highlighter | lib/highlighter.js | function(subject, search) {
var children = [];
var remaining = subject;
while (remaining) {
var remainingCleaned = (this.props.ignoreDiacritics
? removeDiacritics(remaining, this.props.diacriticsBlacklist)
: remaining
);
if (!search.test(remainingCleaned)) {
child... | javascript | function(subject, search) {
var children = [];
var remaining = subject;
while (remaining) {
var remainingCleaned = (this.props.ignoreDiacritics
? removeDiacritics(remaining, this.props.diacriticsBlacklist)
: remaining
);
if (!search.test(remainingCleaned)) {
child... | [
"function",
"(",
"subject",
",",
"search",
")",
"{",
"var",
"children",
"=",
"[",
"]",
";",
"var",
"remaining",
"=",
"subject",
";",
"while",
"(",
"remaining",
")",
"{",
"var",
"remainingCleaned",
"=",
"(",
"this",
".",
"props",
".",
"ignoreDiacritics",
... | Determines which strings of text should be highlighted or not.
@param {string} subject
The body of text that will be searched for highlighted words.
@param {string} search
The search used to search for highlighted words.
@return {Array}
An array of ReactElements | [
"Determines",
"which",
"strings",
"of",
"text",
"should",
"be",
"highlighted",
"or",
"not",
"."
] | 9c59bfe8a19bc8df1fa02cb2298a94a6bbb13b3f | https://github.com/helior/react-highlighter/blob/9c59bfe8a19bc8df1fa02cb2298a94a6bbb13b3f/lib/highlighter.js#L161-L201 | train | |
helior/react-highlighter | lib/highlighter.js | function(string) {
this.count++;
return React.createElement(this.props.matchElement, {
key: this.count,
className: this.props.matchClass,
style: this.props.matchStyle,
children: string
});
} | javascript | function(string) {
this.count++;
return React.createElement(this.props.matchElement, {
key: this.count,
className: this.props.matchClass,
style: this.props.matchStyle,
children: string
});
} | [
"function",
"(",
"string",
")",
"{",
"this",
".",
"count",
"++",
";",
"return",
"React",
".",
"createElement",
"(",
"this",
".",
"props",
".",
"matchElement",
",",
"{",
"key",
":",
"this",
".",
"count",
",",
"className",
":",
"this",
".",
"props",
".... | Responsible for rending a highlighted element.
@param {string} string
A string value to wrap an element around.
@return {ReactElement} | [
"Responsible",
"for",
"rending",
"a",
"highlighted",
"element",
"."
] | 9c59bfe8a19bc8df1fa02cb2298a94a6bbb13b3f | https://github.com/helior/react-highlighter/blob/9c59bfe8a19bc8df1fa02cb2298a94a6bbb13b3f/lib/highlighter.js#L224-L232 | train | |
iVis-at-Bilkent/cytoscape.js-expand-collapse | src/cueUtilities.js | function(node, e){
if (node){
var currMousePos = e.position || e.cyPosition;
var topLeft = {
x: (node.position("x") - node.width() / 2 - parseFloat(node.css('padding-left'))),
y: (node.position("y") - node.height() / 2 - parseFloat(node.css('padding-top')))};
var bottomRight = {
x: (node.p... | javascript | function(node, e){
if (node){
var currMousePos = e.position || e.cyPosition;
var topLeft = {
x: (node.position("x") - node.width() / 2 - parseFloat(node.css('padding-left'))),
y: (node.position("y") - node.height() / 2 - parseFloat(node.css('padding-top')))};
var bottomRight = {
x: (node.p... | [
"function",
"(",
"node",
",",
"e",
")",
"{",
"if",
"(",
"node",
")",
"{",
"var",
"currMousePos",
"=",
"e",
".",
"position",
"||",
"e",
".",
"cyPosition",
";",
"var",
"topLeft",
"=",
"{",
"x",
":",
"(",
"node",
".",
"position",
"(",
"\"x\"",
")",
... | check if mouse is inside given node | [
"check",
"if",
"mouse",
"is",
"inside",
"given",
"node"
] | 8a2e4157def5613e0e477e393dc2c0720e41c032 | https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/cueUtilities.js#L208-L224 | train | |
iVis-at-Bilkent/cytoscape.js-expand-collapse | src/index.js | evalOptions | function evalOptions(options) {
var animate = typeof options.animate === 'function' ? options.animate.call() : options.animate;
var fisheye = typeof options.fisheye === 'function' ? options.fisheye.call() : options.fisheye;
options.animate = animate;
options.fisheye = fisheye;
} | javascript | function evalOptions(options) {
var animate = typeof options.animate === 'function' ? options.animate.call() : options.animate;
var fisheye = typeof options.fisheye === 'function' ? options.fisheye.call() : options.fisheye;
options.animate = animate;
options.fisheye = fisheye;
} | [
"function",
"evalOptions",
"(",
"options",
")",
"{",
"var",
"animate",
"=",
"typeof",
"options",
".",
"animate",
"===",
"'function'",
"?",
"options",
".",
"animate",
".",
"call",
"(",
")",
":",
"options",
".",
"animate",
";",
"var",
"fisheye",
"=",
"type... | evaluate some specific options in case of they are specified as functions to be dynamically changed | [
"evaluate",
"some",
"specific",
"options",
"in",
"case",
"of",
"they",
"are",
"specified",
"as",
"functions",
"to",
"be",
"dynamically",
"changed"
] | 8a2e4157def5613e0e477e393dc2c0720e41c032 | https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/index.js#L27-L33 | train |
iVis-at-Bilkent/cytoscape.js-expand-collapse | src/expandCollapseUtilities.js | function (nodes, options) {
// If there is just one node to expand we need to animate for fisheye view, but if there are more then one node we do not
if (nodes.length === 1) {
var node = nodes[0];
if (node._private.data.collapsedChildren != null) {
// Expand the given node the third p... | javascript | function (nodes, options) {
// If there is just one node to expand we need to animate for fisheye view, but if there are more then one node we do not
if (nodes.length === 1) {
var node = nodes[0];
if (node._private.data.collapsedChildren != null) {
// Expand the given node the third p... | [
"function",
"(",
"nodes",
",",
"options",
")",
"{",
"// If there is just one node to expand we need to animate for fisheye view, but if there are more then one node we do not",
"if",
"(",
"nodes",
".",
"length",
"===",
"1",
")",
"{",
"var",
"node",
"=",
"nodes",
"[",
"0",... | Expand the given nodes perform end operation after expandation | [
"Expand",
"the",
"given",
"nodes",
"perform",
"end",
"operation",
"after",
"expandation"
] | 8a2e4157def5613e0e477e393dc2c0720e41c032 | https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/expandCollapseUtilities.js#L129-L149 | train | |
iVis-at-Bilkent/cytoscape.js-expand-collapse | src/expandCollapseUtilities.js | function (nodes, options) {
/*
* In collapse operation there is no fisheye view to be applied so there is no animation to be destroyed here. We can do this
* in a batch.
*/
cy.startBatch();
this.simpleCollapseGivenNodes(nodes, options);
cy.endBatch();
nodes.trigger("position"); // ... | javascript | function (nodes, options) {
/*
* In collapse operation there is no fisheye view to be applied so there is no animation to be destroyed here. We can do this
* in a batch.
*/
cy.startBatch();
this.simpleCollapseGivenNodes(nodes, options);
cy.endBatch();
nodes.trigger("position"); // ... | [
"function",
"(",
"nodes",
",",
"options",
")",
"{",
"/*\n * In collapse operation there is no fisheye view to be applied so there is no animation to be destroyed here. We can do this \n * in a batch.\n */",
"cy",
".",
"startBatch",
"(",
")",
";",
"this",
".",
"simpleColla... | collapse the given nodes then perform end operation | [
"collapse",
"the",
"given",
"nodes",
"then",
"perform",
"end",
"operation"
] | 8a2e4157def5613e0e477e393dc2c0720e41c032 | https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/expandCollapseUtilities.js#L151-L170 | train | |
iVis-at-Bilkent/cytoscape.js-expand-collapse | src/expandCollapseUtilities.js | function (root) {
var children = root.children();
for (var i = 0; i < children.length; i++) {
var node = children[i];
this.collapseBottomUp(node);
}
//If the root is a compound node to be collapsed then collapse it
if (root.data("collapse") && root.children().length > 0) {
this.col... | javascript | function (root) {
var children = root.children();
for (var i = 0; i < children.length; i++) {
var node = children[i];
this.collapseBottomUp(node);
}
//If the root is a compound node to be collapsed then collapse it
if (root.data("collapse") && root.children().length > 0) {
this.col... | [
"function",
"(",
"root",
")",
"{",
"var",
"children",
"=",
"root",
".",
"children",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"node",
"=",
"children",
"[",
"i",
... | collapse the nodes in bottom up order starting from the root | [
"collapse",
"the",
"nodes",
"in",
"bottom",
"up",
"order",
"starting",
"from",
"the",
"root"
] | 8a2e4157def5613e0e477e393dc2c0720e41c032 | https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/expandCollapseUtilities.js#L172-L183 | train | |
iVis-at-Bilkent/cytoscape.js-expand-collapse | src/expandCollapseUtilities.js | function (root, applyFishEyeViewToEachNode) {
if (root.data("expand") && root._private.data.collapsedChildren != null) {
// Expand the root and unmark its expand data to specify that it is no more to be expanded
this.expandNode(root, applyFishEyeViewToEachNode);
root.removeData("expand");
}
... | javascript | function (root, applyFishEyeViewToEachNode) {
if (root.data("expand") && root._private.data.collapsedChildren != null) {
// Expand the root and unmark its expand data to specify that it is no more to be expanded
this.expandNode(root, applyFishEyeViewToEachNode);
root.removeData("expand");
}
... | [
"function",
"(",
"root",
",",
"applyFishEyeViewToEachNode",
")",
"{",
"if",
"(",
"root",
".",
"data",
"(",
"\"expand\"",
")",
"&&",
"root",
".",
"_private",
".",
"data",
".",
"collapsedChildren",
"!=",
"null",
")",
"{",
"// Expand the root and unmark its expand ... | expand the nodes in top down order starting from the root | [
"expand",
"the",
"nodes",
"in",
"top",
"down",
"order",
"starting",
"from",
"the",
"root"
] | 8a2e4157def5613e0e477e393dc2c0720e41c032 | https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/expandCollapseUtilities.js#L185-L197 | train | |
iVis-at-Bilkent/cytoscape.js-expand-collapse | src/expandCollapseUtilities.js | function (renderedPosition) {
var pan = cy.pan();
var zoom = cy.zoom();
var x = (renderedPosition.x - pan.x) / zoom;
var y = (renderedPosition.y - pan.y) / zoom;
return {
x: x,
y: y
};
} | javascript | function (renderedPosition) {
var pan = cy.pan();
var zoom = cy.zoom();
var x = (renderedPosition.x - pan.x) / zoom;
var y = (renderedPosition.y - pan.y) / zoom;
return {
x: x,
y: y
};
} | [
"function",
"(",
"renderedPosition",
")",
"{",
"var",
"pan",
"=",
"cy",
".",
"pan",
"(",
")",
";",
"var",
"zoom",
"=",
"cy",
".",
"zoom",
"(",
")",
";",
"var",
"x",
"=",
"(",
"renderedPosition",
".",
"x",
"-",
"pan",
".",
"x",
")",
"/",
"zoom",... | Converst the rendered position to model position according to global pan and zoom values | [
"Converst",
"the",
"rendered",
"position",
"to",
"model",
"position",
"according",
"to",
"global",
"pan",
"and",
"zoom",
"values"
] | 8a2e4157def5613e0e477e393dc2c0720e41c032 | https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/expandCollapseUtilities.js#L199-L210 | train | |
iVis-at-Bilkent/cytoscape.js-expand-collapse | src/expandCollapseUtilities.js | function (node) {
if (node._private.data.collapsedChildren == null) {
node.data('position-before-collapse', {
x: node.position().x,
y: node.position().y
});
node.data('size-before-collapse', {
w: node.outerWidth(),
h: node.outerHeight()
});
var childre... | javascript | function (node) {
if (node._private.data.collapsedChildren == null) {
node.data('position-before-collapse', {
x: node.position().x,
y: node.position().y
});
node.data('size-before-collapse', {
w: node.outerWidth(),
h: node.outerHeight()
});
var childre... | [
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"_private",
".",
"data",
".",
"collapsedChildren",
"==",
"null",
")",
"{",
"node",
".",
"data",
"(",
"'position-before-collapse'",
",",
"{",
"x",
":",
"node",
".",
"position",
"(",
")",
".",
... | collapse the given node without performing end operation | [
"collapse",
"the",
"given",
"node",
"without",
"performing",
"end",
"operation"
] | 8a2e4157def5613e0e477e393dc2c0720e41c032 | https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/expandCollapseUtilities.js#L299-L329 | train | |
iVis-at-Bilkent/cytoscape.js-expand-collapse | src/expandCollapseUtilities.js | function(node, collapsedChildren){
var children = node.data('collapsedChildren');
var i;
for (i=0; i < children.length; i++){
if (children[i].data('collapsedChildren')){
collapsedChildren = collapsedChildren.union(this.getCollapsedChildrenRecursively(children[i], collapsedChildren));
}
... | javascript | function(node, collapsedChildren){
var children = node.data('collapsedChildren');
var i;
for (i=0; i < children.length; i++){
if (children[i].data('collapsedChildren')){
collapsedChildren = collapsedChildren.union(this.getCollapsedChildrenRecursively(children[i], collapsedChildren));
}
... | [
"function",
"(",
"node",
",",
"collapsedChildren",
")",
"{",
"var",
"children",
"=",
"node",
".",
"data",
"(",
"'collapsedChildren'",
")",
";",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")... | Get all collapsed children - including nested ones
@param node : a collapsed node
@param collapsedChildren : a collection to store the result
@return : collapsed children | [
"Get",
"all",
"collapsed",
"children",
"-",
"including",
"nested",
"ones"
] | 8a2e4157def5613e0e477e393dc2c0720e41c032 | https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/expandCollapseUtilities.js#L656-L666 | train | |
uupaa/UserAgent.js | docs/lib/WebModule.js | function(moduleName, moduleClosure) {
var wm = this; // GLOBAL.WebModule
// https://github.com/uupaa/WebModule/wiki/SwitchModulePattern
var alias = wm[moduleName] ? (moduleName + "_") : moduleName;
if (!wm[alias]) { // secondary module already exported -> skip
wm[alias] = m... | javascript | function(moduleName, moduleClosure) {
var wm = this; // GLOBAL.WebModule
// https://github.com/uupaa/WebModule/wiki/SwitchModulePattern
var alias = wm[moduleName] ? (moduleName + "_") : moduleName;
if (!wm[alias]) { // secondary module already exported -> skip
wm[alias] = m... | [
"function",
"(",
"moduleName",
",",
"moduleClosure",
")",
"{",
"var",
"wm",
"=",
"this",
";",
"// GLOBAL.WebModule",
"// https://github.com/uupaa/WebModule/wiki/SwitchModulePattern",
"var",
"alias",
"=",
"wm",
"[",
"moduleName",
"]",
"?",
"(",
"moduleName",
"+",
"\"... | module script stocker | [
"module",
"script",
"stocker"
] | 5d90111f44c1a90a68c804f30f949b3feac436dd | https://github.com/uupaa/UserAgent.js/blob/5d90111f44c1a90a68c804f30f949b3feac436dd/docs/lib/WebModule.js#L39-L54 | train | |
uupaa/UserAgent.js | lib/WebModule.js | function(moduleName, // @arg ModuleNameString
moduleClosure) { // @arg JavaScriptCodeString
// @ret ModuleObject
var wm = this; // GLOBAL.WebModule
// https://github.com/uupaa/WebModule/wiki/SwitchModulePattern
var alias = wm[mod... | javascript | function(moduleName, // @arg ModuleNameString
moduleClosure) { // @arg JavaScriptCodeString
// @ret ModuleObject
var wm = this; // GLOBAL.WebModule
// https://github.com/uupaa/WebModule/wiki/SwitchModulePattern
var alias = wm[mod... | [
"function",
"(",
"moduleName",
",",
"// @arg ModuleNameString",
"moduleClosure",
")",
"{",
"// @arg JavaScriptCodeString",
"// @ret ModuleObject",
"var",
"wm",
"=",
"this",
";",
"// GLOBAL.WebModule",
"// https://github.com/uupaa/WebModule/wiki/SwitchModulePattern",
"var",
"alias... | publish flag, module publish to global namespace. | [
"publish",
"flag",
"module",
"publish",
"to",
"global",
"namespace",
"."
] | 5d90111f44c1a90a68c804f30f949b3feac436dd | https://github.com/uupaa/UserAgent.js/blob/5d90111f44c1a90a68c804f30f949b3feac436dd/lib/WebModule.js#L39-L56 | train | |
garrows/browser-serialport | index.js | buffer2ArrayBuffer | function buffer2ArrayBuffer(buffer) {
var buf = new ArrayBuffer(buffer.length);
var bufView = new Uint8Array(buf);
for (var i = 0; i < buffer.length; i++) {
bufView[i] = buffer[i];
}
return buf;
} | javascript | function buffer2ArrayBuffer(buffer) {
var buf = new ArrayBuffer(buffer.length);
var bufView = new Uint8Array(buf);
for (var i = 0; i < buffer.length; i++) {
bufView[i] = buffer[i];
}
return buf;
} | [
"function",
"buffer2ArrayBuffer",
"(",
"buffer",
")",
"{",
"var",
"buf",
"=",
"new",
"ArrayBuffer",
"(",
"buffer",
".",
"length",
")",
";",
"var",
"bufView",
"=",
"new",
"Uint8Array",
"(",
"buf",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
... | Convert buffer to ArrayBuffer | [
"Convert",
"buffer",
"to",
"ArrayBuffer"
] | 3238bfa89a3f9d098a5263e1f63c3a7dbbeda759 | https://github.com/garrows/browser-serialport/blob/3238bfa89a3f9d098a5263e1f63c3a7dbbeda759/index.js#L400-L407 | train |
feathers-plus/graphql | lib/run-time/feathers/feathers-batch-loader.js | batchLoaderFunc | function batchLoaderFunc(graphqlType, serializeRecordKey, getRecords) {
return keys => getRecords(keys)
.then(resultArray => getResultsByKey(
keys, extractAllItems(resultArray), serializeRecordKey, graphqlType,
{ onError: logger }
)
);
} | javascript | function batchLoaderFunc(graphqlType, serializeRecordKey, getRecords) {
return keys => getRecords(keys)
.then(resultArray => getResultsByKey(
keys, extractAllItems(resultArray), serializeRecordKey, graphqlType,
{ onError: logger }
)
);
} | [
"function",
"batchLoaderFunc",
"(",
"graphqlType",
",",
"serializeRecordKey",
",",
"getRecords",
")",
"{",
"return",
"keys",
"=>",
"getRecords",
"(",
"keys",
")",
".",
"then",
"(",
"resultArray",
"=>",
"getResultsByKey",
"(",
"keys",
",",
"extractAllItems",
"(",... | Key loader function for BatchLoader. Note that serializeBatchLoaderKey has already been passed to BatchLoader as cacheKeyFn | [
"Key",
"loader",
"function",
"for",
"BatchLoader",
".",
"Note",
"that",
"serializeBatchLoaderKey",
"has",
"already",
"been",
"passed",
"to",
"BatchLoader",
"as",
"cacheKeyFn"
] | 259c0e6375d7054476d3ae24b2b27e194e375852 | https://github.com/feathers-plus/graphql/blob/259c0e6375d7054476d3ae24b2b27e194e375852/lib/run-time/feathers/feathers-batch-loader.js#L74-L81 | train |
fshost/node-dir | lib/readfiles.js | extend | function extend(target, source, modify) {
var result = target ? modify ? target : extend({}, target, true) : {};
if (!source) return result;
for (var key in source) {
if (source.hasOwnProperty(key) && source[key] !== undefined) {
result[key] = source[key];
}
}
return resu... | javascript | function extend(target, source, modify) {
var result = target ? modify ? target : extend({}, target, true) : {};
if (!source) return result;
for (var key in source) {
if (source.hasOwnProperty(key) && source[key] !== undefined) {
result[key] = source[key];
}
}
return resu... | [
"function",
"extend",
"(",
"target",
",",
"source",
",",
"modify",
")",
"{",
"var",
"result",
"=",
"target",
"?",
"modify",
"?",
"target",
":",
"extend",
"(",
"{",
"}",
",",
"target",
",",
"true",
")",
":",
"{",
"}",
";",
"if",
"(",
"!",
"source"... | merge two objects by extending target object with source object
@param target object to merge
@param source object to merge
@param {Boolean} [modify] whether to modify the target
@returns {Object} extended object | [
"merge",
"two",
"objects",
"by",
"extending",
"target",
"object",
"with",
"source",
"object"
] | a57c3b1b571dd91f464ae398090ba40f64ba38a2 | https://github.com/fshost/node-dir/blob/a57c3b1b571dd91f464ae398090ba40f64ba38a2/lib/readfiles.js#L11-L20 | train |
feathers-plus/graphql | lib/run-time/feathers/extract-items.js | extractAllItems | function extractAllItems (result) {
if (!result) return null;
if (!Array.isArray(result)) result = ('data' in result) ? result.data : result;
if (!result) return null;
if (!Array.isArray(result)) result = [result];
return result;
} | javascript | function extractAllItems (result) {
if (!result) return null;
if (!Array.isArray(result)) result = ('data' in result) ? result.data : result;
if (!result) return null;
if (!Array.isArray(result)) result = [result];
return result;
} | [
"function",
"extractAllItems",
"(",
"result",
")",
"{",
"if",
"(",
"!",
"result",
")",
"return",
"null",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"result",
")",
")",
"result",
"=",
"(",
"'data'",
"in",
"result",
")",
"?",
"result",
".",
"... | Return an array of objects from a Feathers service call. | [
"Return",
"an",
"array",
"of",
"objects",
"from",
"a",
"Feathers",
"service",
"call",
"."
] | 259c0e6375d7054476d3ae24b2b27e194e375852 | https://github.com/feathers-plus/graphql/blob/259c0e6375d7054476d3ae24b2b27e194e375852/lib/run-time/feathers/extract-items.js#L8-L17 | train |
feathers-plus/graphql | lib/run-time/feathers/extract-items.js | extractFirstItem | function extractFirstItem (result) {
const data = extractAllItems(result);
if (!data) return null;
if (data.length > 1) throw new Error(`service.find expected 0 or 1 objects, not ${data.length}. (extractFirstItem)`);
return data.length ? data[0] : null;
} | javascript | function extractFirstItem (result) {
const data = extractAllItems(result);
if (!data) return null;
if (data.length > 1) throw new Error(`service.find expected 0 or 1 objects, not ${data.length}. (extractFirstItem)`);
return data.length ? data[0] : null;
} | [
"function",
"extractFirstItem",
"(",
"result",
")",
"{",
"const",
"data",
"=",
"extractAllItems",
"(",
"result",
")",
";",
"if",
"(",
"!",
"data",
")",
"return",
"null",
";",
"if",
"(",
"data",
".",
"length",
">",
"1",
")",
"throw",
"new",
"Error",
"... | Return the first and only object from a Feathers service call, or null if none. | [
"Return",
"the",
"first",
"and",
"only",
"object",
"from",
"a",
"Feathers",
"service",
"call",
"or",
"null",
"if",
"none",
"."
] | 259c0e6375d7054476d3ae24b2b27e194e375852 | https://github.com/feathers-plus/graphql/blob/259c0e6375d7054476d3ae24b2b27e194e375852/lib/run-time/feathers/extract-items.js#L20-L27 | train |
reinerBa/Vue-Responsive | src/index.js | checkDisplay | function checkDisplay () {
var myPermissions = self.allProperties[resizeListenerId] // JSON.parse(el.dataset.responsives)
var curWidth = window.innerWidth
var initial = el.dataset.initialDisplay ? el.dataset.initialDisplay : ''
var parameters = self._rPermissions[binding.arg]
for (let i in... | javascript | function checkDisplay () {
var myPermissions = self.allProperties[resizeListenerId] // JSON.parse(el.dataset.responsives)
var curWidth = window.innerWidth
var initial = el.dataset.initialDisplay ? el.dataset.initialDisplay : ''
var parameters = self._rPermissions[binding.arg]
for (let i in... | [
"function",
"checkDisplay",
"(",
")",
"{",
"var",
"myPermissions",
"=",
"self",
".",
"allProperties",
"[",
"resizeListenerId",
"]",
"// JSON.parse(el.dataset.responsives)",
"var",
"curWidth",
"=",
"window",
".",
"innerWidth",
"var",
"initial",
"=",
"el",
".",
"dat... | This function checks the current breakpoint constraints for this element | [
"This",
"function",
"checks",
"the",
"current",
"breakpoint",
"constraints",
"for",
"this",
"element"
] | 9edf8298fc6e922d856bb74db5c38c5cd3d9c39c | https://github.com/reinerBa/Vue-Responsive/blob/9edf8298fc6e922d856bb74db5c38c5cd3d9c39c/src/index.js#L176-L196 | train |
reinerBa/Vue-Responsive | src/index.js | function (el, binding, vnode) {
let resizeListenerId = el.dataset.responsives
delete self.resizeListeners[resizeListenerId]
} | javascript | function (el, binding, vnode) {
let resizeListenerId = el.dataset.responsives
delete self.resizeListeners[resizeListenerId]
} | [
"function",
"(",
"el",
",",
"binding",
",",
"vnode",
")",
"{",
"let",
"resizeListenerId",
"=",
"el",
".",
"dataset",
".",
"responsives",
"delete",
"self",
".",
"resizeListeners",
"[",
"resizeListenerId",
"]",
"}"
] | Is called when the html element is removed from DOM
@param {object} el html element
@param {object} binding the parameters of the mixin
@param {object} vnode the virtual html elment | [
"Is",
"called",
"when",
"the",
"html",
"element",
"is",
"removed",
"from",
"DOM"
] | 9edf8298fc6e922d856bb74db5c38c5cd3d9c39c | https://github.com/reinerBa/Vue-Responsive/blob/9edf8298fc6e922d856bb74db5c38c5cd3d9c39c/src/index.js#L208-L211 | train | |
d3plus/d3plus-text | src/textWidth.js | htmlDecode | function htmlDecode(input) {
if (input === " ") return input;
const doc = new DOMParser().parseFromString(input.replace(/<[^>]+>/g, ""), "text/html");
return doc.documentElement.textContent;
} | javascript | function htmlDecode(input) {
if (input === " ") return input;
const doc = new DOMParser().parseFromString(input.replace(/<[^>]+>/g, ""), "text/html");
return doc.documentElement.textContent;
} | [
"function",
"htmlDecode",
"(",
"input",
")",
"{",
"if",
"(",
"input",
"===",
"\" \"",
")",
"return",
"input",
";",
"const",
"doc",
"=",
"new",
"DOMParser",
"(",
")",
".",
"parseFromString",
"(",
"input",
".",
"replace",
"(",
"/",
"<[^>]+>",
"/",
"g",
... | Strips HTML and "un-escapes" escape characters.
@param {String} input | [
"Strips",
"HTML",
"and",
"un",
"-",
"escapes",
"escape",
"characters",
"."
] | 00af6bb99ff048e132c287dd7f43fcc3143264d5 | https://github.com/d3plus/d3plus-text/blob/00af6bb99ff048e132c287dd7f43fcc3143264d5/src/textWidth.js#L5-L9 | train |
bencentra/jq-signature | jq-signature.js | function() {
this.id = 'jq-signature-canvas-' + (++idCounter);
// Set up the canvas
this.$canvas = $(canvasFixture).appendTo(this.$element);
this.$canvas.attr({
width: this.settings.width,
height: this.settings.height
});
this.$canvas.css({
boxSizing: 'border-bo... | javascript | function() {
this.id = 'jq-signature-canvas-' + (++idCounter);
// Set up the canvas
this.$canvas = $(canvasFixture).appendTo(this.$element);
this.$canvas.attr({
width: this.settings.width,
height: this.settings.height
});
this.$canvas.css({
boxSizing: 'border-bo... | [
"function",
"(",
")",
"{",
"this",
".",
"id",
"=",
"'jq-signature-canvas-'",
"+",
"(",
"++",
"idCounter",
")",
";",
"// Set up the canvas",
"this",
".",
"$canvas",
"=",
"$",
"(",
"canvasFixture",
")",
".",
"appendTo",
"(",
"this",
".",
"$element",
")",
"... | Initialize the signature canvas | [
"Initialize",
"the",
"signature",
"canvas"
] | 0316358410c41319977d076ece050fedd11411c4 | https://github.com/bencentra/jq-signature/blob/0316358410c41319977d076ece050fedd11411c4/jq-signature.js#L56-L112 | train | |
bencentra/jq-signature | jq-signature.js | function (e) {
this.drawing = true;
this.lastPos = this.currentPos = this._getPosition(e);
// Prevent scrolling, etc
$('body').css('overflow', 'hidden');
e.preventDefault();
} | javascript | function (e) {
this.drawing = true;
this.lastPos = this.currentPos = this._getPosition(e);
// Prevent scrolling, etc
$('body').css('overflow', 'hidden');
e.preventDefault();
} | [
"function",
"(",
"e",
")",
"{",
"this",
".",
"drawing",
"=",
"true",
";",
"this",
".",
"lastPos",
"=",
"this",
".",
"currentPos",
"=",
"this",
".",
"_getPosition",
"(",
"e",
")",
";",
"// Prevent scrolling, etc",
"$",
"(",
"'body'",
")",
".",
"css",
... | Handle the start of a signature | [
"Handle",
"the",
"start",
"of",
"a",
"signature"
] | 0316358410c41319977d076ece050fedd11411c4 | https://github.com/bencentra/jq-signature/blob/0316358410c41319977d076ece050fedd11411c4/jq-signature.js#L126-L132 | train | |
bencentra/jq-signature | jq-signature.js | function (e) {
this.drawing = false;
// Trigger a change event
var changedEvent = $.Event('jq.signature.changed');
this.$element.trigger(changedEvent);
// Allow scrolling again
$('body').css('overflow', 'auto');
e.preventDefault();
} | javascript | function (e) {
this.drawing = false;
// Trigger a change event
var changedEvent = $.Event('jq.signature.changed');
this.$element.trigger(changedEvent);
// Allow scrolling again
$('body').css('overflow', 'auto');
e.preventDefault();
} | [
"function",
"(",
"e",
")",
"{",
"this",
".",
"drawing",
"=",
"false",
";",
"// Trigger a change event",
"var",
"changedEvent",
"=",
"$",
".",
"Event",
"(",
"'jq.signature.changed'",
")",
";",
"this",
".",
"$element",
".",
"trigger",
"(",
"changedEvent",
")",... | Handle the end of a signature | [
"Handle",
"the",
"end",
"of",
"a",
"signature"
] | 0316358410c41319977d076ece050fedd11411c4 | https://github.com/bencentra/jq-signature/blob/0316358410c41319977d076ece050fedd11411c4/jq-signature.js#L141-L149 | train | |
bencentra/jq-signature | jq-signature.js | function() {
if (this.drawing) {
this.ctx.beginPath();
this.ctx.moveTo(this.lastPos.x, this.lastPos.y);
this.ctx.lineTo(this.currentPos.x, this.currentPos.y);
this.ctx.stroke();
this.lastPos = this.currentPos;
}
} | javascript | function() {
if (this.drawing) {
this.ctx.beginPath();
this.ctx.moveTo(this.lastPos.x, this.lastPos.y);
this.ctx.lineTo(this.currentPos.x, this.currentPos.y);
this.ctx.stroke();
this.lastPos = this.currentPos;
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"drawing",
")",
"{",
"this",
".",
"ctx",
".",
"beginPath",
"(",
")",
";",
"this",
".",
"ctx",
".",
"moveTo",
"(",
"this",
".",
"lastPos",
".",
"x",
",",
"this",
".",
"lastPos",
".",
"y",
")",
... | Render the signature to the canvas | [
"Render",
"the",
"signature",
"to",
"the",
"canvas"
] | 0316358410c41319977d076ece050fedd11411c4 | https://github.com/bencentra/jq-signature/blob/0316358410c41319977d076ece050fedd11411c4/jq-signature.js#L175-L183 | train | |
bencentra/jq-signature | jq-signature.js | function() {
this.ctx = this.canvas.getContext("2d");
this.ctx.strokeStyle = this.settings.lineColor;
this.ctx.lineWidth = this.settings.lineWidth;
} | javascript | function() {
this.ctx = this.canvas.getContext("2d");
this.ctx.strokeStyle = this.settings.lineColor;
this.ctx.lineWidth = this.settings.lineWidth;
} | [
"function",
"(",
")",
"{",
"this",
".",
"ctx",
"=",
"this",
".",
"canvas",
".",
"getContext",
"(",
"\"2d\"",
")",
";",
"this",
".",
"ctx",
".",
"strokeStyle",
"=",
"this",
".",
"settings",
".",
"lineColor",
";",
"this",
".",
"ctx",
".",
"lineWidth",
... | Reset the canvas context | [
"Reset",
"the",
"canvas",
"context"
] | 0316358410c41319977d076ece050fedd11411c4 | https://github.com/bencentra/jq-signature/blob/0316358410c41319977d076ece050fedd11411c4/jq-signature.js#L186-L190 | train | |
philbooth/bfj | src/read.js | read | function read (path, options) {
return parse(fs.createReadStream(path, options), Object.assign({}, options, { ndjson: false }))
} | javascript | function read (path, options) {
return parse(fs.createReadStream(path, options), Object.assign({}, options, { ndjson: false }))
} | [
"function",
"read",
"(",
"path",
",",
"options",
")",
"{",
"return",
"parse",
"(",
"fs",
".",
"createReadStream",
"(",
"path",
",",
"options",
")",
",",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
",",
"{",
"ndjson",
":",
"false",
"}",
... | Public function `read`.
Returns a promise and asynchronously parses a JSON file read from disk. If
there are no errors, the promise is resolved with the parsed data. If errors
occur, the promise is rejected with the first error.
@param path: Path to the JSON file.
@option reviver: Transformation function, in... | [
"Public",
"function",
"read",
"."
] | 61087c194d5675c75569a2e08617a98609b16ead | https://github.com/philbooth/bfj/blob/61087c194d5675c75569a2e08617a98609b16ead/src/read.js#L24-L26 | train |
philbooth/bfj | src/write.js | write | function write (path, data, options) {
const Promise = promise(options)
return new Promise((resolve, reject) => {
streamify(data, options)
.pipe(fs.createWriteStream(path, options))
.on('finish', () => {
resolve()
})
.on('error', reject)
.on('dataError', reject)
})
} | javascript | function write (path, data, options) {
const Promise = promise(options)
return new Promise((resolve, reject) => {
streamify(data, options)
.pipe(fs.createWriteStream(path, options))
.on('finish', () => {
resolve()
})
.on('error', reject)
.on('dataError', reject)
})
} | [
"function",
"write",
"(",
"path",
",",
"data",
",",
"options",
")",
"{",
"const",
"Promise",
"=",
"promise",
"(",
"options",
")",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"streamify",
"(",
"data",
",",
"options",
... | Public function `write`.
Returns a promise and asynchronously serialises a data structure to a
JSON file on disk. Sanely handles promises, buffers, maps and other
iterables.
@param path: Path to the JSON file.
@param data: The data to transform.
@option space: Indentation string, or the ... | [
"Public",
"function",
"write",
"."
] | 61087c194d5675c75569a2e08617a98609b16ead | https://github.com/philbooth/bfj/blob/61087c194d5675c75569a2e08617a98609b16ead/src/write.js#L43-L55 | train |
philbooth/bfj | src/stringify.js | stringify | function stringify (data, options) {
const json = []
const Promise = promise(options)
const stream = streamify(data, options)
let resolve, reject
stream.on('data', read)
stream.on('end', end)
stream.on('error', error)
stream.on('dataError', error)
return new Promise((res, rej) => {
resolve = re... | javascript | function stringify (data, options) {
const json = []
const Promise = promise(options)
const stream = streamify(data, options)
let resolve, reject
stream.on('data', read)
stream.on('end', end)
stream.on('error', error)
stream.on('dataError', error)
return new Promise((res, rej) => {
resolve = re... | [
"function",
"stringify",
"(",
"data",
",",
"options",
")",
"{",
"const",
"json",
"=",
"[",
"]",
"const",
"Promise",
"=",
"promise",
"(",
"options",
")",
"const",
"stream",
"=",
"streamify",
"(",
"data",
",",
"options",
")",
"let",
"resolve",
",",
"reje... | Public function `stringify`.
Returns a promise and asynchronously serialises a data structure to a
JSON string. Sanely handles promises, buffers, maps and other iterables.
@param data: The data to transform
@option space: Indentation string, or the number of spaces
to indent each nested level by.
@o... | [
"Public",
"function",
"stringify",
"."
] | 61087c194d5675c75569a2e08617a98609b16ead | https://github.com/philbooth/bfj/blob/61087c194d5675c75569a2e08617a98609b16ead/src/stringify.js#L39-L67 | train |
philbooth/bfj | src/unpipe.js | unpipe | function unpipe (callback, options) {
check.assert.function(callback, 'Invalid callback argument')
const jsonstream = new stream.PassThrough()
parse(jsonstream, Object.assign({}, options, { ndjson: false }))
.then(data => callback(null, data))
.catch(error => callback(error))
return jsonstream
} | javascript | function unpipe (callback, options) {
check.assert.function(callback, 'Invalid callback argument')
const jsonstream = new stream.PassThrough()
parse(jsonstream, Object.assign({}, options, { ndjson: false }))
.then(data => callback(null, data))
.catch(error => callback(error))
return jsonstream
} | [
"function",
"unpipe",
"(",
"callback",
",",
"options",
")",
"{",
"check",
".",
"assert",
".",
"function",
"(",
"callback",
",",
"'Invalid callback argument'",
")",
"const",
"jsonstream",
"=",
"new",
"stream",
".",
"PassThrough",
"(",
")",
"parse",
"(",
"json... | Public function `unpipe`.
Returns a writeable stream that can be passed to stream.pipe, then parses JSON
data read from the stream. If there are no errors, the callback is invoked with
the result as the second argument. If errors occur, the first error is passed to
the callback as the first argument.
@param callback:... | [
"Public",
"function",
"unpipe",
"."
] | 61087c194d5675c75569a2e08617a98609b16ead | https://github.com/philbooth/bfj/blob/61087c194d5675c75569a2e08617a98609b16ead/src/unpipe.js#L27-L37 | train |
kevinbeaty/any-promise | register.js | loadImplementation | function loadImplementation(implementation){
var impl = null
if(shouldPreferGlobalPromise(implementation)){
// if no implementation or env specified use global.Promise
impl = {
Promise: global.Promise,
implementation: 'global.Promise'
}
} else if(implementation){
// if implementation ... | javascript | function loadImplementation(implementation){
var impl = null
if(shouldPreferGlobalPromise(implementation)){
// if no implementation or env specified use global.Promise
impl = {
Promise: global.Promise,
implementation: 'global.Promise'
}
} else if(implementation){
// if implementation ... | [
"function",
"loadImplementation",
"(",
"implementation",
")",
"{",
"var",
"impl",
"=",
"null",
"if",
"(",
"shouldPreferGlobalPromise",
"(",
"implementation",
")",
")",
"{",
"// if no implementation or env specified use global.Promise",
"impl",
"=",
"{",
"Promise",
":",
... | Node.js version of loadImplementation.
Requires the given implementation and returns the registration
containing {Promise, implementation}
If implementation is undefined or global.Promise, loads it
Otherwise uses require | [
"Node",
".",
"js",
"version",
"of",
"loadImplementation",
"."
] | c2029f9e37a15b04c303bd0ec19cf16d00ec8f3d | https://github.com/kevinbeaty/any-promise/blob/c2029f9e37a15b04c303bd0ec19cf16d00ec8f3d/register.js#L13-L45 | train |
kevinbeaty/any-promise | register.js | shouldPreferGlobalPromise | function shouldPreferGlobalPromise(implementation){
if(implementation){
return implementation === 'global.Promise'
} else if(typeof global.Promise !== 'undefined'){
// Load global promise if implementation not specified
// Versions < 0.11 did not have global Promise
// Do not use for version < 0.12 ... | javascript | function shouldPreferGlobalPromise(implementation){
if(implementation){
return implementation === 'global.Promise'
} else if(typeof global.Promise !== 'undefined'){
// Load global promise if implementation not specified
// Versions < 0.11 did not have global Promise
// Do not use for version < 0.12 ... | [
"function",
"shouldPreferGlobalPromise",
"(",
"implementation",
")",
"{",
"if",
"(",
"implementation",
")",
"{",
"return",
"implementation",
"===",
"'global.Promise'",
"}",
"else",
"if",
"(",
"typeof",
"global",
".",
"Promise",
"!==",
"'undefined'",
")",
"{",
"/... | Determines if the global.Promise should be preferred if an implementation
has not been registered. | [
"Determines",
"if",
"the",
"global",
".",
"Promise",
"should",
"be",
"preferred",
"if",
"an",
"implementation",
"has",
"not",
"been",
"registered",
"."
] | c2029f9e37a15b04c303bd0ec19cf16d00ec8f3d | https://github.com/kevinbeaty/any-promise/blob/c2029f9e37a15b04c303bd0ec19cf16d00ec8f3d/register.js#L51-L64 | train |
kevinbeaty/any-promise | register.js | tryAutoDetect | function tryAutoDetect(){
var libs = [
"es6-promise",
"promise",
"native-promise-only",
"bluebird",
"rsvp",
"when",
"q",
"pinkie",
"lie",
"vow"]
var i = 0, len = libs.length
for(; i < len; i++){
try {
return loadImplementation(libs[i])
} ca... | javascript | function tryAutoDetect(){
var libs = [
"es6-promise",
"promise",
"native-promise-only",
"bluebird",
"rsvp",
"when",
"q",
"pinkie",
"lie",
"vow"]
var i = 0, len = libs.length
for(; i < len; i++){
try {
return loadImplementation(libs[i])
} ca... | [
"function",
"tryAutoDetect",
"(",
")",
"{",
"var",
"libs",
"=",
"[",
"\"es6-promise\"",
",",
"\"promise\"",
",",
"\"native-promise-only\"",
",",
"\"bluebird\"",
",",
"\"rsvp\"",
",",
"\"when\"",
",",
"\"q\"",
",",
"\"pinkie\"",
",",
"\"lie\"",
",",
"\"vow\"",
... | Look for common libs as last resort there is no guarantee that
this will return a desired implementation or even be deterministic.
The priority is also nearly arbitrary. We are only doing this
for older versions of Node.js <0.12 that do not have a reasonable
global.Promise implementation and we the user has not registe... | [
"Look",
"for",
"common",
"libs",
"as",
"last",
"resort",
"there",
"is",
"no",
"guarantee",
"that",
"this",
"will",
"return",
"a",
"desired",
"implementation",
"or",
"even",
"be",
"deterministic",
".",
"The",
"priority",
"is",
"also",
"nearly",
"arbitrary",
"... | c2029f9e37a15b04c303bd0ec19cf16d00ec8f3d | https://github.com/kevinbeaty/any-promise/blob/c2029f9e37a15b04c303bd0ec19cf16d00ec8f3d/register.js#L75-L94 | train |
ranm8/requestify | lib/request.js | Request | function Request(url, options) {
if (!url) {
throw new Error('URL must in mandatory to initialize Request object');
}
if (!options.method) {
throw new Error('Cannot execute HTTP request without specifying method');
}
this.url = url;
this.method = options.method;
this.body =... | javascript | function Request(url, options) {
if (!url) {
throw new Error('URL must in mandatory to initialize Request object');
}
if (!options.method) {
throw new Error('Cannot execute HTTP request without specifying method');
}
this.url = url;
this.method = options.method;
this.body =... | [
"function",
"Request",
"(",
"url",
",",
"options",
")",
"{",
"if",
"(",
"!",
"url",
")",
"{",
"throw",
"new",
"Error",
"(",
"'URL must in mandatory to initialize Request object'",
")",
";",
"}",
"if",
"(",
"!",
"options",
".",
"method",
")",
"{",
"throw",
... | Constructor for the Request object
@param {string} url - Full endpoint URL (e.g. [protocol]://[host]/[uri]
@param {{ method: string, body: string|object, params: object, headers: object, dataType: string, auth: object, timeout: number, cookies: object }} options
@constructor | [
"Constructor",
"for",
"the",
"Request",
"object"
] | c7ca8b716ad04f94a12d94d69b2fe3a838c3d6e6 | https://github.com/ranm8/requestify/blob/c7ca8b716ad04f94a12d94d69b2fe3a838c3d6e6/lib/request.js#L13-L34 | train |
ranm8/requestify | lib/response.js | Response | function Response(code, headers, body) {
this.code = code;
this.headers = headers;
this.body = body || '';
} | javascript | function Response(code, headers, body) {
this.code = code;
this.headers = headers;
this.body = body || '';
} | [
"function",
"Response",
"(",
"code",
",",
"headers",
",",
"body",
")",
"{",
"this",
".",
"code",
"=",
"code",
";",
"this",
".",
"headers",
"=",
"headers",
";",
"this",
".",
"body",
"=",
"body",
"||",
"''",
";",
"}"
] | Constructor to the Response object
@param {number} code - HTTP response code
@param {object} headers - Key value pairs of response headers
@param {string} body
@constructor | [
"Constructor",
"to",
"the",
"Response",
"object"
] | c7ca8b716ad04f94a12d94d69b2fe3a838c3d6e6 | https://github.com/ranm8/requestify/blob/c7ca8b716ad04f94a12d94d69b2fe3a838c3d6e6/lib/response.js#L15-L19 | train |
fractal-code/meteor-azure | distribution/lib/bundle.js | compileBundle | function compileBundle(_ref) {
var customWebConfig = _ref.customWebConfig,
architecture = _ref.architecture;
var workingDir = _tmp.default.dirSync().name;
_winston.default.info('Compiling application bundle'); // Generate Meteor build
_winston.default.debug('generate meteor build');
_shelljs.defaul... | javascript | function compileBundle(_ref) {
var customWebConfig = _ref.customWebConfig,
architecture = _ref.architecture;
var workingDir = _tmp.default.dirSync().name;
_winston.default.info('Compiling application bundle'); // Generate Meteor build
_winston.default.debug('generate meteor build');
_shelljs.defaul... | [
"function",
"compileBundle",
"(",
"_ref",
")",
"{",
"var",
"customWebConfig",
"=",
"_ref",
".",
"customWebConfig",
",",
"architecture",
"=",
"_ref",
".",
"architecture",
";",
"var",
"workingDir",
"=",
"_tmp",
".",
"default",
".",
"dirSync",
"(",
")",
".",
... | Bundle compilation method | [
"Bundle",
"compilation",
"method"
] | 87aaf8582be5734c78445c40569444101c02bc3f | https://github.com/fractal-code/meteor-azure/blob/87aaf8582be5734c78445c40569444101c02bc3f/distribution/lib/bundle.js#L21-L74 | train |
bryanburgers/node-mustache-express | mustache-express.js | loadFile | function loadFile(fullFilePath, callback) {
fs.readFile(fullFilePath, "utf-8", function(err, data) {
if (err) {
return callback(err);
}
return callback(null, data);
});
} | javascript | function loadFile(fullFilePath, callback) {
fs.readFile(fullFilePath, "utf-8", function(err, data) {
if (err) {
return callback(err);
}
return callback(null, data);
});
} | [
"function",
"loadFile",
"(",
"fullFilePath",
",",
"callback",
")",
"{",
"fs",
".",
"readFile",
"(",
"fullFilePath",
",",
"\"utf-8\"",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",... | Load a single file, and return the data. | [
"Load",
"a",
"single",
"file",
"and",
"return",
"the",
"data",
"."
] | 1700934e0ac510ee69225de226ccf4b4db41b65d | https://github.com/bryanburgers/node-mustache-express/blob/1700934e0ac510ee69225de226ccf4b4db41b65d/mustache-express.js#L17-L25 | train |
bryanburgers/node-mustache-express | mustache-express.js | handleFile | function handleFile(name, file, options, cache, callback) {
var cachedData;
if(!options || !options.settings || options.settings['view cache'] !== false) {
cachedData = cache && cache.get(file);
}
if (!cachedData) {
loadFile(file, function(err, fileData) {
if (err) {
return callback(err);
}
var pa... | javascript | function handleFile(name, file, options, cache, callback) {
var cachedData;
if(!options || !options.settings || options.settings['view cache'] !== false) {
cachedData = cache && cache.get(file);
}
if (!cachedData) {
loadFile(file, function(err, fileData) {
if (err) {
return callback(err);
}
var pa... | [
"function",
"handleFile",
"(",
"name",
",",
"file",
",",
"options",
",",
"cache",
",",
"callback",
")",
"{",
"var",
"cachedData",
";",
"if",
"(",
"!",
"options",
"||",
"!",
"options",
".",
"settings",
"||",
"options",
".",
"settings",
"[",
"'view cache'"... | Load a file, find it's partials, and return the relevant data. | [
"Load",
"a",
"file",
"find",
"it",
"s",
"partials",
"and",
"return",
"the",
"relevant",
"data",
"."
] | 1700934e0ac510ee69225de226ccf4b4db41b65d | https://github.com/bryanburgers/node-mustache-express/blob/1700934e0ac510ee69225de226ccf4b4db41b65d/mustache-express.js#L28-L60 | train |
bryanburgers/node-mustache-express | mustache-express.js | consolidatePartials | function consolidatePartials(arr) {
var partialsSet = {};
arr.forEach(function(item) {
item.partials.forEach(function(partial) {
partialsSet[partial] = true;
});
});
return Object.keys(partialsSet);
} | javascript | function consolidatePartials(arr) {
var partialsSet = {};
arr.forEach(function(item) {
item.partials.forEach(function(partial) {
partialsSet[partial] = true;
});
});
return Object.keys(partialsSet);
} | [
"function",
"consolidatePartials",
"(",
"arr",
")",
"{",
"var",
"partialsSet",
"=",
"{",
"}",
";",
"arr",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"item",
".",
"partials",
".",
"forEach",
"(",
"function",
"(",
"partial",
")",
"{",
"parti... | Using the return data from all of the files, consolidate the partials into a single list | [
"Using",
"the",
"return",
"data",
"from",
"all",
"of",
"the",
"files",
"consolidate",
"the",
"partials",
"into",
"a",
"single",
"list"
] | 1700934e0ac510ee69225de226ccf4b4db41b65d | https://github.com/bryanburgers/node-mustache-express/blob/1700934e0ac510ee69225de226ccf4b4db41b65d/mustache-express.js#L64-L72 | train |
bryanburgers/node-mustache-express | mustache-express.js | loadAllPartials | function loadAllPartials(unparsedPartials, partialsDirectory, partialsExtension, options, cache, partials, callback) {
if (!partials) {
partials = {};
}
// This function is called recursively. This is our base case: the point where we
// don't call recursively anymore.
// That point is when there are no partial... | javascript | function loadAllPartials(unparsedPartials, partialsDirectory, partialsExtension, options, cache, partials, callback) {
if (!partials) {
partials = {};
}
// This function is called recursively. This is our base case: the point where we
// don't call recursively anymore.
// That point is when there are no partial... | [
"function",
"loadAllPartials",
"(",
"unparsedPartials",
",",
"partialsDirectory",
",",
"partialsExtension",
",",
"options",
",",
"cache",
",",
"partials",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"partials",
")",
"{",
"partials",
"=",
"{",
"}",
";",
"}",
... | Load all of the partials recursively | [
"Load",
"all",
"of",
"the",
"partials",
"recursively"
] | 1700934e0ac510ee69225de226ccf4b4db41b65d | https://github.com/bryanburgers/node-mustache-express/blob/1700934e0ac510ee69225de226ccf4b4db41b65d/mustache-express.js#L82-L121 | train |
bryanburgers/node-mustache-express | mustache-express.js | loadTemplateAndPartials | function loadTemplateAndPartials(templateFile, partialsDirectory, partialsExtension, options, cache, callback) {
handleFile(null, templateFile, options, cache, function(err, partialData) {
if (err) {
return callback(err);
}
return loadAllPartials(partialData.partials, partialsDirectory, partialsExtension, op... | javascript | function loadTemplateAndPartials(templateFile, partialsDirectory, partialsExtension, options, cache, callback) {
handleFile(null, templateFile, options, cache, function(err, partialData) {
if (err) {
return callback(err);
}
return loadAllPartials(partialData.partials, partialsDirectory, partialsExtension, op... | [
"function",
"loadTemplateAndPartials",
"(",
"templateFile",
",",
"partialsDirectory",
",",
"partialsExtension",
",",
"options",
",",
"cache",
",",
"callback",
")",
"{",
"handleFile",
"(",
"null",
",",
"templateFile",
",",
"options",
",",
"cache",
",",
"function",
... | Load the root template, and all of the partials that go with it | [
"Load",
"the",
"root",
"template",
"and",
"all",
"of",
"the",
"partials",
"that",
"go",
"with",
"it"
] | 1700934e0ac510ee69225de226ccf4b4db41b65d | https://github.com/bryanburgers/node-mustache-express/blob/1700934e0ac510ee69225de226ccf4b4db41b65d/mustache-express.js#L124-L138 | train |
jaredhanson/oauthorize | examples/express2/auth.js | function(consumerKey, done) {
db.clients.findByConsumerKey(consumerKey, function(err, client) {
if (err) { return done(err); }
if (!client) { return done(null, false); }
return done(null, client, client.consumerSecret);
});
} | javascript | function(consumerKey, done) {
db.clients.findByConsumerKey(consumerKey, function(err, client) {
if (err) { return done(err); }
if (!client) { return done(null, false); }
return done(null, client, client.consumerSecret);
});
} | [
"function",
"(",
"consumerKey",
",",
"done",
")",
"{",
"db",
".",
"clients",
".",
"findByConsumerKey",
"(",
"consumerKey",
",",
"function",
"(",
"err",
",",
"client",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"done",
"(",
"err",
")",
";",
"}",
... | consumer callback This callback finds the registered client associated with `consumerKey`. The client should be supplied to the `done` callback as the second argument, and the consumer secret known by the server should be supplied as the third argument. The `ConsumerStrategy` will use this secret to validate the requ... | [
"consumer",
"callback",
"This",
"callback",
"finds",
"the",
"registered",
"client",
"associated",
"with",
"consumerKey",
".",
"The",
"client",
"should",
"be",
"supplied",
"to",
"the",
"done",
"callback",
"as",
"the",
"second",
"argument",
"and",
"the",
"consumer... | 3d9438c871f810fdec269596ccd40148dab31420 | https://github.com/jaredhanson/oauthorize/blob/3d9438c871f810fdec269596ccd40148dab31420/examples/express2/auth.js#L57-L63 | train | |
jaredhanson/oauthorize | examples/express2/auth.js | function(requestToken, done) {
db.requestTokens.find(requestToken, function(err, token) {
if (err) { return done(err); }
var info = { verifier: token.verifier,
clientID: token.clientID,
userID: token.userID,
approved: token.approved
}
done(null, token.secret, i... | javascript | function(requestToken, done) {
db.requestTokens.find(requestToken, function(err, token) {
if (err) { return done(err); }
var info = { verifier: token.verifier,
clientID: token.clientID,
userID: token.userID,
approved: token.approved
}
done(null, token.secret, i... | [
"function",
"(",
"requestToken",
",",
"done",
")",
"{",
"db",
".",
"requestTokens",
".",
"find",
"(",
"requestToken",
",",
"function",
"(",
"err",
",",
"token",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"done",
"(",
"err",
")",
";",
"}",
"var... | token callback This callback finds the request token identified by `requestToken`. This is typically only invoked when a client is exchanging a request token for an access token. The `done` callback accepts the corresponding token secret as the second argument. The `ConsumerStrategy` will use this secret to validat... | [
"token",
"callback",
"This",
"callback",
"finds",
"the",
"request",
"token",
"identified",
"by",
"requestToken",
".",
"This",
"is",
"typically",
"only",
"invoked",
"when",
"a",
"client",
"is",
"exchanging",
"a",
"request",
"token",
"for",
"an",
"access",
"toke... | 3d9438c871f810fdec269596ccd40148dab31420 | https://github.com/jaredhanson/oauthorize/blob/3d9438c871f810fdec269596ccd40148dab31420/examples/express2/auth.js#L80-L91 | train | |
patrickkettner/grunt-compile-handlebars | tasks/compile-handlebars.js | function(config) {
if (!config) {
return [];
}
var files = grunt.file.expand(config);
if (files.length) {
return files;
}
return [config];
} | javascript | function(config) {
if (!config) {
return [];
}
var files = grunt.file.expand(config);
if (files.length) {
return files;
}
return [config];
} | [
"function",
"(",
"config",
")",
"{",
"if",
"(",
"!",
"config",
")",
"{",
"return",
"[",
"]",
";",
"}",
"var",
"files",
"=",
"grunt",
".",
"file",
".",
"expand",
"(",
"config",
")",
";",
"if",
"(",
"files",
".",
"length",
")",
"{",
"return",
"fi... | Normalizes the input so that it is always an array for the forEach loop | [
"Normalizes",
"the",
"input",
"so",
"that",
"it",
"is",
"always",
"an",
"array",
"for",
"the",
"forEach",
"loop"
] | 92d7fb401340892a8f04d497d4e1508c9ed1f8bb | https://github.com/patrickkettner/grunt-compile-handlebars/blob/92d7fb401340892a8f04d497d4e1508c9ed1f8bb/tasks/compile-handlebars.js#L22-L34 | train | |
patrickkettner/grunt-compile-handlebars | tasks/compile-handlebars.js | function(data, dontParse) {
// grunt.file chokes on objects, so we check for it immiedietly
if (typeof data === 'object') {
return data;
}
// `data` isn't an object, so its probably a file
try {
// alce allows us to parse single-quote JSON (which is tehcnically invalid, and thereby chok... | javascript | function(data, dontParse) {
// grunt.file chokes on objects, so we check for it immiedietly
if (typeof data === 'object') {
return data;
}
// `data` isn't an object, so its probably a file
try {
// alce allows us to parse single-quote JSON (which is tehcnically invalid, and thereby chok... | [
"function",
"(",
"data",
",",
"dontParse",
")",
"{",
"// grunt.file chokes on objects, so we check for it immiedietly",
"if",
"(",
"typeof",
"data",
"===",
"'object'",
")",
"{",
"return",
"data",
";",
"}",
"// `data` isn't an object, so its probably a file",
"try",
"{",
... | Gets the final representation of the input, whether it be object, or string | [
"Gets",
"the",
"final",
"representation",
"of",
"the",
"input",
"whether",
"it",
"be",
"object",
"or",
"string"
] | 92d7fb401340892a8f04d497d4e1508c9ed1f8bb | https://github.com/patrickkettner/grunt-compile-handlebars/blob/92d7fb401340892a8f04d497d4e1508c9ed1f8bb/tasks/compile-handlebars.js#L37-L54 | train | |
patrickkettner/grunt-compile-handlebars | tasks/compile-handlebars.js | function(filename) {
if (!filename || typeof filename === 'object') {
return;
}
var match = filename.match(/[^\*]*/);
if (match[0] !== filename) {
return match.pop();
}
} | javascript | function(filename) {
if (!filename || typeof filename === 'object') {
return;
}
var match = filename.match(/[^\*]*/);
if (match[0] !== filename) {
return match.pop();
}
} | [
"function",
"(",
"filename",
")",
"{",
"if",
"(",
"!",
"filename",
"||",
"typeof",
"filename",
"===",
"'object'",
")",
"{",
"return",
";",
"}",
"var",
"match",
"=",
"filename",
".",
"match",
"(",
"/",
"[^\\*]*",
"/",
")",
";",
"if",
"(",
"match",
"... | Checks if the input is a glob and if so, returns the unglobbed version of the filename | [
"Checks",
"if",
"the",
"input",
"is",
"a",
"glob",
"and",
"if",
"so",
"returns",
"the",
"unglobbed",
"version",
"of",
"the",
"filename"
] | 92d7fb401340892a8f04d497d4e1508c9ed1f8bb | https://github.com/patrickkettner/grunt-compile-handlebars/blob/92d7fb401340892a8f04d497d4e1508c9ed1f8bb/tasks/compile-handlebars.js#L57-L67 | train | |
patrickkettner/grunt-compile-handlebars | tasks/compile-handlebars.js | function(filename, template, outputInInput) {
var basename;
var glob;
template = Array.isArray(template) ? filename : template;
glob = isGlob(template);
if (outputInInput) {
basename = _toArray(filename.split('.').pop()) ;
} else if (glob) {
basename = filename.slice(glob.length, fi... | javascript | function(filename, template, outputInInput) {
var basename;
var glob;
template = Array.isArray(template) ? filename : template;
glob = isGlob(template);
if (outputInInput) {
basename = _toArray(filename.split('.').pop()) ;
} else if (glob) {
basename = filename.slice(glob.length, fi... | [
"function",
"(",
"filename",
",",
"template",
",",
"outputInInput",
")",
"{",
"var",
"basename",
";",
"var",
"glob",
";",
"template",
"=",
"Array",
".",
"isArray",
"(",
"template",
")",
"?",
"filename",
":",
"template",
";",
"glob",
"=",
"isGlob",
"(",
... | Figures out the name of the file before any globs are used, so the globbed outputs can be generated | [
"Figures",
"out",
"the",
"name",
"of",
"the",
"file",
"before",
"any",
"globs",
"are",
"used",
"so",
"the",
"globbed",
"outputs",
"can",
"be",
"generated"
] | 92d7fb401340892a8f04d497d4e1508c9ed1f8bb | https://github.com/patrickkettner/grunt-compile-handlebars/blob/92d7fb401340892a8f04d497d4e1508c9ed1f8bb/tasks/compile-handlebars.js#L70-L86 | train | |
hacdias/electron-menubar | positioner.js | calculateXAlign | function calculateXAlign (windowBounds, trayBounds, align) {
const display = getDisplay()
let x
switch (align) {
case 'right':
x = trayBounds.x
break
case 'left':
x = trayBounds.x + trayBounds.width - windowBounds.width
break
case 'center':
default:
x = Math.round(tr... | javascript | function calculateXAlign (windowBounds, trayBounds, align) {
const display = getDisplay()
let x
switch (align) {
case 'right':
x = trayBounds.x
break
case 'left':
x = trayBounds.x + trayBounds.width - windowBounds.width
break
case 'center':
default:
x = Math.round(tr... | [
"function",
"calculateXAlign",
"(",
"windowBounds",
",",
"trayBounds",
",",
"align",
")",
"{",
"const",
"display",
"=",
"getDisplay",
"(",
")",
"let",
"x",
"switch",
"(",
"align",
")",
"{",
"case",
"'right'",
":",
"x",
"=",
"trayBounds",
".",
"x",
"break... | Calculates the x position of the tray window
@param {Rectangle} windowBounds - electron BrowserWindow bounds of tray window to position
@param {Rectangle} trayBounds - tray bounds from electron Tray.getBounds()
@param {string} [align] - align left|center|right, default: center
@return {integer} - calculated x positio... | [
"Calculates",
"the",
"x",
"position",
"of",
"the",
"tray",
"window"
] | 57d850f2f53c4227df4413855907cbd48e28bc16 | https://github.com/hacdias/electron-menubar/blob/57d850f2f53c4227df4413855907cbd48e28bc16/positioner.js#L31-L56 | train |
hacdias/electron-menubar | positioner.js | calculateYAlign | function calculateYAlign (windowBounds, trayBounds, align) {
const display = getDisplay()
let y
switch (align) {
case 'up':
y = trayBounds.y + trayBounds.height - windowBounds.height
break
case 'down':
y = trayBounds.y
break
case 'center':
default:
y = Math.round((tr... | javascript | function calculateYAlign (windowBounds, trayBounds, align) {
const display = getDisplay()
let y
switch (align) {
case 'up':
y = trayBounds.y + trayBounds.height - windowBounds.height
break
case 'down':
y = trayBounds.y
break
case 'center':
default:
y = Math.round((tr... | [
"function",
"calculateYAlign",
"(",
"windowBounds",
",",
"trayBounds",
",",
"align",
")",
"{",
"const",
"display",
"=",
"getDisplay",
"(",
")",
"let",
"y",
"switch",
"(",
"align",
")",
"{",
"case",
"'up'",
":",
"y",
"=",
"trayBounds",
".",
"y",
"+",
"t... | Calculates the y position of the tray window
@param {Rectangle} windowBounds - electron BrowserWindow bounds
@param {Rectangle} trayBounds - tray bounds from electron Tray.getBounds()
@param {string} [align] - align up|middle|down, default: down
@return {integer} - calculated y position | [
"Calculates",
"the",
"y",
"position",
"of",
"the",
"tray",
"window"
] | 57d850f2f53c4227df4413855907cbd48e28bc16 | https://github.com/hacdias/electron-menubar/blob/57d850f2f53c4227df4413855907cbd48e28bc16/positioner.js#L67-L91 | train |
hacdias/electron-menubar | positioner.js | calculateByCursorPosition | function calculateByCursorPosition (windowBounds, display, cursor) {
let x = cursor.x
let y = cursor.y
if (x + windowBounds.width > display.bounds.width) {
// if window would overlap on right side of screen, align it to the left of the cursor
x -= windowBounds.width
}
if (y + windowBounds.height > d... | javascript | function calculateByCursorPosition (windowBounds, display, cursor) {
let x = cursor.x
let y = cursor.y
if (x + windowBounds.width > display.bounds.width) {
// if window would overlap on right side of screen, align it to the left of the cursor
x -= windowBounds.width
}
if (y + windowBounds.height > d... | [
"function",
"calculateByCursorPosition",
"(",
"windowBounds",
",",
"display",
",",
"cursor",
")",
"{",
"let",
"x",
"=",
"cursor",
".",
"x",
"let",
"y",
"=",
"cursor",
".",
"y",
"if",
"(",
"x",
"+",
"windowBounds",
".",
"width",
">",
"display",
".",
"bo... | Calculates the position of the tray window based on current cursor position
This method is used on linux where trayBounds are not available
@param {Rectangle} windowBounds - electron BrowserWindow bounds of tray window to position
@param {Eelectron.Display} display - display on which the cursor is currently
@param {Po... | [
"Calculates",
"the",
"position",
"of",
"the",
"tray",
"window",
"based",
"on",
"current",
"cursor",
"position",
"This",
"method",
"is",
"used",
"on",
"linux",
"where",
"trayBounds",
"are",
"not",
"available"
] | 57d850f2f53c4227df4413855907cbd48e28bc16 | https://github.com/hacdias/electron-menubar/blob/57d850f2f53c4227df4413855907cbd48e28bc16/positioner.js#L103-L121 | train |
robwierzbowski/node-pixrem | lib/pixrem.js | detectBrowser | function detectBrowser (browsers, browserQuery) {
var b = false;
browserQuery = browserslist(browserQuery);
for (var i = 0; i < browsers.length; i++) {
for (var j = 0; j < browserQuery.length; j++) {
if (browsers[i] === browserQuery[j]) {
b = true;
break;
}
}
if (b) { break... | javascript | function detectBrowser (browsers, browserQuery) {
var b = false;
browserQuery = browserslist(browserQuery);
for (var i = 0; i < browsers.length; i++) {
for (var j = 0; j < browserQuery.length; j++) {
if (browsers[i] === browserQuery[j]) {
b = true;
break;
}
}
if (b) { break... | [
"function",
"detectBrowser",
"(",
"browsers",
",",
"browserQuery",
")",
"{",
"var",
"b",
"=",
"false",
";",
"browserQuery",
"=",
"browserslist",
"(",
"browserQuery",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"browsers",
".",
"length",
... | Detect if one browser from the browserQuery is in browsers | [
"Detect",
"if",
"one",
"browser",
"from",
"the",
"browserQuery",
"is",
"in",
"browsers"
] | 80581f4416fd2d0962ee24d3203a310b7d520c1d | https://github.com/robwierzbowski/node-pixrem/blob/80581f4416fd2d0962ee24d3203a310b7d520c1d/lib/pixrem.js#L108-L121 | train |
robwierzbowski/node-pixrem | lib/pixrem.js | toPx | function toPx (value, decl, result) {
value = (typeof value === 'string' && value.indexOf('calc(') !== -1) ? calc(value) : value;
var parts = /^(\d*\.?\d+)([a-zA-Z%]*)$/.exec(value);
if (parts !== null) {
var number = parts[1];
var unit = parts[2];
if (unit === 'px' || unit === '') {
return p... | javascript | function toPx (value, decl, result) {
value = (typeof value === 'string' && value.indexOf('calc(') !== -1) ? calc(value) : value;
var parts = /^(\d*\.?\d+)([a-zA-Z%]*)$/.exec(value);
if (parts !== null) {
var number = parts[1];
var unit = parts[2];
if (unit === 'px' || unit === '') {
return p... | [
"function",
"toPx",
"(",
"value",
",",
"decl",
",",
"result",
")",
"{",
"value",
"=",
"(",
"typeof",
"value",
"===",
"'string'",
"&&",
"value",
".",
"indexOf",
"(",
"'calc('",
")",
"!==",
"-",
"1",
")",
"?",
"calc",
"(",
"value",
")",
":",
"value",... | Return a unitless pixel value from any root font-size value. | [
"Return",
"a",
"unitless",
"pixel",
"value",
"from",
"any",
"root",
"font",
"-",
"size",
"value",
"."
] | 80581f4416fd2d0962ee24d3203a310b7d520c1d | https://github.com/robwierzbowski/node-pixrem/blob/80581f4416fd2d0962ee24d3203a310b7d520c1d/lib/pixrem.js#L124-L147 | train |
mikolalysenko/box-intersect | lib/intersect.js | iterInit | function iterInit(d, count) {
var levels = (8 * bits.log2(count+1) * (d+1))|0
var maxInts = bits.nextPow2(IFRAME_SIZE*levels)
if(BOX_ISTACK.length < maxInts) {
pool.free(BOX_ISTACK)
BOX_ISTACK = pool.mallocInt32(maxInts)
}
var maxDoubles = bits.nextPow2(DFRAME_SIZE*levels)
if(BOX_DSTACK.length < max... | javascript | function iterInit(d, count) {
var levels = (8 * bits.log2(count+1) * (d+1))|0
var maxInts = bits.nextPow2(IFRAME_SIZE*levels)
if(BOX_ISTACK.length < maxInts) {
pool.free(BOX_ISTACK)
BOX_ISTACK = pool.mallocInt32(maxInts)
}
var maxDoubles = bits.nextPow2(DFRAME_SIZE*levels)
if(BOX_DSTACK.length < max... | [
"function",
"iterInit",
"(",
"d",
",",
"count",
")",
"{",
"var",
"levels",
"=",
"(",
"8",
"*",
"bits",
".",
"log2",
"(",
"count",
"+",
"1",
")",
"*",
"(",
"d",
"+",
"1",
")",
")",
"|",
"0",
"var",
"maxInts",
"=",
"bits",
".",
"nextPow2",
"(",... | Initialize iterative loop queue | [
"Initialize",
"iterative",
"loop",
"queue"
] | 7e6770bab1fb90217a92eec4b8e0f4c293a71801 | https://github.com/mikolalysenko/box-intersect/blob/7e6770bab1fb90217a92eec4b8e0f4c293a71801/lib/intersect.js#L54-L66 | train |
mikolalysenko/box-intersect | lib/intersect.js | iterPush | function iterPush(ptr,
axis,
redStart, redEnd,
blueStart, blueEnd,
state,
lo, hi) {
var iptr = IFRAME_SIZE * ptr
BOX_ISTACK[iptr] = axis
BOX_ISTACK[iptr+1] = redStart
BOX_ISTACK[iptr+2] = redEnd
BOX_ISTACK[iptr+3] = blueStart
BOX_ISTACK[iptr+4] = blueEnd
BOX_ISTACK[iptr+5] = state
var ... | javascript | function iterPush(ptr,
axis,
redStart, redEnd,
blueStart, blueEnd,
state,
lo, hi) {
var iptr = IFRAME_SIZE * ptr
BOX_ISTACK[iptr] = axis
BOX_ISTACK[iptr+1] = redStart
BOX_ISTACK[iptr+2] = redEnd
BOX_ISTACK[iptr+3] = blueStart
BOX_ISTACK[iptr+4] = blueEnd
BOX_ISTACK[iptr+5] = state
var ... | [
"function",
"iterPush",
"(",
"ptr",
",",
"axis",
",",
"redStart",
",",
"redEnd",
",",
"blueStart",
",",
"blueEnd",
",",
"state",
",",
"lo",
",",
"hi",
")",
"{",
"var",
"iptr",
"=",
"IFRAME_SIZE",
"*",
"ptr",
"BOX_ISTACK",
"[",
"iptr",
"]",
"=",
"axis... | Append item to queue | [
"Append",
"item",
"to",
"queue"
] | 7e6770bab1fb90217a92eec4b8e0f4c293a71801 | https://github.com/mikolalysenko/box-intersect/blob/7e6770bab1fb90217a92eec4b8e0f4c293a71801/lib/intersect.js#L69-L87 | train |
mikolalysenko/box-intersect | index.js | convertBoxes | function convertBoxes(boxes, d, data, ids) {
var ptr = 0
var count = 0
for(var i=0, n=boxes.length; i<n; ++i) {
var b = boxes[i]
if(boxEmpty(d, b)) {
continue
}
for(var j=0; j<2*d; ++j) {
data[ptr++] = b[j]
}
ids[count++] = i
}
return count
} | javascript | function convertBoxes(boxes, d, data, ids) {
var ptr = 0
var count = 0
for(var i=0, n=boxes.length; i<n; ++i) {
var b = boxes[i]
if(boxEmpty(d, b)) {
continue
}
for(var j=0; j<2*d; ++j) {
data[ptr++] = b[j]
}
ids[count++] = i
}
return count
} | [
"function",
"convertBoxes",
"(",
"boxes",
",",
"d",
",",
"data",
",",
"ids",
")",
"{",
"var",
"ptr",
"=",
"0",
"var",
"count",
"=",
"0",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"n",
"=",
"boxes",
".",
"length",
";",
"i",
"<",
"n",
";",
"++",
... | Unpack boxes into a flat typed array, remove empty boxes | [
"Unpack",
"boxes",
"into",
"a",
"flat",
"typed",
"array",
"remove",
"empty",
"boxes"
] | 7e6770bab1fb90217a92eec4b8e0f4c293a71801 | https://github.com/mikolalysenko/box-intersect/blob/7e6770bab1fb90217a92eec4b8e0f4c293a71801/index.js#L19-L33 | train |
mikolalysenko/box-intersect | index.js | boxIntersect | function boxIntersect(red, blue, visit, full) {
var n = red.length
var m = blue.length
//If either array is empty, then we can skip this whole thing
if(n <= 0 || m <= 0) {
return
}
//Compute dimension, if it is 0 then we skip
var d = (red[0].length)>>>1
if(d <= 0) {
return
}
var retval
... | javascript | function boxIntersect(red, blue, visit, full) {
var n = red.length
var m = blue.length
//If either array is empty, then we can skip this whole thing
if(n <= 0 || m <= 0) {
return
}
//Compute dimension, if it is 0 then we skip
var d = (red[0].length)>>>1
if(d <= 0) {
return
}
var retval
... | [
"function",
"boxIntersect",
"(",
"red",
",",
"blue",
",",
"visit",
",",
"full",
")",
"{",
"var",
"n",
"=",
"red",
".",
"length",
"var",
"m",
"=",
"blue",
".",
"length",
"//If either array is empty, then we can skip this whole thing",
"if",
"(",
"n",
"<=",
"0... | Perform type conversions, check bounds | [
"Perform",
"type",
"conversions",
"check",
"bounds"
] | 7e6770bab1fb90217a92eec4b8e0f4c293a71801 | https://github.com/mikolalysenko/box-intersect/blob/7e6770bab1fb90217a92eec4b8e0f4c293a71801/index.js#L36-L100 | train |
mikolalysenko/box-intersect | index.js | boxIntersectWrapper | function boxIntersectWrapper(arg0, arg1, arg2) {
var result
switch(arguments.length) {
case 1:
return intersectFullArray(arg0)
case 2:
if(typeof arg1 === 'function') {
return boxIntersect(arg0, arg0, arg1, true)
} else {
return intersectBipartiteArray(arg0, arg1)
}
... | javascript | function boxIntersectWrapper(arg0, arg1, arg2) {
var result
switch(arguments.length) {
case 1:
return intersectFullArray(arg0)
case 2:
if(typeof arg1 === 'function') {
return boxIntersect(arg0, arg0, arg1, true)
} else {
return intersectBipartiteArray(arg0, arg1)
}
... | [
"function",
"boxIntersectWrapper",
"(",
"arg0",
",",
"arg1",
",",
"arg2",
")",
"{",
"var",
"result",
"switch",
"(",
"arguments",
".",
"length",
")",
"{",
"case",
"1",
":",
"return",
"intersectFullArray",
"(",
"arg0",
")",
"case",
"2",
":",
"if",
"(",
"... | User-friendly wrapper, handle full input and no-visitor cases | [
"User",
"-",
"friendly",
"wrapper",
"handle",
"full",
"input",
"and",
"no",
"-",
"visitor",
"cases"
] | 7e6770bab1fb90217a92eec4b8e0f4c293a71801 | https://github.com/mikolalysenko/box-intersect/blob/7e6770bab1fb90217a92eec4b8e0f4c293a71801/index.js#L122-L138 | train |
mikolalysenko/box-intersect | lib/sweep.js | sqInit | function sqInit(count) {
var rcount = bits.nextPow2(count)
if(RED_SWEEP_QUEUE.length < rcount) {
pool.free(RED_SWEEP_QUEUE)
RED_SWEEP_QUEUE = pool.mallocInt32(rcount)
}
if(RED_SWEEP_INDEX.length < rcount) {
pool.free(RED_SWEEP_INDEX)
RED_SWEEP_INDEX = pool.mallocInt32(rcount)
}
if(BLUE_SWEEP... | javascript | function sqInit(count) {
var rcount = bits.nextPow2(count)
if(RED_SWEEP_QUEUE.length < rcount) {
pool.free(RED_SWEEP_QUEUE)
RED_SWEEP_QUEUE = pool.mallocInt32(rcount)
}
if(RED_SWEEP_INDEX.length < rcount) {
pool.free(RED_SWEEP_INDEX)
RED_SWEEP_INDEX = pool.mallocInt32(rcount)
}
if(BLUE_SWEEP... | [
"function",
"sqInit",
"(",
"count",
")",
"{",
"var",
"rcount",
"=",
"bits",
".",
"nextPow2",
"(",
"count",
")",
"if",
"(",
"RED_SWEEP_QUEUE",
".",
"length",
"<",
"rcount",
")",
"{",
"pool",
".",
"free",
"(",
"RED_SWEEP_QUEUE",
")",
"RED_SWEEP_QUEUE",
"="... | Reserves memory for the 1D sweep data structures | [
"Reserves",
"memory",
"for",
"the",
"1D",
"sweep",
"data",
"structures"
] | 7e6770bab1fb90217a92eec4b8e0f4c293a71801 | https://github.com/mikolalysenko/box-intersect/blob/7e6770bab1fb90217a92eec4b8e0f4c293a71801/lib/sweep.js#L29-L60 | train |
dmarcos/aframe-motion-capture-components | src/components/motion-capture-replayer.js | function (delta) {
var currentPose;
var currentEvent
var playingPoses = this.playingPoses;
var playingEvents = this.playingEvents;
currentPose = playingPoses && playingPoses[this.currentPoseIndex]
currentEvent = playingEvents && playingEvents[this.currentEventIndex];
this.currentPoseTime += ... | javascript | function (delta) {
var currentPose;
var currentEvent
var playingPoses = this.playingPoses;
var playingEvents = this.playingEvents;
currentPose = playingPoses && playingPoses[this.currentPoseIndex]
currentEvent = playingEvents && playingEvents[this.currentEventIndex];
this.currentPoseTime += ... | [
"function",
"(",
"delta",
")",
"{",
"var",
"currentPose",
";",
"var",
"currentEvent",
"var",
"playingPoses",
"=",
"this",
".",
"playingPoses",
";",
"var",
"playingEvents",
"=",
"this",
".",
"playingEvents",
";",
"currentPose",
"=",
"playingPoses",
"&&",
"playi... | Called on tick. | [
"Called",
"on",
"tick",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/motion-capture-replayer.js#L164-L202 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-replayer.js | function () {
var data = this.data;
var sceneEl = this.el;
if (data.cameraOverride) {
// Specify which camera is the original camera (e.g., used by Inspector).
this.cameraEl = data.cameraOverride;
} else {
// Default camera.
this.cameraEl = sceneEl.camera.el;
// Make sure ... | javascript | function () {
var data = this.data;
var sceneEl = this.el;
if (data.cameraOverride) {
// Specify which camera is the original camera (e.g., used by Inspector).
this.cameraEl = data.cameraOverride;
} else {
// Default camera.
this.cameraEl = sceneEl.camera.el;
// Make sure ... | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"sceneEl",
"=",
"this",
".",
"el",
";",
"if",
"(",
"data",
".",
"cameraOverride",
")",
"{",
"// Specify which camera is the original camera (e.g., used by Inspector).",
"this",
".",
... | Grab a handle to the "original" camera.
Initialize spectator camera and dummy geometry for original camera. | [
"Grab",
"a",
"handle",
"to",
"the",
"original",
"camera",
".",
"Initialize",
"spectator",
"camera",
"and",
"dummy",
"geometry",
"for",
"original",
"camera",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-replayer.js#L83-L104 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-replayer.js | function () {
var spectatorCameraEl = this.spectatorCameraEl;
if (!spectatorCameraEl) {
this.el.addEventListener('spectatorcameracreated',
bind(this.activateSpectatorCamera, this));
return;
}
if (!spectatorCameraEl.hasLoaded) {
spectatorCameraEl.addEven... | javascript | function () {
var spectatorCameraEl = this.spectatorCameraEl;
if (!spectatorCameraEl) {
this.el.addEventListener('spectatorcameracreated',
bind(this.activateSpectatorCamera, this));
return;
}
if (!spectatorCameraEl.hasLoaded) {
spectatorCameraEl.addEven... | [
"function",
"(",
")",
"{",
"var",
"spectatorCameraEl",
"=",
"this",
".",
"spectatorCameraEl",
";",
"if",
"(",
"!",
"spectatorCameraEl",
")",
"{",
"this",
".",
"el",
".",
"addEventListener",
"(",
"'spectatorcameracreated'",
",",
"bind",
"(",
"this",
".",
"act... | Activate spectator camera, show replayer mesh. | [
"Activate",
"spectator",
"camera",
"show",
"replayer",
"mesh",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-replayer.js#L122-L139 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-replayer.js | function () {
var data = this.data;
var sceneEl = this.el;
var spectatorCameraEl;
var spectatorCameraRigEl;
// Developer-defined spectator rig.
if (this.el.querySelector('#spectatorCameraRig')) {
this.spectatorCameraEl = sceneEl.querySelector('#spectatorCameraRig');
return;
}
... | javascript | function () {
var data = this.data;
var sceneEl = this.el;
var spectatorCameraEl;
var spectatorCameraRigEl;
// Developer-defined spectator rig.
if (this.el.querySelector('#spectatorCameraRig')) {
this.spectatorCameraEl = sceneEl.querySelector('#spectatorCameraRig');
return;
}
... | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"sceneEl",
"=",
"this",
".",
"el",
";",
"var",
"spectatorCameraEl",
";",
"var",
"spectatorCameraRigEl",
";",
"// Developer-defined spectator rig.",
"if",
"(",
"this",
".",
"el",
... | Create and activate spectator camera if in spectator mode. | [
"Create",
"and",
"activate",
"spectator",
"camera",
"if",
"in",
"spectator",
"mode",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-replayer.js#L153-L185 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-replayer.js | function () {
var data = this.data;
var recordingdb = this.el.systems.recordingdb;;
var recordingNames;
var src;
var self = this;
// Allow override to display replayer from query param.
if (new URLSearchParams(window.location.search).get('avatar-replayer-disabled') !== null) {
return;... | javascript | function () {
var data = this.data;
var recordingdb = this.el.systems.recordingdb;;
var recordingNames;
var src;
var self = this;
// Allow override to display replayer from query param.
if (new URLSearchParams(window.location.search).get('avatar-replayer-disabled') !== null) {
return;... | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"recordingdb",
"=",
"this",
".",
"el",
".",
"systems",
".",
"recordingdb",
";",
";",
"var",
"recordingNames",
";",
"var",
"src",
";",
"var",
"self",
"=",
"this",
";",
"... | Check for recording sources and play. | [
"Check",
"for",
"recording",
"sources",
"and",
"play",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-replayer.js#L190-L231 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-replayer.js | function () {
var cameraEl = this.cameraEl;
var headMesh;
var leftEyeMesh;
var rightEyeMesh;
var leftEyeBallMesh;
var rightEyeBallMesh;
if (cameraEl.getObject3D('mesh') || cameraEl.getObject3D('replayerMesh')) { return; }
// Head.
headMesh = new THREE.Mesh();
headMesh.geometry ... | javascript | function () {
var cameraEl = this.cameraEl;
var headMesh;
var leftEyeMesh;
var rightEyeMesh;
var leftEyeBallMesh;
var rightEyeBallMesh;
if (cameraEl.getObject3D('mesh') || cameraEl.getObject3D('replayerMesh')) { return; }
// Head.
headMesh = new THREE.Mesh();
headMesh.geometry ... | [
"function",
"(",
")",
"{",
"var",
"cameraEl",
"=",
"this",
".",
"cameraEl",
";",
"var",
"headMesh",
";",
"var",
"leftEyeMesh",
";",
"var",
"rightEyeMesh",
";",
"var",
"leftEyeBallMesh",
";",
"var",
"rightEyeBallMesh",
";",
"if",
"(",
"cameraEl",
".",
"getO... | Create head geometry for spectator mode.
Always created in case we want to toggle, but only visible during spectator mode. | [
"Create",
"head",
"geometry",
"for",
"spectator",
"mode",
".",
"Always",
"created",
"in",
"case",
"we",
"want",
"to",
"toggle",
"but",
"only",
"visible",
"during",
"spectator",
"mode",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-replayer.js#L296-L341 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-replayer.js | function () {
var self = this;
if (!this.isReplaying || !this.replayData) { return; }
this.isReplaying = false;
Object.keys(this.replayData).forEach(function removeReplayer (key) {
if (key === 'camera') {
self.cameraEl.removeComponent('motion-capture-replayer');
} else {
el... | javascript | function () {
var self = this;
if (!this.isReplaying || !this.replayData) { return; }
this.isReplaying = false;
Object.keys(this.replayData).forEach(function removeReplayer (key) {
if (key === 'camera') {
self.cameraEl.removeComponent('motion-capture-replayer');
} else {
el... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"this",
".",
"isReplaying",
"||",
"!",
"this",
".",
"replayData",
")",
"{",
"return",
";",
"}",
"this",
".",
"isReplaying",
"=",
"false",
";",
"Object",
".",
"keys",
"(",
... | Remove motion-capture-replayer components. | [
"Remove",
"motion",
"-",
"capture",
"-",
"replayer",
"components",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-replayer.js#L346-L364 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-replayer.js | function (url, binary, callback) {
var data;
var self = this;
fileLoader.crossOrigin = 'anonymous';
if (binary === true) {
fileLoader.setResponseType('arraybuffer');
}
fileLoader.load(url, function (buffer) {
if (binary === true) {
data = self.loadStrokeBinary(buffer);
... | javascript | function (url, binary, callback) {
var data;
var self = this;
fileLoader.crossOrigin = 'anonymous';
if (binary === true) {
fileLoader.setResponseType('arraybuffer');
}
fileLoader.load(url, function (buffer) {
if (binary === true) {
data = self.loadStrokeBinary(buffer);
... | [
"function",
"(",
"url",
",",
"binary",
",",
"callback",
")",
"{",
"var",
"data",
";",
"var",
"self",
"=",
"this",
";",
"fileLoader",
".",
"crossOrigin",
"=",
"'anonymous'",
";",
"if",
"(",
"binary",
"===",
"true",
")",
"{",
"fileLoader",
".",
"setRespo... | XHR for data. | [
"XHR",
"for",
"data",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-replayer.js#L369-L384 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-recorder.js | function () {
var self = this;
var trackedControllerEls = this.el.querySelectorAll('[tracked-controls]');
this.trackedControllerEls = {};
trackedControllerEls.forEach(function setupController (trackedControllerEl) {
if (!trackedControllerEl.id) {
warn('Found a tracked controller entity wit... | javascript | function () {
var self = this;
var trackedControllerEls = this.el.querySelectorAll('[tracked-controls]');
this.trackedControllerEls = {};
trackedControllerEls.forEach(function setupController (trackedControllerEl) {
if (!trackedControllerEl.id) {
warn('Found a tracked controller entity wit... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"trackedControllerEls",
"=",
"this",
".",
"el",
".",
"querySelectorAll",
"(",
"'[tracked-controls]'",
")",
";",
"this",
".",
"trackedControllerEls",
"=",
"{",
"}",
";",
"trackedControllerEls",
... | Poll for tracked controllers. | [
"Poll",
"for",
"tracked",
"controllers",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-recorder.js#L33-L52 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-recorder.js | function (evt) {
var key = evt.keyCode;
var KEYS = {space: 32};
switch (key) {
// <space>: Toggle recording.
case KEYS.space: {
this.toggleRecording();
break;
}
}
} | javascript | function (evt) {
var key = evt.keyCode;
var KEYS = {space: 32};
switch (key) {
// <space>: Toggle recording.
case KEYS.space: {
this.toggleRecording();
break;
}
}
} | [
"function",
"(",
"evt",
")",
"{",
"var",
"key",
"=",
"evt",
".",
"keyCode",
";",
"var",
"KEYS",
"=",
"{",
"space",
":",
"32",
"}",
";",
"switch",
"(",
"key",
")",
"{",
"// <space>: Toggle recording.",
"case",
"KEYS",
".",
"space",
":",
"{",
"this",
... | Keyboard shortcuts. | [
"Keyboard",
"shortcuts",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-recorder.js#L65-L75 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-recorder.js | function (doneCb) {
var el = this.el;
var self = this;
if (this.data.cameraOverride) {
prepareCamera(this.data.cameraOverride);
return;
}
// Grab camera.
if (el.camera && el.camera.el) {
prepareCamera(el.camera.el);
return;
}
el.addEventListener('camera-set-act... | javascript | function (doneCb) {
var el = this.el;
var self = this;
if (this.data.cameraOverride) {
prepareCamera(this.data.cameraOverride);
return;
}
// Grab camera.
if (el.camera && el.camera.el) {
prepareCamera(el.camera.el);
return;
}
el.addEventListener('camera-set-act... | [
"function",
"(",
"doneCb",
")",
"{",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"this",
".",
"data",
".",
"cameraOverride",
")",
"{",
"prepareCamera",
"(",
"this",
".",
"data",
".",
"cameraOverride",
")",
... | Set motion capture recorder on the camera once the camera is ready. | [
"Set",
"motion",
"capture",
"recorder",
"on",
"the",
"camera",
"once",
"the",
"camera",
"is",
"ready",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-recorder.js#L91-L122 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-recorder.js | function () {
var trackedControllerEls = this.trackedControllerEls;
var self = this;
if (this.isRecording) { return; }
log('Starting recording!');
if (this.el.components['avatar-replayer']) {
this.el.components['avatar-replayer'].stopReplaying();
}
// Get camera.
this.setupCame... | javascript | function () {
var trackedControllerEls = this.trackedControllerEls;
var self = this;
if (this.isRecording) { return; }
log('Starting recording!');
if (this.el.components['avatar-replayer']) {
this.el.components['avatar-replayer'].stopReplaying();
}
// Get camera.
this.setupCame... | [
"function",
"(",
")",
"{",
"var",
"trackedControllerEls",
"=",
"this",
".",
"trackedControllerEls",
";",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"this",
".",
"isRecording",
")",
"{",
"return",
";",
"}",
"log",
"(",
"'Starting recording!'",
")",
";",
... | Start recording camera and tracked controls. | [
"Start",
"recording",
"camera",
"and",
"tracked",
"controls",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-recorder.js#L127-L149 | train | |
dmarcos/aframe-motion-capture-components | src/components/avatar-recorder.js | function () {
var trackedControllerEls = this.trackedControllerEls;
if (!this.isRecording) { return; }
log('Stopped recording.');
this.isRecording = false;
this.cameraEl.components['motion-capture-recorder'].stopRecording();
Object.keys(trackedControllerEls).forEach(function (id) {
track... | javascript | function () {
var trackedControllerEls = this.trackedControllerEls;
if (!this.isRecording) { return; }
log('Stopped recording.');
this.isRecording = false;
this.cameraEl.components['motion-capture-recorder'].stopRecording();
Object.keys(trackedControllerEls).forEach(function (id) {
track... | [
"function",
"(",
")",
"{",
"var",
"trackedControllerEls",
"=",
"this",
".",
"trackedControllerEls",
";",
"if",
"(",
"!",
"this",
".",
"isRecording",
")",
"{",
"return",
";",
"}",
"log",
"(",
"'Stopped recording.'",
")",
";",
"this",
".",
"isRecording",
"="... | Tell camera and tracked controls motion-capture-recorder components to stop recording.
Store recording and replay if autoPlay is on. | [
"Tell",
"camera",
"and",
"tracked",
"controls",
"motion",
"-",
"capture",
"-",
"recorder",
"components",
"to",
"stop",
"recording",
".",
"Store",
"recording",
"and",
"replay",
"if",
"autoPlay",
"is",
"on",
"."
] | 3a3cbd73ffc751285be95e9729a09121ff03c440 | https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-recorder.js#L155-L172 | 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.