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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
techfort/LokiJS | benchmark/benchmark_web.js | runStep | function runStep(step)
{
switch (step) {
case 1 :
trace("-- Beginning benchmark --");
initializeDB();
initializeUnique();
setTimeout(function() { runStep(2); }, 100);
break;
case 2 :
benchGet();
setTimeout(function() { runStep(3); }, 100);
break;
case 3 :... | javascript | function runStep(step)
{
switch (step) {
case 1 :
trace("-- Beginning benchmark --");
initializeDB();
initializeUnique();
setTimeout(function() { runStep(2); }, 100);
break;
case 2 :
benchGet();
setTimeout(function() { runStep(3); }, 100);
break;
case 3 :... | [
"function",
"runStep",
"(",
"step",
")",
"{",
"switch",
"(",
"step",
")",
"{",
"case",
"1",
":",
"trace",
"(",
"\"-- Beginning benchmark --\"",
")",
";",
"initializeDB",
"(",
")",
";",
"initializeUnique",
"(",
")",
";",
"setTimeout",
"(",
"function",
"(",
... | async yielding after each step to avoid browser warnings of long running scripts | [
"async",
"yielding",
"after",
"each",
"step",
"to",
"avoid",
"browser",
"warnings",
"of",
"long",
"running",
"scripts"
] | dda4764ee43b644c29779ab533ba0dc327838ff4 | https://github.com/techfort/LokiJS/blob/dda4764ee43b644c29779ab533ba0dc327838ff4/benchmark/benchmark_web.js#L294-L345 | train |
techfort/LokiJS | examples/quickstart2.js | databaseInitialize | function databaseInitialize() {
// on the first load of (non-existent database), we will have no collections so we can
// detect the absence of our collections and add (and configure) them now.
var entries = db.getCollection("entries");
if (entries === null) {
entries = db.addCollection("entries");
}
... | javascript | function databaseInitialize() {
// on the first load of (non-existent database), we will have no collections so we can
// detect the absence of our collections and add (and configure) them now.
var entries = db.getCollection("entries");
if (entries === null) {
entries = db.addCollection("entries");
}
... | [
"function",
"databaseInitialize",
"(",
")",
"{",
"// on the first load of (non-existent database), we will have no collections so we can ",
"// detect the absence of our collections and add (and configure) them now.",
"var",
"entries",
"=",
"db",
".",
"getCollection",
"(",
"\"entries\"... | implement the autoloadback referenced in loki constructor | [
"implement",
"the",
"autoloadback",
"referenced",
"in",
"loki",
"constructor"
] | dda4764ee43b644c29779ab533ba0dc327838ff4 | https://github.com/techfort/LokiJS/blob/dda4764ee43b644c29779ab533ba0dc327838ff4/examples/quickstart2.js#L17-L27 | train |
techfort/LokiJS | examples/quickstart4.js | runProgramLogic | function runProgramLogic() {
var entries = db.getCollection("entries");
var entryCount = entries.count();
var now = new Date();
console.log("old number of entries in database : " + entryCount);
entries.insert({ x: now.getTime(), y: 100 - entryCount });
entryCount = entries.count();
console.log("new num... | javascript | function runProgramLogic() {
var entries = db.getCollection("entries");
var entryCount = entries.count();
var now = new Date();
console.log("old number of entries in database : " + entryCount);
entries.insert({ x: now.getTime(), y: 100 - entryCount });
entryCount = entries.count();
console.log("new num... | [
"function",
"runProgramLogic",
"(",
")",
"{",
"var",
"entries",
"=",
"db",
".",
"getCollection",
"(",
"\"entries\"",
")",
";",
"var",
"entryCount",
"=",
"entries",
".",
"count",
"(",
")",
";",
"var",
"now",
"=",
"new",
"Date",
"(",
")",
";",
"console",... | place any bootstrap logic which needs to be run after loadDatabase has completed | [
"place",
"any",
"bootstrap",
"logic",
"which",
"needs",
"to",
"be",
"run",
"after",
"loadDatabase",
"has",
"completed"
] | dda4764ee43b644c29779ab533ba0dc327838ff4 | https://github.com/techfort/LokiJS/blob/dda4764ee43b644c29779ab533ba0dc327838ff4/examples/quickstart4.js#L35-L57 | train |
techfort/LokiJS | examples/quickstart3.js | databaseInitialize | function databaseInitialize() {
var entries = db.getCollection("entries");
var messages = db.getCollection("messages");
// Since our LokiFsStructuredAdapter is partitioned, the default 'quickstart3.db'
// file will actually contain only the loki database shell and each of the collections
// will be saved int... | javascript | function databaseInitialize() {
var entries = db.getCollection("entries");
var messages = db.getCollection("messages");
// Since our LokiFsStructuredAdapter is partitioned, the default 'quickstart3.db'
// file will actually contain only the loki database shell and each of the collections
// will be saved int... | [
"function",
"databaseInitialize",
"(",
")",
"{",
"var",
"entries",
"=",
"db",
".",
"getCollection",
"(",
"\"entries\"",
")",
";",
"var",
"messages",
"=",
"db",
".",
"getCollection",
"(",
"\"messages\"",
")",
";",
"// Since our LokiFsStructuredAdapter is partitioned,... | Now let's implement the autoload callback referenced in loki constructor | [
"Now",
"let",
"s",
"implement",
"the",
"autoload",
"callback",
"referenced",
"in",
"loki",
"constructor"
] | dda4764ee43b644c29779ab533ba0dc327838ff4 | https://github.com/techfort/LokiJS/blob/dda4764ee43b644c29779ab533ba0dc327838ff4/examples/quickstart3.js#L29-L54 | train |
techfort/LokiJS | examples/loki-continuum.js | Balance | function Balance(amount, balanceDate, description, affectingActor) {
this.amount = amount;
this.balanceDate = balanceDate;
this.description = description;
this.affectingActor = affectingActor;
} | javascript | function Balance(amount, balanceDate, description, affectingActor) {
this.amount = amount;
this.balanceDate = balanceDate;
this.description = description;
this.affectingActor = affectingActor;
} | [
"function",
"Balance",
"(",
"amount",
",",
"balanceDate",
",",
"description",
",",
"affectingActor",
")",
"{",
"this",
".",
"amount",
"=",
"amount",
";",
"this",
".",
"balanceDate",
"=",
"balanceDate",
";",
"this",
".",
"description",
"=",
"description",
";"... | consolidating Balance and Tranction classes transactions inherited balance and added 'affectingActor' reference | [
"consolidating",
"Balance",
"and",
"Tranction",
"classes",
"transactions",
"inherited",
"balance",
"and",
"added",
"affectingActor",
"reference"
] | dda4764ee43b644c29779ab533ba0dc327838ff4 | https://github.com/techfort/LokiJS/blob/dda4764ee43b644c29779ab533ba0dc327838ff4/examples/loki-continuum.js#L221-L226 | train |
techfort/LokiJS | spec/generic/transforms.spec.js | fdmap | function fdmap(left, right) {
// PhantomJS does not support es6 Object.assign
//left = Object.assign(left, right);
Object.keys(right).forEach(function(key) {
left[key] = right[key];
});
return left;
} | javascript | function fdmap(left, right) {
// PhantomJS does not support es6 Object.assign
//left = Object.assign(left, right);
Object.keys(right).forEach(function(key) {
left[key] = right[key];
});
return left;
} | [
"function",
"fdmap",
"(",
"left",
",",
"right",
")",
"{",
"// PhantomJS does not support es6 Object.assign",
"//left = Object.assign(left, right);",
"Object",
".",
"keys",
"(",
"right",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"left",
"[",
"key"... | Since our collection options do not specify cloning, this is only safe because we have cloned internal objects with dataOptions before modifying them. | [
"Since",
"our",
"collection",
"options",
"do",
"not",
"specify",
"cloning",
"this",
"is",
"only",
"safe",
"because",
"we",
"have",
"cloned",
"internal",
"objects",
"with",
"dataOptions",
"before",
"modifying",
"them",
"."
] | dda4764ee43b644c29779ab533ba0dc327838ff4 | https://github.com/techfort/LokiJS/blob/dda4764ee43b644c29779ab533ba0dc327838ff4/spec/generic/transforms.spec.js#L358-L365 | train |
techfort/LokiJS | benchmark/bindex-stress.js | createDatabase | function createDatabase() {
var idx, a, b;
db = new loki('sorting-bench.db');
coll = db.addCollection('profile', { indices: ['a', 'b', 'c'] });
for(idx=0;idx<INITIAL_DOCUMENT_COUNT;idx++) {
coll.insert(genRandomObject());
}
} | javascript | function createDatabase() {
var idx, a, b;
db = new loki('sorting-bench.db');
coll = db.addCollection('profile', { indices: ['a', 'b', 'c'] });
for(idx=0;idx<INITIAL_DOCUMENT_COUNT;idx++) {
coll.insert(genRandomObject());
}
} | [
"function",
"createDatabase",
"(",
")",
"{",
"var",
"idx",
",",
"a",
",",
"b",
";",
"db",
"=",
"new",
"loki",
"(",
"'sorting-bench.db'",
")",
";",
"coll",
"=",
"db",
".",
"addCollection",
"(",
"'profile'",
",",
"{",
"indices",
":",
"[",
"'a'",
",",
... | create database, collection, and seed initial documents | [
"create",
"database",
"collection",
"and",
"seed",
"initial",
"documents"
] | dda4764ee43b644c29779ab533ba0dc327838ff4 | https://github.com/techfort/LokiJS/blob/dda4764ee43b644c29779ab533ba0dc327838ff4/benchmark/bindex-stress.js#L29-L39 | train |
techfort/LokiJS | benchmark/benchmark_binary.js | initializeDatabase | function initializeDatabase(silent, docCount) {
var start, end, totalTime;
var totalTimes = [];
var totalMS = 0.0;
if (typeof docCount === "undefined") {
docCount = 5000;
}
arraySize = docCount;
for (var idx = 0; idx < arraySize; idx++) {
var v1 = genRandomVal();
var v2 = genRandomVal();
... | javascript | function initializeDatabase(silent, docCount) {
var start, end, totalTime;
var totalTimes = [];
var totalMS = 0.0;
if (typeof docCount === "undefined") {
docCount = 5000;
}
arraySize = docCount;
for (var idx = 0; idx < arraySize; idx++) {
var v1 = genRandomVal();
var v2 = genRandomVal();
... | [
"function",
"initializeDatabase",
"(",
"silent",
",",
"docCount",
")",
"{",
"var",
"start",
",",
"end",
",",
"totalTime",
";",
"var",
"totalTimes",
"=",
"[",
"]",
";",
"var",
"totalMS",
"=",
"0.0",
";",
"if",
"(",
"typeof",
"docCount",
"===",
"\"undefine... | scenario for many individual, consecutive inserts | [
"scenario",
"for",
"many",
"individual",
"consecutive",
"inserts"
] | dda4764ee43b644c29779ab533ba0dc327838ff4 | https://github.com/techfort/LokiJS/blob/dda4764ee43b644c29779ab533ba0dc327838ff4/benchmark/benchmark_binary.js#L61-L106 | train |
techfort/LokiJS | benchmark/benchmark_binary.js | perfFindInterlacedInserts | function perfFindInterlacedInserts(multiplier) {
var start, end;
var totalTimes = [];
var totalMS = 0;
var loopIterations = arraySize;
if (typeof (multiplier) != "undefined") {
loopIterations = loopIterations * multiplier;
}
for (var idx = 0; idx < loopIterations; idx++) {
var customidx = Math.f... | javascript | function perfFindInterlacedInserts(multiplier) {
var start, end;
var totalTimes = [];
var totalMS = 0;
var loopIterations = arraySize;
if (typeof (multiplier) != "undefined") {
loopIterations = loopIterations * multiplier;
}
for (var idx = 0; idx < loopIterations; idx++) {
var customidx = Math.f... | [
"function",
"perfFindInterlacedInserts",
"(",
"multiplier",
")",
"{",
"var",
"start",
",",
"end",
";",
"var",
"totalTimes",
"=",
"[",
"]",
";",
"var",
"totalMS",
"=",
"0",
";",
"var",
"loopIterations",
"=",
"arraySize",
";",
"if",
"(",
"typeof",
"(",
"mu... | Find Interlaced Inserts -> insert 5000, for 5000 more iterations insert same test obj after | [
"Find",
"Interlaced",
"Inserts",
"-",
">",
"insert",
"5000",
"for",
"5000",
"more",
"iterations",
"insert",
"same",
"test",
"obj",
"after"
] | dda4764ee43b644c29779ab533ba0dc327838ff4 | https://github.com/techfort/LokiJS/blob/dda4764ee43b644c29779ab533ba0dc327838ff4/benchmark/benchmark_binary.js#L186-L225 | train |
techfort/LokiJS | examples/quickstart-transforms.js | seedData | function seedData() {
var users = db.getCollection("users");
users.insert({ name: "odin", gender: "m", age: 1000, tags : ["woden", "knowlege", "sorcery", "frenzy", "runes"], items: ["gungnir"], attributes: { eyes: 1} });
users.insert({ name: "frigg", gender: "f", age: 800, tags: ["foreknowlege"], items: ["eski"]... | javascript | function seedData() {
var users = db.getCollection("users");
users.insert({ name: "odin", gender: "m", age: 1000, tags : ["woden", "knowlege", "sorcery", "frenzy", "runes"], items: ["gungnir"], attributes: { eyes: 1} });
users.insert({ name: "frigg", gender: "f", age: 800, tags: ["foreknowlege"], items: ["eski"]... | [
"function",
"seedData",
"(",
")",
"{",
"var",
"users",
"=",
"db",
".",
"getCollection",
"(",
"\"users\"",
")",
";",
"users",
".",
"insert",
"(",
"{",
"name",
":",
"\"odin\"",
",",
"gender",
":",
"\"m\"",
",",
"age",
":",
"1000",
",",
"tags",
":",
"... | example-specific seeding of user data | [
"example",
"-",
"specific",
"seeding",
"of",
"user",
"data"
] | dda4764ee43b644c29779ab533ba0dc327838ff4 | https://github.com/techfort/LokiJS/blob/dda4764ee43b644c29779ab533ba0dc327838ff4/examples/quickstart-transforms.js#L77-L89 | train |
JasonEtco/actions-toolkit | bin/create-action.js | readTemplate | async function readTemplate (filename) {
const templateDir = path.join(__dirname, 'template')
return readFile(path.join(templateDir, filename), 'utf8')
} | javascript | async function readTemplate (filename) {
const templateDir = path.join(__dirname, 'template')
return readFile(path.join(templateDir, filename), 'utf8')
} | [
"async",
"function",
"readTemplate",
"(",
"filename",
")",
"{",
"const",
"templateDir",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'template'",
")",
"return",
"readFile",
"(",
"path",
".",
"join",
"(",
"templateDir",
",",
"filename",
")",
",",
"'utf... | Reads a template file from disk.
@param {string} filename The template filename to read.
@returns {Promise<string>} The template file string contents. | [
"Reads",
"a",
"template",
"file",
"from",
"disk",
"."
] | 294ac11efd551cc382f3fed79c190e536069d6ce | https://github.com/JasonEtco/actions-toolkit/blob/294ac11efd551cc382f3fed79c190e536069d6ce/bin/create-action.js#L20-L23 | train |
JasonEtco/actions-toolkit | bin/create-action.js | createDockerfile | async function createDockerfile (answers) {
const dockerfileTemplate = await readTemplate('Dockerfile')
return dockerfileTemplate
.replace(':NAME', answers.name)
.replace(':DESCRIPTION', answers.description)
.replace(':ICON', answers.icon)
.replace(':COLOR', answers.color)
} | javascript | async function createDockerfile (answers) {
const dockerfileTemplate = await readTemplate('Dockerfile')
return dockerfileTemplate
.replace(':NAME', answers.name)
.replace(':DESCRIPTION', answers.description)
.replace(':ICON', answers.icon)
.replace(':COLOR', answers.color)
} | [
"async",
"function",
"createDockerfile",
"(",
"answers",
")",
"{",
"const",
"dockerfileTemplate",
"=",
"await",
"readTemplate",
"(",
"'Dockerfile'",
")",
"return",
"dockerfileTemplate",
".",
"replace",
"(",
"':NAME'",
",",
"answers",
".",
"name",
")",
".",
"repl... | Creates a Dockerfile contents string, replacing variables in the Dockerfile template
with values passed in by the user from the CLI prompt.
@param {PromptAnswers} answers The CLI prompt answers.
@returns {Promise<string>} The Dockerfile contents. | [
"Creates",
"a",
"Dockerfile",
"contents",
"string",
"replacing",
"variables",
"in",
"the",
"Dockerfile",
"template",
"with",
"values",
"passed",
"in",
"by",
"the",
"user",
"from",
"the",
"CLI",
"prompt",
"."
] | 294ac11efd551cc382f3fed79c190e536069d6ce | https://github.com/JasonEtco/actions-toolkit/blob/294ac11efd551cc382f3fed79c190e536069d6ce/bin/create-action.js#L86-L93 | train |
JasonEtco/actions-toolkit | bin/create-action.js | createPackageJson | function createPackageJson (name) {
const { version, devDependencies } = require('../package.json')
return {
name,
private: true,
main: 'index.js',
scripts: {
start: 'node ./index.js',
test: 'jest'
},
dependencies: {
'actions-toolkit': `^${version}`
},
devDependenci... | javascript | function createPackageJson (name) {
const { version, devDependencies } = require('../package.json')
return {
name,
private: true,
main: 'index.js',
scripts: {
start: 'node ./index.js',
test: 'jest'
},
dependencies: {
'actions-toolkit': `^${version}`
},
devDependenci... | [
"function",
"createPackageJson",
"(",
"name",
")",
"{",
"const",
"{",
"version",
",",
"devDependencies",
"}",
"=",
"require",
"(",
"'../package.json'",
")",
"return",
"{",
"name",
",",
"private",
":",
"true",
",",
"main",
":",
"'index.js'",
",",
"scripts",
... | Creates a `package.json` object with the latest version
of `actions-toolkit` ready to be installed.
@param {string} name The action package name.
@returns {object} The `package.json` contents. | [
"Creates",
"a",
"package",
".",
"json",
"object",
"with",
"the",
"latest",
"version",
"of",
"actions",
"-",
"toolkit",
"ready",
"to",
"be",
"installed",
"."
] | 294ac11efd551cc382f3fed79c190e536069d6ce | https://github.com/JasonEtco/actions-toolkit/blob/294ac11efd551cc382f3fed79c190e536069d6ce/bin/create-action.js#L115-L132 | train |
CreateJS/SoundJS | lib/flashaudioplugin.js | function() {
if (isExpressInstallActive) {
var obj = getElementById(EXPRESS_INSTALL_ID);
if (obj && storedAltContent) {
obj.parentNode.replaceChild(storedAltContent, obj);
if (storedAltContentId) {
setVisibility(storedAltContentId, true);
if (ua.ie && ua.win) { storedAltContent.style.di... | javascript | function() {
if (isExpressInstallActive) {
var obj = getElementById(EXPRESS_INSTALL_ID);
if (obj && storedAltContent) {
obj.parentNode.replaceChild(storedAltContent, obj);
if (storedAltContentId) {
setVisibility(storedAltContentId, true);
if (ua.ie && ua.win) { storedAltContent.style.di... | [
"function",
"(",
")",
"{",
"if",
"(",
"isExpressInstallActive",
")",
"{",
"var",
"obj",
"=",
"getElementById",
"(",
"EXPRESS_INSTALL_ID",
")",
";",
"if",
"(",
"obj",
"&&",
"storedAltContent",
")",
"{",
"obj",
".",
"parentNode",
".",
"replaceChild",
"(",
"s... | For internal usage only | [
"For",
"internal",
"usage",
"only"
] | 416db509bfd0741eaa8c88600e1197e027f986e6 | https://github.com/CreateJS/SoundJS/blob/416db509bfd0741eaa8c88600e1197e027f986e6/lib/flashaudioplugin.js#L795-L808 | train | |
CreateJS/SoundJS | lib/flashaudioplugin.js | Loader | function Loader(loadItem) {
this.AbstractLoader_constructor(loadItem, false, createjs.Types.SOUND);
// Public properties
/**
* ID used to facilitate communication with flash.
* Not doc'd because this should not be altered externally
* @property flashId
* @type {String}
*/
this.flashId = null;
} | javascript | function Loader(loadItem) {
this.AbstractLoader_constructor(loadItem, false, createjs.Types.SOUND);
// Public properties
/**
* ID used to facilitate communication with flash.
* Not doc'd because this should not be altered externally
* @property flashId
* @type {String}
*/
this.flashId = null;
} | [
"function",
"Loader",
"(",
"loadItem",
")",
"{",
"this",
".",
"AbstractLoader_constructor",
"(",
"loadItem",
",",
"false",
",",
"createjs",
".",
"Types",
".",
"SOUND",
")",
";",
"// Public properties",
"/**\n\t\t * ID used to facilitate communication with flash.\n\t\t * N... | Loader provides a mechanism to preload Flash content via PreloadJS or internally. Instances are returned to
the preloader, and the load method is called when the asset needs to be requested.
@class FlashAudioLoader
@param {String} loadItem The item to be loaded
@param {Object} flash The flash instance that will do the... | [
"Loader",
"provides",
"a",
"mechanism",
"to",
"preload",
"Flash",
"content",
"via",
"PreloadJS",
"or",
"internally",
".",
"Instances",
"are",
"returned",
"to",
"the",
"preloader",
"and",
"the",
"load",
"method",
"is",
"called",
"when",
"the",
"asset",
"needs",... | 416db509bfd0741eaa8c88600e1197e027f986e6 | https://github.com/CreateJS/SoundJS/blob/416db509bfd0741eaa8c88600e1197e027f986e6/lib/flashaudioplugin.js#L831-L844 | train |
mapbox/mapbox-gl-draw | src/lib/create_supplementary_points.js | processMultiGeometry | function processMultiGeometry() {
const subType = type.replace(Constants.geojsonTypes.MULTI_PREFIX, '');
coordinates.forEach((subCoordinates, index) => {
const subFeature = {
type: Constants.geojsonTypes.FEATURE,
properties: geojson.properties,
geometry: {
type: subType,
... | javascript | function processMultiGeometry() {
const subType = type.replace(Constants.geojsonTypes.MULTI_PREFIX, '');
coordinates.forEach((subCoordinates, index) => {
const subFeature = {
type: Constants.geojsonTypes.FEATURE,
properties: geojson.properties,
geometry: {
type: subType,
... | [
"function",
"processMultiGeometry",
"(",
")",
"{",
"const",
"subType",
"=",
"type",
".",
"replace",
"(",
"Constants",
".",
"geojsonTypes",
".",
"MULTI_PREFIX",
",",
"''",
")",
";",
"coordinates",
".",
"forEach",
"(",
"(",
"subCoordinates",
",",
"index",
")",... | Split a multi-geometry into constituent geometries, and accumulate the supplementary points for each of those constituents | [
"Split",
"a",
"multi",
"-",
"geometry",
"into",
"constituent",
"geometries",
"and",
"accumulate",
"the",
"supplementary",
"points",
"for",
"each",
"of",
"those",
"constituents"
] | 7f6fd83f04bfb9e2300a352ca7f14b0203cd48c8 | https://github.com/mapbox/mapbox-gl-draw/blob/7f6fd83f04bfb9e2300a352ca7f14b0203cd48c8/src/lib/create_supplementary_points.js#L65-L78 | train |
mapbox/mapbox-gl-draw | src/lib/sort_features.js | sortFeatures | function sortFeatures(features) {
return features.map(feature => {
if (feature.geometry.type === Constants.geojsonTypes.POLYGON) {
feature.area = area.geometry({
type: Constants.geojsonTypes.FEATURE,
property: {},
geometry: feature.geometry
});
}
return feature;
}).so... | javascript | function sortFeatures(features) {
return features.map(feature => {
if (feature.geometry.type === Constants.geojsonTypes.POLYGON) {
feature.area = area.geometry({
type: Constants.geojsonTypes.FEATURE,
property: {},
geometry: feature.geometry
});
}
return feature;
}).so... | [
"function",
"sortFeatures",
"(",
"features",
")",
"{",
"return",
"features",
".",
"map",
"(",
"feature",
"=>",
"{",
"if",
"(",
"feature",
".",
"geometry",
".",
"type",
"===",
"Constants",
".",
"geojsonTypes",
".",
"POLYGON",
")",
"{",
"feature",
".",
"ar... | Sort in the order above, then sort polygons by area ascending. | [
"Sort",
"in",
"the",
"order",
"above",
"then",
"sort",
"polygons",
"by",
"area",
"ascending",
"."
] | 7f6fd83f04bfb9e2300a352ca7f14b0203cd48c8 | https://github.com/mapbox/mapbox-gl-draw/blob/7f6fd83f04bfb9e2300a352ca7f14b0203cd48c8/src/lib/sort_features.js#L21-L35 | train |
mapbox/mapbox-gl-draw | src/setup.js | function() {
ctx.options.styles.forEach(style => {
if (ctx.map.getLayer(style.id)) {
ctx.map.removeLayer(style.id);
}
});
if (ctx.map.getSource(Constants.sources.COLD)) {
ctx.map.removeSource(Constants.sources.COLD);
}
if (ctx.map.getSource(Constants.sou... | javascript | function() {
ctx.options.styles.forEach(style => {
if (ctx.map.getLayer(style.id)) {
ctx.map.removeLayer(style.id);
}
});
if (ctx.map.getSource(Constants.sources.COLD)) {
ctx.map.removeSource(Constants.sources.COLD);
}
if (ctx.map.getSource(Constants.sou... | [
"function",
"(",
")",
"{",
"ctx",
".",
"options",
".",
"styles",
".",
"forEach",
"(",
"style",
"=>",
"{",
"if",
"(",
"ctx",
".",
"map",
".",
"getLayer",
"(",
"style",
".",
"id",
")",
")",
"{",
"ctx",
".",
"map",
".",
"removeLayer",
"(",
"style",
... | Check for layers and sources before attempting to remove If user adds draw control and removes it before the map is loaded, layers and sources will be missing | [
"Check",
"for",
"layers",
"and",
"sources",
"before",
"attempting",
"to",
"remove",
"If",
"user",
"adds",
"draw",
"control",
"and",
"removes",
"it",
"before",
"the",
"map",
"is",
"loaded",
"layers",
"and",
"sources",
"will",
"be",
"missing"
] | 7f6fd83f04bfb9e2300a352ca7f14b0203cd48c8 | https://github.com/mapbox/mapbox-gl-draw/blob/7f6fd83f04bfb9e2300a352ca7f14b0203cd48c8/src/setup.js#L110-L124 | train | |
mapbox/mapbox-gl-draw | src/lib/mouse_event_point.js | mouseEventPoint | function mouseEventPoint(mouseEvent, container) {
const rect = container.getBoundingClientRect();
return new Point(
mouseEvent.clientX - rect.left - (container.clientLeft || 0),
mouseEvent.clientY - rect.top - (container.clientTop || 0)
);
} | javascript | function mouseEventPoint(mouseEvent, container) {
const rect = container.getBoundingClientRect();
return new Point(
mouseEvent.clientX - rect.left - (container.clientLeft || 0),
mouseEvent.clientY - rect.top - (container.clientTop || 0)
);
} | [
"function",
"mouseEventPoint",
"(",
"mouseEvent",
",",
"container",
")",
"{",
"const",
"rect",
"=",
"container",
".",
"getBoundingClientRect",
"(",
")",
";",
"return",
"new",
"Point",
"(",
"mouseEvent",
".",
"clientX",
"-",
"rect",
".",
"left",
"-",
"(",
"... | Returns a Point representing a mouse event's position
relative to a containing element.
@param {MouseEvent} mouseEvent
@param {Node} container
@returns {Point} | [
"Returns",
"a",
"Point",
"representing",
"a",
"mouse",
"event",
"s",
"position",
"relative",
"to",
"a",
"containing",
"element",
"."
] | 7f6fd83f04bfb9e2300a352ca7f14b0203cd48c8 | https://github.com/mapbox/mapbox-gl-draw/blob/7f6fd83f04bfb9e2300a352ca7f14b0203cd48c8/src/lib/mouse_event_point.js#L11-L17 | train |
mapbox/mapbox-gl-draw | src/lib/map_event_to_bounding_box.js | mapEventToBoundingBox | function mapEventToBoundingBox(mapEvent, buffer = 0) {
return [
[mapEvent.point.x - buffer, mapEvent.point.y - buffer],
[mapEvent.point.x + buffer, mapEvent.point.y + buffer]
];
} | javascript | function mapEventToBoundingBox(mapEvent, buffer = 0) {
return [
[mapEvent.point.x - buffer, mapEvent.point.y - buffer],
[mapEvent.point.x + buffer, mapEvent.point.y + buffer]
];
} | [
"function",
"mapEventToBoundingBox",
"(",
"mapEvent",
",",
"buffer",
"=",
"0",
")",
"{",
"return",
"[",
"[",
"mapEvent",
".",
"point",
".",
"x",
"-",
"buffer",
",",
"mapEvent",
".",
"point",
".",
"y",
"-",
"buffer",
"]",
",",
"[",
"mapEvent",
".",
"p... | Returns a bounding box representing the event's location.
@param {Event} mapEvent - Mapbox GL JS map event, with a point properties.
@return {Array<Array<number>>} Bounding box. | [
"Returns",
"a",
"bounding",
"box",
"representing",
"the",
"event",
"s",
"location",
"."
] | 7f6fd83f04bfb9e2300a352ca7f14b0203cd48c8 | https://github.com/mapbox/mapbox-gl-draw/blob/7f6fd83f04bfb9e2300a352ca7f14b0203cd48c8/src/lib/map_event_to_bounding_box.js#L7-L12 | train |
line/line-bot-sdk-nodejs | examples/kitchensink/index.js | handleEvent | function handleEvent(event) {
if (event.replyToken && event.replyToken.match(/^(.)\1*$/)) {
return console.log("Test hook recieved: " + JSON.stringify(event.message));
}
switch (event.type) {
case 'message':
const message = event.message;
switch (message.type) {
case 'text':
... | javascript | function handleEvent(event) {
if (event.replyToken && event.replyToken.match(/^(.)\1*$/)) {
return console.log("Test hook recieved: " + JSON.stringify(event.message));
}
switch (event.type) {
case 'message':
const message = event.message;
switch (message.type) {
case 'text':
... | [
"function",
"handleEvent",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"replyToken",
"&&",
"event",
".",
"replyToken",
".",
"match",
"(",
"/",
"^(.)\\1*$",
"/",
")",
")",
"{",
"return",
"console",
".",
"log",
"(",
"\"Test hook recieved: \"",
"+",
"J... | callback function to handle a single event | [
"callback",
"function",
"to",
"handle",
"a",
"single",
"event"
] | aa3f04749250341a3fd700ceffc3ac68e76c3402 | https://github.com/line/line-bot-sdk-nodejs/blob/aa3f04749250341a3fd700ceffc3ac68e76c3402/examples/kitchensink/index.js#L62-L112 | train |
algolia/places | docs/source/javascripts/sidebar.js | activeLinks | function activeLinks(sidebarContainer) {
const linksContainer = sidebarContainer.querySelector('ul');
linksContainer.addEventListener('click', e => {
if (e.target.tagName === 'A') {
Array.from(linksContainer.querySelectorAll('a')).forEach(item =>
item.classList.remove('active')
);
e.t... | javascript | function activeLinks(sidebarContainer) {
const linksContainer = sidebarContainer.querySelector('ul');
linksContainer.addEventListener('click', e => {
if (e.target.tagName === 'A') {
Array.from(linksContainer.querySelectorAll('a')).forEach(item =>
item.classList.remove('active')
);
e.t... | [
"function",
"activeLinks",
"(",
"sidebarContainer",
")",
"{",
"const",
"linksContainer",
"=",
"sidebarContainer",
".",
"querySelector",
"(",
"'ul'",
")",
";",
"linksContainer",
".",
"addEventListener",
"(",
"'click'",
",",
"e",
"=>",
"{",
"if",
"(",
"e",
".",
... | The Following code is used to set active items On the documentation sidebar depending on the clicked item | [
"The",
"Following",
"code",
"is",
"used",
"to",
"set",
"active",
"items",
"On",
"the",
"documentation",
"sidebar",
"depending",
"on",
"the",
"clicked",
"item"
] | c183814eb967202e1c0aa2ed655f33f60e008c13 | https://github.com/algolia/places/blob/c183814eb967202e1c0aa2ed655f33f60e008c13/docs/source/javascripts/sidebar.js#L152-L163 | train |
zendeskgarden/react-components | packages/forms/src/fields/common/Field.js | Field | function Field({ id, children }) {
const fieldProps = useField(id);
return <FieldContext.Provider value={fieldProps}>{children}</FieldContext.Provider>;
} | javascript | function Field({ id, children }) {
const fieldProps = useField(id);
return <FieldContext.Provider value={fieldProps}>{children}</FieldContext.Provider>;
} | [
"function",
"Field",
"(",
"{",
"id",
",",
"children",
"}",
")",
"{",
"const",
"fieldProps",
"=",
"useField",
"(",
"id",
")",
";",
"return",
"<",
"FieldContext",
".",
"Provider",
"value",
"=",
"{",
"fieldProps",
"}",
">",
"{",
"children",
"}",
"<",
"/... | Provides accessibility attributes to child form fields.
Does not render a corresponding DOM element. | [
"Provides",
"accessibility",
"attributes",
"to",
"child",
"form",
"fields",
".",
"Does",
"not",
"render",
"a",
"corresponding",
"DOM",
"element",
"."
] | 51c52457959e6c12f049e789d76d8cd7ed17d872 | https://github.com/zendeskgarden/react-components/blob/51c52457959e6c12f049e789d76d8cd7ed17d872/packages/forms/src/fields/common/Field.js#L18-L22 | train |
zendeskgarden/react-components | packages/typography/src/views/Ellipsis.js | Ellipsis | function Ellipsis({ children, title, tag, ...other }) {
const CustomTagEllipsis = StyledEllipsis.withComponent(tag);
let textContent = null;
if (title !== undefined) {
textContent = title;
} else if (typeof children === 'string') {
textContent = children;
}
return (
<CustomTagEllipsis title={... | javascript | function Ellipsis({ children, title, tag, ...other }) {
const CustomTagEllipsis = StyledEllipsis.withComponent(tag);
let textContent = null;
if (title !== undefined) {
textContent = title;
} else if (typeof children === 'string') {
textContent = children;
}
return (
<CustomTagEllipsis title={... | [
"function",
"Ellipsis",
"(",
"{",
"children",
",",
"title",
",",
"tag",
",",
"...",
"other",
"}",
")",
"{",
"const",
"CustomTagEllipsis",
"=",
"StyledEllipsis",
".",
"withComponent",
"(",
"tag",
")",
";",
"let",
"textContent",
"=",
"null",
";",
"if",
"("... | A component that automatically includes a native `title` attribute
and any text-overflow styling.
All other props are spread onto the element.
@param {*} props | [
"A",
"component",
"that",
"automatically",
"includes",
"a",
"native",
"title",
"attribute",
"and",
"any",
"text",
"-",
"overflow",
"styling",
"."
] | 51c52457959e6c12f049e789d76d8cd7ed17d872 | https://github.com/zendeskgarden/react-components/blob/51c52457959e6c12f049e789d76d8cd7ed17d872/packages/typography/src/views/Ellipsis.js#L36-L52 | train |
josdejong/workerpool | lib/Promise.js | function (result) {
// update status
me.resolved = true;
me.rejected = false;
me.pending = false;
_onSuccess.forEach(function (fn) {
fn(result);
});
_process = function (onSuccess, onFail) {
onSuccess(result);
};
_resolve = _reject = function () { };
return me;
... | javascript | function (result) {
// update status
me.resolved = true;
me.rejected = false;
me.pending = false;
_onSuccess.forEach(function (fn) {
fn(result);
});
_process = function (onSuccess, onFail) {
onSuccess(result);
};
_resolve = _reject = function () { };
return me;
... | [
"function",
"(",
"result",
")",
"{",
"// update status",
"me",
".",
"resolved",
"=",
"true",
";",
"me",
".",
"rejected",
"=",
"false",
";",
"me",
".",
"pending",
"=",
"false",
";",
"_onSuccess",
".",
"forEach",
"(",
"function",
"(",
"fn",
")",
"{",
"... | Resolve the promise
@param {*} result
@type {Function} | [
"Resolve",
"the",
"promise"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/Promise.js#L62-L79 | train | |
josdejong/workerpool | lib/Promise.js | function (error) {
// update status
me.resolved = false;
me.rejected = true;
me.pending = false;
_onFail.forEach(function (fn) {
fn(error);
});
_process = function (onSuccess, onFail) {
onFail(error);
};
_resolve = _reject = function () { }
return me;
} | javascript | function (error) {
// update status
me.resolved = false;
me.rejected = true;
me.pending = false;
_onFail.forEach(function (fn) {
fn(error);
});
_process = function (onSuccess, onFail) {
onFail(error);
};
_resolve = _reject = function () { }
return me;
} | [
"function",
"(",
"error",
")",
"{",
"// update status",
"me",
".",
"resolved",
"=",
"false",
";",
"me",
".",
"rejected",
"=",
"true",
";",
"me",
".",
"pending",
"=",
"false",
";",
"_onFail",
".",
"forEach",
"(",
"function",
"(",
"fn",
")",
"{",
"fn",... | Reject the promise
@param {Error} error
@type {Function} | [
"Reject",
"the",
"promise"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/Promise.js#L86-L103 | train | |
josdejong/workerpool | lib/Pool.js | Pool | function Pool(script, options) {
if (typeof script === 'string') {
this.script = script || null;
}
else {
this.script = null;
options = script;
}
this.workers = []; // queue with all workers
this.tasks = []; // queue with tasks awaiting execution
options = options || {};
this.forkArgs... | javascript | function Pool(script, options) {
if (typeof script === 'string') {
this.script = script || null;
}
else {
this.script = null;
options = script;
}
this.workers = []; // queue with all workers
this.tasks = []; // queue with tasks awaiting execution
options = options || {};
this.forkArgs... | [
"function",
"Pool",
"(",
"script",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"script",
"===",
"'string'",
")",
"{",
"this",
".",
"script",
"=",
"script",
"||",
"null",
";",
"}",
"else",
"{",
"this",
".",
"script",
"=",
"null",
";",
"options",
... | A pool to manage workers
@param {String} [script] Optional worker script
@param {Object} [options] Available options: maxWorkers: Number
@constructor | [
"A",
"pool",
"to",
"manage",
"workers"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/Pool.js#L12-L57 | train |
josdejong/workerpool | lib/WorkerHandler.js | getDefaultWorker | function getDefaultWorker() {
if (environment.platform == 'browser') {
// test whether the browser supports all features that we need
if (typeof Blob === 'undefined') {
throw new Error('Blob not supported by the browser');
}
if (!window.URL || typeof window.URL.createObjectURL !== 'function') {
... | javascript | function getDefaultWorker() {
if (environment.platform == 'browser') {
// test whether the browser supports all features that we need
if (typeof Blob === 'undefined') {
throw new Error('Blob not supported by the browser');
}
if (!window.URL || typeof window.URL.createObjectURL !== 'function') {
... | [
"function",
"getDefaultWorker",
"(",
")",
"{",
"if",
"(",
"environment",
".",
"platform",
"==",
"'browser'",
")",
"{",
"// test whether the browser supports all features that we need",
"if",
"(",
"typeof",
"Blob",
"===",
"'undefined'",
")",
"{",
"throw",
"new",
"Err... | get the default worker script | [
"get",
"the",
"default",
"worker",
"script"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/WorkerHandler.js#L32-L50 | train |
josdejong/workerpool | lib/WorkerHandler.js | resolveForkOptions | function resolveForkOptions(opts) {
opts = opts || {};
var processExecArgv = process.execArgv.join(' ');
var inspectorActive = processExecArgv.indexOf('--inspect') !== -1;
var debugBrk = processExecArgv.indexOf('--debug-brk') !== -1;
var execArgv = [];
if (inspectorActive) {
execArgv.push('--inspect='... | javascript | function resolveForkOptions(opts) {
opts = opts || {};
var processExecArgv = process.execArgv.join(' ');
var inspectorActive = processExecArgv.indexOf('--inspect') !== -1;
var debugBrk = processExecArgv.indexOf('--debug-brk') !== -1;
var execArgv = [];
if (inspectorActive) {
execArgv.push('--inspect='... | [
"function",
"resolveForkOptions",
"(",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"processExecArgv",
"=",
"process",
".",
"execArgv",
".",
"join",
"(",
"' '",
")",
";",
"var",
"inspectorActive",
"=",
"processExecArgv",
".",
"indexOf... | add debug flags to child processes if the node inspector is active | [
"add",
"debug",
"flags",
"to",
"child",
"processes",
"if",
"the",
"node",
"inspector",
"is",
"active"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/WorkerHandler.js#L104-L127 | train |
josdejong/workerpool | lib/WorkerHandler.js | objectToError | function objectToError (obj) {
var temp = new Error('')
var props = Object.keys(obj)
for (var i = 0; i < props.length; i++) {
temp[props[i]] = obj[props[i]]
}
return temp
} | javascript | function objectToError (obj) {
var temp = new Error('')
var props = Object.keys(obj)
for (var i = 0; i < props.length; i++) {
temp[props[i]] = obj[props[i]]
}
return temp
} | [
"function",
"objectToError",
"(",
"obj",
")",
"{",
"var",
"temp",
"=",
"new",
"Error",
"(",
"''",
")",
"var",
"props",
"=",
"Object",
".",
"keys",
"(",
"obj",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"props",
".",
"length",
";",
"i... | Converts a serialized error to Error
@param {Object} obj Error that has been serialized and parsed to object
@return {Error} The equivalent Error. | [
"Converts",
"a",
"serialized",
"error",
"to",
"Error"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/WorkerHandler.js#L134-L143 | train |
josdejong/workerpool | lib/WorkerHandler.js | onError | function onError(error) {
me.terminated = true;
if (me.terminating && me.terminationHandler) {
me.terminationHandler(me);
}
me.terminating = false;
for (var id in me.processing) {
if (me.processing[id] !== undefined) {
me.processing[id].resolver.reject(error);
}
}
... | javascript | function onError(error) {
me.terminated = true;
if (me.terminating && me.terminationHandler) {
me.terminationHandler(me);
}
me.terminating = false;
for (var id in me.processing) {
if (me.processing[id] !== undefined) {
me.processing[id].resolver.reject(error);
}
}
... | [
"function",
"onError",
"(",
"error",
")",
"{",
"me",
".",
"terminated",
"=",
"true",
";",
"if",
"(",
"me",
".",
"terminating",
"&&",
"me",
".",
"terminationHandler",
")",
"{",
"me",
".",
"terminationHandler",
"(",
"me",
")",
";",
"}",
"me",
".",
"ter... | reject all running tasks on worker error | [
"reject",
"all",
"running",
"tasks",
"on",
"worker",
"error"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/WorkerHandler.js#L222-L235 | train |
josdejong/workerpool | lib/WorkerHandler.js | dispatchQueuedRequests | function dispatchQueuedRequests()
{
me.requestQueue.forEach(me.worker.send.bind(me.worker));
me.requestQueue = [];
} | javascript | function dispatchQueuedRequests()
{
me.requestQueue.forEach(me.worker.send.bind(me.worker));
me.requestQueue = [];
} | [
"function",
"dispatchQueuedRequests",
"(",
")",
"{",
"me",
".",
"requestQueue",
".",
"forEach",
"(",
"me",
".",
"worker",
".",
"send",
".",
"bind",
"(",
"me",
".",
"worker",
")",
")",
";",
"me",
".",
"requestQueue",
"=",
"[",
"]",
";",
"}"
] | send all queued requests to worker | [
"send",
"all",
"queued",
"requests",
"to",
"worker"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/WorkerHandler.js#L238-L242 | train |
Caligatio/jsSHA | src/sha_dev.js | hex2packed | function hex2packed(str, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, length = str.length, i, num, intOffset, byteOffset,
existingByteLen, shiftModifier;
if (0 !== (length % 2))
{
throw new Error("String of HEX type must be in byte increments");
}
packed = existingPacked || [0];
e... | javascript | function hex2packed(str, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, length = str.length, i, num, intOffset, byteOffset,
existingByteLen, shiftModifier;
if (0 !== (length % 2))
{
throw new Error("String of HEX type must be in byte increments");
}
packed = existingPacked || [0];
e... | [
"function",
"hex2packed",
"(",
"str",
",",
"existingPacked",
",",
"existingPackedLen",
",",
"bigEndianMod",
")",
"{",
"var",
"packed",
",",
"length",
"=",
"str",
".",
"length",
",",
"i",
",",
"num",
",",
"intOffset",
",",
"byteOffset",
",",
"existingByteLen"... | Convert a hex string to an array of big-endian words
@private
@param {string} str String to be converted to binary representation
@param {Array<number>} existingPacked A packed int array of bytes to
append the results to
@param {number} existingPackedLen The number of bits in the existingPacked
array
@param {number} b... | [
"Convert",
"a",
"hex",
"string",
"to",
"an",
"array",
"of",
"big",
"-",
"endian",
"words"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L172-L207 | train |
Caligatio/jsSHA | src/sha_dev.js | bytes2packed | function bytes2packed(str, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, codePnt, i, existingByteLen, intOffset,
byteOffset, shiftModifier;
packed = existingPacked || [0];
existingPackedLen = existingPackedLen || 0;
existingByteLen = existingPackedLen >>> 3;
shiftModifier = (bigEndianMod... | javascript | function bytes2packed(str, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, codePnt, i, existingByteLen, intOffset,
byteOffset, shiftModifier;
packed = existingPacked || [0];
existingPackedLen = existingPackedLen || 0;
existingByteLen = existingPackedLen >>> 3;
shiftModifier = (bigEndianMod... | [
"function",
"bytes2packed",
"(",
"str",
",",
"existingPacked",
",",
"existingPackedLen",
",",
"bigEndianMod",
")",
"{",
"var",
"packed",
",",
"codePnt",
",",
"i",
",",
"existingByteLen",
",",
"intOffset",
",",
"byteOffset",
",",
"shiftModifier",
";",
"packed",
... | Convert a string of raw bytes to an array of big-endian words
@private
@param {string} str String of raw bytes to be converted to binary representation
@param {Array<number>} existingPacked A packed int array of bytes to
append the results to
@param {number} existingPackedLen The number of bits in the existingPacked
a... | [
"Convert",
"a",
"string",
"of",
"raw",
"bytes",
"to",
"an",
"array",
"of",
"big",
"-",
"endian",
"words"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L224-L248 | train |
Caligatio/jsSHA | src/sha_dev.js | b642packed | function b642packed(str, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, byteCnt = 0, index, i, j, tmpInt, strPart, firstEqual,
b64Tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
existingByteLen, intOffset, byteOffset, shiftModifier;
if (-1 === str.search(/^[a-zA-Z0-... | javascript | function b642packed(str, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, byteCnt = 0, index, i, j, tmpInt, strPart, firstEqual,
b64Tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
existingByteLen, intOffset, byteOffset, shiftModifier;
if (-1 === str.search(/^[a-zA-Z0-... | [
"function",
"b642packed",
"(",
"str",
",",
"existingPacked",
",",
"existingPackedLen",
",",
"bigEndianMod",
")",
"{",
"var",
"packed",
",",
"byteCnt",
"=",
"0",
",",
"index",
",",
"i",
",",
"j",
",",
"tmpInt",
",",
"strPart",
",",
"firstEqual",
",",
"b64... | Convert a base-64 string to an array of big-endian words
@private
@param {string} str String to be converted to binary representation
@param {Array<number>} existingPacked A packed int array of bytes to
append the results to
@param {number} existingPackedLen The number of bits in the existingPacked
array
@param {numbe... | [
"Convert",
"a",
"base",
"-",
"64",
"string",
"to",
"an",
"array",
"of",
"big",
"-",
"endian",
"words"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L265-L314 | train |
Caligatio/jsSHA | src/sha_dev.js | arraybuffer2packed | function arraybuffer2packed(arr, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, i, existingByteLen, intOffset, byteOffset, shiftModifier, arrView;
packed = existingPacked || [0];
existingPackedLen = existingPackedLen || 0;
existingByteLen = existingPackedLen >>> 3;
shiftModifier = (bigEndian... | javascript | function arraybuffer2packed(arr, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, i, existingByteLen, intOffset, byteOffset, shiftModifier, arrView;
packed = existingPacked || [0];
existingPackedLen = existingPackedLen || 0;
existingByteLen = existingPackedLen >>> 3;
shiftModifier = (bigEndian... | [
"function",
"arraybuffer2packed",
"(",
"arr",
",",
"existingPacked",
",",
"existingPackedLen",
",",
"bigEndianMod",
")",
"{",
"var",
"packed",
",",
"i",
",",
"existingByteLen",
",",
"intOffset",
",",
"byteOffset",
",",
"shiftModifier",
",",
"arrView",
";",
"pack... | Convert an ArrayBuffer to an array of big-endian words
@private
@param {ArrayBuffer} arr ArrayBuffer to be converted to binary
representation
@param {Array<number>} existingPacked A packed int array of bytes to
append the results to
@param {number} existingPackedLen The number of bits in the existingPacked
array
@para... | [
"Convert",
"an",
"ArrayBuffer",
"to",
"an",
"array",
"of",
"big",
"-",
"endian",
"words"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L332-L354 | train |
Caligatio/jsSHA | src/sha_dev.js | packed2b64 | function packed2b64(packed, outputLength, bigEndianMod, formatOpts)
{
var str = "", length = outputLength / 8, i, j, triplet, int1, int2, shiftModifier,
b64Tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 3)... | javascript | function packed2b64(packed, outputLength, bigEndianMod, formatOpts)
{
var str = "", length = outputLength / 8, i, j, triplet, int1, int2, shiftModifier,
b64Tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 3)... | [
"function",
"packed2b64",
"(",
"packed",
",",
"outputLength",
",",
"bigEndianMod",
",",
"formatOpts",
")",
"{",
"var",
"str",
"=",
"\"\"",
",",
"length",
"=",
"outputLength",
"/",
"8",
",",
"i",
",",
"j",
",",
"triplet",
",",
"int1",
",",
"int2",
",",
... | Convert an array of big-endian words to a base-64 string
@private
@param {Array<number>} packed Array of integers to be converted to
base-64 representation
@param {number} outputLength Length of output in bits
@param {number} bigEndianMod Modifier for whether hash function is
big or small endian
@param {{outputUpper :... | [
"Convert",
"an",
"array",
"of",
"big",
"-",
"endian",
"words",
"to",
"a",
"base",
"-",
"64",
"string"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L402-L429 | train |
Caligatio/jsSHA | src/sha_dev.js | packed2bytes | function packed2bytes(packed, outputLength, bigEndianMod)
{
var str = "", length = outputLength / 8, i, srcByte, shiftModifier;
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 1)
{
srcByte = (packed[i >>> 2] >>> (8 * (shiftModifier + bigEndianMod * (i % 4)))) & 0xFF;
str += ... | javascript | function packed2bytes(packed, outputLength, bigEndianMod)
{
var str = "", length = outputLength / 8, i, srcByte, shiftModifier;
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 1)
{
srcByte = (packed[i >>> 2] >>> (8 * (shiftModifier + bigEndianMod * (i % 4)))) & 0xFF;
str += ... | [
"function",
"packed2bytes",
"(",
"packed",
",",
"outputLength",
",",
"bigEndianMod",
")",
"{",
"var",
"str",
"=",
"\"\"",
",",
"length",
"=",
"outputLength",
"/",
"8",
",",
"i",
",",
"srcByte",
",",
"shiftModifier",
";",
"shiftModifier",
"=",
"(",
"bigEndi... | Convert an array of big-endian words to raw bytes string
@private
@param {Array<number>} packed Array of integers to be converted to
a raw bytes string representation
@param {number} outputLength Length of output in bits
@param {number} bigEndianMod Modifier for whether hash function is
big or small endian
@return {st... | [
"Convert",
"an",
"array",
"of",
"big",
"-",
"endian",
"words",
"to",
"raw",
"bytes",
"string"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L443-L456 | train |
Caligatio/jsSHA | src/sha_dev.js | packed2arraybuffer | function packed2arraybuffer(packed, outputLength, bigEndianMod)
{
var length = outputLength / 8, i, retVal = new ArrayBuffer(length), shiftModifier, arrView;
arrView = new Uint8Array(retVal);
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 1)
{
arrView[i] = (packed[i >>> 2] >... | javascript | function packed2arraybuffer(packed, outputLength, bigEndianMod)
{
var length = outputLength / 8, i, retVal = new ArrayBuffer(length), shiftModifier, arrView;
arrView = new Uint8Array(retVal);
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 1)
{
arrView[i] = (packed[i >>> 2] >... | [
"function",
"packed2arraybuffer",
"(",
"packed",
",",
"outputLength",
",",
"bigEndianMod",
")",
"{",
"var",
"length",
"=",
"outputLength",
"/",
"8",
",",
"i",
",",
"retVal",
"=",
"new",
"ArrayBuffer",
"(",
"length",
")",
",",
"shiftModifier",
",",
"arrView",... | Convert an array of big-endian words to an ArrayBuffer
@private
@param {Array<number>} packed Array of integers to be converted to
an ArrayBuffer
@param {number} outputLength Length of output in bits
@param {number} bigEndianMod Modifier for whether hash function is
big or small endian
@return {ArrayBuffer} Raw bytes ... | [
"Convert",
"an",
"array",
"of",
"big",
"-",
"endian",
"words",
"to",
"an",
"ArrayBuffer"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L470-L483 | train |
Caligatio/jsSHA | src/sha_dev.js | getOutputOpts | function getOutputOpts(options)
{
var retVal = {"outputUpper" : false, "b64Pad" : "=", "shakeLen" : -1},
outputOptions;
outputOptions = options || {};
retVal["outputUpper"] = outputOptions["outputUpper"] || false;
if (true === outputOptions.hasOwnProperty("b64Pad"))
{
retVal["b64Pad"] = outputOptions... | javascript | function getOutputOpts(options)
{
var retVal = {"outputUpper" : false, "b64Pad" : "=", "shakeLen" : -1},
outputOptions;
outputOptions = options || {};
retVal["outputUpper"] = outputOptions["outputUpper"] || false;
if (true === outputOptions.hasOwnProperty("b64Pad"))
{
retVal["b64Pad"] = outputOptions... | [
"function",
"getOutputOpts",
"(",
"options",
")",
"{",
"var",
"retVal",
"=",
"{",
"\"outputUpper\"",
":",
"false",
",",
"\"b64Pad\"",
":",
"\"=\"",
",",
"\"shakeLen\"",
":",
"-",
"1",
"}",
",",
"outputOptions",
";",
"outputOptions",
"=",
"options",
"||",
"... | Validate hash list containing output formatting options, ensuring
presence of every option or adding the default value
@private
@param {{outputUpper : (boolean|undefined), b64Pad : (string|undefined),
shakeLen : (number|undefined)}=} options Hash list of output formatting options
@return {{outputUpper : boolean, b64Pa... | [
"Validate",
"hash",
"list",
"containing",
"output",
"formatting",
"options",
"ensuring",
"presence",
"of",
"every",
"option",
"or",
"adding",
"the",
"default",
"value"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L495-L528 | train |
Caligatio/jsSHA | src/sha_dev.js | rotl_64 | function rotl_64(x, n)
{
if (n > 32)
{
n = n - 32;
return new Int_64(
x.lowOrder << n | x.highOrder >>> (32 - n),
x.highOrder << n | x.lowOrder >>> (32 - n)
);
}
else if (0 !== n)
{
return new Int_64(
x.highOrder << n | x.lowOrder >>> (32 - n),
x.lowOrder << n | x.highOrder >>> (3... | javascript | function rotl_64(x, n)
{
if (n > 32)
{
n = n - 32;
return new Int_64(
x.lowOrder << n | x.highOrder >>> (32 - n),
x.highOrder << n | x.lowOrder >>> (32 - n)
);
}
else if (0 !== n)
{
return new Int_64(
x.highOrder << n | x.lowOrder >>> (32 - n),
x.lowOrder << n | x.highOrder >>> (3... | [
"function",
"rotl_64",
"(",
"x",
",",
"n",
")",
"{",
"if",
"(",
"n",
">",
"32",
")",
"{",
"n",
"=",
"n",
"-",
"32",
";",
"return",
"new",
"Int_64",
"(",
"x",
".",
"lowOrder",
"<<",
"n",
"|",
"x",
".",
"highOrder",
">>>",
"(",
"32",
"-",
"n"... | The 64-bit implementation of circular rotate left
@private
@param {Int_64} x The 64-bit integer argument
@param {number} n The number of bits to shift
@return {Int_64} The x shifted circularly by n bits | [
"The",
"64",
"-",
"bit",
"implementation",
"of",
"circular",
"rotate",
"left"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L679-L700 | train |
Caligatio/jsSHA | src/sha_dev.js | rotr_64 | function rotr_64(x, n)
{
var retVal = null, tmp = new Int_64(x.highOrder, x.lowOrder);
if (32 >= n)
{
retVal = new Int_64(
(tmp.highOrder >>> n) | ((tmp.lowOrder << (32 - n)) & 0xFFFFFFFF),
(tmp.lowOrder >>> n) | ((tmp.highOrder << (32 - n)) & 0xFFFFFFFF)
);
}
else
{
retVal = new Int_6... | javascript | function rotr_64(x, n)
{
var retVal = null, tmp = new Int_64(x.highOrder, x.lowOrder);
if (32 >= n)
{
retVal = new Int_64(
(tmp.highOrder >>> n) | ((tmp.lowOrder << (32 - n)) & 0xFFFFFFFF),
(tmp.lowOrder >>> n) | ((tmp.highOrder << (32 - n)) & 0xFFFFFFFF)
);
}
else
{
retVal = new Int_6... | [
"function",
"rotr_64",
"(",
"x",
",",
"n",
")",
"{",
"var",
"retVal",
"=",
"null",
",",
"tmp",
"=",
"new",
"Int_64",
"(",
"x",
".",
"highOrder",
",",
"x",
".",
"lowOrder",
")",
";",
"if",
"(",
"32",
">=",
"n",
")",
"{",
"retVal",
"=",
"new",
... | The 64-bit implementation of circular rotate right
@private
@param {Int_64} x The 64-bit integer argument
@param {number} n The number of bits to shift
@return {Int_64} The x shifted circularly by n bits | [
"The",
"64",
"-",
"bit",
"implementation",
"of",
"circular",
"rotate",
"right"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L723-L743 | train |
Caligatio/jsSHA | src/sha_dev.js | shr_64 | function shr_64(x, n)
{
var retVal = null;
if (32 >= n)
{
retVal = new Int_64(
x.highOrder >>> n,
x.lowOrder >>> n | ((x.highOrder << (32 - n)) & 0xFFFFFFFF)
);
}
else
{
retVal = new Int_64(
0,
x.highOrder >>> (n - 32)
);
}
return retVal;
} | javascript | function shr_64(x, n)
{
var retVal = null;
if (32 >= n)
{
retVal = new Int_64(
x.highOrder >>> n,
x.lowOrder >>> n | ((x.highOrder << (32 - n)) & 0xFFFFFFFF)
);
}
else
{
retVal = new Int_64(
0,
x.highOrder >>> (n - 32)
);
}
return retVal;
} | [
"function",
"shr_64",
"(",
"x",
",",
"n",
")",
"{",
"var",
"retVal",
"=",
"null",
";",
"if",
"(",
"32",
">=",
"n",
")",
"{",
"retVal",
"=",
"new",
"Int_64",
"(",
"x",
".",
"highOrder",
">>>",
"n",
",",
"x",
".",
"lowOrder",
">>>",
"n",
"|",
"... | The 64-bit implementation of shift right
@private
@param {Int_64} x The 64-bit integer argument
@param {number} n The number of bits to shift
@return {Int_64} The x shifted by n bits | [
"The",
"64",
"-",
"bit",
"implementation",
"of",
"shift",
"right"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L766-L786 | train |
Caligatio/jsSHA | src/sha_dev.js | ch_64 | function ch_64(x, y, z)
{
return new Int_64(
(x.highOrder & y.highOrder) ^ (~x.highOrder & z.highOrder),
(x.lowOrder & y.lowOrder) ^ (~x.lowOrder & z.lowOrder)
);
} | javascript | function ch_64(x, y, z)
{
return new Int_64(
(x.highOrder & y.highOrder) ^ (~x.highOrder & z.highOrder),
(x.lowOrder & y.lowOrder) ^ (~x.lowOrder & z.lowOrder)
);
} | [
"function",
"ch_64",
"(",
"x",
",",
"y",
",",
"z",
")",
"{",
"return",
"new",
"Int_64",
"(",
"(",
"x",
".",
"highOrder",
"&",
"y",
".",
"highOrder",
")",
"^",
"(",
"~",
"x",
".",
"highOrder",
"&",
"z",
".",
"highOrder",
")",
",",
"(",
"x",
".... | The 64-bit implementation of the NIST specified Ch function
@private
@param {Int_64} x The first 64-bit integer argument
@param {Int_64} y The second 64-bit integer argument
@param {Int_64} z The third 64-bit integer argument
@return {Int_64} The NIST specified output of the function | [
"The",
"64",
"-",
"bit",
"implementation",
"of",
"the",
"NIST",
"specified",
"Ch",
"function"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L825-L831 | train |
Caligatio/jsSHA | src/sha_dev.js | maj_32 | function maj_32(x, y, z)
{
return (x & y) ^ (x & z) ^ (y & z);
} | javascript | function maj_32(x, y, z)
{
return (x & y) ^ (x & z) ^ (y & z);
} | [
"function",
"maj_32",
"(",
"x",
",",
"y",
",",
"z",
")",
"{",
"return",
"(",
"x",
"&",
"y",
")",
"^",
"(",
"x",
"&",
"z",
")",
"^",
"(",
"y",
"&",
"z",
")",
";",
"}"
] | The 32-bit implementation of the NIST specified Maj function
@private
@param {number} x The first 32-bit integer argument
@param {number} y The second 32-bit integer argument
@param {number} z The third 32-bit integer argument
@return {number} The NIST specified output of the function | [
"The",
"32",
"-",
"bit",
"implementation",
"of",
"the",
"NIST",
"specified",
"Maj",
"function"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L842-L845 | train |
Caligatio/jsSHA | src/sha_dev.js | maj_64 | function maj_64(x, y, z)
{
return new Int_64(
(x.highOrder & y.highOrder) ^
(x.highOrder & z.highOrder) ^
(y.highOrder & z.highOrder),
(x.lowOrder & y.lowOrder) ^
(x.lowOrder & z.lowOrder) ^
(y.lowOrder & z.lowOrder)
);
} | javascript | function maj_64(x, y, z)
{
return new Int_64(
(x.highOrder & y.highOrder) ^
(x.highOrder & z.highOrder) ^
(y.highOrder & z.highOrder),
(x.lowOrder & y.lowOrder) ^
(x.lowOrder & z.lowOrder) ^
(y.lowOrder & z.lowOrder)
);
} | [
"function",
"maj_64",
"(",
"x",
",",
"y",
",",
"z",
")",
"{",
"return",
"new",
"Int_64",
"(",
"(",
"x",
".",
"highOrder",
"&",
"y",
".",
"highOrder",
")",
"^",
"(",
"x",
".",
"highOrder",
"&",
"z",
".",
"highOrder",
")",
"^",
"(",
"y",
".",
"... | The 64-bit implementation of the NIST specified Maj function
@private
@param {Int_64} x The first 64-bit integer argument
@param {Int_64} y The second 64-bit integer argument
@param {Int_64} z The third 64-bit integer argument
@return {Int_64} The NIST specified output of the function | [
"The",
"64",
"-",
"bit",
"implementation",
"of",
"the",
"NIST",
"specified",
"Maj",
"function"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L856-L866 | train |
Caligatio/jsSHA | src/sha_dev.js | sigma0_64 | function sigma0_64(x)
{
var rotr28 = rotr_64(x, 28), rotr34 = rotr_64(x, 34),
rotr39 = rotr_64(x, 39);
return new Int_64(
rotr28.highOrder ^ rotr34.highOrder ^ rotr39.highOrder,
rotr28.lowOrder ^ rotr34.lowOrder ^ rotr39.lowOrder);
} | javascript | function sigma0_64(x)
{
var rotr28 = rotr_64(x, 28), rotr34 = rotr_64(x, 34),
rotr39 = rotr_64(x, 39);
return new Int_64(
rotr28.highOrder ^ rotr34.highOrder ^ rotr39.highOrder,
rotr28.lowOrder ^ rotr34.lowOrder ^ rotr39.lowOrder);
} | [
"function",
"sigma0_64",
"(",
"x",
")",
"{",
"var",
"rotr28",
"=",
"rotr_64",
"(",
"x",
",",
"28",
")",
",",
"rotr34",
"=",
"rotr_64",
"(",
"x",
",",
"34",
")",
",",
"rotr39",
"=",
"rotr_64",
"(",
"x",
",",
"39",
")",
";",
"return",
"new",
"Int... | The 64-bit implementation of the NIST specified Sigma0 function
@private
@param {Int_64} x The 64-bit integer argument
@return {Int_64} The NIST specified output of the function | [
"The",
"64",
"-",
"bit",
"implementation",
"of",
"the",
"NIST",
"specified",
"Sigma0",
"function"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L887-L895 | train |
Caligatio/jsSHA | src/sha_dev.js | sigma1_64 | function sigma1_64(x)
{
var rotr14 = rotr_64(x, 14), rotr18 = rotr_64(x, 18),
rotr41 = rotr_64(x, 41);
return new Int_64(
rotr14.highOrder ^ rotr18.highOrder ^ rotr41.highOrder,
rotr14.lowOrder ^ rotr18.lowOrder ^ rotr41.lowOrder);
} | javascript | function sigma1_64(x)
{
var rotr14 = rotr_64(x, 14), rotr18 = rotr_64(x, 18),
rotr41 = rotr_64(x, 41);
return new Int_64(
rotr14.highOrder ^ rotr18.highOrder ^ rotr41.highOrder,
rotr14.lowOrder ^ rotr18.lowOrder ^ rotr41.lowOrder);
} | [
"function",
"sigma1_64",
"(",
"x",
")",
"{",
"var",
"rotr14",
"=",
"rotr_64",
"(",
"x",
",",
"14",
")",
",",
"rotr18",
"=",
"rotr_64",
"(",
"x",
",",
"18",
")",
",",
"rotr41",
"=",
"rotr_64",
"(",
"x",
",",
"41",
")",
";",
"return",
"new",
"Int... | The 64-bit implementation of the NIST specified Sigma1 function
@private
@param {Int_64} x The 64-bit integer argument
@return {Int_64} The NIST specified output of the function | [
"The",
"64",
"-",
"bit",
"implementation",
"of",
"the",
"NIST",
"specified",
"Sigma1",
"function"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L916-L924 | train |
Caligatio/jsSHA | src/sha_dev.js | gamma0_64 | function gamma0_64(x)
{
var rotr1 = rotr_64(x, 1), rotr8 = rotr_64(x, 8), shr7 = shr_64(x, 7);
return new Int_64(
rotr1.highOrder ^ rotr8.highOrder ^ shr7.highOrder,
rotr1.lowOrder ^ rotr8.lowOrder ^ shr7.lowOrder
);
} | javascript | function gamma0_64(x)
{
var rotr1 = rotr_64(x, 1), rotr8 = rotr_64(x, 8), shr7 = shr_64(x, 7);
return new Int_64(
rotr1.highOrder ^ rotr8.highOrder ^ shr7.highOrder,
rotr1.lowOrder ^ rotr8.lowOrder ^ shr7.lowOrder
);
} | [
"function",
"gamma0_64",
"(",
"x",
")",
"{",
"var",
"rotr1",
"=",
"rotr_64",
"(",
"x",
",",
"1",
")",
",",
"rotr8",
"=",
"rotr_64",
"(",
"x",
",",
"8",
")",
",",
"shr7",
"=",
"shr_64",
"(",
"x",
",",
"7",
")",
";",
"return",
"new",
"Int_64",
... | The 64-bit implementation of the NIST specified Gamma0 function
@private
@param {Int_64} x The 64-bit integer argument
@return {Int_64} The NIST specified output of the function | [
"The",
"64",
"-",
"bit",
"implementation",
"of",
"the",
"NIST",
"specified",
"Gamma0",
"function"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L945-L953 | train |
Caligatio/jsSHA | src/sha_dev.js | gamma1_64 | function gamma1_64(x)
{
var rotr19 = rotr_64(x, 19), rotr61 = rotr_64(x, 61),
shr6 = shr_64(x, 6);
return new Int_64(
rotr19.highOrder ^ rotr61.highOrder ^ shr6.highOrder,
rotr19.lowOrder ^ rotr61.lowOrder ^ shr6.lowOrder
);
} | javascript | function gamma1_64(x)
{
var rotr19 = rotr_64(x, 19), rotr61 = rotr_64(x, 61),
shr6 = shr_64(x, 6);
return new Int_64(
rotr19.highOrder ^ rotr61.highOrder ^ shr6.highOrder,
rotr19.lowOrder ^ rotr61.lowOrder ^ shr6.lowOrder
);
} | [
"function",
"gamma1_64",
"(",
"x",
")",
"{",
"var",
"rotr19",
"=",
"rotr_64",
"(",
"x",
",",
"19",
")",
",",
"rotr61",
"=",
"rotr_64",
"(",
"x",
",",
"61",
")",
",",
"shr6",
"=",
"shr_64",
"(",
"x",
",",
"6",
")",
";",
"return",
"new",
"Int_64"... | The 64-bit implementation of the NIST specified Gamma1 function
@private
@param {Int_64} x The 64-bit integer argument
@return {Int_64} The NIST specified output of the function | [
"The",
"64",
"-",
"bit",
"implementation",
"of",
"the",
"NIST",
"specified",
"Gamma1",
"function"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L974-L983 | train |
Caligatio/jsSHA | src/sha_dev.js | safeAdd_32_2 | function safeAdd_32_2(a, b)
{
var lsw = (a & 0xFFFF) + (b & 0xFFFF),
msw = (a >>> 16) + (b >>> 16) + (lsw >>> 16);
return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
} | javascript | function safeAdd_32_2(a, b)
{
var lsw = (a & 0xFFFF) + (b & 0xFFFF),
msw = (a >>> 16) + (b >>> 16) + (lsw >>> 16);
return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
} | [
"function",
"safeAdd_32_2",
"(",
"a",
",",
"b",
")",
"{",
"var",
"lsw",
"=",
"(",
"a",
"&",
"0xFFFF",
")",
"+",
"(",
"b",
"&",
"0xFFFF",
")",
",",
"msw",
"=",
"(",
"a",
">>>",
"16",
")",
"+",
"(",
"b",
">>>",
"16",
")",
"+",
"(",
"lsw",
"... | Add two 32-bit integers, wrapping at 2^32. This uses 16-bit operations
internally to work around bugs in some JS interpreters.
@private
@param {number} a The first 32-bit integer argument to be added
@param {number} b The second 32-bit integer argument to be added
@return {number} The sum of a + b | [
"Add",
"two",
"32",
"-",
"bit",
"integers",
"wrapping",
"at",
"2^32",
".",
"This",
"uses",
"16",
"-",
"bit",
"operations",
"internally",
"to",
"work",
"around",
"bugs",
"in",
"some",
"JS",
"interpreters",
"."
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L994-L1000 | train |
Caligatio/jsSHA | src/sha_dev.js | safeAdd_32_4 | function safeAdd_32_4(a, b, c, d)
{
var lsw = (a & 0xFFFF) + (b & 0xFFFF) + (c & 0xFFFF) + (d & 0xFFFF),
msw = (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) +
(lsw >>> 16);
return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
} | javascript | function safeAdd_32_4(a, b, c, d)
{
var lsw = (a & 0xFFFF) + (b & 0xFFFF) + (c & 0xFFFF) + (d & 0xFFFF),
msw = (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) +
(lsw >>> 16);
return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
} | [
"function",
"safeAdd_32_4",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
")",
"{",
"var",
"lsw",
"=",
"(",
"a",
"&",
"0xFFFF",
")",
"+",
"(",
"b",
"&",
"0xFFFF",
")",
"+",
"(",
"c",
"&",
"0xFFFF",
")",
"+",
"(",
"d",
"&",
"0xFFFF",
")",
",",
"... | Add four 32-bit integers, wrapping at 2^32. This uses 16-bit operations
internally to work around bugs in some JS interpreters.
@private
@param {number} a The first 32-bit integer argument to be added
@param {number} b The second 32-bit integer argument to be added
@param {number} c The third 32-bit integer argument t... | [
"Add",
"four",
"32",
"-",
"bit",
"integers",
"wrapping",
"at",
"2^32",
".",
"This",
"uses",
"16",
"-",
"bit",
"operations",
"internally",
"to",
"work",
"around",
"bugs",
"in",
"some",
"JS",
"interpreters",
"."
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1013-L1020 | train |
Caligatio/jsSHA | src/sha_dev.js | safeAdd_32_5 | function safeAdd_32_5(a, b, c, d, e)
{
var lsw = (a & 0xFFFF) + (b & 0xFFFF) + (c & 0xFFFF) + (d & 0xFFFF) +
(e & 0xFFFF),
msw = (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) +
(e >>> 16) + (lsw >>> 16);
return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
} | javascript | function safeAdd_32_5(a, b, c, d, e)
{
var lsw = (a & 0xFFFF) + (b & 0xFFFF) + (c & 0xFFFF) + (d & 0xFFFF) +
(e & 0xFFFF),
msw = (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) +
(e >>> 16) + (lsw >>> 16);
return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
} | [
"function",
"safeAdd_32_5",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
")",
"{",
"var",
"lsw",
"=",
"(",
"a",
"&",
"0xFFFF",
")",
"+",
"(",
"b",
"&",
"0xFFFF",
")",
"+",
"(",
"c",
"&",
"0xFFFF",
")",
"+",
"(",
"d",
"&",
"0xFFFF",
"... | Add five 32-bit integers, wrapping at 2^32. This uses 16-bit operations
internally to work around bugs in some JS interpreters.
@private
@param {number} a The first 32-bit integer argument to be added
@param {number} b The second 32-bit integer argument to be added
@param {number} c The third 32-bit integer argument t... | [
"Add",
"five",
"32",
"-",
"bit",
"integers",
"wrapping",
"at",
"2^32",
".",
"This",
"uses",
"16",
"-",
"bit",
"operations",
"internally",
"to",
"work",
"around",
"bugs",
"in",
"some",
"JS",
"interpreters",
"."
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1034-L1042 | train |
Caligatio/jsSHA | src/sha_dev.js | safeAdd_64_2 | function safeAdd_64_2(x, y)
{
var lsw, msw, lowOrder, highOrder;
lsw = (x.lowOrder & 0xFFFF) + (y.lowOrder & 0xFFFF);
msw = (x.lowOrder >>> 16) + (y.lowOrder >>> 16) + (lsw >>> 16);
lowOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
lsw = (x.highOrder & 0xFFFF) + (y.highOrder & 0xFFFF) + (msw >>> 16);
m... | javascript | function safeAdd_64_2(x, y)
{
var lsw, msw, lowOrder, highOrder;
lsw = (x.lowOrder & 0xFFFF) + (y.lowOrder & 0xFFFF);
msw = (x.lowOrder >>> 16) + (y.lowOrder >>> 16) + (lsw >>> 16);
lowOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
lsw = (x.highOrder & 0xFFFF) + (y.highOrder & 0xFFFF) + (msw >>> 16);
m... | [
"function",
"safeAdd_64_2",
"(",
"x",
",",
"y",
")",
"{",
"var",
"lsw",
",",
"msw",
",",
"lowOrder",
",",
"highOrder",
";",
"lsw",
"=",
"(",
"x",
".",
"lowOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"y",
".",
"lowOrder",
"&",
"0xFFFF",
")",
";",
"msw",... | Add two 64-bit integers, wrapping at 2^64. This uses 16-bit operations
internally to work around bugs in some JS interpreters.
@private
@param {Int_64} x The first 64-bit integer argument to be added
@param {Int_64} y The second 64-bit integer argument to be added
@return {Int_64} The sum of x + y | [
"Add",
"two",
"64",
"-",
"bit",
"integers",
"wrapping",
"at",
"2^64",
".",
"This",
"uses",
"16",
"-",
"bit",
"operations",
"internally",
"to",
"work",
"around",
"bugs",
"in",
"some",
"JS",
"interpreters",
"."
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1053-L1066 | train |
Caligatio/jsSHA | src/sha_dev.js | safeAdd_64_4 | function safeAdd_64_4(a, b, c, d)
{
var lsw, msw, lowOrder, highOrder;
lsw = (a.lowOrder & 0xFFFF) + (b.lowOrder & 0xFFFF) +
(c.lowOrder & 0xFFFF) + (d.lowOrder & 0xFFFF);
msw = (a.lowOrder >>> 16) + (b.lowOrder >>> 16) +
(c.lowOrder >>> 16) + (d.lowOrder >>> 16) + (lsw >>> 16);
lowOrder = ((msw & 0xFFF... | javascript | function safeAdd_64_4(a, b, c, d)
{
var lsw, msw, lowOrder, highOrder;
lsw = (a.lowOrder & 0xFFFF) + (b.lowOrder & 0xFFFF) +
(c.lowOrder & 0xFFFF) + (d.lowOrder & 0xFFFF);
msw = (a.lowOrder >>> 16) + (b.lowOrder >>> 16) +
(c.lowOrder >>> 16) + (d.lowOrder >>> 16) + (lsw >>> 16);
lowOrder = ((msw & 0xFFF... | [
"function",
"safeAdd_64_4",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
")",
"{",
"var",
"lsw",
",",
"msw",
",",
"lowOrder",
",",
"highOrder",
";",
"lsw",
"=",
"(",
"a",
".",
"lowOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"b",
".",
"lowOrder",
"&",
"0xF... | Add four 64-bit integers, wrapping at 2^64. This uses 16-bit operations
internally to work around bugs in some JS interpreters.
@private
@param {Int_64} a The first 64-bit integer argument to be added
@param {Int_64} b The second 64-bit integer argument to be added
@param {Int_64} c The third 64-bit integer argument t... | [
"Add",
"four",
"64",
"-",
"bit",
"integers",
"wrapping",
"at",
"2^64",
".",
"This",
"uses",
"16",
"-",
"bit",
"operations",
"internally",
"to",
"work",
"around",
"bugs",
"in",
"some",
"JS",
"interpreters",
"."
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1079-L1096 | train |
Caligatio/jsSHA | src/sha_dev.js | safeAdd_64_5 | function safeAdd_64_5(a, b, c, d, e)
{
var lsw, msw, lowOrder, highOrder;
lsw = (a.lowOrder & 0xFFFF) + (b.lowOrder & 0xFFFF) +
(c.lowOrder & 0xFFFF) + (d.lowOrder & 0xFFFF) +
(e.lowOrder & 0xFFFF);
msw = (a.lowOrder >>> 16) + (b.lowOrder >>> 16) +
(c.lowOrder >>> 16) + (d.lowOrder >>> 16) + (e.lowOrde... | javascript | function safeAdd_64_5(a, b, c, d, e)
{
var lsw, msw, lowOrder, highOrder;
lsw = (a.lowOrder & 0xFFFF) + (b.lowOrder & 0xFFFF) +
(c.lowOrder & 0xFFFF) + (d.lowOrder & 0xFFFF) +
(e.lowOrder & 0xFFFF);
msw = (a.lowOrder >>> 16) + (b.lowOrder >>> 16) +
(c.lowOrder >>> 16) + (d.lowOrder >>> 16) + (e.lowOrde... | [
"function",
"safeAdd_64_5",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
")",
"{",
"var",
"lsw",
",",
"msw",
",",
"lowOrder",
",",
"highOrder",
";",
"lsw",
"=",
"(",
"a",
".",
"lowOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"b",
".",
"lowOrder",... | Add five 64-bit integers, wrapping at 2^64. This uses 16-bit operations
internally to work around bugs in some JS interpreters.
@private
@param {Int_64} a The first 64-bit integer argument to be added
@param {Int_64} b The second 64-bit integer argument to be added
@param {Int_64} c The third 64-bit integer argument t... | [
"Add",
"five",
"64",
"-",
"bit",
"integers",
"wrapping",
"at",
"2^64",
".",
"This",
"uses",
"16",
"-",
"bit",
"operations",
"internally",
"to",
"work",
"around",
"bugs",
"in",
"some",
"JS",
"interpreters",
"."
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1110-L1131 | train |
Caligatio/jsSHA | src/sha_dev.js | xor_64_2 | function xor_64_2(a, b)
{
return new Int_64(
a.highOrder ^ b.highOrder,
a.lowOrder ^ b.lowOrder
);
} | javascript | function xor_64_2(a, b)
{
return new Int_64(
a.highOrder ^ b.highOrder,
a.lowOrder ^ b.lowOrder
);
} | [
"function",
"xor_64_2",
"(",
"a",
",",
"b",
")",
"{",
"return",
"new",
"Int_64",
"(",
"a",
".",
"highOrder",
"^",
"b",
".",
"highOrder",
",",
"a",
".",
"lowOrder",
"^",
"b",
".",
"lowOrder",
")",
";",
"}"
] | XORs two given arguments.
@private
@param {Int_64} a First argument to be XORed
@param {Int_64} b Second argument to be XORed
@return {Int_64} The XOR of the arguments | [
"XORs",
"two",
"given",
"arguments",
"."
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1141-L1147 | train |
Caligatio/jsSHA | src/sha_dev.js | xor_64_5 | function xor_64_5(a, b, c, d, e)
{
return new Int_64(
a.highOrder ^ b.highOrder ^ c.highOrder ^ d.highOrder ^ e.highOrder,
a.lowOrder ^ b.lowOrder ^ c.lowOrder ^ d.lowOrder ^ e.lowOrder
);
} | javascript | function xor_64_5(a, b, c, d, e)
{
return new Int_64(
a.highOrder ^ b.highOrder ^ c.highOrder ^ d.highOrder ^ e.highOrder,
a.lowOrder ^ b.lowOrder ^ c.lowOrder ^ d.lowOrder ^ e.lowOrder
);
} | [
"function",
"xor_64_5",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
")",
"{",
"return",
"new",
"Int_64",
"(",
"a",
".",
"highOrder",
"^",
"b",
".",
"highOrder",
"^",
"c",
".",
"highOrder",
"^",
"d",
".",
"highOrder",
"^",
"e",
".",
"highO... | XORs five given arguments.
@private
@param {Int_64} a First argument to be XORed
@param {Int_64} b Second argument to be XORed
@param {Int_64} c Third argument to be XORed
@param {Int_64} d Fourth argument to be XORed
@param {Int_64} e Fifth argument to be XORed
@return {Int_64} The XOR of the arguments | [
"XORs",
"five",
"given",
"arguments",
"."
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1160-L1166 | train |
Caligatio/jsSHA | src/sha_dev.js | cloneSHA3State | function cloneSHA3State(state) {
var clone = [], i;
for (i = 0; i < 5; i += 1)
{
clone[i] = state[i].slice();
}
return clone;
} | javascript | function cloneSHA3State(state) {
var clone = [], i;
for (i = 0; i < 5; i += 1)
{
clone[i] = state[i].slice();
}
return clone;
} | [
"function",
"cloneSHA3State",
"(",
"state",
")",
"{",
"var",
"clone",
"=",
"[",
"]",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"5",
";",
"i",
"+=",
"1",
")",
"{",
"clone",
"[",
"i",
"]",
"=",
"state",
"[",
"i",
"]",
".",
"s... | Returns a clone of the given SHA3 state
@private
@param {Array<Array<Int_64>>} state The state to be cloned
@return {Array<Array<Int_64>>} The cloned state | [
"Returns",
"a",
"clone",
"of",
"the",
"given",
"SHA3",
"state"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1175-L1183 | train |
Caligatio/jsSHA | src/sha_dev.js | getNewState | function getNewState(variant)
{
var retVal = [], H_trunc, H_full, i;
if (("SHA-1" === variant) && ((1 & SUPPORTED_ALGS) !== 0))
{
retVal = [
0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0
];
}
else if ((variant.lastIndexOf("SHA-", 0) === 0) && ((6 & SUPPORTED_ALGS) !== 0))
{
H_tru... | javascript | function getNewState(variant)
{
var retVal = [], H_trunc, H_full, i;
if (("SHA-1" === variant) && ((1 & SUPPORTED_ALGS) !== 0))
{
retVal = [
0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0
];
}
else if ((variant.lastIndexOf("SHA-", 0) === 0) && ((6 & SUPPORTED_ALGS) !== 0))
{
H_tru... | [
"function",
"getNewState",
"(",
"variant",
")",
"{",
"var",
"retVal",
"=",
"[",
"]",
",",
"H_trunc",
",",
"H_full",
",",
"i",
";",
"if",
"(",
"(",
"\"SHA-1\"",
"===",
"variant",
")",
"&&",
"(",
"(",
"1",
"&",
"SUPPORTED_ALGS",
")",
"!==",
"0",
")",... | Gets the state values for the specified SHA variant
@param {string} variant The SHA variant
@return {Array<number|Int_64|Array<null>>} The initial state values | [
"Gets",
"the",
"state",
"values",
"for",
"the",
"specified",
"SHA",
"variant"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1191-L1262 | train |
Caligatio/jsSHA | src/sha_dev.js | roundSHA1 | function roundSHA1(block, H)
{
var W = [], a, b, c, d, e, T, ch = ch_32, parity = parity_32,
maj = maj_32, rotl = rotl_32, safeAdd_2 = safeAdd_32_2, t,
safeAdd_5 = safeAdd_32_5;
a = H[0];
b = H[1];
c = H[2];
d = H[3];
e = H[4];
for (t = 0; t < 80; t += 1)
{
if (t < 16)
{
W[t] = block[... | javascript | function roundSHA1(block, H)
{
var W = [], a, b, c, d, e, T, ch = ch_32, parity = parity_32,
maj = maj_32, rotl = rotl_32, safeAdd_2 = safeAdd_32_2, t,
safeAdd_5 = safeAdd_32_5;
a = H[0];
b = H[1];
c = H[2];
d = H[3];
e = H[4];
for (t = 0; t < 80; t += 1)
{
if (t < 16)
{
W[t] = block[... | [
"function",
"roundSHA1",
"(",
"block",
",",
"H",
")",
"{",
"var",
"W",
"=",
"[",
"]",
",",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
",",
"T",
",",
"ch",
"=",
"ch_32",
",",
"parity",
"=",
"parity_32",
",",
"maj",
"=",
"maj_32",
",",
"rot... | Performs a round of SHA-1 hashing over a 512-byte block
@private
@param {Array<number>} block The binary array representation of the
block to hash
@param {Array<number>} H The intermediate H values from a previous
round
@return {Array<number>} The resulting H values | [
"Performs",
"a",
"round",
"of",
"SHA",
"-",
"1",
"hashing",
"over",
"a",
"512",
"-",
"byte",
"block"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1274-L1326 | train |
Caligatio/jsSHA | src/sha_dev.js | finalizeSHA1 | function finalizeSHA1(remainder, remainderBinLen, processedBinLen, H, outputLen)
{
var i, appendedMessageLength, offset, totalLen;
/* The 65 addition is a hack but it works. The correct number is
actually 72 (64 + 8) but the below math fails if
remainderBinLen + 72 % 512 = 0. Since remainderBinLen % 8 ... | javascript | function finalizeSHA1(remainder, remainderBinLen, processedBinLen, H, outputLen)
{
var i, appendedMessageLength, offset, totalLen;
/* The 65 addition is a hack but it works. The correct number is
actually 72 (64 + 8) but the below math fails if
remainderBinLen + 72 % 512 = 0. Since remainderBinLen % 8 ... | [
"function",
"finalizeSHA1",
"(",
"remainder",
",",
"remainderBinLen",
",",
"processedBinLen",
",",
"H",
",",
"outputLen",
")",
"{",
"var",
"i",
",",
"appendedMessageLength",
",",
"offset",
",",
"totalLen",
";",
"/* The 65 addition is a hack but it works. The correct nu... | Finalizes the SHA-1 hash
@private
@param {Array<number>} remainder Any leftover unprocessed packed ints
that still need to be processed
@param {number} remainderBinLen The number of bits in remainder
@param {number} processedBinLen The number of bits already
processed
@param {Array<number>} H The intermediate H values... | [
"Finalizes",
"the",
"SHA",
"-",
"1",
"hash"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1343-L1378 | train |
Caligatio/jsSHA | src/sha_dev.js | finalizeSHA3 | function finalizeSHA3(remainder, remainderBinLen, processedBinLen, state, blockSize, delimiter, outputLen)
{
var i, retVal = [], binaryStringInc = blockSize >>> 5, state_offset = 0,
remainderIntLen = remainderBinLen >>> 5, temp;
/* Process as many blocks as possible, some may be here for multiple rounds
... | javascript | function finalizeSHA3(remainder, remainderBinLen, processedBinLen, state, blockSize, delimiter, outputLen)
{
var i, retVal = [], binaryStringInc = blockSize >>> 5, state_offset = 0,
remainderIntLen = remainderBinLen >>> 5, temp;
/* Process as many blocks as possible, some may be here for multiple rounds
... | [
"function",
"finalizeSHA3",
"(",
"remainder",
",",
"remainderBinLen",
",",
"processedBinLen",
",",
"state",
",",
"blockSize",
",",
"delimiter",
",",
"outputLen",
")",
"{",
"var",
"i",
",",
"retVal",
"=",
"[",
"]",
",",
"binaryStringInc",
"=",
"blockSize",
">... | Finalizes the SHA-3 hash
@private
@param {Array<number>} remainder Any leftover unprocessed packed ints
that still need to be processed
@param {number} remainderBinLen The number of bits in remainder
@param {number} processedBinLen The number of bits already
processed
@param {Array<Array<Int_64>>} state The state from... | [
"Finalizes",
"the",
"SHA",
"-",
"3",
"hash"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1799-L1848 | train |
solkimicreb/react-easy-state | src/scheduler.js | batchMethod | function batchMethod (obj, method) {
const descriptor = Object.getOwnPropertyDescriptor(obj, method)
if (descriptor) {
const newDescriptor = Object.assign({}, descriptor, {
set (value) {
return descriptor.set.call(this, batchFn(value))
}
})
Object.defineProperty(obj, method, newDescr... | javascript | function batchMethod (obj, method) {
const descriptor = Object.getOwnPropertyDescriptor(obj, method)
if (descriptor) {
const newDescriptor = Object.assign({}, descriptor, {
set (value) {
return descriptor.set.call(this, batchFn(value))
}
})
Object.defineProperty(obj, method, newDescr... | [
"function",
"batchMethod",
"(",
"obj",
",",
"method",
")",
"{",
"const",
"descriptor",
"=",
"Object",
".",
"getOwnPropertyDescriptor",
"(",
"obj",
",",
"method",
")",
"if",
"(",
"descriptor",
")",
"{",
"const",
"newDescriptor",
"=",
"Object",
".",
"assign",
... | batches obj.onevent = fn like calls | [
"batches",
"obj",
".",
"onevent",
"=",
"fn",
"like",
"calls"
] | cb9694cab826c35c9fa4ac232eb1758d05342cd2 | https://github.com/solkimicreb/react-easy-state/blob/cb9694cab826c35c9fa4ac232eb1758d05342cd2/src/scheduler.js#L41-L51 | train |
erikbrinkman/d3-dag | src/dag/equals.js | toSet | function toSet(arr) {
const set = {};
arr.forEach((e) => (set[e] = true));
return set;
} | javascript | function toSet(arr) {
const set = {};
arr.forEach((e) => (set[e] = true));
return set;
} | [
"function",
"toSet",
"(",
"arr",
")",
"{",
"const",
"set",
"=",
"{",
"}",
";",
"arr",
".",
"forEach",
"(",
"(",
"e",
")",
"=>",
"(",
"set",
"[",
"e",
"]",
"=",
"true",
")",
")",
";",
"return",
"set",
";",
"}"
] | Compare two dag_like objects for equality | [
"Compare",
"two",
"dag_like",
"objects",
"for",
"equality"
] | 26c84107c51585c9b0111fd68f91955be87d25e4 | https://github.com/erikbrinkman/d3-dag/blob/26c84107c51585c9b0111fd68f91955be87d25e4/src/dag/equals.js#L2-L6 | train |
erikbrinkman/d3-dag | src/dag/index.js | copy | function copy() {
const nodes = [];
const cnodes = [];
const mapping = {};
this.each((node) => {
nodes.push(node);
const cnode = new Node(node.id, node.data);
cnodes.push(cnode);
mapping[cnode.id] = cnode;
});
cnodes.forEach((cnode, i) => {
const node = nodes[i];
cnode.children = no... | javascript | function copy() {
const nodes = [];
const cnodes = [];
const mapping = {};
this.each((node) => {
nodes.push(node);
const cnode = new Node(node.id, node.data);
cnodes.push(cnode);
mapping[cnode.id] = cnode;
});
cnodes.forEach((cnode, i) => {
const node = nodes[i];
cnode.children = no... | [
"function",
"copy",
"(",
")",
"{",
"const",
"nodes",
"=",
"[",
"]",
";",
"const",
"cnodes",
"=",
"[",
"]",
";",
"const",
"mapping",
"=",
"{",
"}",
";",
"this",
".",
"each",
"(",
"(",
"node",
")",
"=>",
"{",
"nodes",
".",
"push",
"(",
"node",
... | Must be internal for new Node creation Copy this dag returning a new DAG pointing to the same data with same structure. | [
"Must",
"be",
"internal",
"for",
"new",
"Node",
"creation",
"Copy",
"this",
"dag",
"returning",
"a",
"new",
"DAG",
"pointing",
"to",
"the",
"same",
"data",
"with",
"same",
"structure",
"."
] | 26c84107c51585c9b0111fd68f91955be87d25e4 | https://github.com/erikbrinkman/d3-dag/blob/26c84107c51585c9b0111fd68f91955be87d25e4/src/dag/index.js#L30-L52 | train |
stellarterm/stellarterm | api/functions/history.js | getLumenPrice | function getLumenPrice() {
return Promise.all([
rp('https://poloniex.com/public?command=returnTicker')
.then(data => {
return parseFloat(JSON.parse(data).BTC_STR.last);
})
.catch(() => {
return null;
})
,
rp('https://bittrex.com/api/v1.1/public/getticker?market=BTC-... | javascript | function getLumenPrice() {
return Promise.all([
rp('https://poloniex.com/public?command=returnTicker')
.then(data => {
return parseFloat(JSON.parse(data).BTC_STR.last);
})
.catch(() => {
return null;
})
,
rp('https://bittrex.com/api/v1.1/public/getticker?market=BTC-... | [
"function",
"getLumenPrice",
"(",
")",
"{",
"return",
"Promise",
".",
"all",
"(",
"[",
"rp",
"(",
"'https://poloniex.com/public?command=returnTicker'",
")",
".",
"then",
"(",
"data",
"=>",
"{",
"return",
"parseFloat",
"(",
"JSON",
".",
"parse",
"(",
"data",
... | Get lumen price in terms of btc | [
"Get",
"lumen",
"price",
"in",
"terms",
"of",
"btc"
] | 4d6125088be80fed230a1f71b9d8a26b2b7d443e | https://github.com/stellarterm/stellarterm/blob/4d6125088be80fed230a1f71b9d8a26b2b7d443e/api/functions/history.js#L140-L169 | train |
apache/cordova-cli | src/telemetry.js | showPrompt | function showPrompt () {
return new Promise(function (resolve, reject) {
var msg = 'May Cordova anonymously report usage statistics to improve the tool over time?';
insight._permissionTimeout = module.exports.timeoutInSecs || 30;
insight.askPermission(msg, function (unused, optIn) {
... | javascript | function showPrompt () {
return new Promise(function (resolve, reject) {
var msg = 'May Cordova anonymously report usage statistics to improve the tool over time?';
insight._permissionTimeout = module.exports.timeoutInSecs || 30;
insight.askPermission(msg, function (unused, optIn) {
... | [
"function",
"showPrompt",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"msg",
"=",
"'May Cordova anonymously report usage statistics to improve the tool over time?'",
";",
"insight",
".",
"_permissionTimeout... | Returns true if the user opted in, and false otherwise | [
"Returns",
"true",
"if",
"the",
"user",
"opted",
"in",
"and",
"false",
"otherwise"
] | 7c4b092779e82f02c0fb7ad40d70483310601e37 | https://github.com/apache/cordova-cli/blob/7c4b092779e82f02c0fb7ad40d70483310601e37/src/telemetry.js#L34-L51 | train |
intljusticemission/react-big-calendar | src/utils/DayEventLayout.js | onSameRow | function onSameRow(a, b, minimumStartDifference) {
return (
// Occupies the same start slot.
Math.abs(b.start - a.start) < minimumStartDifference ||
// A's start slot overlaps with b's end slot.
(b.start > a.start && b.start < a.end)
)
} | javascript | function onSameRow(a, b, minimumStartDifference) {
return (
// Occupies the same start slot.
Math.abs(b.start - a.start) < minimumStartDifference ||
// A's start slot overlaps with b's end slot.
(b.start > a.start && b.start < a.end)
)
} | [
"function",
"onSameRow",
"(",
"a",
",",
"b",
",",
"minimumStartDifference",
")",
"{",
"return",
"(",
"// Occupies the same start slot.",
"Math",
".",
"abs",
"(",
"b",
".",
"start",
"-",
"a",
".",
"start",
")",
"<",
"minimumStartDifference",
"||",
"// A's start... | Return true if event a and b is considered to be on the same row. | [
"Return",
"true",
"if",
"event",
"a",
"and",
"b",
"is",
"considered",
"to",
"be",
"on",
"the",
"same",
"row",
"."
] | 5d9a16faf3568cef22970b7d6992c33f7a95bc33 | https://github.com/intljusticemission/react-big-calendar/blob/5d9a16faf3568cef22970b7d6992c33f7a95bc33/src/utils/DayEventLayout.js#L92-L99 | train |
segmentio/evergreen | src/theme/src/withTheme.js | withTheme | function withTheme(WrappedComponent) {
const displayName =
WrappedComponent.displayName || WrappedComponent.name || 'Component'
return class extends React.Component {
static displayName = `withTheme(${displayName})`
render() {
return (
<ThemeConsumer>
{theme => <WrappedComponen... | javascript | function withTheme(WrappedComponent) {
const displayName =
WrappedComponent.displayName || WrappedComponent.name || 'Component'
return class extends React.Component {
static displayName = `withTheme(${displayName})`
render() {
return (
<ThemeConsumer>
{theme => <WrappedComponen... | [
"function",
"withTheme",
"(",
"WrappedComponent",
")",
"{",
"const",
"displayName",
"=",
"WrappedComponent",
".",
"displayName",
"||",
"WrappedComponent",
".",
"name",
"||",
"'Component'",
"return",
"class",
"extends",
"React",
".",
"Component",
"{",
"static",
"di... | HOC that uses ThemeConsumer.
@param {React.Component} WrappedComponent - Component that gets theme. | [
"HOC",
"that",
"uses",
"ThemeConsumer",
"."
] | 8c48fa7dccce80018a29b8c6857c9915256897ec | https://github.com/segmentio/evergreen/blob/8c48fa7dccce80018a29b8c6857c9915256897ec/src/theme/src/withTheme.js#L8-L23 | train |
kazupon/vue-i18n | dist/vue-i18n.esm.js | stripQuotes | function stripQuotes (str) {
var a = str.charCodeAt(0);
var b = str.charCodeAt(str.length - 1);
return a === b && (a === 0x22 || a === 0x27)
? str.slice(1, -1)
: str
} | javascript | function stripQuotes (str) {
var a = str.charCodeAt(0);
var b = str.charCodeAt(str.length - 1);
return a === b && (a === 0x22 || a === 0x27)
? str.slice(1, -1)
: str
} | [
"function",
"stripQuotes",
"(",
"str",
")",
"{",
"var",
"a",
"=",
"str",
".",
"charCodeAt",
"(",
"0",
")",
";",
"var",
"b",
"=",
"str",
".",
"charCodeAt",
"(",
"str",
".",
"length",
"-",
"1",
")",
";",
"return",
"a",
"===",
"b",
"&&",
"(",
"a",... | Strip quotes from a string | [
"Strip",
"quotes",
"from",
"a",
"string"
] | d28e3b25d9bd9eac51fc3714a4a2940772d85c3d | https://github.com/kazupon/vue-i18n/blob/d28e3b25d9bd9eac51fc3714a4a2940772d85c3d/dist/vue-i18n.esm.js#L841-L847 | train |
kazupon/vue-i18n | dist/vue-i18n.esm.browser.js | getPathCharType | function getPathCharType (ch) {
if (ch === undefined || ch === null) { return 'eof' }
const code = ch.charCodeAt(0);
switch (code) {
case 0x5B: // [
case 0x5D: // ]
case 0x2E: // .
case 0x22: // "
case 0x27: // '
return ch
case 0x5F: // _
case 0x24: // $
case 0x2D: // -
... | javascript | function getPathCharType (ch) {
if (ch === undefined || ch === null) { return 'eof' }
const code = ch.charCodeAt(0);
switch (code) {
case 0x5B: // [
case 0x5D: // ]
case 0x2E: // .
case 0x22: // "
case 0x27: // '
return ch
case 0x5F: // _
case 0x24: // $
case 0x2D: // -
... | [
"function",
"getPathCharType",
"(",
"ch",
")",
"{",
"if",
"(",
"ch",
"===",
"undefined",
"||",
"ch",
"===",
"null",
")",
"{",
"return",
"'eof'",
"}",
"const",
"code",
"=",
"ch",
".",
"charCodeAt",
"(",
"0",
")",
";",
"switch",
"(",
"code",
")",
"{"... | Determine the type of a character in a keypath. | [
"Determine",
"the",
"type",
"of",
"a",
"character",
"in",
"a",
"keypath",
"."
] | d28e3b25d9bd9eac51fc3714a4a2940772d85c3d | https://github.com/kazupon/vue-i18n/blob/d28e3b25d9bd9eac51fc3714a4a2940772d85c3d/dist/vue-i18n.esm.browser.js#L814-L843 | train |
kazupon/vue-i18n | dist/vue-i18n.esm.browser.js | parse$1 | function parse$1 (path) {
const keys = [];
let index = -1;
let mode = BEFORE_PATH;
let subPathDepth = 0;
let c;
let key;
let newChar;
let type;
let transition;
let action;
let typeMap;
const actions = [];
actions[PUSH] = function () {
if (key !== undefined) {
keys.push(key);
k... | javascript | function parse$1 (path) {
const keys = [];
let index = -1;
let mode = BEFORE_PATH;
let subPathDepth = 0;
let c;
let key;
let newChar;
let type;
let transition;
let action;
let typeMap;
const actions = [];
actions[PUSH] = function () {
if (key !== undefined) {
keys.push(key);
k... | [
"function",
"parse$1",
"(",
"path",
")",
"{",
"const",
"keys",
"=",
"[",
"]",
";",
"let",
"index",
"=",
"-",
"1",
";",
"let",
"mode",
"=",
"BEFORE_PATH",
";",
"let",
"subPathDepth",
"=",
"0",
";",
"let",
"c",
";",
"let",
"key",
";",
"let",
"newCh... | Parse a string path into an array of segments | [
"Parse",
"a",
"string",
"path",
"into",
"an",
"array",
"of",
"segments"
] | d28e3b25d9bd9eac51fc3714a4a2940772d85c3d | https://github.com/kazupon/vue-i18n/blob/d28e3b25d9bd9eac51fc3714a4a2940772d85c3d/dist/vue-i18n.esm.browser.js#L863-L956 | train |
dundalek/markmap | lib/d3-flextree.js | wrapTree | function wrapTree(t) {
var wt = {
t: t,
prelim: 0,
mod: 0,
shift: 0,
change: 0,
msel: 0,
mser: 0,
};
t.x = 0;
t.y = 0;
if (size) {
wt.x_size = 1;
wt.y_size = 1;
}
else if (typeof nodeSize == "object") { // fixed array
wt.x_size =... | javascript | function wrapTree(t) {
var wt = {
t: t,
prelim: 0,
mod: 0,
shift: 0,
change: 0,
msel: 0,
mser: 0,
};
t.x = 0;
t.y = 0;
if (size) {
wt.x_size = 1;
wt.y_size = 1;
}
else if (typeof nodeSize == "object") { // fixed array
wt.x_size =... | [
"function",
"wrapTree",
"(",
"t",
")",
"{",
"var",
"wt",
"=",
"{",
"t",
":",
"t",
",",
"prelim",
":",
"0",
",",
"mod",
":",
"0",
",",
"shift",
":",
"0",
",",
"change",
":",
"0",
",",
"msel",
":",
"0",
",",
"mser",
":",
"0",
",",
"}",
";",... | Every node in the tree is wrapped in an object that holds data used during the algorithm | [
"Every",
"node",
"in",
"the",
"tree",
"is",
"wrapped",
"in",
"an",
"object",
"that",
"holds",
"data",
"used",
"during",
"the",
"algorithm"
] | c09614be60676725ccbc1cfd161f07aa7269e5c9 | https://github.com/dundalek/markmap/blob/c09614be60676725ccbc1cfd161f07aa7269e5c9/lib/d3-flextree.js#L54-L93 | train |
dundalek/markmap | lib/d3-flextree.js | zerothWalk | function zerothWalk(wt, initial) {
wt.t.y = initial;
wt.t.depth = 0;
_zerothWalk(wt);
} | javascript | function zerothWalk(wt, initial) {
wt.t.y = initial;
wt.t.depth = 0;
_zerothWalk(wt);
} | [
"function",
"zerothWalk",
"(",
"wt",
",",
"initial",
")",
"{",
"wt",
".",
"t",
".",
"y",
"=",
"initial",
";",
"wt",
".",
"t",
".",
"depth",
"=",
"0",
";",
"_zerothWalk",
"(",
"wt",
")",
";",
"}"
] | Recursively set the y coordinate of the children, based on the y coordinate of the parent, and its height. Also set parent and depth. | [
"Recursively",
"set",
"the",
"y",
"coordinate",
"of",
"the",
"children",
"based",
"on",
"the",
"y",
"coordinate",
"of",
"the",
"parent",
"and",
"its",
"height",
".",
"Also",
"set",
"parent",
"and",
"depth",
"."
] | c09614be60676725ccbc1cfd161f07aa7269e5c9 | https://github.com/dundalek/markmap/blob/c09614be60676725ccbc1cfd161f07aa7269e5c9/lib/d3-flextree.js#L98-L102 | train |
dundalek/markmap | lib/d3-flextree.js | setRightThread | function setRightThread(wt, i, sr, modsumsr) {
var ri = wt.children[i].er;
ri.tr = sr;
var diff = (modsumsr - sr.mod) - wt.children[i].mser;
ri.mod += diff;
ri.prelim -= diff;
wt.children[i].er = wt.children[i - 1].er;
wt.children[i].mser = wt.children[i - 1].mser;
} | javascript | function setRightThread(wt, i, sr, modsumsr) {
var ri = wt.children[i].er;
ri.tr = sr;
var diff = (modsumsr - sr.mod) - wt.children[i].mser;
ri.mod += diff;
ri.prelim -= diff;
wt.children[i].er = wt.children[i - 1].er;
wt.children[i].mser = wt.children[i - 1].mser;
} | [
"function",
"setRightThread",
"(",
"wt",
",",
"i",
",",
"sr",
",",
"modsumsr",
")",
"{",
"var",
"ri",
"=",
"wt",
".",
"children",
"[",
"i",
"]",
".",
"er",
";",
"ri",
".",
"tr",
"=",
"sr",
";",
"var",
"diff",
"=",
"(",
"modsumsr",
"-",
"sr",
... | Symmetrical to setLeftThread. | [
"Symmetrical",
"to",
"setLeftThread",
"."
] | c09614be60676725ccbc1cfd161f07aa7269e5c9 | https://github.com/dundalek/markmap/blob/c09614be60676725ccbc1cfd161f07aa7269e5c9/lib/d3-flextree.js#L250-L258 | train |
dundalek/markmap | lib/d3-flextree.js | positionRoot | function positionRoot(wt) {
wt.prelim = ( wt.children[0].prelim +
wt.children[0].mod -
wt.children[0].x_size/2 +
wt.children[wt.num_children - 1].mod +
wt.children[wt.num_children - 1].prelim +
wt.children[wt.num_children - ... | javascript | function positionRoot(wt) {
wt.prelim = ( wt.children[0].prelim +
wt.children[0].mod -
wt.children[0].x_size/2 +
wt.children[wt.num_children - 1].mod +
wt.children[wt.num_children - 1].prelim +
wt.children[wt.num_children - ... | [
"function",
"positionRoot",
"(",
"wt",
")",
"{",
"wt",
".",
"prelim",
"=",
"(",
"wt",
".",
"children",
"[",
"0",
"]",
".",
"prelim",
"+",
"wt",
".",
"children",
"[",
"0",
"]",
".",
"mod",
"-",
"wt",
".",
"children",
"[",
"0",
"]",
".",
"x_size"... | Position root between children, taking into account their mod. | [
"Position",
"root",
"between",
"children",
"taking",
"into",
"account",
"their",
"mod",
"."
] | c09614be60676725ccbc1cfd161f07aa7269e5c9 | https://github.com/dundalek/markmap/blob/c09614be60676725ccbc1cfd161f07aa7269e5c9/lib/d3-flextree.js#L261-L268 | train |
dundalek/markmap | lib/d3-flextree.js | addChildSpacing | function addChildSpacing(wt) {
var d = 0, modsumdelta = 0;
for (var i = 0; i < wt.num_children; i++) {
d += wt.children[i].shift;
modsumdelta += d + wt.children[i].change; ... | javascript | function addChildSpacing(wt) {
var d = 0, modsumdelta = 0;
for (var i = 0; i < wt.num_children; i++) {
d += wt.children[i].shift;
modsumdelta += d + wt.children[i].change; ... | [
"function",
"addChildSpacing",
"(",
"wt",
")",
"{",
"var",
"d",
"=",
"0",
",",
"modsumdelta",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"wt",
".",
"num_children",
";",
"i",
"++",
")",
"{",
"d",
"+=",
"wt",
".",
"children",... | Process change and shift to add intermediate spacing to mod. | [
"Process",
"change",
"and",
"shift",
"to",
"add",
"intermediate",
"spacing",
"to",
"mod",
"."
] | c09614be60676725ccbc1cfd161f07aa7269e5c9 | https://github.com/dundalek/markmap/blob/c09614be60676725ccbc1cfd161f07aa7269e5c9/lib/d3-flextree.js#L290-L297 | train |
dundalek/markmap | lib/d3-flextree.js | renormalize | function renormalize(wt) {
// If a fixed tree size is specified, scale x and y based on the extent.
// Compute the left-most, right-most, and depth-most nodes for extents.
if (size != null) {
var left = wt,
right = wt,
bottom = wt;
var toVisit = [wt],
node;
w... | javascript | function renormalize(wt) {
// If a fixed tree size is specified, scale x and y based on the extent.
// Compute the left-most, right-most, and depth-most nodes for extents.
if (size != null) {
var left = wt,
right = wt,
bottom = wt;
var toVisit = [wt],
node;
w... | [
"function",
"renormalize",
"(",
"wt",
")",
"{",
"// If a fixed tree size is specified, scale x and y based on the extent.",
"// Compute the left-most, right-most, and depth-most nodes for extents.",
"if",
"(",
"size",
"!=",
"null",
")",
"{",
"var",
"left",
"=",
"wt",
",",
"ri... | Renormalize the coordinates | [
"Renormalize",
"the",
"coordinates"
] | c09614be60676725ccbc1cfd161f07aa7269e5c9 | https://github.com/dundalek/markmap/blob/c09614be60676725ccbc1cfd161f07aa7269e5c9/lib/d3-flextree.js#L313-L357 | train |
contentful/contentful.js | lib/paged-sync.js | getSyncPage | function getSyncPage (http, items, query, { paginate }) {
if (query.nextSyncToken) {
query.sync_token = query.nextSyncToken
delete query.nextSyncToken
}
if (query.nextPageToken) {
query.sync_token = query.nextPageToken
delete query.nextPageToken
}
if (query.sync_token) {
delete query.ini... | javascript | function getSyncPage (http, items, query, { paginate }) {
if (query.nextSyncToken) {
query.sync_token = query.nextSyncToken
delete query.nextSyncToken
}
if (query.nextPageToken) {
query.sync_token = query.nextPageToken
delete query.nextPageToken
}
if (query.sync_token) {
delete query.ini... | [
"function",
"getSyncPage",
"(",
"http",
",",
"items",
",",
"query",
",",
"{",
"paginate",
"}",
")",
"{",
"if",
"(",
"query",
".",
"nextSyncToken",
")",
"{",
"query",
".",
"sync_token",
"=",
"query",
".",
"nextSyncToken",
"delete",
"query",
".",
"nextSync... | If the response contains a nextPageUrl, extracts the sync token to get the
next page and calls itself again with that token.
Otherwise, if the response contains a nextSyncUrl, extracts the sync token
and returns it.
On each call of this function, any retrieved items are collected in the
supplied items array, which gets... | [
"If",
"the",
"response",
"contains",
"a",
"nextPageUrl",
"extracts",
"the",
"sync",
"token",
"to",
"get",
"the",
"next",
"page",
"and",
"calls",
"itself",
"again",
"with",
"that",
"token",
".",
"Otherwise",
"if",
"the",
"response",
"contains",
"a",
"nextSync... | 0a3cd39b0b39b554129ec699024bfd09558c29a9 | https://github.com/contentful/contentful.js/blob/0a3cd39b0b39b554129ec699024bfd09558c29a9/lib/paged-sync.js#L128-L166 | train |
downshift-js/downshift | src/utils.js | scrollIntoView | function scrollIntoView(node, menuNode) {
if (node === null) {
return
}
const actions = computeScrollIntoView(node, {
boundary: menuNode,
block: 'nearest',
scrollMode: 'if-needed',
})
actions.forEach(({el, top, left}) => {
el.scrollTop = top
el.scrollLeft = left
})
} | javascript | function scrollIntoView(node, menuNode) {
if (node === null) {
return
}
const actions = computeScrollIntoView(node, {
boundary: menuNode,
block: 'nearest',
scrollMode: 'if-needed',
})
actions.forEach(({el, top, left}) => {
el.scrollTop = top
el.scrollLeft = left
})
} | [
"function",
"scrollIntoView",
"(",
"node",
",",
"menuNode",
")",
"{",
"if",
"(",
"node",
"===",
"null",
")",
"{",
"return",
"}",
"const",
"actions",
"=",
"computeScrollIntoView",
"(",
"node",
",",
"{",
"boundary",
":",
"menuNode",
",",
"block",
":",
"'ne... | Scroll node into view if necessary
@param {HTMLElement} node the element that should scroll into view
@param {HTMLElement} menuNode the menu element of the component | [
"Scroll",
"node",
"into",
"view",
"if",
"necessary"
] | 7dc7a5b4a06c640f0c375878b78b82b65119f89b | https://github.com/downshift-js/downshift/blob/7dc7a5b4a06c640f0c375878b78b82b65119f89b/src/utils.js#L25-L39 | train |
downshift-js/downshift | src/utils.js | debounce | function debounce(fn, time) {
let timeoutId
function cancel() {
if (timeoutId) {
clearTimeout(timeoutId)
}
}
function wrapper(...args) {
cancel()
timeoutId = setTimeout(() => {
timeoutId = null
fn(...args)
}, time)
}
wrapper.cancel = cancel
return wrapper
} | javascript | function debounce(fn, time) {
let timeoutId
function cancel() {
if (timeoutId) {
clearTimeout(timeoutId)
}
}
function wrapper(...args) {
cancel()
timeoutId = setTimeout(() => {
timeoutId = null
fn(...args)
}, time)
}
wrapper.cancel = cancel
return wrapper
} | [
"function",
"debounce",
"(",
"fn",
",",
"time",
")",
"{",
"let",
"timeoutId",
"function",
"cancel",
"(",
")",
"{",
"if",
"(",
"timeoutId",
")",
"{",
"clearTimeout",
"(",
"timeoutId",
")",
"}",
"}",
"function",
"wrapper",
"(",
"...",
"args",
")",
"{",
... | Simple debounce implementation. Will call the given
function once after the time given has passed since
it was last called.
@param {Function} fn the function to call after the time
@param {Number} time the time to wait
@return {Function} the debounced function | [
"Simple",
"debounce",
"implementation",
".",
"Will",
"call",
"the",
"given",
"function",
"once",
"after",
"the",
"time",
"given",
"has",
"passed",
"since",
"it",
"was",
"last",
"called",
"."
] | 7dc7a5b4a06c640f0c375878b78b82b65119f89b | https://github.com/downshift-js/downshift/blob/7dc7a5b4a06c640f0c375878b78b82b65119f89b/src/utils.js#L58-L78 | train |
downshift-js/downshift | src/utils.js | callAllEventHandlers | function callAllEventHandlers(...fns) {
return (event, ...args) =>
fns.some(fn => {
if (fn) {
fn(event, ...args)
}
return (
event.preventDownshiftDefault ||
(event.hasOwnProperty('nativeEvent') &&
event.nativeEvent.preventDownshiftDefault)
)
})
} | javascript | function callAllEventHandlers(...fns) {
return (event, ...args) =>
fns.some(fn => {
if (fn) {
fn(event, ...args)
}
return (
event.preventDownshiftDefault ||
(event.hasOwnProperty('nativeEvent') &&
event.nativeEvent.preventDownshiftDefault)
)
})
} | [
"function",
"callAllEventHandlers",
"(",
"...",
"fns",
")",
"{",
"return",
"(",
"event",
",",
"...",
"args",
")",
"=>",
"fns",
".",
"some",
"(",
"fn",
"=>",
"{",
"if",
"(",
"fn",
")",
"{",
"fn",
"(",
"event",
",",
"...",
"args",
")",
"}",
"return... | This is intended to be used to compose event handlers.
They are executed in order until one of them sets
`event.preventDownshiftDefault = true`.
@param {...Function} fns the event handler functions
@return {Function} the event handler to add to an element | [
"This",
"is",
"intended",
"to",
"be",
"used",
"to",
"compose",
"event",
"handlers",
".",
"They",
"are",
"executed",
"in",
"order",
"until",
"one",
"of",
"them",
"sets",
"event",
".",
"preventDownshiftDefault",
"=",
"true",
"."
] | 7dc7a5b4a06c640f0c375878b78b82b65119f89b | https://github.com/downshift-js/downshift/blob/7dc7a5b4a06c640f0c375878b78b82b65119f89b/src/utils.js#L87-L99 | train |
downshift-js/downshift | src/utils.js | getNextWrappingIndex | function getNextWrappingIndex(moveAmount, baseIndex, itemCount) {
const itemsLastIndex = itemCount - 1
if (
typeof baseIndex !== 'number' ||
baseIndex < 0 ||
baseIndex >= itemCount
) {
baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1
}
let newIndex = baseIndex + moveAmount
if (newIndex ... | javascript | function getNextWrappingIndex(moveAmount, baseIndex, itemCount) {
const itemsLastIndex = itemCount - 1
if (
typeof baseIndex !== 'number' ||
baseIndex < 0 ||
baseIndex >= itemCount
) {
baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1
}
let newIndex = baseIndex + moveAmount
if (newIndex ... | [
"function",
"getNextWrappingIndex",
"(",
"moveAmount",
",",
"baseIndex",
",",
"itemCount",
")",
"{",
"const",
"itemsLastIndex",
"=",
"itemCount",
"-",
"1",
"if",
"(",
"typeof",
"baseIndex",
"!==",
"'number'",
"||",
"baseIndex",
"<",
"0",
"||",
"baseIndex",
">=... | Returns the new index in the list, in a circular way. If next value is out of bonds from the total,
it will wrap to either 0 or itemCount - 1.
@param {number} moveAmount Number of positions to move. Negative to move backwards, positive forwards.
@param {number} baseIndex The initial position to move from.
@param {numb... | [
"Returns",
"the",
"new",
"index",
"in",
"the",
"list",
"in",
"a",
"circular",
"way",
".",
"If",
"next",
"value",
"is",
"out",
"of",
"bonds",
"from",
"the",
"total",
"it",
"will",
"wrap",
"to",
"either",
"0",
"or",
"itemCount",
"-",
"1",
"."
] | 7dc7a5b4a06c640f0c375878b78b82b65119f89b | https://github.com/downshift-js/downshift/blob/7dc7a5b4a06c640f0c375878b78b82b65119f89b/src/utils.js#L276-L293 | train |
downshift-js/downshift | src/set-a11y-status.js | getStatusDiv | function getStatusDiv() {
if (statusDiv) {
return statusDiv
}
statusDiv = document.createElement('div')
statusDiv.setAttribute('id', 'a11y-status-message')
statusDiv.setAttribute('role', 'status')
statusDiv.setAttribute('aria-live', 'polite')
statusDiv.setAttribute('aria-relevant', 'additions text')
... | javascript | function getStatusDiv() {
if (statusDiv) {
return statusDiv
}
statusDiv = document.createElement('div')
statusDiv.setAttribute('id', 'a11y-status-message')
statusDiv.setAttribute('role', 'status')
statusDiv.setAttribute('aria-live', 'polite')
statusDiv.setAttribute('aria-relevant', 'additions text')
... | [
"function",
"getStatusDiv",
"(",
")",
"{",
"if",
"(",
"statusDiv",
")",
"{",
"return",
"statusDiv",
"}",
"statusDiv",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
"statusDiv",
".",
"setAttribute",
"(",
"'id'",
",",
"'a11y-status-message'",
")",
... | Get the status node or create it if it does not already exist
@return {HTMLElement} the status node | [
"Get",
"the",
"status",
"node",
"or",
"create",
"it",
"if",
"it",
"does",
"not",
"already",
"exist"
] | 7dc7a5b4a06c640f0c375878b78b82b65119f89b | https://github.com/downshift-js/downshift/blob/7dc7a5b4a06c640f0c375878b78b82b65119f89b/src/set-a11y-status.js#L34-L55 | train |
dataarts/dat.gui | src/dat/gui/GUI.js | function(controller) {
// TODO listening?
this.__ul.removeChild(controller.__li);
this.__controllers.splice(this.__controllers.indexOf(controller), 1);
const _this = this;
common.defer(function() {
_this.onResize();
});
} | javascript | function(controller) {
// TODO listening?
this.__ul.removeChild(controller.__li);
this.__controllers.splice(this.__controllers.indexOf(controller), 1);
const _this = this;
common.defer(function() {
_this.onResize();
});
} | [
"function",
"(",
"controller",
")",
"{",
"// TODO listening?",
"this",
".",
"__ul",
".",
"removeChild",
"(",
"controller",
".",
"__li",
")",
";",
"this",
".",
"__controllers",
".",
"splice",
"(",
"this",
".",
"__controllers",
".",
"indexOf",
"(",
"controller... | Removes the given controller from the GUI.
@param {Controller} controller
@instance | [
"Removes",
"the",
"given",
"controller",
"from",
"the",
"GUI",
"."
] | c2edd82e39d99e9d8b9f1e79011c675bc81eff52 | https://github.com/dataarts/dat.gui/blob/c2edd82e39d99e9d8b9f1e79011c675bc81eff52/src/dat/gui/GUI.js#L564-L572 | train | |
immersive-web/webvr-polyfill | examples/third_party/three.js/VREffect.js | getEyeMatrices | function getEyeMatrices( frameData ) {
// Compute the matrix for the position of the head based on the pose
if ( frameData.pose.orientation ) {
poseOrientation.fromArray( frameData.pose.orientation );
headMatrix.makeRotationFromQuaternion( poseOrientation );
} else {
headMatrix.identity();
}
if... | javascript | function getEyeMatrices( frameData ) {
// Compute the matrix for the position of the head based on the pose
if ( frameData.pose.orientation ) {
poseOrientation.fromArray( frameData.pose.orientation );
headMatrix.makeRotationFromQuaternion( poseOrientation );
} else {
headMatrix.identity();
}
if... | [
"function",
"getEyeMatrices",
"(",
"frameData",
")",
"{",
"// Compute the matrix for the position of the head based on the pose",
"if",
"(",
"frameData",
".",
"pose",
".",
"orientation",
")",
"{",
"poseOrientation",
".",
"fromArray",
"(",
"frameData",
".",
"pose",
".",
... | Compute model matrices of the eyes with respect to the head. | [
"Compute",
"model",
"matrices",
"of",
"the",
"eyes",
"with",
"respect",
"to",
"the",
"head",
"."
] | ceb80d0e2d1d66e318782e30d89e0a09ca4857cd | https://github.com/immersive-web/webvr-polyfill/blob/ceb80d0e2d1d66e318782e30d89e0a09ca4857cd/examples/third_party/three.js/VREffect.js#L422-L460 | train |
IdentityModel/oidc-client-js | jsrsasign/ext/rng.js | rng_seed_int | function rng_seed_int(x) {
rng_pool[rng_pptr++] ^= x & 255;
rng_pool[rng_pptr++] ^= (x >> 8) & 255;
rng_pool[rng_pptr++] ^= (x >> 16) & 255;
rng_pool[rng_pptr++] ^= (x >> 24) & 255;
if(rng_pptr >= rng_psize) rng_pptr -= rng_psize;
} | javascript | function rng_seed_int(x) {
rng_pool[rng_pptr++] ^= x & 255;
rng_pool[rng_pptr++] ^= (x >> 8) & 255;
rng_pool[rng_pptr++] ^= (x >> 16) & 255;
rng_pool[rng_pptr++] ^= (x >> 24) & 255;
if(rng_pptr >= rng_psize) rng_pptr -= rng_psize;
} | [
"function",
"rng_seed_int",
"(",
"x",
")",
"{",
"rng_pool",
"[",
"rng_pptr",
"++",
"]",
"^=",
"x",
"&",
"255",
";",
"rng_pool",
"[",
"rng_pptr",
"++",
"]",
"^=",
"(",
"x",
">>",
"8",
")",
"&",
"255",
";",
"rng_pool",
"[",
"rng_pptr",
"++",
"]",
"... | Mix in a 32-bit integer into the pool | [
"Mix",
"in",
"a",
"32",
"-",
"bit",
"integer",
"into",
"the",
"pool"
] | 9adbe5627b82a84fe7b5a6cb0441e4cc1a624500 | https://github.com/IdentityModel/oidc-client-js/blob/9adbe5627b82a84fe7b5a6cb0441e4cc1a624500/jsrsasign/ext/rng.js#L14-L20 | train |
IdentityModel/oidc-client-js | jsrsasign/ext/ec.js | curveFpDecodePointHex | function curveFpDecodePointHex(s) {
switch(parseInt(s.substr(0,2), 16)) { // first byte
case 0:
return this.infinity;
case 2:
case 3:
// point compression not supported yet
return null;
case 4:
case 6:
case 7:
var len = (s.length - 2) / 2;
var xHex = s.substr(2, len);
var yHex = s.subs... | javascript | function curveFpDecodePointHex(s) {
switch(parseInt(s.substr(0,2), 16)) { // first byte
case 0:
return this.infinity;
case 2:
case 3:
// point compression not supported yet
return null;
case 4:
case 6:
case 7:
var len = (s.length - 2) / 2;
var xHex = s.substr(2, len);
var yHex = s.subs... | [
"function",
"curveFpDecodePointHex",
"(",
"s",
")",
"{",
"switch",
"(",
"parseInt",
"(",
"s",
".",
"substr",
"(",
"0",
",",
"2",
")",
",",
"16",
")",
")",
"{",
"// first byte",
"case",
"0",
":",
"return",
"this",
".",
"infinity",
";",
"case",
"2",
... | for now, work with hex strings because they're easier in JS | [
"for",
"now",
"work",
"with",
"hex",
"strings",
"because",
"they",
"re",
"easier",
"in",
"JS"
] | 9adbe5627b82a84fe7b5a6cb0441e4cc1a624500 | https://github.com/IdentityModel/oidc-client-js/blob/9adbe5627b82a84fe7b5a6cb0441e4cc1a624500/jsrsasign/ext/ec.js#L288-L310 | train |
IdentityModel/oidc-client-js | gulpfile.js | build_lib_sourcemap | function build_lib_sourcemap(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'development',
entry: npmEntry,
output: {
filename:'oidc-client.js',
libraryTarget:'umd',
// Workaround for https://github.com/webpack/webpack/issues/6642
... | javascript | function build_lib_sourcemap(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'development',
entry: npmEntry,
output: {
filename:'oidc-client.js',
libraryTarget:'umd',
// Workaround for https://github.com/webpack/webpack/issues/6642
... | [
"function",
"build_lib_sourcemap",
"(",
")",
"{",
"// run webpack",
"return",
"gulp",
".",
"src",
"(",
"'index.js'",
")",
".",
"pipe",
"(",
"webpackStream",
"(",
"createWebpackConfig",
"(",
"{",
"mode",
":",
"'development'",
",",
"entry",
":",
"npmEntry",
",",... | npm compliant build with source-maps | [
"npm",
"compliant",
"build",
"with",
"source",
"-",
"maps"
] | 9adbe5627b82a84fe7b5a6cb0441e4cc1a624500 | https://github.com/IdentityModel/oidc-client-js/blob/9adbe5627b82a84fe7b5a6cb0441e4cc1a624500/gulpfile.js#L13-L28 | train |
IdentityModel/oidc-client-js | gulpfile.js | build_lib_min | function build_lib_min(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'production',
entry: npmEntry,
output: {
filename:'oidc-client.min.js',
libraryTarget:'umd',
// Workaround for https://github.com/webpack/webpack/issues/6642
... | javascript | function build_lib_min(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'production',
entry: npmEntry,
output: {
filename:'oidc-client.min.js',
libraryTarget:'umd',
// Workaround for https://github.com/webpack/webpack/issues/6642
... | [
"function",
"build_lib_min",
"(",
")",
"{",
"// run webpack",
"return",
"gulp",
".",
"src",
"(",
"'index.js'",
")",
".",
"pipe",
"(",
"webpackStream",
"(",
"createWebpackConfig",
"(",
"{",
"mode",
":",
"'production'",
",",
"entry",
":",
"npmEntry",
",",
"out... | npm compliant build without source-maps & minified | [
"npm",
"compliant",
"build",
"without",
"source",
"-",
"maps",
"&",
"minified"
] | 9adbe5627b82a84fe7b5a6cb0441e4cc1a624500 | https://github.com/IdentityModel/oidc-client-js/blob/9adbe5627b82a84fe7b5a6cb0441e4cc1a624500/gulpfile.js#L31-L55 | train |
IdentityModel/oidc-client-js | gulpfile.js | build_dist_sourcemap | function build_dist_sourcemap(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'development',
entry: classicEntry,
output: {
filename:'oidc-client.js',
libraryTarget:'var',
library:'Oidc'
},
plugins: [],
devtool:'inline-sour... | javascript | function build_dist_sourcemap(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'development',
entry: classicEntry,
output: {
filename:'oidc-client.js',
libraryTarget:'var',
library:'Oidc'
},
plugins: [],
devtool:'inline-sour... | [
"function",
"build_dist_sourcemap",
"(",
")",
"{",
"// run webpack",
"return",
"gulp",
".",
"src",
"(",
"'index.js'",
")",
".",
"pipe",
"(",
"webpackStream",
"(",
"createWebpackConfig",
"(",
"{",
"mode",
":",
"'development'",
",",
"entry",
":",
"classicEntry",
... | classic build with sourcemaps | [
"classic",
"build",
"with",
"sourcemaps"
] | 9adbe5627b82a84fe7b5a6cb0441e4cc1a624500 | https://github.com/IdentityModel/oidc-client-js/blob/9adbe5627b82a84fe7b5a6cb0441e4cc1a624500/gulpfile.js#L58-L72 | train |
IdentityModel/oidc-client-js | gulpfile.js | build_dist_min | function build_dist_min(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'production',
entry: classicEntry,
output: {
filename:'oidc-client.min.js',
libraryTarget:'var',
library:'Oidc'
},
plugins: [],
devtool: false,
opt... | javascript | function build_dist_min(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'production',
entry: classicEntry,
output: {
filename:'oidc-client.min.js',
libraryTarget:'var',
library:'Oidc'
},
plugins: [],
devtool: false,
opt... | [
"function",
"build_dist_min",
"(",
")",
"{",
"// run webpack",
"return",
"gulp",
".",
"src",
"(",
"'index.js'",
")",
".",
"pipe",
"(",
"webpackStream",
"(",
"createWebpackConfig",
"(",
"{",
"mode",
":",
"'production'",
",",
"entry",
":",
"classicEntry",
",",
... | classic build without sourcemaps & minified | [
"classic",
"build",
"without",
"sourcemaps",
"&",
"minified"
] | 9adbe5627b82a84fe7b5a6cb0441e4cc1a624500 | https://github.com/IdentityModel/oidc-client-js/blob/9adbe5627b82a84fe7b5a6cb0441e4cc1a624500/gulpfile.js#L75-L98 | train |
overtrue/share.js | src/js/social-share.js | share | function share(elem, options) {
var data = mixin({}, defaults, options || {}, dataset(elem));
if (data.imageSelector) {
data.image = querySelectorAlls(data.imageSelector).map(function(item) {
return item.src;
}).join('||');
}
addClass(elem, 'shar... | javascript | function share(elem, options) {
var data = mixin({}, defaults, options || {}, dataset(elem));
if (data.imageSelector) {
data.image = querySelectorAlls(data.imageSelector).map(function(item) {
return item.src;
}).join('||');
}
addClass(elem, 'shar... | [
"function",
"share",
"(",
"elem",
",",
"options",
")",
"{",
"var",
"data",
"=",
"mixin",
"(",
"{",
"}",
",",
"defaults",
",",
"options",
"||",
"{",
"}",
",",
"dataset",
"(",
"elem",
")",
")",
";",
"if",
"(",
"data",
".",
"imageSelector",
")",
"{"... | Initialize a share bar.
@param {Object} $options globals (optional).
@return {Void} | [
"Initialize",
"a",
"share",
"bar",
"."
] | ddc699dfabf56b41f11865b6195dda05614f1e2a | https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L101-L115 | train |
overtrue/share.js | src/js/social-share.js | makeUrl | function makeUrl(name, data) {
if (! data['summary']){
data['summary'] = data['description'];
}
return templates[name].replace(/\{\{(\w)(\w*)\}\}/g, function (m, fix, key) {
var nameKey = name + fix + key.toLowerCase();
key = (fix + key).toLowerCase();
... | javascript | function makeUrl(name, data) {
if (! data['summary']){
data['summary'] = data['description'];
}
return templates[name].replace(/\{\{(\w)(\w*)\}\}/g, function (m, fix, key) {
var nameKey = name + fix + key.toLowerCase();
key = (fix + key).toLowerCase();
... | [
"function",
"makeUrl",
"(",
"name",
",",
"data",
")",
"{",
"if",
"(",
"!",
"data",
"[",
"'summary'",
"]",
")",
"{",
"data",
"[",
"'summary'",
"]",
"=",
"data",
"[",
"'description'",
"]",
";",
"}",
"return",
"templates",
"[",
"name",
"]",
".",
"repl... | Build the url of icon.
@param {String} name
@param {Object} data
@returns {String} | [
"Build",
"the",
"url",
"of",
"icon",
"."
] | ddc699dfabf56b41f11865b6195dda05614f1e2a | https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L215-L227 | train |
overtrue/share.js | src/js/social-share.js | querySelectorAlls | function querySelectorAlls(str) {
return (document.querySelectorAll || window.jQuery || window.Zepto || selector).call(document, str);
} | javascript | function querySelectorAlls(str) {
return (document.querySelectorAll || window.jQuery || window.Zepto || selector).call(document, str);
} | [
"function",
"querySelectorAlls",
"(",
"str",
")",
"{",
"return",
"(",
"document",
".",
"querySelectorAll",
"||",
"window",
".",
"jQuery",
"||",
"window",
".",
"Zepto",
"||",
"selector",
")",
".",
"call",
"(",
"document",
",",
"str",
")",
";",
"}"
] | Supports querySelectorAll, jQuery, Zepto and simple selector.
@param str
@returns {*} | [
"Supports",
"querySelectorAll",
"jQuery",
"Zepto",
"and",
"simple",
"selector",
"."
] | ddc699dfabf56b41f11865b6195dda05614f1e2a | https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L237-L239 | train |
overtrue/share.js | src/js/social-share.js | selector | function selector(str) {
var elems = [];
each(str.split(/\s*,\s*/), function(s) {
var m = s.match(/([#.])(\w+)/);
if (m === null) {
throw Error('Supports only simple single #ID or .CLASS selector.');
}
if (m[1]) {
var elem... | javascript | function selector(str) {
var elems = [];
each(str.split(/\s*,\s*/), function(s) {
var m = s.match(/([#.])(\w+)/);
if (m === null) {
throw Error('Supports only simple single #ID or .CLASS selector.');
}
if (m[1]) {
var elem... | [
"function",
"selector",
"(",
"str",
")",
"{",
"var",
"elems",
"=",
"[",
"]",
";",
"each",
"(",
"str",
".",
"split",
"(",
"/",
"\\s*,\\s*",
"/",
")",
",",
"function",
"(",
"s",
")",
"{",
"var",
"m",
"=",
"s",
".",
"match",
"(",
"/",
"([#.])(\\w+... | Simple selector.
@param {String} str #ID or .CLASS
@returns {Array} | [
"Simple",
"selector",
"."
] | ddc699dfabf56b41f11865b6195dda05614f1e2a | https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L249-L270 | train |
overtrue/share.js | src/js/social-share.js | addClass | function addClass(elem, value) {
if (value && typeof value === "string") {
var classNames = (elem.className + ' ' + value).split(/\s+/);
var setClass = ' ';
each(classNames, function (className) {
if (setClass.indexOf(' ' + className + ' ') < 0) {
... | javascript | function addClass(elem, value) {
if (value && typeof value === "string") {
var classNames = (elem.className + ' ' + value).split(/\s+/);
var setClass = ' ';
each(classNames, function (className) {
if (setClass.indexOf(' ' + className + ' ') < 0) {
... | [
"function",
"addClass",
"(",
"elem",
",",
"value",
")",
"{",
"if",
"(",
"value",
"&&",
"typeof",
"value",
"===",
"\"string\"",
")",
"{",
"var",
"classNames",
"=",
"(",
"elem",
".",
"className",
"+",
"' '",
"+",
"value",
")",
".",
"split",
"(",
"/",
... | Add the classNames for element.
@param {Element} elem
@param {String} value | [
"Add",
"the",
"classNames",
"for",
"element",
"."
] | ddc699dfabf56b41f11865b6195dda05614f1e2a | https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L279-L292 | train |
overtrue/share.js | src/js/social-share.js | getElementsByClassName | function getElementsByClassName(elem, name, tag) {
if (elem.getElementsByClassName) {
return elem.getElementsByClassName(name);
}
var elements = [];
var elems = elem.getElementsByTagName(tag || '*');
name = ' ' + name + ' ';
each(elems, function (elem) {
... | javascript | function getElementsByClassName(elem, name, tag) {
if (elem.getElementsByClassName) {
return elem.getElementsByClassName(name);
}
var elements = [];
var elems = elem.getElementsByTagName(tag || '*');
name = ' ' + name + ' ';
each(elems, function (elem) {
... | [
"function",
"getElementsByClassName",
"(",
"elem",
",",
"name",
",",
"tag",
")",
"{",
"if",
"(",
"elem",
".",
"getElementsByClassName",
")",
"{",
"return",
"elem",
".",
"getElementsByClassName",
"(",
"name",
")",
";",
"}",
"var",
"elements",
"=",
"[",
"]",... | Get elements By className for IE8-
@param {Element} elem element
@param {String} name className
@param {String} tag tagName
@returns {HTMLCollection|Array} | [
"Get",
"elements",
"By",
"className",
"for",
"IE8",
"-"
] | ddc699dfabf56b41f11865b6195dda05614f1e2a | https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L316-L332 | train |
overtrue/share.js | src/js/social-share.js | createElementByString | function createElementByString(str) {
var div = document.createElement('div');
div.innerHTML = str;
return div.childNodes;
} | javascript | function createElementByString(str) {
var div = document.createElement('div');
div.innerHTML = str;
return div.childNodes;
} | [
"function",
"createElementByString",
"(",
"str",
")",
"{",
"var",
"div",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"div",
".",
"innerHTML",
"=",
"str",
";",
"return",
"div",
".",
"childNodes",
";",
"}"
] | Create element by string.
@param {String} str
@returns {NodeList} | [
"Create",
"element",
"by",
"string",
"."
] | ddc699dfabf56b41f11865b6195dda05614f1e2a | https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L342-L347 | 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.