id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
7,900 | firebase/angularfire | src/database/FirebaseArray.js | function(indexOrItem) {
this._assertNotDestroyed('$save');
var self = this;
var item = self._resolveItem(indexOrItem);
var key = self.$keyAt(item);
var def = $q.defer();
if( key !== null ) {
var ref = self.$ref().ref.child(key);
var dataJSON;
try {
dataJSON = $firebaseUtils.toJSON(item);
} catch (err) {
def.reject(err);
}
if (typeof dataJSON !== 'undefined') {
$firebaseUtils.doSet(ref, dataJSON).then(function() {
self.$$notify('child_changed', key);
def.resolve(ref);
}).catch(def.reject);
}
}
else {
def.reject('Invalid record; could not determine key for '+indexOrItem);
}
return def.promise;
} | javascript | function(indexOrItem) {
this._assertNotDestroyed('$save');
var self = this;
var item = self._resolveItem(indexOrItem);
var key = self.$keyAt(item);
var def = $q.defer();
if( key !== null ) {
var ref = self.$ref().ref.child(key);
var dataJSON;
try {
dataJSON = $firebaseUtils.toJSON(item);
} catch (err) {
def.reject(err);
}
if (typeof dataJSON !== 'undefined') {
$firebaseUtils.doSet(ref, dataJSON).then(function() {
self.$$notify('child_changed', key);
def.resolve(ref);
}).catch(def.reject);
}
}
else {
def.reject('Invalid record; could not determine key for '+indexOrItem);
}
return def.promise;
} | [
"function",
"(",
"indexOrItem",
")",
"{",
"this",
".",
"_assertNotDestroyed",
"(",
"'$save'",
")",
";",
"var",
"self",
"=",
"this",
";",
"var",
"item",
"=",
"self",
".",
"_resolveItem",
"(",
"indexOrItem",
")",
";",
"var",
"key",
"=",
"self",
".",
"$keyAt",
"(",
"item",
")",
";",
"var",
"def",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"if",
"(",
"key",
"!==",
"null",
")",
"{",
"var",
"ref",
"=",
"self",
".",
"$ref",
"(",
")",
".",
"ref",
".",
"child",
"(",
"key",
")",
";",
"var",
"dataJSON",
";",
"try",
"{",
"dataJSON",
"=",
"$firebaseUtils",
".",
"toJSON",
"(",
"item",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"def",
".",
"reject",
"(",
"err",
")",
";",
"}",
"if",
"(",
"typeof",
"dataJSON",
"!==",
"'undefined'",
")",
"{",
"$firebaseUtils",
".",
"doSet",
"(",
"ref",
",",
"dataJSON",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"self",
".",
"$$notify",
"(",
"'child_changed'",
",",
"key",
")",
";",
"def",
".",
"resolve",
"(",
"ref",
")",
";",
"}",
")",
".",
"catch",
"(",
"def",
".",
"reject",
")",
";",
"}",
"}",
"else",
"{",
"def",
".",
"reject",
"(",
"'Invalid record; could not determine key for '",
"+",
"indexOrItem",
")",
";",
"}",
"return",
"def",
".",
"promise",
";",
"}"
] | Pass either an item in the array or the index of an item and it will be saved back
to Firebase. While the array is read-only and its structure should not be changed,
it is okay to modify properties on the objects it contains and then save those back
individually.
Returns a future which is resolved when the data has successfully saved to the server.
The resolve callback will be passed a Firebase ref representing the saved element.
If passed an invalid index or an object which is not a record in this array,
the promise will be rejected.
@param {int|object} indexOrItem
@returns a promise resolved after data is saved | [
"Pass",
"either",
"an",
"item",
"in",
"the",
"array",
"or",
"the",
"index",
"of",
"an",
"item",
"and",
"it",
"will",
"be",
"saved",
"back",
"to",
"Firebase",
".",
"While",
"the",
"array",
"is",
"read",
"-",
"only",
"and",
"its",
"structure",
"should",
"not",
"be",
"changed",
"it",
"is",
"okay",
"to",
"modify",
"properties",
"on",
"the",
"objects",
"it",
"contains",
"and",
"then",
"save",
"those",
"back",
"individually",
"."
] | b6dca6ea5a81b3edd44230fb1cb6ca62419f1926 | https://github.com/firebase/angularfire/blob/b6dca6ea5a81b3edd44230fb1cb6ca62419f1926/src/database/FirebaseArray.js#L155-L184 |
|
7,901 | firebase/angularfire | src/database/FirebaseArray.js | function(rec, prevChild) {
var i;
if( prevChild === null ) {
i = 0;
}
else {
i = this.$indexFor(prevChild)+1;
if( i === 0 ) { i = this.$list.length; }
}
this.$list.splice(i, 0, rec);
this._indexCache[this.$$getKey(rec)] = i;
return i;
} | javascript | function(rec, prevChild) {
var i;
if( prevChild === null ) {
i = 0;
}
else {
i = this.$indexFor(prevChild)+1;
if( i === 0 ) { i = this.$list.length; }
}
this.$list.splice(i, 0, rec);
this._indexCache[this.$$getKey(rec)] = i;
return i;
} | [
"function",
"(",
"rec",
",",
"prevChild",
")",
"{",
"var",
"i",
";",
"if",
"(",
"prevChild",
"===",
"null",
")",
"{",
"i",
"=",
"0",
";",
"}",
"else",
"{",
"i",
"=",
"this",
".",
"$indexFor",
"(",
"prevChild",
")",
"+",
"1",
";",
"if",
"(",
"i",
"===",
"0",
")",
"{",
"i",
"=",
"this",
".",
"$list",
".",
"length",
";",
"}",
"}",
"this",
".",
"$list",
".",
"splice",
"(",
"i",
",",
"0",
",",
"rec",
")",
";",
"this",
".",
"_indexCache",
"[",
"this",
".",
"$$getKey",
"(",
"rec",
")",
"]",
"=",
"i",
";",
"return",
"i",
";",
"}"
] | Used to insert a new record into the array at a specific position. If prevChild is
null, is inserted first, if prevChild is not found, it is inserted last, otherwise,
it goes immediately after prevChild.
@param {object} rec
@param {string|null} prevChild
@private | [
"Used",
"to",
"insert",
"a",
"new",
"record",
"into",
"the",
"array",
"at",
"a",
"specific",
"position",
".",
"If",
"prevChild",
"is",
"null",
"is",
"inserted",
"first",
"if",
"prevChild",
"is",
"not",
"found",
"it",
"is",
"inserted",
"last",
"otherwise",
"it",
"goes",
"immediately",
"after",
"prevChild",
"."
] | b6dca6ea5a81b3edd44230fb1cb6ca62419f1926 | https://github.com/firebase/angularfire/blob/b6dca6ea5a81b3edd44230fb1cb6ca62419f1926/src/database/FirebaseArray.js#L512-L524 |
|
7,902 | firebase/angularfire | src/database/FirebaseArray.js | function(indexOrItem) {
var list = this.$list;
if( angular.isNumber(indexOrItem) && indexOrItem >= 0 && list.length >= indexOrItem ) {
return list[indexOrItem];
}
else if( angular.isObject(indexOrItem) ) {
// it must be an item in this array; it's not sufficient for it just to have
// a $id or even a $id that is in the array, it must be an actual record
// the fastest way to determine this is to use $getRecord (to avoid iterating all recs)
// and compare the two
var key = this.$$getKey(indexOrItem);
var rec = this.$getRecord(key);
return rec === indexOrItem? rec : null;
}
return null;
} | javascript | function(indexOrItem) {
var list = this.$list;
if( angular.isNumber(indexOrItem) && indexOrItem >= 0 && list.length >= indexOrItem ) {
return list[indexOrItem];
}
else if( angular.isObject(indexOrItem) ) {
// it must be an item in this array; it's not sufficient for it just to have
// a $id or even a $id that is in the array, it must be an actual record
// the fastest way to determine this is to use $getRecord (to avoid iterating all recs)
// and compare the two
var key = this.$$getKey(indexOrItem);
var rec = this.$getRecord(key);
return rec === indexOrItem? rec : null;
}
return null;
} | [
"function",
"(",
"indexOrItem",
")",
"{",
"var",
"list",
"=",
"this",
".",
"$list",
";",
"if",
"(",
"angular",
".",
"isNumber",
"(",
"indexOrItem",
")",
"&&",
"indexOrItem",
">=",
"0",
"&&",
"list",
".",
"length",
">=",
"indexOrItem",
")",
"{",
"return",
"list",
"[",
"indexOrItem",
"]",
";",
"}",
"else",
"if",
"(",
"angular",
".",
"isObject",
"(",
"indexOrItem",
")",
")",
"{",
"// it must be an item in this array; it's not sufficient for it just to have",
"// a $id or even a $id that is in the array, it must be an actual record",
"// the fastest way to determine this is to use $getRecord (to avoid iterating all recs)",
"// and compare the two",
"var",
"key",
"=",
"this",
".",
"$$getKey",
"(",
"indexOrItem",
")",
";",
"var",
"rec",
"=",
"this",
".",
"$getRecord",
"(",
"key",
")",
";",
"return",
"rec",
"===",
"indexOrItem",
"?",
"rec",
":",
"null",
";",
"}",
"return",
"null",
";",
"}"
] | Resolves a variable which may contain an integer or an item that exists in this array.
Returns the item or null if it does not exist.
@param indexOrItem
@returns {*}
@private | [
"Resolves",
"a",
"variable",
"which",
"may",
"contain",
"an",
"integer",
"or",
"an",
"item",
"that",
"exists",
"in",
"this",
"array",
".",
"Returns",
"the",
"item",
"or",
"null",
"if",
"it",
"does",
"not",
"exist",
"."
] | b6dca6ea5a81b3edd44230fb1cb6ca62419f1926 | https://github.com/firebase/angularfire/blob/b6dca6ea5a81b3edd44230fb1cb6ca62419f1926/src/database/FirebaseArray.js#L551-L566 |
|
7,903 | lance-gg/lance | src/physics/SimplePhysics/BruteForceCollisionDetection.js | getBox | function getBox(o) {
return {
xMin: o.position.x,
xMax: o.position.x + o.width,
yMin: o.position.y,
yMax: o.position.y + o.height
};
} | javascript | function getBox(o) {
return {
xMin: o.position.x,
xMax: o.position.x + o.width,
yMin: o.position.y,
yMax: o.position.y + o.height
};
} | [
"function",
"getBox",
"(",
"o",
")",
"{",
"return",
"{",
"xMin",
":",
"o",
".",
"position",
".",
"x",
",",
"xMax",
":",
"o",
".",
"position",
".",
"x",
"+",
"o",
".",
"width",
",",
"yMin",
":",
"o",
".",
"position",
".",
"y",
",",
"yMax",
":",
"o",
".",
"position",
".",
"y",
"+",
"o",
".",
"height",
"}",
";",
"}"
] | get bounding box of object o | [
"get",
"bounding",
"box",
"of",
"object",
"o"
] | af5dcaec10c9a2e3e373bf53528d4a1d0f57e3b6 | https://github.com/lance-gg/lance/blob/af5dcaec10c9a2e3e373bf53528d4a1d0f57e3b6/src/physics/SimplePhysics/BruteForceCollisionDetection.js#L138-L145 |
7,904 | expressjs/morgan | index.js | clfdate | function clfdate (dateTime) {
var date = dateTime.getUTCDate()
var hour = dateTime.getUTCHours()
var mins = dateTime.getUTCMinutes()
var secs = dateTime.getUTCSeconds()
var year = dateTime.getUTCFullYear()
var month = CLF_MONTH[dateTime.getUTCMonth()]
return pad2(date) + '/' + month + '/' + year +
':' + pad2(hour) + ':' + pad2(mins) + ':' + pad2(secs) +
' +0000'
} | javascript | function clfdate (dateTime) {
var date = dateTime.getUTCDate()
var hour = dateTime.getUTCHours()
var mins = dateTime.getUTCMinutes()
var secs = dateTime.getUTCSeconds()
var year = dateTime.getUTCFullYear()
var month = CLF_MONTH[dateTime.getUTCMonth()]
return pad2(date) + '/' + month + '/' + year +
':' + pad2(hour) + ':' + pad2(mins) + ':' + pad2(secs) +
' +0000'
} | [
"function",
"clfdate",
"(",
"dateTime",
")",
"{",
"var",
"date",
"=",
"dateTime",
".",
"getUTCDate",
"(",
")",
"var",
"hour",
"=",
"dateTime",
".",
"getUTCHours",
"(",
")",
"var",
"mins",
"=",
"dateTime",
".",
"getUTCMinutes",
"(",
")",
"var",
"secs",
"=",
"dateTime",
".",
"getUTCSeconds",
"(",
")",
"var",
"year",
"=",
"dateTime",
".",
"getUTCFullYear",
"(",
")",
"var",
"month",
"=",
"CLF_MONTH",
"[",
"dateTime",
".",
"getUTCMonth",
"(",
")",
"]",
"return",
"pad2",
"(",
"date",
")",
"+",
"'/'",
"+",
"month",
"+",
"'/'",
"+",
"year",
"+",
"':'",
"+",
"pad2",
"(",
"hour",
")",
"+",
"':'",
"+",
"pad2",
"(",
"mins",
")",
"+",
"':'",
"+",
"pad2",
"(",
"secs",
")",
"+",
"' +0000'",
"}"
] | Format a Date in the common log format.
@private
@param {Date} dateTime
@return {string} | [
"Format",
"a",
"Date",
"in",
"the",
"common",
"log",
"format",
"."
] | 12a48c5598d67f67bc09ceac393176200bf65865 | https://github.com/expressjs/morgan/blob/12a48c5598d67f67bc09ceac393176200bf65865/index.js#L351-L363 |
7,905 | expressjs/morgan | index.js | createBufferStream | function createBufferStream (stream, interval) {
var buf = []
var timer = null
// flush function
function flush () {
timer = null
stream.write(buf.join(''))
buf.length = 0
}
// write function
function write (str) {
if (timer === null) {
timer = setTimeout(flush, interval)
}
buf.push(str)
}
// return a minimal "stream"
return { write: write }
} | javascript | function createBufferStream (stream, interval) {
var buf = []
var timer = null
// flush function
function flush () {
timer = null
stream.write(buf.join(''))
buf.length = 0
}
// write function
function write (str) {
if (timer === null) {
timer = setTimeout(flush, interval)
}
buf.push(str)
}
// return a minimal "stream"
return { write: write }
} | [
"function",
"createBufferStream",
"(",
"stream",
",",
"interval",
")",
"{",
"var",
"buf",
"=",
"[",
"]",
"var",
"timer",
"=",
"null",
"// flush function",
"function",
"flush",
"(",
")",
"{",
"timer",
"=",
"null",
"stream",
".",
"write",
"(",
"buf",
".",
"join",
"(",
"''",
")",
")",
"buf",
".",
"length",
"=",
"0",
"}",
"// write function",
"function",
"write",
"(",
"str",
")",
"{",
"if",
"(",
"timer",
"===",
"null",
")",
"{",
"timer",
"=",
"setTimeout",
"(",
"flush",
",",
"interval",
")",
"}",
"buf",
".",
"push",
"(",
"str",
")",
"}",
"// return a minimal \"stream\"",
"return",
"{",
"write",
":",
"write",
"}",
"}"
] | Create a basic buffering stream.
@param {object} stream
@param {number} interval
@public | [
"Create",
"a",
"basic",
"buffering",
"stream",
"."
] | 12a48c5598d67f67bc09ceac393176200bf65865 | https://github.com/expressjs/morgan/blob/12a48c5598d67f67bc09ceac393176200bf65865/index.js#L402-L424 |
7,906 | expressjs/morgan | index.js | getFormatFunction | function getFormatFunction (name) {
// lookup format
var fmt = morgan[name] || name || morgan.default
// return compiled format
return typeof fmt !== 'function'
? compile(fmt)
: fmt
} | javascript | function getFormatFunction (name) {
// lookup format
var fmt = morgan[name] || name || morgan.default
// return compiled format
return typeof fmt !== 'function'
? compile(fmt)
: fmt
} | [
"function",
"getFormatFunction",
"(",
"name",
")",
"{",
"// lookup format",
"var",
"fmt",
"=",
"morgan",
"[",
"name",
"]",
"||",
"name",
"||",
"morgan",
".",
"default",
"// return compiled format",
"return",
"typeof",
"fmt",
"!==",
"'function'",
"?",
"compile",
"(",
"fmt",
")",
":",
"fmt",
"}"
] | Lookup and compile a named format function.
@param {string} name
@return {function}
@public | [
"Lookup",
"and",
"compile",
"a",
"named",
"format",
"function",
"."
] | 12a48c5598d67f67bc09ceac393176200bf65865 | https://github.com/expressjs/morgan/blob/12a48c5598d67f67bc09ceac393176200bf65865/index.js#L447-L455 |
7,907 | vuejs/vue-hot-reload-api | src/index.js | injectHook | function injectHook(options, name, hook) {
const existing = options[name]
options[name] = existing
? Array.isArray(existing) ? existing.concat(hook) : [existing, hook]
: [hook]
} | javascript | function injectHook(options, name, hook) {
const existing = options[name]
options[name] = existing
? Array.isArray(existing) ? existing.concat(hook) : [existing, hook]
: [hook]
} | [
"function",
"injectHook",
"(",
"options",
",",
"name",
",",
"hook",
")",
"{",
"const",
"existing",
"=",
"options",
"[",
"name",
"]",
"options",
"[",
"name",
"]",
"=",
"existing",
"?",
"Array",
".",
"isArray",
"(",
"existing",
")",
"?",
"existing",
".",
"concat",
"(",
"hook",
")",
":",
"[",
"existing",
",",
"hook",
"]",
":",
"[",
"hook",
"]",
"}"
] | Inject a hook to a hot reloadable component so that
we can keep track of it.
@param {Object} options
@param {String} name
@param {Function} hook | [
"Inject",
"a",
"hook",
"to",
"a",
"hot",
"reloadable",
"component",
"so",
"that",
"we",
"can",
"keep",
"track",
"of",
"it",
"."
] | 5dc0e49332802fa0154de3fed7dde31437309698 | https://github.com/vuejs/vue-hot-reload-api/blob/5dc0e49332802fa0154de3fed7dde31437309698/src/index.js#L109-L114 |
7,908 | vuejs/vue-hot-reload-api | src/index.js | patchScopedSlots | function patchScopedSlots (instance) {
if (!instance._u) return
// https://github.com/vuejs/vue/blob/dev/src/core/instance/render-helpers/resolve-scoped-slots.js
const original = instance._u
instance._u = slots => {
try {
// 2.6.4 ~ 2.6.6
return original(slots, true)
} catch (e) {
// 2.5 / >= 2.6.7
return original(slots, null, true)
}
}
return () => {
instance._u = original
}
} | javascript | function patchScopedSlots (instance) {
if (!instance._u) return
// https://github.com/vuejs/vue/blob/dev/src/core/instance/render-helpers/resolve-scoped-slots.js
const original = instance._u
instance._u = slots => {
try {
// 2.6.4 ~ 2.6.6
return original(slots, true)
} catch (e) {
// 2.5 / >= 2.6.7
return original(slots, null, true)
}
}
return () => {
instance._u = original
}
} | [
"function",
"patchScopedSlots",
"(",
"instance",
")",
"{",
"if",
"(",
"!",
"instance",
".",
"_u",
")",
"return",
"// https://github.com/vuejs/vue/blob/dev/src/core/instance/render-helpers/resolve-scoped-slots.js",
"const",
"original",
"=",
"instance",
".",
"_u",
"instance",
".",
"_u",
"=",
"slots",
"=>",
"{",
"try",
"{",
"// 2.6.4 ~ 2.6.6",
"return",
"original",
"(",
"slots",
",",
"true",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"// 2.5 / >= 2.6.7",
"return",
"original",
"(",
"slots",
",",
"null",
",",
"true",
")",
"}",
"}",
"return",
"(",
")",
"=>",
"{",
"instance",
".",
"_u",
"=",
"original",
"}",
"}"
] | 2.6 optimizes template-compiled scoped slots and skips updates if child only uses scoped slots. We need to patch the scoped slots resolving helper to temporarily mark all scoped slots as unstable in order to force child updates. | [
"2",
".",
"6",
"optimizes",
"template",
"-",
"compiled",
"scoped",
"slots",
"and",
"skips",
"updates",
"if",
"child",
"only",
"uses",
"scoped",
"slots",
".",
"We",
"need",
"to",
"patch",
"the",
"scoped",
"slots",
"resolving",
"helper",
"to",
"temporarily",
"mark",
"all",
"scoped",
"slots",
"as",
"unstable",
"in",
"order",
"to",
"force",
"child",
"updates",
"."
] | 5dc0e49332802fa0154de3fed7dde31437309698 | https://github.com/vuejs/vue-hot-reload-api/blob/5dc0e49332802fa0154de3fed7dde31437309698/src/index.js#L255-L271 |
7,909 | alibaba/uirecorder | chrome-extension/js/mobile.js | getNodeInfo | function getNodeInfo(x, y){
var nodeInfo = {};
var bestNodeInfo = {
node: null,
boundSize: 0
};
getBestNode(appTree, x, y, bestNodeInfo);
var bestNode = bestNodeInfo.node;
if(bestNode){
var text = bestNode.text || bestNode.label;
if(text){
text = text.replace(/\s*\r?\n\s*/g,' ');
text = text.replace(/^\s+|\s+$/g, '');
var textLen = byteLen(text);
text = textLen > 20 ? leftstr(text, 20) + '...' : text;
nodeInfo.text = text;
}
nodeInfo.path = getNodeXPath(bestNode);
}
else{
nodeInfo.x = x;
nodeInfo.y = y;
}
return nodeInfo;
} | javascript | function getNodeInfo(x, y){
var nodeInfo = {};
var bestNodeInfo = {
node: null,
boundSize: 0
};
getBestNode(appTree, x, y, bestNodeInfo);
var bestNode = bestNodeInfo.node;
if(bestNode){
var text = bestNode.text || bestNode.label;
if(text){
text = text.replace(/\s*\r?\n\s*/g,' ');
text = text.replace(/^\s+|\s+$/g, '');
var textLen = byteLen(text);
text = textLen > 20 ? leftstr(text, 20) + '...' : text;
nodeInfo.text = text;
}
nodeInfo.path = getNodeXPath(bestNode);
}
else{
nodeInfo.x = x;
nodeInfo.y = y;
}
return nodeInfo;
} | [
"function",
"getNodeInfo",
"(",
"x",
",",
"y",
")",
"{",
"var",
"nodeInfo",
"=",
"{",
"}",
";",
"var",
"bestNodeInfo",
"=",
"{",
"node",
":",
"null",
",",
"boundSize",
":",
"0",
"}",
";",
"getBestNode",
"(",
"appTree",
",",
"x",
",",
"y",
",",
"bestNodeInfo",
")",
";",
"var",
"bestNode",
"=",
"bestNodeInfo",
".",
"node",
";",
"if",
"(",
"bestNode",
")",
"{",
"var",
"text",
"=",
"bestNode",
".",
"text",
"||",
"bestNode",
".",
"label",
";",
"if",
"(",
"text",
")",
"{",
"text",
"=",
"text",
".",
"replace",
"(",
"/",
"\\s*\\r?\\n\\s*",
"/",
"g",
",",
"' '",
")",
";",
"text",
"=",
"text",
".",
"replace",
"(",
"/",
"^\\s+|\\s+$",
"/",
"g",
",",
"''",
")",
";",
"var",
"textLen",
"=",
"byteLen",
"(",
"text",
")",
";",
"text",
"=",
"textLen",
">",
"20",
"?",
"leftstr",
"(",
"text",
",",
"20",
")",
"+",
"'...'",
":",
"text",
";",
"nodeInfo",
".",
"text",
"=",
"text",
";",
"}",
"nodeInfo",
".",
"path",
"=",
"getNodeXPath",
"(",
"bestNode",
")",
";",
"}",
"else",
"{",
"nodeInfo",
".",
"x",
"=",
"x",
";",
"nodeInfo",
".",
"y",
"=",
"y",
";",
"}",
"return",
"nodeInfo",
";",
"}"
] | get node info by x,y | [
"get",
"node",
"info",
"by",
"x",
"y"
] | 2b6ed319e75657eadbef2e80baca46c655a3ce94 | https://github.com/alibaba/uirecorder/blob/2b6ed319e75657eadbef2e80baca46c655a3ce94/chrome-extension/js/mobile.js#L445-L469 |
7,910 | alibaba/uirecorder | lib/start.js | getRootPath | function getRootPath(){
var rootPath = path.resolve('.');
while(rootPath){
if(fs.existsSync(rootPath + '/config.json')){
break;
}
rootPath = rootPath.substring(0, rootPath.lastIndexOf(path.sep));
}
return rootPath;
} | javascript | function getRootPath(){
var rootPath = path.resolve('.');
while(rootPath){
if(fs.existsSync(rootPath + '/config.json')){
break;
}
rootPath = rootPath.substring(0, rootPath.lastIndexOf(path.sep));
}
return rootPath;
} | [
"function",
"getRootPath",
"(",
")",
"{",
"var",
"rootPath",
"=",
"path",
".",
"resolve",
"(",
"'.'",
")",
";",
"while",
"(",
"rootPath",
")",
"{",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"rootPath",
"+",
"'/config.json'",
")",
")",
"{",
"break",
";",
"}",
"rootPath",
"=",
"rootPath",
".",
"substring",
"(",
"0",
",",
"rootPath",
".",
"lastIndexOf",
"(",
"path",
".",
"sep",
")",
")",
";",
"}",
"return",
"rootPath",
";",
"}"
] | get test root | [
"get",
"test",
"root"
] | 2b6ed319e75657eadbef2e80baca46c655a3ce94 | https://github.com/alibaba/uirecorder/blob/2b6ed319e75657eadbef2e80baca46c655a3ce94/lib/start.js#L1618-L1627 |
7,911 | alibaba/uirecorder | lib/start.js | startRecorderServer | function startRecorderServer(config, onReady, onCommand, onEnd){
var server = http.createServer(function(req, res){
if(req.url === '/proxy.pac'){
var wdproxy = config.wdproxy;
if(wdproxy){
res.writeHead(200, { 'Content-Type': 'text/plain' });
var pacContent = 'function FindProxyForURL(url, host){if(!/^(127.0.0.1|localhost)$/.test(host))return "PROXY '+config.wdproxy+'";\r\nreturn "DIRECT"}';
res.end(pacContent);
}
else{
res.end('No wdproxy finded!');
}
}
});
server.listen(0, function(){
var serverPort = server.address().port;
console.log('');
console.log(__('recorder_server_listen_on').green, serverPort);
onReady(serverPort);
});
wsServer = new WebSocketServer({
httpServer: server,
autoAcceptConnections: true
});
wsServer.on('connect', function(connection) {
wsConnection = connection;
sendWsMessage('config', config);
connection.on('message', function(message) {
var message = message.utf8Data;
try{
message = JSON.parse(message);
}
catch(e){};
var type = message.type;
switch(type){
case 'saveCmd':
onCommand(message.data);
break;
case 'save':
onCommand({
cmd: 'end'
});
setTimeout(function(){
wsConnection && wsConnection.close();
server.close(function(){
onEnd(true);
});
}, 500);
break;
case 'end':
onCommand({
cmd: 'end'
});
setTimeout(function(){
wsConnection && wsConnection.close();
server.close(function(){
onEnd(false);
});
}, 500);
break;
}
});
connection.on('close', function(reasonCode, description) {
wsConnection = null;
});
});
} | javascript | function startRecorderServer(config, onReady, onCommand, onEnd){
var server = http.createServer(function(req, res){
if(req.url === '/proxy.pac'){
var wdproxy = config.wdproxy;
if(wdproxy){
res.writeHead(200, { 'Content-Type': 'text/plain' });
var pacContent = 'function FindProxyForURL(url, host){if(!/^(127.0.0.1|localhost)$/.test(host))return "PROXY '+config.wdproxy+'";\r\nreturn "DIRECT"}';
res.end(pacContent);
}
else{
res.end('No wdproxy finded!');
}
}
});
server.listen(0, function(){
var serverPort = server.address().port;
console.log('');
console.log(__('recorder_server_listen_on').green, serverPort);
onReady(serverPort);
});
wsServer = new WebSocketServer({
httpServer: server,
autoAcceptConnections: true
});
wsServer.on('connect', function(connection) {
wsConnection = connection;
sendWsMessage('config', config);
connection.on('message', function(message) {
var message = message.utf8Data;
try{
message = JSON.parse(message);
}
catch(e){};
var type = message.type;
switch(type){
case 'saveCmd':
onCommand(message.data);
break;
case 'save':
onCommand({
cmd: 'end'
});
setTimeout(function(){
wsConnection && wsConnection.close();
server.close(function(){
onEnd(true);
});
}, 500);
break;
case 'end':
onCommand({
cmd: 'end'
});
setTimeout(function(){
wsConnection && wsConnection.close();
server.close(function(){
onEnd(false);
});
}, 500);
break;
}
});
connection.on('close', function(reasonCode, description) {
wsConnection = null;
});
});
} | [
"function",
"startRecorderServer",
"(",
"config",
",",
"onReady",
",",
"onCommand",
",",
"onEnd",
")",
"{",
"var",
"server",
"=",
"http",
".",
"createServer",
"(",
"function",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"req",
".",
"url",
"===",
"'/proxy.pac'",
")",
"{",
"var",
"wdproxy",
"=",
"config",
".",
"wdproxy",
";",
"if",
"(",
"wdproxy",
")",
"{",
"res",
".",
"writeHead",
"(",
"200",
",",
"{",
"'Content-Type'",
":",
"'text/plain'",
"}",
")",
";",
"var",
"pacContent",
"=",
"'function FindProxyForURL(url, host){if(!/^(127.0.0.1|localhost)$/.test(host))return \"PROXY '",
"+",
"config",
".",
"wdproxy",
"+",
"'\";\\r\\nreturn \"DIRECT\"}'",
";",
"res",
".",
"end",
"(",
"pacContent",
")",
";",
"}",
"else",
"{",
"res",
".",
"end",
"(",
"'No wdproxy finded!'",
")",
";",
"}",
"}",
"}",
")",
";",
"server",
".",
"listen",
"(",
"0",
",",
"function",
"(",
")",
"{",
"var",
"serverPort",
"=",
"server",
".",
"address",
"(",
")",
".",
"port",
";",
"console",
".",
"log",
"(",
"''",
")",
";",
"console",
".",
"log",
"(",
"__",
"(",
"'recorder_server_listen_on'",
")",
".",
"green",
",",
"serverPort",
")",
";",
"onReady",
"(",
"serverPort",
")",
";",
"}",
")",
";",
"wsServer",
"=",
"new",
"WebSocketServer",
"(",
"{",
"httpServer",
":",
"server",
",",
"autoAcceptConnections",
":",
"true",
"}",
")",
";",
"wsServer",
".",
"on",
"(",
"'connect'",
",",
"function",
"(",
"connection",
")",
"{",
"wsConnection",
"=",
"connection",
";",
"sendWsMessage",
"(",
"'config'",
",",
"config",
")",
";",
"connection",
".",
"on",
"(",
"'message'",
",",
"function",
"(",
"message",
")",
"{",
"var",
"message",
"=",
"message",
".",
"utf8Data",
";",
"try",
"{",
"message",
"=",
"JSON",
".",
"parse",
"(",
"message",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
";",
"var",
"type",
"=",
"message",
".",
"type",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"'saveCmd'",
":",
"onCommand",
"(",
"message",
".",
"data",
")",
";",
"break",
";",
"case",
"'save'",
":",
"onCommand",
"(",
"{",
"cmd",
":",
"'end'",
"}",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"wsConnection",
"&&",
"wsConnection",
".",
"close",
"(",
")",
";",
"server",
".",
"close",
"(",
"function",
"(",
")",
"{",
"onEnd",
"(",
"true",
")",
";",
"}",
")",
";",
"}",
",",
"500",
")",
";",
"break",
";",
"case",
"'end'",
":",
"onCommand",
"(",
"{",
"cmd",
":",
"'end'",
"}",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"wsConnection",
"&&",
"wsConnection",
".",
"close",
"(",
")",
";",
"server",
".",
"close",
"(",
"function",
"(",
")",
"{",
"onEnd",
"(",
"false",
")",
";",
"}",
")",
";",
"}",
",",
"500",
")",
";",
"break",
";",
"}",
"}",
")",
";",
"connection",
".",
"on",
"(",
"'close'",
",",
"function",
"(",
"reasonCode",
",",
"description",
")",
"{",
"wsConnection",
"=",
"null",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | start recorder server | [
"start",
"recorder",
"server"
] | 2b6ed319e75657eadbef2e80baca46c655a3ce94 | https://github.com/alibaba/uirecorder/blob/2b6ed319e75657eadbef2e80baca46c655a3ce94/lib/start.js#L1635-L1701 |
7,912 | alibaba/uirecorder | chrome-extension/js/foreground.js | getDomPath | function getDomPath(target, isAllDom){
var arrAllPaths = [];
var node = target, path;
while(node){
var nodeName = node.nodeName.toLowerCase();
if(/^#document/.test(nodeName)){
path = getRelativeDomPath(node, target, isAllDom);
if(path){
arrAllPaths.push(path);
}
node = node.parentNode || node.host;
target = node;
}
else{
node = node.parentNode || node.host;
}
}
return arrAllPaths.length > 0 ? arrAllPaths.reverse().join(' /deep/ ') : null;
} | javascript | function getDomPath(target, isAllDom){
var arrAllPaths = [];
var node = target, path;
while(node){
var nodeName = node.nodeName.toLowerCase();
if(/^#document/.test(nodeName)){
path = getRelativeDomPath(node, target, isAllDom);
if(path){
arrAllPaths.push(path);
}
node = node.parentNode || node.host;
target = node;
}
else{
node = node.parentNode || node.host;
}
}
return arrAllPaths.length > 0 ? arrAllPaths.reverse().join(' /deep/ ') : null;
} | [
"function",
"getDomPath",
"(",
"target",
",",
"isAllDom",
")",
"{",
"var",
"arrAllPaths",
"=",
"[",
"]",
";",
"var",
"node",
"=",
"target",
",",
"path",
";",
"while",
"(",
"node",
")",
"{",
"var",
"nodeName",
"=",
"node",
".",
"nodeName",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"/",
"^#document",
"/",
".",
"test",
"(",
"nodeName",
")",
")",
"{",
"path",
"=",
"getRelativeDomPath",
"(",
"node",
",",
"target",
",",
"isAllDom",
")",
";",
"if",
"(",
"path",
")",
"{",
"arrAllPaths",
".",
"push",
"(",
"path",
")",
";",
"}",
"node",
"=",
"node",
".",
"parentNode",
"||",
"node",
".",
"host",
";",
"target",
"=",
"node",
";",
"}",
"else",
"{",
"node",
"=",
"node",
".",
"parentNode",
"||",
"node",
".",
"host",
";",
"}",
"}",
"return",
"arrAllPaths",
".",
"length",
">",
"0",
"?",
"arrAllPaths",
".",
"reverse",
"(",
")",
".",
"join",
"(",
"' /deep/ '",
")",
":",
"null",
";",
"}"
] | get selector path | [
"get",
"selector",
"path"
] | 2b6ed319e75657eadbef2e80baca46c655a3ce94 | https://github.com/alibaba/uirecorder/blob/2b6ed319e75657eadbef2e80baca46c655a3ce94/chrome-extension/js/foreground.js#L166-L184 |
7,913 | alibaba/uirecorder | chrome-extension/js/foreground.js | getFrameId | function getFrameId(){
var frame = -1;
if(isIframe){
try{
var frameElement = window.frameElement;
if(frameElement !== null){
frame = getDomPath(frameElement) || -1;
}
else{
frame = '!'+location.href.replace(/^https?:/,'');
var parentFrames = parent.frames;
for(var i=0,len=parentFrames.length;i<len;i++){
if(parentFrames[i] === window){
frame = '!'+i;
break;
}
}
}
}
catch(e){}
}
else{
frame = null;
}
return frame;
} | javascript | function getFrameId(){
var frame = -1;
if(isIframe){
try{
var frameElement = window.frameElement;
if(frameElement !== null){
frame = getDomPath(frameElement) || -1;
}
else{
frame = '!'+location.href.replace(/^https?:/,'');
var parentFrames = parent.frames;
for(var i=0,len=parentFrames.length;i<len;i++){
if(parentFrames[i] === window){
frame = '!'+i;
break;
}
}
}
}
catch(e){}
}
else{
frame = null;
}
return frame;
} | [
"function",
"getFrameId",
"(",
")",
"{",
"var",
"frame",
"=",
"-",
"1",
";",
"if",
"(",
"isIframe",
")",
"{",
"try",
"{",
"var",
"frameElement",
"=",
"window",
".",
"frameElement",
";",
"if",
"(",
"frameElement",
"!==",
"null",
")",
"{",
"frame",
"=",
"getDomPath",
"(",
"frameElement",
")",
"||",
"-",
"1",
";",
"}",
"else",
"{",
"frame",
"=",
"'!'",
"+",
"location",
".",
"href",
".",
"replace",
"(",
"/",
"^https?:",
"/",
",",
"''",
")",
";",
"var",
"parentFrames",
"=",
"parent",
".",
"frames",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"parentFrames",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"parentFrames",
"[",
"i",
"]",
"===",
"window",
")",
"{",
"frame",
"=",
"'!'",
"+",
"i",
";",
"break",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"}",
"else",
"{",
"frame",
"=",
"null",
";",
"}",
"return",
"frame",
";",
"}"
] | get frame id | [
"get",
"frame",
"id"
] | 2b6ed319e75657eadbef2e80baca46c655a3ce94 | https://github.com/alibaba/uirecorder/blob/2b6ed319e75657eadbef2e80baca46c655a3ce94/chrome-extension/js/foreground.js#L436-L461 |
7,914 | alibaba/uirecorder | chrome-extension/js/foreground.js | unsafeEval | function unsafeEval(str){
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.innerHTML = '('+str+')();';
head.appendChild(script);
head.removeChild(script);
} | javascript | function unsafeEval(str){
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.innerHTML = '('+str+')();';
head.appendChild(script);
head.removeChild(script);
} | [
"function",
"unsafeEval",
"(",
"str",
")",
"{",
"var",
"head",
"=",
"document",
".",
"getElementsByTagName",
"(",
"\"head\"",
")",
"[",
"0",
"]",
";",
"var",
"script",
"=",
"document",
".",
"createElement",
"(",
"\"script\"",
")",
";",
"script",
".",
"innerHTML",
"=",
"'('",
"+",
"str",
"+",
"')();'",
";",
"head",
".",
"appendChild",
"(",
"script",
")",
";",
"head",
".",
"removeChild",
"(",
"script",
")",
";",
"}"
] | eval with unsafe window | [
"eval",
"with",
"unsafe",
"window"
] | 2b6ed319e75657eadbef2e80baca46c655a3ce94 | https://github.com/alibaba/uirecorder/blob/2b6ed319e75657eadbef2e80baca46c655a3ce94/chrome-extension/js/foreground.js#L985-L991 |
7,915 | alibaba/uirecorder | chrome-extension/js/foreground.js | hookAlertFunction | function hookAlertFunction(){
var rawAlert = window.alert;
function sendAlertCmd(cmd, data){
var cmdInfo = {
cmd: cmd,
data: data || {}
};
window.postMessage({
'type': 'uiRecorderAlertCommand',
'cmdInfo': cmdInfo
}, '*');
}
window.alert = function(str){
var ret = rawAlert.call(this, str);
sendAlertCmd('acceptAlert');
return ret;
}
var rawConfirm = window.confirm;
window.confirm = function(str){
var ret = rawConfirm.call(this, str);
sendAlertCmd(ret?'acceptAlert':'dismissAlert');
return ret;
}
var rawPrompt = window.prompt;
window.prompt = function(str){
var ret = rawPrompt.call(this, str);
if(ret === null){
sendAlertCmd('dismissAlert');
}
else{
sendAlertCmd('setAlert', {
text: ret
});
sendAlertCmd('acceptAlert');
}
return ret;
}
function wrapBeforeUnloadListener(oldListener){
var newListener = function(e){
var returnValue = oldListener(e);
if(returnValue){
sendAlertCmd('acceptAlert');
}
return returnValue;
}
return newListener;
}
var rawAddEventListener = window.addEventListener;
window.addEventListener = function(type, listener, useCapture){
if(type === 'beforeunload'){
listener = wrapBeforeUnloadListener(listener);
}
return rawAddEventListener.call(window, type, listener, useCapture);
};
setTimeout(function(){
var oldBeforeunload = window.onbeforeunload;
if(oldBeforeunload){
window.onbeforeunload = wrapBeforeUnloadListener(oldBeforeunload)
}
}, 1000);
} | javascript | function hookAlertFunction(){
var rawAlert = window.alert;
function sendAlertCmd(cmd, data){
var cmdInfo = {
cmd: cmd,
data: data || {}
};
window.postMessage({
'type': 'uiRecorderAlertCommand',
'cmdInfo': cmdInfo
}, '*');
}
window.alert = function(str){
var ret = rawAlert.call(this, str);
sendAlertCmd('acceptAlert');
return ret;
}
var rawConfirm = window.confirm;
window.confirm = function(str){
var ret = rawConfirm.call(this, str);
sendAlertCmd(ret?'acceptAlert':'dismissAlert');
return ret;
}
var rawPrompt = window.prompt;
window.prompt = function(str){
var ret = rawPrompt.call(this, str);
if(ret === null){
sendAlertCmd('dismissAlert');
}
else{
sendAlertCmd('setAlert', {
text: ret
});
sendAlertCmd('acceptAlert');
}
return ret;
}
function wrapBeforeUnloadListener(oldListener){
var newListener = function(e){
var returnValue = oldListener(e);
if(returnValue){
sendAlertCmd('acceptAlert');
}
return returnValue;
}
return newListener;
}
var rawAddEventListener = window.addEventListener;
window.addEventListener = function(type, listener, useCapture){
if(type === 'beforeunload'){
listener = wrapBeforeUnloadListener(listener);
}
return rawAddEventListener.call(window, type, listener, useCapture);
};
setTimeout(function(){
var oldBeforeunload = window.onbeforeunload;
if(oldBeforeunload){
window.onbeforeunload = wrapBeforeUnloadListener(oldBeforeunload)
}
}, 1000);
} | [
"function",
"hookAlertFunction",
"(",
")",
"{",
"var",
"rawAlert",
"=",
"window",
".",
"alert",
";",
"function",
"sendAlertCmd",
"(",
"cmd",
",",
"data",
")",
"{",
"var",
"cmdInfo",
"=",
"{",
"cmd",
":",
"cmd",
",",
"data",
":",
"data",
"||",
"{",
"}",
"}",
";",
"window",
".",
"postMessage",
"(",
"{",
"'type'",
":",
"'uiRecorderAlertCommand'",
",",
"'cmdInfo'",
":",
"cmdInfo",
"}",
",",
"'*'",
")",
";",
"}",
"window",
".",
"alert",
"=",
"function",
"(",
"str",
")",
"{",
"var",
"ret",
"=",
"rawAlert",
".",
"call",
"(",
"this",
",",
"str",
")",
";",
"sendAlertCmd",
"(",
"'acceptAlert'",
")",
";",
"return",
"ret",
";",
"}",
"var",
"rawConfirm",
"=",
"window",
".",
"confirm",
";",
"window",
".",
"confirm",
"=",
"function",
"(",
"str",
")",
"{",
"var",
"ret",
"=",
"rawConfirm",
".",
"call",
"(",
"this",
",",
"str",
")",
";",
"sendAlertCmd",
"(",
"ret",
"?",
"'acceptAlert'",
":",
"'dismissAlert'",
")",
";",
"return",
"ret",
";",
"}",
"var",
"rawPrompt",
"=",
"window",
".",
"prompt",
";",
"window",
".",
"prompt",
"=",
"function",
"(",
"str",
")",
"{",
"var",
"ret",
"=",
"rawPrompt",
".",
"call",
"(",
"this",
",",
"str",
")",
";",
"if",
"(",
"ret",
"===",
"null",
")",
"{",
"sendAlertCmd",
"(",
"'dismissAlert'",
")",
";",
"}",
"else",
"{",
"sendAlertCmd",
"(",
"'setAlert'",
",",
"{",
"text",
":",
"ret",
"}",
")",
";",
"sendAlertCmd",
"(",
"'acceptAlert'",
")",
";",
"}",
"return",
"ret",
";",
"}",
"function",
"wrapBeforeUnloadListener",
"(",
"oldListener",
")",
"{",
"var",
"newListener",
"=",
"function",
"(",
"e",
")",
"{",
"var",
"returnValue",
"=",
"oldListener",
"(",
"e",
")",
";",
"if",
"(",
"returnValue",
")",
"{",
"sendAlertCmd",
"(",
"'acceptAlert'",
")",
";",
"}",
"return",
"returnValue",
";",
"}",
"return",
"newListener",
";",
"}",
"var",
"rawAddEventListener",
"=",
"window",
".",
"addEventListener",
";",
"window",
".",
"addEventListener",
"=",
"function",
"(",
"type",
",",
"listener",
",",
"useCapture",
")",
"{",
"if",
"(",
"type",
"===",
"'beforeunload'",
")",
"{",
"listener",
"=",
"wrapBeforeUnloadListener",
"(",
"listener",
")",
";",
"}",
"return",
"rawAddEventListener",
".",
"call",
"(",
"window",
",",
"type",
",",
"listener",
",",
"useCapture",
")",
";",
"}",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"oldBeforeunload",
"=",
"window",
".",
"onbeforeunload",
";",
"if",
"(",
"oldBeforeunload",
")",
"{",
"window",
".",
"onbeforeunload",
"=",
"wrapBeforeUnloadListener",
"(",
"oldBeforeunload",
")",
"}",
"}",
",",
"1000",
")",
";",
"}"
] | hook alert, confirm, prompt | [
"hook",
"alert",
"confirm",
"prompt"
] | 2b6ed319e75657eadbef2e80baca46c655a3ce94 | https://github.com/alibaba/uirecorder/blob/2b6ed319e75657eadbef2e80baca46c655a3ce94/chrome-extension/js/foreground.js#L994-L1054 |
7,916 | alibaba/uirecorder | chrome-extension/js/foreground.js | getFixedParent | function getFixedParent(target){
var documentElement = document.documentElement;
var node = target;
var nodeName, path, offset, left, top, savedParent;
var notFirstNode = false; // 当前点击控件以可见范围内进行定位,其它以全局定位(很多局部控件是不可见的)
while(node !== null){
nodeName = node.nodeName.toLowerCase();
if(nodeName !== '#document-fragment'){
path = getDomPath(node, notFirstNode);
if(path === null){
break;
}
offset = node.getBoundingClientRect();
left = parseInt(offset.left, 10);
top = parseInt(offset.top, 10);
savedParent = mapParentsOffset[path];
if(savedParent && left === savedParent.left && top === savedParent.top){
return {
path: path,
left: left,
top: top
};
}
}
if(nodeName === 'html'){
node = null;
}
else{
node = node.parentNode;
}
notFirstNode = true;
}
path = getDomPath(target);
if(path !== null){
offset = target.getBoundingClientRect();
return {
path: path,
left: offset.left,
top: offset.top
};
}
else{
return null;
}
} | javascript | function getFixedParent(target){
var documentElement = document.documentElement;
var node = target;
var nodeName, path, offset, left, top, savedParent;
var notFirstNode = false; // 当前点击控件以可见范围内进行定位,其它以全局定位(很多局部控件是不可见的)
while(node !== null){
nodeName = node.nodeName.toLowerCase();
if(nodeName !== '#document-fragment'){
path = getDomPath(node, notFirstNode);
if(path === null){
break;
}
offset = node.getBoundingClientRect();
left = parseInt(offset.left, 10);
top = parseInt(offset.top, 10);
savedParent = mapParentsOffset[path];
if(savedParent && left === savedParent.left && top === savedParent.top){
return {
path: path,
left: left,
top: top
};
}
}
if(nodeName === 'html'){
node = null;
}
else{
node = node.parentNode;
}
notFirstNode = true;
}
path = getDomPath(target);
if(path !== null){
offset = target.getBoundingClientRect();
return {
path: path,
left: offset.left,
top: offset.top
};
}
else{
return null;
}
} | [
"function",
"getFixedParent",
"(",
"target",
")",
"{",
"var",
"documentElement",
"=",
"document",
".",
"documentElement",
";",
"var",
"node",
"=",
"target",
";",
"var",
"nodeName",
",",
"path",
",",
"offset",
",",
"left",
",",
"top",
",",
"savedParent",
";",
"var",
"notFirstNode",
"=",
"false",
";",
"// 当前点击控件以可见范围内进行定位,其它以全局定位(很多局部控件是不可见的)",
"while",
"(",
"node",
"!==",
"null",
")",
"{",
"nodeName",
"=",
"node",
".",
"nodeName",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"nodeName",
"!==",
"'#document-fragment'",
")",
"{",
"path",
"=",
"getDomPath",
"(",
"node",
",",
"notFirstNode",
")",
";",
"if",
"(",
"path",
"===",
"null",
")",
"{",
"break",
";",
"}",
"offset",
"=",
"node",
".",
"getBoundingClientRect",
"(",
")",
";",
"left",
"=",
"parseInt",
"(",
"offset",
".",
"left",
",",
"10",
")",
";",
"top",
"=",
"parseInt",
"(",
"offset",
".",
"top",
",",
"10",
")",
";",
"savedParent",
"=",
"mapParentsOffset",
"[",
"path",
"]",
";",
"if",
"(",
"savedParent",
"&&",
"left",
"===",
"savedParent",
".",
"left",
"&&",
"top",
"===",
"savedParent",
".",
"top",
")",
"{",
"return",
"{",
"path",
":",
"path",
",",
"left",
":",
"left",
",",
"top",
":",
"top",
"}",
";",
"}",
"}",
"if",
"(",
"nodeName",
"===",
"'html'",
")",
"{",
"node",
"=",
"null",
";",
"}",
"else",
"{",
"node",
"=",
"node",
".",
"parentNode",
";",
"}",
"notFirstNode",
"=",
"true",
";",
"}",
"path",
"=",
"getDomPath",
"(",
"target",
")",
";",
"if",
"(",
"path",
"!==",
"null",
")",
"{",
"offset",
"=",
"target",
".",
"getBoundingClientRect",
"(",
")",
";",
"return",
"{",
"path",
":",
"path",
",",
"left",
":",
"offset",
".",
"left",
",",
"top",
":",
"offset",
".",
"top",
"}",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | get the fixed offset parent | [
"get",
"the",
"fixed",
"offset",
"parent"
] | 2b6ed319e75657eadbef2e80baca46c655a3ce94 | https://github.com/alibaba/uirecorder/blob/2b6ed319e75657eadbef2e80baca46c655a3ce94/chrome-extension/js/foreground.js#L1352-L1396 |
7,917 | alibaba/uirecorder | chrome-extension/js/background.js | setRecorderWork | function setRecorderWork(enable){
isWorking = enable;
if(isWorking){
chrome.browserAction.setTitle({title: __('icon_record_tip')});
chrome.browserAction.setIcon({path: workIcon===1?ENABLE_ICON1:ENABLE_ICON2});
workIcon *= -1;
workIconTimer = setTimeout(function(){
setRecorderWork(true);
}, 1000);
}
else{
clearTimeout(workIconTimer);
chrome.browserAction.setTitle({title: __('icon_end_tip')});
chrome.browserAction.setIcon({path: DISABLE_ICON});
}
} | javascript | function setRecorderWork(enable){
isWorking = enable;
if(isWorking){
chrome.browserAction.setTitle({title: __('icon_record_tip')});
chrome.browserAction.setIcon({path: workIcon===1?ENABLE_ICON1:ENABLE_ICON2});
workIcon *= -1;
workIconTimer = setTimeout(function(){
setRecorderWork(true);
}, 1000);
}
else{
clearTimeout(workIconTimer);
chrome.browserAction.setTitle({title: __('icon_end_tip')});
chrome.browserAction.setIcon({path: DISABLE_ICON});
}
} | [
"function",
"setRecorderWork",
"(",
"enable",
")",
"{",
"isWorking",
"=",
"enable",
";",
"if",
"(",
"isWorking",
")",
"{",
"chrome",
".",
"browserAction",
".",
"setTitle",
"(",
"{",
"title",
":",
"__",
"(",
"'icon_record_tip'",
")",
"}",
")",
";",
"chrome",
".",
"browserAction",
".",
"setIcon",
"(",
"{",
"path",
":",
"workIcon",
"===",
"1",
"?",
"ENABLE_ICON1",
":",
"ENABLE_ICON2",
"}",
")",
";",
"workIcon",
"*=",
"-",
"1",
";",
"workIconTimer",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"setRecorderWork",
"(",
"true",
")",
";",
"}",
",",
"1000",
")",
";",
"}",
"else",
"{",
"clearTimeout",
"(",
"workIconTimer",
")",
";",
"chrome",
".",
"browserAction",
".",
"setTitle",
"(",
"{",
"title",
":",
"__",
"(",
"'icon_end_tip'",
")",
"}",
")",
";",
"chrome",
".",
"browserAction",
".",
"setIcon",
"(",
"{",
"path",
":",
"DISABLE_ICON",
"}",
")",
";",
"}",
"}"
] | set recorder work status | [
"set",
"recorder",
"work",
"status"
] | 2b6ed319e75657eadbef2e80baca46c655a3ce94 | https://github.com/alibaba/uirecorder/blob/2b6ed319e75657eadbef2e80baca46c655a3ce94/chrome-extension/js/background.js#L157-L172 |
7,918 | alibaba/uirecorder | chrome-extension/js/background.js | saveCommand | function saveCommand(windowId, frame, cmd, data){
if(isModuleLoading){
return;
}
var cmdInfo = {
window: windowId,
frame: frame,
cmd: cmd,
data: data,
fix: false
};
checkLostKey(windowId);
switch(cmd){
case 'keyDown':
allKeyMap[data.character] = cmdInfo;
break;
case 'keyUp':
delete allKeyMap[data.character];
break;
case 'mouseDown':
allMouseMap[data.button] = cmdInfo;
break;
case 'mouseUp':
delete allMouseMap[data.button];
break;
}
execNextCommand(cmdInfo);
} | javascript | function saveCommand(windowId, frame, cmd, data){
if(isModuleLoading){
return;
}
var cmdInfo = {
window: windowId,
frame: frame,
cmd: cmd,
data: data,
fix: false
};
checkLostKey(windowId);
switch(cmd){
case 'keyDown':
allKeyMap[data.character] = cmdInfo;
break;
case 'keyUp':
delete allKeyMap[data.character];
break;
case 'mouseDown':
allMouseMap[data.button] = cmdInfo;
break;
case 'mouseUp':
delete allMouseMap[data.button];
break;
}
execNextCommand(cmdInfo);
} | [
"function",
"saveCommand",
"(",
"windowId",
",",
"frame",
",",
"cmd",
",",
"data",
")",
"{",
"if",
"(",
"isModuleLoading",
")",
"{",
"return",
";",
"}",
"var",
"cmdInfo",
"=",
"{",
"window",
":",
"windowId",
",",
"frame",
":",
"frame",
",",
"cmd",
":",
"cmd",
",",
"data",
":",
"data",
",",
"fix",
":",
"false",
"}",
";",
"checkLostKey",
"(",
"windowId",
")",
";",
"switch",
"(",
"cmd",
")",
"{",
"case",
"'keyDown'",
":",
"allKeyMap",
"[",
"data",
".",
"character",
"]",
"=",
"cmdInfo",
";",
"break",
";",
"case",
"'keyUp'",
":",
"delete",
"allKeyMap",
"[",
"data",
".",
"character",
"]",
";",
"break",
";",
"case",
"'mouseDown'",
":",
"allMouseMap",
"[",
"data",
".",
"button",
"]",
"=",
"cmdInfo",
";",
"break",
";",
"case",
"'mouseUp'",
":",
"delete",
"allMouseMap",
"[",
"data",
".",
"button",
"]",
";",
"break",
";",
"}",
"execNextCommand",
"(",
"cmdInfo",
")",
";",
"}"
] | save recoreded command | [
"save",
"recoreded",
"command"
] | 2b6ed319e75657eadbef2e80baca46c655a3ce94 | https://github.com/alibaba/uirecorder/blob/2b6ed319e75657eadbef2e80baca46c655a3ce94/chrome-extension/js/background.js#L180-L210 |
7,919 | 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 :
benchUniquePerf();
setTimeout(function() { runStep(4); }, 100);
trace("");
trace("-- Benchmarking query on non-indexed column --");
break;
case 4 :
benchFind(); // find benchmark on unindexed customid field
setTimeout(function() { runStep(5); }, 100);
break;
case 5 :
benchRS(); // resultset find benchmark on unindexed customid field
setTimeout(function() { runStep(6); }, 100);
break;
case 6 :
benchDV();
setTimeout(function() { runStep(7); }, 100);
trace("");
trace("-- Adding Binary Index to query column and repeating benchmarks --");
break;
case 7 :
samplecoll.ensureIndex("customId");
setTimeout(function() { runStep(8); }, 100);
break;
case 8 :
benchFind(20);
setTimeout(function() { runStep(9); }, 100);
break;
case 9 :
benchRS(15);
setTimeout(function() { runStep(10); }, 100);
break;
case 10 :
benchDV(15);
trace("");
trace("done.");
break;
}
} | 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 :
benchUniquePerf();
setTimeout(function() { runStep(4); }, 100);
trace("");
trace("-- Benchmarking query on non-indexed column --");
break;
case 4 :
benchFind(); // find benchmark on unindexed customid field
setTimeout(function() { runStep(5); }, 100);
break;
case 5 :
benchRS(); // resultset find benchmark on unindexed customid field
setTimeout(function() { runStep(6); }, 100);
break;
case 6 :
benchDV();
setTimeout(function() { runStep(7); }, 100);
trace("");
trace("-- Adding Binary Index to query column and repeating benchmarks --");
break;
case 7 :
samplecoll.ensureIndex("customId");
setTimeout(function() { runStep(8); }, 100);
break;
case 8 :
benchFind(20);
setTimeout(function() { runStep(9); }, 100);
break;
case 9 :
benchRS(15);
setTimeout(function() { runStep(10); }, 100);
break;
case 10 :
benchDV(15);
trace("");
trace("done.");
break;
}
} | [
"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",
":",
"benchUniquePerf",
"(",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"runStep",
"(",
"4",
")",
";",
"}",
",",
"100",
")",
";",
"trace",
"(",
"\"\"",
")",
";",
"trace",
"(",
"\"-- Benchmarking query on non-indexed column --\"",
")",
";",
"break",
";",
"case",
"4",
":",
"benchFind",
"(",
")",
";",
"// find benchmark on unindexed customid field",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"runStep",
"(",
"5",
")",
";",
"}",
",",
"100",
")",
";",
"break",
";",
"case",
"5",
":",
"benchRS",
"(",
")",
";",
"// resultset find benchmark on unindexed customid field",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"runStep",
"(",
"6",
")",
";",
"}",
",",
"100",
")",
";",
"break",
";",
"case",
"6",
":",
"benchDV",
"(",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"runStep",
"(",
"7",
")",
";",
"}",
",",
"100",
")",
";",
"trace",
"(",
"\"\"",
")",
";",
"trace",
"(",
"\"-- Adding Binary Index to query column and repeating benchmarks --\"",
")",
";",
"break",
";",
"case",
"7",
":",
"samplecoll",
".",
"ensureIndex",
"(",
"\"customId\"",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"runStep",
"(",
"8",
")",
";",
"}",
",",
"100",
")",
";",
"break",
";",
"case",
"8",
":",
"benchFind",
"(",
"20",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"runStep",
"(",
"9",
")",
";",
"}",
",",
"100",
")",
";",
"break",
";",
"case",
"9",
":",
"benchRS",
"(",
"15",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"runStep",
"(",
"10",
")",
";",
"}",
",",
"100",
")",
";",
"break",
";",
"case",
"10",
":",
"benchDV",
"(",
"15",
")",
";",
"trace",
"(",
"\"\"",
")",
";",
"trace",
"(",
"\"done.\"",
")",
";",
"break",
";",
"}",
"}"
] | 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 |
7,920 | 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");
}
// kick off any program logic or start listening to external events
runProgramLogic();
} | 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");
}
// kick off any program logic or start listening to external events
runProgramLogic();
} | [
"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\"",
")",
";",
"}",
"// kick off any program logic or start listening to external events",
"runProgramLogic",
"(",
")",
";",
"}"
] | 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 |
7,921 | 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 number of entries in database : " + entryCount);
console.log("");
// manually save
db.saveDatabase(function(err) {
if (err) {
console.log(err);
}
else {
console.log("saved... it can now be loaded or reloaded with up to date data");
}
});
} | 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 number of entries in database : " + entryCount);
console.log("");
// manually save
db.saveDatabase(function(err) {
if (err) {
console.log(err);
}
else {
console.log("saved... it can now be loaded or reloaded with up to date data");
}
});
} | [
"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 number of entries in database : \"",
"+",
"entryCount",
")",
";",
"console",
".",
"log",
"(",
"\"\"",
")",
";",
"// manually save",
"db",
".",
"saveDatabase",
"(",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"err",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"\"saved... it can now be loaded or reloaded with up to date data\"",
")",
";",
"}",
"}",
")",
";",
"}"
] | 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 |
7,922 | 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 into independent 'partition' files with numeric suffix.
// Add our main example collection if this is first run.
// This collection will save into a partition named quickstart3.db.0 (collection 0)
if (entries === null) {
// first time run so add and configure collection with some arbitrary options
entries = db.addCollection("entries", { indices: ['x'], clone: true });
}
// Now let's add a second collection only to prove that this saved partition (quickstart3.db.1)
// doesn't need to be saved every time the other partitions do if it never gets any changes
// which need to be saved. The first time we run this should be the only time we save it.
if (messages === null) {
messages = db.addCollection("messages");
messages.insert({ txt: "i will only insert into this collection during databaseInitialize" });
}
// kick off any program logic or start listening to external events
runProgramLogic();
} | 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 into independent 'partition' files with numeric suffix.
// Add our main example collection if this is first run.
// This collection will save into a partition named quickstart3.db.0 (collection 0)
if (entries === null) {
// first time run so add and configure collection with some arbitrary options
entries = db.addCollection("entries", { indices: ['x'], clone: true });
}
// Now let's add a second collection only to prove that this saved partition (quickstart3.db.1)
// doesn't need to be saved every time the other partitions do if it never gets any changes
// which need to be saved. The first time we run this should be the only time we save it.
if (messages === null) {
messages = db.addCollection("messages");
messages.insert({ txt: "i will only insert into this collection during databaseInitialize" });
}
// kick off any program logic or start listening to external events
runProgramLogic();
} | [
"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 into independent 'partition' files with numeric suffix.",
"// Add our main example collection if this is first run.",
"// This collection will save into a partition named quickstart3.db.0 (collection 0) ",
"if",
"(",
"entries",
"===",
"null",
")",
"{",
"// first time run so add and configure collection with some arbitrary options",
"entries",
"=",
"db",
".",
"addCollection",
"(",
"\"entries\"",
",",
"{",
"indices",
":",
"[",
"'x'",
"]",
",",
"clone",
":",
"true",
"}",
")",
";",
"}",
"// Now let's add a second collection only to prove that this saved partition (quickstart3.db.1) ",
"// doesn't need to be saved every time the other partitions do if it never gets any changes",
"// which need to be saved. The first time we run this should be the only time we save it.",
"if",
"(",
"messages",
"===",
"null",
")",
"{",
"messages",
"=",
"db",
".",
"addCollection",
"(",
"\"messages\"",
")",
";",
"messages",
".",
"insert",
"(",
"{",
"txt",
":",
"\"i will only insert into this collection during databaseInitialize\"",
"}",
")",
";",
"}",
"// kick off any program logic or start listening to external events",
"runProgramLogic",
"(",
")",
";",
"}"
] | 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 |
7,923 | 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",
";",
"this",
".",
"affectingActor",
"=",
"affectingActor",
";",
"}"
] | 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 |
7,924 | 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",
"]",
"=",
"right",
"[",
"key",
"]",
";",
"}",
")",
";",
"return",
"left",
";",
"}"
] | 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 |
7,925 | 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'",
",",
"'b'",
",",
"'c'",
"]",
"}",
")",
";",
"for",
"(",
"idx",
"=",
"0",
";",
"idx",
"<",
"INITIAL_DOCUMENT_COUNT",
";",
"idx",
"++",
")",
"{",
"coll",
".",
"insert",
"(",
"genRandomObject",
"(",
")",
")",
";",
"}",
"}"
] | 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 |
7,926 | 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();
start = process.hrtime();
samplecoll.insert({
customId: idx,
val: v1,
val2: v2,
val3: "more data 1234567890"
});
end = process.hrtime(start);
totalTimes.push(end);
}
if (silent === true) {
return;
}
for (var idx = 0; idx < totalTimes.length; idx++) {
totalMS += totalTimes[idx][0] * 1e3 + totalTimes[idx][1] / 1e6;
}
// let's include final find which will probably punish lazy indexes more
start = process.hrtime();
samplecoll.find({customIdx: 50});
end = process.hrtime(start);
totalTimes.push(end);
//var totalMS = end[0] * 1e3 + end[1]/1e6;
totalMS = totalMS.toFixed(2);
var rate = arraySize * 1000 / totalMS;
rate = rate.toFixed(2);
console.log("load (individual inserts) : " + totalMS + "ms (" + rate + ") ops/s (" + arraySize + " documents)");
} | 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();
start = process.hrtime();
samplecoll.insert({
customId: idx,
val: v1,
val2: v2,
val3: "more data 1234567890"
});
end = process.hrtime(start);
totalTimes.push(end);
}
if (silent === true) {
return;
}
for (var idx = 0; idx < totalTimes.length; idx++) {
totalMS += totalTimes[idx][0] * 1e3 + totalTimes[idx][1] / 1e6;
}
// let's include final find which will probably punish lazy indexes more
start = process.hrtime();
samplecoll.find({customIdx: 50});
end = process.hrtime(start);
totalTimes.push(end);
//var totalMS = end[0] * 1e3 + end[1]/1e6;
totalMS = totalMS.toFixed(2);
var rate = arraySize * 1000 / totalMS;
rate = rate.toFixed(2);
console.log("load (individual inserts) : " + totalMS + "ms (" + rate + ") ops/s (" + arraySize + " documents)");
} | [
"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",
"(",
")",
";",
"start",
"=",
"process",
".",
"hrtime",
"(",
")",
";",
"samplecoll",
".",
"insert",
"(",
"{",
"customId",
":",
"idx",
",",
"val",
":",
"v1",
",",
"val2",
":",
"v2",
",",
"val3",
":",
"\"more data 1234567890\"",
"}",
")",
";",
"end",
"=",
"process",
".",
"hrtime",
"(",
"start",
")",
";",
"totalTimes",
".",
"push",
"(",
"end",
")",
";",
"}",
"if",
"(",
"silent",
"===",
"true",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"idx",
"=",
"0",
";",
"idx",
"<",
"totalTimes",
".",
"length",
";",
"idx",
"++",
")",
"{",
"totalMS",
"+=",
"totalTimes",
"[",
"idx",
"]",
"[",
"0",
"]",
"*",
"1e3",
"+",
"totalTimes",
"[",
"idx",
"]",
"[",
"1",
"]",
"/",
"1e6",
";",
"}",
"// let's include final find which will probably punish lazy indexes more ",
"start",
"=",
"process",
".",
"hrtime",
"(",
")",
";",
"samplecoll",
".",
"find",
"(",
"{",
"customIdx",
":",
"50",
"}",
")",
";",
"end",
"=",
"process",
".",
"hrtime",
"(",
"start",
")",
";",
"totalTimes",
".",
"push",
"(",
"end",
")",
";",
"//var totalMS = end[0] * 1e3 + end[1]/1e6;",
"totalMS",
"=",
"totalMS",
".",
"toFixed",
"(",
"2",
")",
";",
"var",
"rate",
"=",
"arraySize",
"*",
"1000",
"/",
"totalMS",
";",
"rate",
"=",
"rate",
".",
"toFixed",
"(",
"2",
")",
";",
"console",
".",
"log",
"(",
"\"load (individual inserts) : \"",
"+",
"totalMS",
"+",
"\"ms (\"",
"+",
"rate",
"+",
"\") ops/s (\"",
"+",
"arraySize",
"+",
"\" documents)\"",
")",
";",
"}"
] | 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 |
7,927 | 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.floor(Math.random() * arraySize) + 1;
start = process.hrtime();
var results = samplecoll.find({
'customId': customidx
});
// insert junk record, now (outside timing routine) to force index rebuild
var obj = samplecoll.insert({
customId: 999,
val: 999,
val2: 999,
val3: "more data 1234567890"
});
end = process.hrtime(start);
totalTimes.push(end);
}
for (var idx = 0; idx < totalTimes.length; idx++) {
totalMS += totalTimes[idx][0] * 1e3 + totalTimes[idx][1] / 1e6;
}
totalMS = totalMS.toFixed(2);
var rate = loopIterations * 1000 / totalMS;
rate = rate.toFixed(2);
console.log("interlaced inserts + coll.find() : " + totalMS + "ms (" + rate + " ops/s) " + loopIterations + " iterations");
} | 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.floor(Math.random() * arraySize) + 1;
start = process.hrtime();
var results = samplecoll.find({
'customId': customidx
});
// insert junk record, now (outside timing routine) to force index rebuild
var obj = samplecoll.insert({
customId: 999,
val: 999,
val2: 999,
val3: "more data 1234567890"
});
end = process.hrtime(start);
totalTimes.push(end);
}
for (var idx = 0; idx < totalTimes.length; idx++) {
totalMS += totalTimes[idx][0] * 1e3 + totalTimes[idx][1] / 1e6;
}
totalMS = totalMS.toFixed(2);
var rate = loopIterations * 1000 / totalMS;
rate = rate.toFixed(2);
console.log("interlaced inserts + coll.find() : " + totalMS + "ms (" + rate + " ops/s) " + loopIterations + " iterations");
} | [
"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",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"arraySize",
")",
"+",
"1",
";",
"start",
"=",
"process",
".",
"hrtime",
"(",
")",
";",
"var",
"results",
"=",
"samplecoll",
".",
"find",
"(",
"{",
"'customId'",
":",
"customidx",
"}",
")",
";",
"// insert junk record, now (outside timing routine) to force index rebuild",
"var",
"obj",
"=",
"samplecoll",
".",
"insert",
"(",
"{",
"customId",
":",
"999",
",",
"val",
":",
"999",
",",
"val2",
":",
"999",
",",
"val3",
":",
"\"more data 1234567890\"",
"}",
")",
";",
"end",
"=",
"process",
".",
"hrtime",
"(",
"start",
")",
";",
"totalTimes",
".",
"push",
"(",
"end",
")",
";",
"}",
"for",
"(",
"var",
"idx",
"=",
"0",
";",
"idx",
"<",
"totalTimes",
".",
"length",
";",
"idx",
"++",
")",
"{",
"totalMS",
"+=",
"totalTimes",
"[",
"idx",
"]",
"[",
"0",
"]",
"*",
"1e3",
"+",
"totalTimes",
"[",
"idx",
"]",
"[",
"1",
"]",
"/",
"1e6",
";",
"}",
"totalMS",
"=",
"totalMS",
".",
"toFixed",
"(",
"2",
")",
";",
"var",
"rate",
"=",
"loopIterations",
"*",
"1000",
"/",
"totalMS",
";",
"rate",
"=",
"rate",
".",
"toFixed",
"(",
"2",
")",
";",
"console",
".",
"log",
"(",
"\"interlaced inserts + coll.find() : \"",
"+",
"totalMS",
"+",
"\"ms (\"",
"+",
"rate",
"+",
"\" ops/s) \"",
"+",
"loopIterations",
"+",
"\" iterations\"",
")",
";",
"}"
] | 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 |
7,928 | 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"] });
users.insert({ name: "thor", gender: "m", age: 35, items: ["mjolnir", "beer"] });
users.insert({ name: "sif", gender: "f", age: 30 });
users.insert({ name: "loki", gender: "m", age: 29 });
users.insert({ name: "sigyn", gender: "f", age: 29 });
users.insert({ name: "freyr", age: 400 });
users.insert({ name: "heimdallr", age: 99 });
users.insert({ name: "mimir", age: 999 });
} | 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"] });
users.insert({ name: "thor", gender: "m", age: 35, items: ["mjolnir", "beer"] });
users.insert({ name: "sif", gender: "f", age: 30 });
users.insert({ name: "loki", gender: "m", age: 29 });
users.insert({ name: "sigyn", gender: "f", age: 29 });
users.insert({ name: "freyr", age: 400 });
users.insert({ name: "heimdallr", age: 99 });
users.insert({ name: "mimir", age: 999 });
} | [
"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\"",
"]",
"}",
")",
";",
"users",
".",
"insert",
"(",
"{",
"name",
":",
"\"thor\"",
",",
"gender",
":",
"\"m\"",
",",
"age",
":",
"35",
",",
"items",
":",
"[",
"\"mjolnir\"",
",",
"\"beer\"",
"]",
"}",
")",
";",
"users",
".",
"insert",
"(",
"{",
"name",
":",
"\"sif\"",
",",
"gender",
":",
"\"f\"",
",",
"age",
":",
"30",
"}",
")",
";",
"users",
".",
"insert",
"(",
"{",
"name",
":",
"\"loki\"",
",",
"gender",
":",
"\"m\"",
",",
"age",
":",
"29",
"}",
")",
";",
"users",
".",
"insert",
"(",
"{",
"name",
":",
"\"sigyn\"",
",",
"gender",
":",
"\"f\"",
",",
"age",
":",
"29",
"}",
")",
";",
"users",
".",
"insert",
"(",
"{",
"name",
":",
"\"freyr\"",
",",
"age",
":",
"400",
"}",
")",
";",
"users",
".",
"insert",
"(",
"{",
"name",
":",
"\"heimdallr\"",
",",
"age",
":",
"99",
"}",
")",
";",
"users",
".",
"insert",
"(",
"{",
"name",
":",
"\"mimir\"",
",",
"age",
":",
"999",
"}",
")",
";",
"}"
] | 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 |
7,929 | 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",
")",
",",
"'utf8'",
")",
"}"
] | 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 |
7,930 | 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",
")",
".",
"replace",
"(",
"':DESCRIPTION'",
",",
"answers",
".",
"description",
")",
".",
"replace",
"(",
"':ICON'",
",",
"answers",
".",
"icon",
")",
".",
"replace",
"(",
"':COLOR'",
",",
"answers",
".",
"color",
")",
"}"
] | 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 |
7,931 | 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}`
},
devDependencies: {
jest: devDependencies.jest
}
}
} | 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}`
},
devDependencies: {
jest: devDependencies.jest
}
}
} | [
"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",
"}",
"`",
"}",
",",
"devDependencies",
":",
"{",
"jest",
":",
"devDependencies",
".",
"jest",
"}",
"}",
"}"
] | 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 |
7,932 | 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.display = "block"; }
}
if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
}
isExpressInstallActive = false;
}
} | 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.display = "block"; }
}
if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
}
isExpressInstallActive = false;
}
} | [
"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",
".",
"display",
"=",
"\"block\"",
";",
"}",
"}",
"if",
"(",
"storedCallbackFn",
")",
"{",
"storedCallbackFn",
"(",
"storedCallbackObj",
")",
";",
"}",
"}",
"isExpressInstallActive",
"=",
"false",
";",
"}",
"}"
] | For internal usage only | [
"For",
"internal",
"usage",
"only"
] | 416db509bfd0741eaa8c88600e1197e027f986e6 | https://github.com/CreateJS/SoundJS/blob/416db509bfd0741eaa8c88600e1197e027f986e6/lib/flashaudioplugin.js#L795-L808 |
|
7,933 | 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 * Not doc'd because this should not be altered externally\n\t\t * @property flashId\n\t\t * @type {String}\n\t\t */",
"this",
".",
"flashId",
"=",
"null",
";",
"}"
] | 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 preloading.
@extends AbstractLoader
@protected | [
"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",
"."
] | 416db509bfd0741eaa8c88600e1197e027f986e6 | https://github.com/CreateJS/SoundJS/blob/416db509bfd0741eaa8c88600e1197e027f986e6/lib/flashaudioplugin.js#L831-L844 |
7,934 | 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,
coordinates: subCoordinates
}
};
supplementaryPoints = supplementaryPoints.concat(createSupplementaryPoints(subFeature, options, index));
});
} | 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,
coordinates: subCoordinates
}
};
supplementaryPoints = supplementaryPoints.concat(createSupplementaryPoints(subFeature, options, index));
});
} | [
"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",
",",
"coordinates",
":",
"subCoordinates",
"}",
"}",
";",
"supplementaryPoints",
"=",
"supplementaryPoints",
".",
"concat",
"(",
"createSupplementaryPoints",
"(",
"subFeature",
",",
"options",
",",
"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 |
7,935 | 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;
}).sort(comparator).map(feature => {
delete feature.area;
return feature;
});
} | 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;
}).sort(comparator).map(feature => {
delete feature.area;
return feature;
});
} | [
"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",
";",
"}",
")",
".",
"sort",
"(",
"comparator",
")",
".",
"map",
"(",
"feature",
"=>",
"{",
"delete",
"feature",
".",
"area",
";",
"return",
"feature",
";",
"}",
")",
";",
"}"
] | 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 |
7,936 | 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.sources.HOT)) {
ctx.map.removeSource(Constants.sources.HOT);
}
} | 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.sources.HOT)) {
ctx.map.removeSource(Constants.sources.HOT);
}
} | [
"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",
".",
"sources",
".",
"HOT",
")",
")",
"{",
"ctx",
".",
"map",
".",
"removeSource",
"(",
"Constants",
".",
"sources",
".",
"HOT",
")",
";",
"}",
"}"
] | 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 |
|
7,937 | 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",
"-",
"(",
"container",
".",
"clientLeft",
"||",
"0",
")",
",",
"mouseEvent",
".",
"clientY",
"-",
"rect",
".",
"top",
"-",
"(",
"container",
".",
"clientTop",
"||",
"0",
")",
")",
";",
"}"
] | 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 |
7,938 | 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",
".",
"point",
".",
"x",
"+",
"buffer",
",",
"mapEvent",
".",
"point",
".",
"y",
"+",
"buffer",
"]",
"]",
";",
"}"
] | 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 |
7,939 | 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':
return handleText(message, event.replyToken, event.source);
case 'image':
return handleImage(message, event.replyToken);
case 'video':
return handleVideo(message, event.replyToken);
case 'audio':
return handleAudio(message, event.replyToken);
case 'location':
return handleLocation(message, event.replyToken);
case 'sticker':
return handleSticker(message, event.replyToken);
default:
throw new Error(`Unknown message: ${JSON.stringify(message)}`);
}
case 'follow':
return replyText(event.replyToken, 'Got followed event');
case 'unfollow':
return console.log(`Unfollowed this bot: ${JSON.stringify(event)}`);
case 'join':
return replyText(event.replyToken, `Joined ${event.source.type}`);
case 'leave':
return console.log(`Left: ${JSON.stringify(event)}`);
case 'postback':
let data = event.postback.data;
if (data === 'DATE' || data === 'TIME' || data === 'DATETIME') {
data += `(${JSON.stringify(event.postback.params)})`;
}
return replyText(event.replyToken, `Got postback: ${data}`);
case 'beacon':
return replyText(event.replyToken, `Got beacon: ${event.beacon.hwid}`);
default:
throw new Error(`Unknown event: ${JSON.stringify(event)}`);
}
} | 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':
return handleText(message, event.replyToken, event.source);
case 'image':
return handleImage(message, event.replyToken);
case 'video':
return handleVideo(message, event.replyToken);
case 'audio':
return handleAudio(message, event.replyToken);
case 'location':
return handleLocation(message, event.replyToken);
case 'sticker':
return handleSticker(message, event.replyToken);
default:
throw new Error(`Unknown message: ${JSON.stringify(message)}`);
}
case 'follow':
return replyText(event.replyToken, 'Got followed event');
case 'unfollow':
return console.log(`Unfollowed this bot: ${JSON.stringify(event)}`);
case 'join':
return replyText(event.replyToken, `Joined ${event.source.type}`);
case 'leave':
return console.log(`Left: ${JSON.stringify(event)}`);
case 'postback':
let data = event.postback.data;
if (data === 'DATE' || data === 'TIME' || data === 'DATETIME') {
data += `(${JSON.stringify(event.postback.params)})`;
}
return replyText(event.replyToken, `Got postback: ${data}`);
case 'beacon':
return replyText(event.replyToken, `Got beacon: ${event.beacon.hwid}`);
default:
throw new Error(`Unknown event: ${JSON.stringify(event)}`);
}
} | [
"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'",
":",
"return",
"handleText",
"(",
"message",
",",
"event",
".",
"replyToken",
",",
"event",
".",
"source",
")",
";",
"case",
"'image'",
":",
"return",
"handleImage",
"(",
"message",
",",
"event",
".",
"replyToken",
")",
";",
"case",
"'video'",
":",
"return",
"handleVideo",
"(",
"message",
",",
"event",
".",
"replyToken",
")",
";",
"case",
"'audio'",
":",
"return",
"handleAudio",
"(",
"message",
",",
"event",
".",
"replyToken",
")",
";",
"case",
"'location'",
":",
"return",
"handleLocation",
"(",
"message",
",",
"event",
".",
"replyToken",
")",
";",
"case",
"'sticker'",
":",
"return",
"handleSticker",
"(",
"message",
",",
"event",
".",
"replyToken",
")",
";",
"default",
":",
"throw",
"new",
"Error",
"(",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"message",
")",
"}",
"`",
")",
";",
"}",
"case",
"'follow'",
":",
"return",
"replyText",
"(",
"event",
".",
"replyToken",
",",
"'Got followed event'",
")",
";",
"case",
"'unfollow'",
":",
"return",
"console",
".",
"log",
"(",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"event",
")",
"}",
"`",
")",
";",
"case",
"'join'",
":",
"return",
"replyText",
"(",
"event",
".",
"replyToken",
",",
"`",
"${",
"event",
".",
"source",
".",
"type",
"}",
"`",
")",
";",
"case",
"'leave'",
":",
"return",
"console",
".",
"log",
"(",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"event",
")",
"}",
"`",
")",
";",
"case",
"'postback'",
":",
"let",
"data",
"=",
"event",
".",
"postback",
".",
"data",
";",
"if",
"(",
"data",
"===",
"'DATE'",
"||",
"data",
"===",
"'TIME'",
"||",
"data",
"===",
"'DATETIME'",
")",
"{",
"data",
"+=",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"event",
".",
"postback",
".",
"params",
")",
"}",
"`",
";",
"}",
"return",
"replyText",
"(",
"event",
".",
"replyToken",
",",
"`",
"${",
"data",
"}",
"`",
")",
";",
"case",
"'beacon'",
":",
"return",
"replyText",
"(",
"event",
".",
"replyToken",
",",
"`",
"${",
"event",
".",
"beacon",
".",
"hwid",
"}",
"`",
")",
";",
"default",
":",
"throw",
"new",
"Error",
"(",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"event",
")",
"}",
"`",
")",
";",
"}",
"}"
] | 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 |
7,940 | 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.target.classList.add('active');
}
});
} | 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.target.classList.add('active');
}
});
} | [
"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",
".",
"target",
".",
"classList",
".",
"add",
"(",
"'active'",
")",
";",
"}",
"}",
")",
";",
"}"
] | 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 |
7,941 | 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",
"}",
"<",
"/",
"FieldContext",
".",
"Provider",
">",
";",
"}"
] | 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 |
7,942 | 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={textContent} {...other}>
{children}
</CustomTagEllipsis>
);
} | 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={textContent} {...other}>
{children}
</CustomTagEllipsis>
);
} | [
"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",
"=",
"{",
"textContent",
"}",
"{",
"...",
"other",
"}",
">",
"\n ",
"{",
"children",
"}",
"\n ",
"<",
"/",
"CustomTagEllipsis",
">",
")",
";",
"}"
] | 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 |
7,943 | 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",
")",
"{",
"fn",
"(",
"result",
")",
";",
"}",
")",
";",
"_process",
"=",
"function",
"(",
"onSuccess",
",",
"onFail",
")",
"{",
"onSuccess",
"(",
"result",
")",
";",
"}",
";",
"_resolve",
"=",
"_reject",
"=",
"function",
"(",
")",
"{",
"}",
";",
"return",
"me",
";",
"}"
] | Resolve the promise
@param {*} result
@type {Function} | [
"Resolve",
"the",
"promise"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/Promise.js#L62-L79 |
|
7,944 | 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",
"(",
"error",
")",
";",
"}",
")",
";",
"_process",
"=",
"function",
"(",
"onSuccess",
",",
"onFail",
")",
"{",
"onFail",
"(",
"error",
")",
";",
"}",
";",
"_resolve",
"=",
"_reject",
"=",
"function",
"(",
")",
"{",
"}",
"return",
"me",
";",
"}"
] | Reject the promise
@param {Error} error
@type {Function} | [
"Reject",
"the",
"promise"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/Promise.js#L86-L103 |
|
7,945 | 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 = options.forkArgs || [];
this.forkOpts = options.forkOpts || {};
this.debugPortStart = (options.debugPortStart || 43210);
this.nodeWorker = options.nodeWorker;
// configuration
if (options && 'maxWorkers' in options) {
validateMaxWorkers(options.maxWorkers);
this.maxWorkers = options.maxWorkers;
}
else {
this.maxWorkers = Math.max((environment.cpus || 4) - 1, 1);
}
if (options && 'minWorkers' in options) {
if(options.minWorkers === 'max') {
this.minWorkers = Math.max((environment.cpus || 4) - 1, 1);
} else {
validateMinWorkers(options.minWorkers);
this.minWorkers = options.minWorkers;
this.maxWorkers = Math.max(this.minWorkers, this.maxWorkers); // in case minWorkers is higher than maxWorkers
}
this._ensureMinWorkers();
}
this._boundNext = this._next.bind(this);
if (this.nodeWorker === 'thread') {
WorkerHandler.ensureWorkerThreads();
}
} | 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 = options.forkArgs || [];
this.forkOpts = options.forkOpts || {};
this.debugPortStart = (options.debugPortStart || 43210);
this.nodeWorker = options.nodeWorker;
// configuration
if (options && 'maxWorkers' in options) {
validateMaxWorkers(options.maxWorkers);
this.maxWorkers = options.maxWorkers;
}
else {
this.maxWorkers = Math.max((environment.cpus || 4) - 1, 1);
}
if (options && 'minWorkers' in options) {
if(options.minWorkers === 'max') {
this.minWorkers = Math.max((environment.cpus || 4) - 1, 1);
} else {
validateMinWorkers(options.minWorkers);
this.minWorkers = options.minWorkers;
this.maxWorkers = Math.max(this.minWorkers, this.maxWorkers); // in case minWorkers is higher than maxWorkers
}
this._ensureMinWorkers();
}
this._boundNext = this._next.bind(this);
if (this.nodeWorker === 'thread') {
WorkerHandler.ensureWorkerThreads();
}
} | [
"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",
"=",
"options",
".",
"forkArgs",
"||",
"[",
"]",
";",
"this",
".",
"forkOpts",
"=",
"options",
".",
"forkOpts",
"||",
"{",
"}",
";",
"this",
".",
"debugPortStart",
"=",
"(",
"options",
".",
"debugPortStart",
"||",
"43210",
")",
";",
"this",
".",
"nodeWorker",
"=",
"options",
".",
"nodeWorker",
";",
"// configuration",
"if",
"(",
"options",
"&&",
"'maxWorkers'",
"in",
"options",
")",
"{",
"validateMaxWorkers",
"(",
"options",
".",
"maxWorkers",
")",
";",
"this",
".",
"maxWorkers",
"=",
"options",
".",
"maxWorkers",
";",
"}",
"else",
"{",
"this",
".",
"maxWorkers",
"=",
"Math",
".",
"max",
"(",
"(",
"environment",
".",
"cpus",
"||",
"4",
")",
"-",
"1",
",",
"1",
")",
";",
"}",
"if",
"(",
"options",
"&&",
"'minWorkers'",
"in",
"options",
")",
"{",
"if",
"(",
"options",
".",
"minWorkers",
"===",
"'max'",
")",
"{",
"this",
".",
"minWorkers",
"=",
"Math",
".",
"max",
"(",
"(",
"environment",
".",
"cpus",
"||",
"4",
")",
"-",
"1",
",",
"1",
")",
";",
"}",
"else",
"{",
"validateMinWorkers",
"(",
"options",
".",
"minWorkers",
")",
";",
"this",
".",
"minWorkers",
"=",
"options",
".",
"minWorkers",
";",
"this",
".",
"maxWorkers",
"=",
"Math",
".",
"max",
"(",
"this",
".",
"minWorkers",
",",
"this",
".",
"maxWorkers",
")",
";",
"// in case minWorkers is higher than maxWorkers",
"}",
"this",
".",
"_ensureMinWorkers",
"(",
")",
";",
"}",
"this",
".",
"_boundNext",
"=",
"this",
".",
"_next",
".",
"bind",
"(",
"this",
")",
";",
"if",
"(",
"this",
".",
"nodeWorker",
"===",
"'thread'",
")",
"{",
"WorkerHandler",
".",
"ensureWorkerThreads",
"(",
")",
";",
"}",
"}"
] | 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 |
7,946 | 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') {
throw new Error('URL.createObjectURL not supported by the browser');
}
// use embedded worker.js
var blob = new Blob([require('./generated/embeddedWorker')], {type: 'text/javascript'});
return window.URL.createObjectURL(blob);
}
else {
// use external worker.js in current directory
return __dirname + '/worker.js';
}
} | 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') {
throw new Error('URL.createObjectURL not supported by the browser');
}
// use embedded worker.js
var blob = new Blob([require('./generated/embeddedWorker')], {type: 'text/javascript'});
return window.URL.createObjectURL(blob);
}
else {
// use external worker.js in current directory
return __dirname + '/worker.js';
}
} | [
"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'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'URL.createObjectURL not supported by the browser'",
")",
";",
"}",
"// use embedded worker.js",
"var",
"blob",
"=",
"new",
"Blob",
"(",
"[",
"require",
"(",
"'./generated/embeddedWorker'",
")",
"]",
",",
"{",
"type",
":",
"'text/javascript'",
"}",
")",
";",
"return",
"window",
".",
"URL",
".",
"createObjectURL",
"(",
"blob",
")",
";",
"}",
"else",
"{",
"// use external worker.js in current directory",
"return",
"__dirname",
"+",
"'/worker.js'",
";",
"}",
"}"
] | get the default worker script | [
"get",
"the",
"default",
"worker",
"script"
] | 52a67c7f9218a9351a90f9fec263337c57df3095 | https://github.com/josdejong/workerpool/blob/52a67c7f9218a9351a90f9fec263337c57df3095/lib/WorkerHandler.js#L32-L50 |
7,947 | 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=' + opts.debugPort);
if (debugBrk) {
execArgv.push('--debug-brk');
}
}
return assign({}, opts, {
forkArgs: opts.forkArgs,
forkOpts: assign({}, opts.forkOpts, {
execArgv: (opts.forkOpts && opts.forkOpts.execArgv || [])
.concat(execArgv)
})
});
} | 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=' + opts.debugPort);
if (debugBrk) {
execArgv.push('--debug-brk');
}
}
return assign({}, opts, {
forkArgs: opts.forkArgs,
forkOpts: assign({}, opts.forkOpts, {
execArgv: (opts.forkOpts && opts.forkOpts.execArgv || [])
.concat(execArgv)
})
});
} | [
"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='",
"+",
"opts",
".",
"debugPort",
")",
";",
"if",
"(",
"debugBrk",
")",
"{",
"execArgv",
".",
"push",
"(",
"'--debug-brk'",
")",
";",
"}",
"}",
"return",
"assign",
"(",
"{",
"}",
",",
"opts",
",",
"{",
"forkArgs",
":",
"opts",
".",
"forkArgs",
",",
"forkOpts",
":",
"assign",
"(",
"{",
"}",
",",
"opts",
".",
"forkOpts",
",",
"{",
"execArgv",
":",
"(",
"opts",
".",
"forkOpts",
"&&",
"opts",
".",
"forkOpts",
".",
"execArgv",
"||",
"[",
"]",
")",
".",
"concat",
"(",
"execArgv",
")",
"}",
")",
"}",
")",
";",
"}"
] | 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 |
7,948 | 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",
"++",
")",
"{",
"temp",
"[",
"props",
"[",
"i",
"]",
"]",
"=",
"obj",
"[",
"props",
"[",
"i",
"]",
"]",
"}",
"return",
"temp",
"}"
] | 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 |
7,949 | 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);
}
}
me.processing = Object.create(null);
} | 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);
}
}
me.processing = Object.create(null);
} | [
"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",
")",
";",
"}",
"}",
"me",
".",
"processing",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"}"
] | 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 |
7,950 | 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 |
7,951 | 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];
existingPackedLen = existingPackedLen || 0;
existingByteLen = existingPackedLen >>> 3;
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 2)
{
num = parseInt(str.substr(i, 2), 16);
if (!isNaN(num))
{
byteOffset = (i >>> 1) + existingByteLen;
intOffset = byteOffset >>> 2;
while (packed.length <= intOffset)
{
packed.push(0);
}
packed[intOffset] |= num << (8 * (shiftModifier + bigEndianMod * (byteOffset % 4)));
}
else
{
throw new Error("String of HEX type contains invalid characters");
}
}
return {"value" : packed, "binLen" : length * 4 + existingPackedLen};
} | 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];
existingPackedLen = existingPackedLen || 0;
existingByteLen = existingPackedLen >>> 3;
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 2)
{
num = parseInt(str.substr(i, 2), 16);
if (!isNaN(num))
{
byteOffset = (i >>> 1) + existingByteLen;
intOffset = byteOffset >>> 2;
while (packed.length <= intOffset)
{
packed.push(0);
}
packed[intOffset] |= num << (8 * (shiftModifier + bigEndianMod * (byteOffset % 4)));
}
else
{
throw new Error("String of HEX type contains invalid characters");
}
}
return {"value" : packed, "binLen" : length * 4 + existingPackedLen};
} | [
"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",
"]",
";",
"existingPackedLen",
"=",
"existingPackedLen",
"||",
"0",
";",
"existingByteLen",
"=",
"existingPackedLen",
">>>",
"3",
";",
"shiftModifier",
"=",
"(",
"bigEndianMod",
"===",
"-",
"1",
")",
"?",
"3",
":",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"num",
"=",
"parseInt",
"(",
"str",
".",
"substr",
"(",
"i",
",",
"2",
")",
",",
"16",
")",
";",
"if",
"(",
"!",
"isNaN",
"(",
"num",
")",
")",
"{",
"byteOffset",
"=",
"(",
"i",
">>>",
"1",
")",
"+",
"existingByteLen",
";",
"intOffset",
"=",
"byteOffset",
">>>",
"2",
";",
"while",
"(",
"packed",
".",
"length",
"<=",
"intOffset",
")",
"{",
"packed",
".",
"push",
"(",
"0",
")",
";",
"}",
"packed",
"[",
"intOffset",
"]",
"|=",
"num",
"<<",
"(",
"8",
"*",
"(",
"shiftModifier",
"+",
"bigEndianMod",
"*",
"(",
"byteOffset",
"%",
"4",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"String of HEX type contains invalid characters\"",
")",
";",
"}",
"}",
"return",
"{",
"\"value\"",
":",
"packed",
",",
"\"binLen\"",
":",
"length",
"*",
"4",
"+",
"existingPackedLen",
"}",
";",
"}"
] | 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} bigEndianMod Modifier for whether hash function is
big or small endian
@return {{value : Array<number>, binLen : number}} Hash list where
"value" contains the output number array and "binLen" is the binary
length of "value" | [
"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 |
7,952 | 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 === -1) ? 3 : 0;
for (i = 0; i < str.length; i += 1)
{
codePnt = str.charCodeAt(i);
byteOffset = i + existingByteLen;
intOffset = byteOffset >>> 2;
if (packed.length <= intOffset)
{
packed.push(0);
}
packed[intOffset] |= codePnt << (8 * (shiftModifier + bigEndianMod * (byteOffset % 4)));
}
return {"value" : packed, "binLen" : str.length * 8 + existingPackedLen};
} | 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 === -1) ? 3 : 0;
for (i = 0; i < str.length; i += 1)
{
codePnt = str.charCodeAt(i);
byteOffset = i + existingByteLen;
intOffset = byteOffset >>> 2;
if (packed.length <= intOffset)
{
packed.push(0);
}
packed[intOffset] |= codePnt << (8 * (shiftModifier + bigEndianMod * (byteOffset % 4)));
}
return {"value" : packed, "binLen" : str.length * 8 + existingPackedLen};
} | [
"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",
"===",
"-",
"1",
")",
"?",
"3",
":",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"codePnt",
"=",
"str",
".",
"charCodeAt",
"(",
"i",
")",
";",
"byteOffset",
"=",
"i",
"+",
"existingByteLen",
";",
"intOffset",
"=",
"byteOffset",
">>>",
"2",
";",
"if",
"(",
"packed",
".",
"length",
"<=",
"intOffset",
")",
"{",
"packed",
".",
"push",
"(",
"0",
")",
";",
"}",
"packed",
"[",
"intOffset",
"]",
"|=",
"codePnt",
"<<",
"(",
"8",
"*",
"(",
"shiftModifier",
"+",
"bigEndianMod",
"*",
"(",
"byteOffset",
"%",
"4",
")",
")",
")",
";",
"}",
"return",
"{",
"\"value\"",
":",
"packed",
",",
"\"binLen\"",
":",
"str",
".",
"length",
"*",
"8",
"+",
"existingPackedLen",
"}",
";",
"}"
] | 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
array
@param {number} bigEndianMod Modifier for whether hash function is
big or small endian
@return {{value : Array<number>, binLen : number}} Hash list where
"value" contains the output number array and "binLen" is the binary
length of "value" | [
"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 |
7,953 | 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-9=+\/]+$/))
{
throw new Error("Invalid character in base-64 string");
}
firstEqual = str.indexOf("=");
str = str.replace(/\=/g, "");
if ((-1 !== firstEqual) && (firstEqual < str.length))
{
throw new Error("Invalid '=' found in base-64 string");
}
packed = existingPacked || [0];
existingPackedLen = existingPackedLen || 0;
existingByteLen = existingPackedLen >>> 3;
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < str.length; i += 4)
{
strPart = str.substr(i, 4);
tmpInt = 0;
for (j = 0; j < strPart.length; j += 1)
{
index = b64Tab.indexOf(strPart[j]);
tmpInt |= index << (18 - (6 * j));
}
for (j = 0; j < strPart.length - 1; j += 1)
{
byteOffset = byteCnt + existingByteLen;
intOffset = byteOffset >>> 2;
while (packed.length <= intOffset)
{
packed.push(0);
}
packed[intOffset] |= ((tmpInt >>> (16 - (j * 8))) & 0xFF) <<
(8 * (shiftModifier + bigEndianMod * (byteOffset % 4)));
byteCnt += 1;
}
}
return {"value" : packed, "binLen" : byteCnt * 8 + existingPackedLen};
} | 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-9=+\/]+$/))
{
throw new Error("Invalid character in base-64 string");
}
firstEqual = str.indexOf("=");
str = str.replace(/\=/g, "");
if ((-1 !== firstEqual) && (firstEqual < str.length))
{
throw new Error("Invalid '=' found in base-64 string");
}
packed = existingPacked || [0];
existingPackedLen = existingPackedLen || 0;
existingByteLen = existingPackedLen >>> 3;
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < str.length; i += 4)
{
strPart = str.substr(i, 4);
tmpInt = 0;
for (j = 0; j < strPart.length; j += 1)
{
index = b64Tab.indexOf(strPart[j]);
tmpInt |= index << (18 - (6 * j));
}
for (j = 0; j < strPart.length - 1; j += 1)
{
byteOffset = byteCnt + existingByteLen;
intOffset = byteOffset >>> 2;
while (packed.length <= intOffset)
{
packed.push(0);
}
packed[intOffset] |= ((tmpInt >>> (16 - (j * 8))) & 0xFF) <<
(8 * (shiftModifier + bigEndianMod * (byteOffset % 4)));
byteCnt += 1;
}
}
return {"value" : packed, "binLen" : byteCnt * 8 + existingPackedLen};
} | [
"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-9=+\\/]+$",
"/",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Invalid character in base-64 string\"",
")",
";",
"}",
"firstEqual",
"=",
"str",
".",
"indexOf",
"(",
"\"=\"",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"\\=",
"/",
"g",
",",
"\"\"",
")",
";",
"if",
"(",
"(",
"-",
"1",
"!==",
"firstEqual",
")",
"&&",
"(",
"firstEqual",
"<",
"str",
".",
"length",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Invalid '=' found in base-64 string\"",
")",
";",
"}",
"packed",
"=",
"existingPacked",
"||",
"[",
"0",
"]",
";",
"existingPackedLen",
"=",
"existingPackedLen",
"||",
"0",
";",
"existingByteLen",
"=",
"existingPackedLen",
">>>",
"3",
";",
"shiftModifier",
"=",
"(",
"bigEndianMod",
"===",
"-",
"1",
")",
"?",
"3",
":",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
";",
"i",
"+=",
"4",
")",
"{",
"strPart",
"=",
"str",
".",
"substr",
"(",
"i",
",",
"4",
")",
";",
"tmpInt",
"=",
"0",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"strPart",
".",
"length",
";",
"j",
"+=",
"1",
")",
"{",
"index",
"=",
"b64Tab",
".",
"indexOf",
"(",
"strPart",
"[",
"j",
"]",
")",
";",
"tmpInt",
"|=",
"index",
"<<",
"(",
"18",
"-",
"(",
"6",
"*",
"j",
")",
")",
";",
"}",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"strPart",
".",
"length",
"-",
"1",
";",
"j",
"+=",
"1",
")",
"{",
"byteOffset",
"=",
"byteCnt",
"+",
"existingByteLen",
";",
"intOffset",
"=",
"byteOffset",
">>>",
"2",
";",
"while",
"(",
"packed",
".",
"length",
"<=",
"intOffset",
")",
"{",
"packed",
".",
"push",
"(",
"0",
")",
";",
"}",
"packed",
"[",
"intOffset",
"]",
"|=",
"(",
"(",
"tmpInt",
">>>",
"(",
"16",
"-",
"(",
"j",
"*",
"8",
")",
")",
")",
"&",
"0xFF",
")",
"<<",
"(",
"8",
"*",
"(",
"shiftModifier",
"+",
"bigEndianMod",
"*",
"(",
"byteOffset",
"%",
"4",
")",
")",
")",
";",
"byteCnt",
"+=",
"1",
";",
"}",
"}",
"return",
"{",
"\"value\"",
":",
"packed",
",",
"\"binLen\"",
":",
"byteCnt",
"*",
"8",
"+",
"existingPackedLen",
"}",
";",
"}"
] | 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 {number} bigEndianMod Modifier for whether hash function is
big or small endian
@return {{value : Array<number>, binLen : number}} Hash list where
"value" contains the output number array and "binLen" is the binary
length of "value" | [
"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 |
7,954 | 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 = (bigEndianMod === -1) ? 3 : 0;
arrView = new Uint8Array(arr);
for (i = 0; i < arr.byteLength; i += 1)
{
byteOffset = i + existingByteLen;
intOffset = byteOffset >>> 2;
if (packed.length <= intOffset)
{
packed.push(0);
}
packed[intOffset] |= arrView[i] << (8 * (shiftModifier + bigEndianMod * (byteOffset % 4)));
}
return {"value" : packed, "binLen" : arr.byteLength * 8 + existingPackedLen};
} | 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 = (bigEndianMod === -1) ? 3 : 0;
arrView = new Uint8Array(arr);
for (i = 0; i < arr.byteLength; i += 1)
{
byteOffset = i + existingByteLen;
intOffset = byteOffset >>> 2;
if (packed.length <= intOffset)
{
packed.push(0);
}
packed[intOffset] |= arrView[i] << (8 * (shiftModifier + bigEndianMod * (byteOffset % 4)));
}
return {"value" : packed, "binLen" : arr.byteLength * 8 + existingPackedLen};
} | [
"function",
"arraybuffer2packed",
"(",
"arr",
",",
"existingPacked",
",",
"existingPackedLen",
",",
"bigEndianMod",
")",
"{",
"var",
"packed",
",",
"i",
",",
"existingByteLen",
",",
"intOffset",
",",
"byteOffset",
",",
"shiftModifier",
",",
"arrView",
";",
"packed",
"=",
"existingPacked",
"||",
"[",
"0",
"]",
";",
"existingPackedLen",
"=",
"existingPackedLen",
"||",
"0",
";",
"existingByteLen",
"=",
"existingPackedLen",
">>>",
"3",
";",
"shiftModifier",
"=",
"(",
"bigEndianMod",
"===",
"-",
"1",
")",
"?",
"3",
":",
"0",
";",
"arrView",
"=",
"new",
"Uint8Array",
"(",
"arr",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"byteLength",
";",
"i",
"+=",
"1",
")",
"{",
"byteOffset",
"=",
"i",
"+",
"existingByteLen",
";",
"intOffset",
"=",
"byteOffset",
">>>",
"2",
";",
"if",
"(",
"packed",
".",
"length",
"<=",
"intOffset",
")",
"{",
"packed",
".",
"push",
"(",
"0",
")",
";",
"}",
"packed",
"[",
"intOffset",
"]",
"|=",
"arrView",
"[",
"i",
"]",
"<<",
"(",
"8",
"*",
"(",
"shiftModifier",
"+",
"bigEndianMod",
"*",
"(",
"byteOffset",
"%",
"4",
")",
")",
")",
";",
"}",
"return",
"{",
"\"value\"",
":",
"packed",
",",
"\"binLen\"",
":",
"arr",
".",
"byteLength",
"*",
"8",
"+",
"existingPackedLen",
"}",
";",
"}"
] | 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
@param {number} bigEndianMod Modifier for whether hash function is
big or small endian
@return {{value : Array<number>, binLen : number}} Hash list where
"value" contains the output number array and "binLen" is the binary
length of "value" | [
"Convert",
"an",
"ArrayBuffer",
"to",
"an",
"array",
"of",
"big",
"-",
"endian",
"words"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L332-L354 |
7,955 | 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)
{
int1 = ((i + 1) < length) ? packed[(i + 1) >>> 2] : 0;
int2 = ((i + 2) < length) ? packed[(i + 2) >>> 2] : 0;
triplet = (((packed[i >>> 2] >>> (8 * (shiftModifier + bigEndianMod * (i % 4)))) & 0xFF) << 16) |
(((int1 >>> (8 * (shiftModifier + bigEndianMod * ((i + 1) % 4)))) & 0xFF) << 8) |
((int2 >>> (8 * (shiftModifier + bigEndianMod * ((i + 2) % 4)))) & 0xFF);
for (j = 0; j < 4; j += 1)
{
if (i * 8 + j * 6 <= outputLength)
{
str += b64Tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F);
}
else
{
str += formatOpts["b64Pad"];
}
}
}
return str;
} | 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)
{
int1 = ((i + 1) < length) ? packed[(i + 1) >>> 2] : 0;
int2 = ((i + 2) < length) ? packed[(i + 2) >>> 2] : 0;
triplet = (((packed[i >>> 2] >>> (8 * (shiftModifier + bigEndianMod * (i % 4)))) & 0xFF) << 16) |
(((int1 >>> (8 * (shiftModifier + bigEndianMod * ((i + 1) % 4)))) & 0xFF) << 8) |
((int2 >>> (8 * (shiftModifier + bigEndianMod * ((i + 2) % 4)))) & 0xFF);
for (j = 0; j < 4; j += 1)
{
if (i * 8 + j * 6 <= outputLength)
{
str += b64Tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F);
}
else
{
str += formatOpts["b64Pad"];
}
}
}
return str;
} | [
"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",
")",
"{",
"int1",
"=",
"(",
"(",
"i",
"+",
"1",
")",
"<",
"length",
")",
"?",
"packed",
"[",
"(",
"i",
"+",
"1",
")",
">>>",
"2",
"]",
":",
"0",
";",
"int2",
"=",
"(",
"(",
"i",
"+",
"2",
")",
"<",
"length",
")",
"?",
"packed",
"[",
"(",
"i",
"+",
"2",
")",
">>>",
"2",
"]",
":",
"0",
";",
"triplet",
"=",
"(",
"(",
"(",
"packed",
"[",
"i",
">>>",
"2",
"]",
">>>",
"(",
"8",
"*",
"(",
"shiftModifier",
"+",
"bigEndianMod",
"*",
"(",
"i",
"%",
"4",
")",
")",
")",
")",
"&",
"0xFF",
")",
"<<",
"16",
")",
"|",
"(",
"(",
"(",
"int1",
">>>",
"(",
"8",
"*",
"(",
"shiftModifier",
"+",
"bigEndianMod",
"*",
"(",
"(",
"i",
"+",
"1",
")",
"%",
"4",
")",
")",
")",
")",
"&",
"0xFF",
")",
"<<",
"8",
")",
"|",
"(",
"(",
"int2",
">>>",
"(",
"8",
"*",
"(",
"shiftModifier",
"+",
"bigEndianMod",
"*",
"(",
"(",
"i",
"+",
"2",
")",
"%",
"4",
")",
")",
")",
")",
"&",
"0xFF",
")",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"4",
";",
"j",
"+=",
"1",
")",
"{",
"if",
"(",
"i",
"*",
"8",
"+",
"j",
"*",
"6",
"<=",
"outputLength",
")",
"{",
"str",
"+=",
"b64Tab",
".",
"charAt",
"(",
"(",
"triplet",
">>>",
"6",
"*",
"(",
"3",
"-",
"j",
")",
")",
"&",
"0x3F",
")",
";",
"}",
"else",
"{",
"str",
"+=",
"formatOpts",
"[",
"\"b64Pad\"",
"]",
";",
"}",
"}",
"}",
"return",
"str",
";",
"}"
] | 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 : boolean, b64Pad : string}} formatOpts Hash list
containing validated output formatting options
@return {string} Base-64 encoded representation of the parameter in
string form | [
"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 |
7,956 | 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 += String.fromCharCode(srcByte);
}
return 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 += String.fromCharCode(srcByte);
}
return str;
} | [
"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",
"+=",
"String",
".",
"fromCharCode",
"(",
"srcByte",
")",
";",
"}",
"return",
"str",
";",
"}"
] | 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 {string} Raw bytes representation of the parameter in string
form | [
"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 |
7,957 | 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] >>> (8 * (shiftModifier + bigEndianMod * (i % 4)))) & 0xFF;
}
return retVal;
} | 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] >>> (8 * (shiftModifier + bigEndianMod * (i % 4)))) & 0xFF;
}
return retVal;
} | [
"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",
"]",
">>>",
"(",
"8",
"*",
"(",
"shiftModifier",
"+",
"bigEndianMod",
"*",
"(",
"i",
"%",
"4",
")",
")",
")",
")",
"&",
"0xFF",
";",
"}",
"return",
"retVal",
";",
"}"
] | 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 representation of the parameter in an
ArrayBuffer | [
"Convert",
"an",
"array",
"of",
"big",
"-",
"endian",
"words",
"to",
"an",
"ArrayBuffer"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L470-L483 |
7,958 | 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["b64Pad"];
}
if ((true === outputOptions.hasOwnProperty("shakeLen")) && ((8 & SUPPORTED_ALGS) !== 0))
{
if (outputOptions["shakeLen"] % 8 !== 0)
{
throw new Error("shakeLen must be a multiple of 8");
}
retVal["shakeLen"] = outputOptions["shakeLen"];
}
if ("boolean" !== typeof(retVal["outputUpper"]))
{
throw new Error("Invalid outputUpper formatting option");
}
if ("string" !== typeof(retVal["b64Pad"]))
{
throw new Error("Invalid b64Pad formatting option");
}
return retVal;
} | 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["b64Pad"];
}
if ((true === outputOptions.hasOwnProperty("shakeLen")) && ((8 & SUPPORTED_ALGS) !== 0))
{
if (outputOptions["shakeLen"] % 8 !== 0)
{
throw new Error("shakeLen must be a multiple of 8");
}
retVal["shakeLen"] = outputOptions["shakeLen"];
}
if ("boolean" !== typeof(retVal["outputUpper"]))
{
throw new Error("Invalid outputUpper formatting option");
}
if ("string" !== typeof(retVal["b64Pad"]))
{
throw new Error("Invalid b64Pad formatting option");
}
return retVal;
} | [
"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",
"[",
"\"b64Pad\"",
"]",
";",
"}",
"if",
"(",
"(",
"true",
"===",
"outputOptions",
".",
"hasOwnProperty",
"(",
"\"shakeLen\"",
")",
")",
"&&",
"(",
"(",
"8",
"&",
"SUPPORTED_ALGS",
")",
"!==",
"0",
")",
")",
"{",
"if",
"(",
"outputOptions",
"[",
"\"shakeLen\"",
"]",
"%",
"8",
"!==",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"shakeLen must be a multiple of 8\"",
")",
";",
"}",
"retVal",
"[",
"\"shakeLen\"",
"]",
"=",
"outputOptions",
"[",
"\"shakeLen\"",
"]",
";",
"}",
"if",
"(",
"\"boolean\"",
"!==",
"typeof",
"(",
"retVal",
"[",
"\"outputUpper\"",
"]",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Invalid outputUpper formatting option\"",
")",
";",
"}",
"if",
"(",
"\"string\"",
"!==",
"typeof",
"(",
"retVal",
"[",
"\"b64Pad\"",
"]",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Invalid b64Pad formatting option\"",
")",
";",
"}",
"return",
"retVal",
";",
"}"
] | 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, b64Pad : string, shakeLen : number}} Validated
hash list containing output formatting options | [
"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 |
7,959 | 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 >>> (32 - n)
);
}
else
{
return x;
}
} | 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 >>> (32 - n)
);
}
else
{
return x;
}
} | [
"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",
">>>",
"(",
"32",
"-",
"n",
")",
")",
";",
"}",
"else",
"{",
"return",
"x",
";",
"}",
"}"
] | 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 |
7,960 | 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_64(
(tmp.lowOrder >>> (n - 32)) | ((tmp.highOrder << (64 - n)) & 0xFFFFFFFF),
(tmp.highOrder >>> (n - 32)) | ((tmp.lowOrder << (64 - n)) & 0xFFFFFFFF)
);
}
return retVal;
} | 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_64(
(tmp.lowOrder >>> (n - 32)) | ((tmp.highOrder << (64 - n)) & 0xFFFFFFFF),
(tmp.highOrder >>> (n - 32)) | ((tmp.lowOrder << (64 - n)) & 0xFFFFFFFF)
);
}
return retVal;
} | [
"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_64",
"(",
"(",
"tmp",
".",
"lowOrder",
">>>",
"(",
"n",
"-",
"32",
")",
")",
"|",
"(",
"(",
"tmp",
".",
"highOrder",
"<<",
"(",
"64",
"-",
"n",
")",
")",
"&",
"0xFFFFFFFF",
")",
",",
"(",
"tmp",
".",
"highOrder",
">>>",
"(",
"n",
"-",
"32",
")",
")",
"|",
"(",
"(",
"tmp",
".",
"lowOrder",
"<<",
"(",
"64",
"-",
"n",
")",
")",
"&",
"0xFFFFFFFF",
")",
")",
";",
"}",
"return",
"retVal",
";",
"}"
] | 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 |
7,961 | 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",
"|",
"(",
"(",
"x",
".",
"highOrder",
"<<",
"(",
"32",
"-",
"n",
")",
")",
"&",
"0xFFFFFFFF",
")",
")",
";",
"}",
"else",
"{",
"retVal",
"=",
"new",
"Int_64",
"(",
"0",
",",
"x",
".",
"highOrder",
">>>",
"(",
"n",
"-",
"32",
")",
")",
";",
"}",
"return",
"retVal",
";",
"}"
] | 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 |
7,962 | 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",
".",
"lowOrder",
"&",
"y",
".",
"lowOrder",
")",
"^",
"(",
"~",
"x",
".",
"lowOrder",
"&",
"z",
".",
"lowOrder",
")",
")",
";",
"}"
] | 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 |
7,963 | 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 |
7,964 | 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",
".",
"highOrder",
"&",
"z",
".",
"highOrder",
")",
",",
"(",
"x",
".",
"lowOrder",
"&",
"y",
".",
"lowOrder",
")",
"^",
"(",
"x",
".",
"lowOrder",
"&",
"z",
".",
"lowOrder",
")",
"^",
"(",
"y",
".",
"lowOrder",
"&",
"z",
".",
"lowOrder",
")",
")",
";",
"}"
] | 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 |
7,965 | 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_64",
"(",
"rotr28",
".",
"highOrder",
"^",
"rotr34",
".",
"highOrder",
"^",
"rotr39",
".",
"highOrder",
",",
"rotr28",
".",
"lowOrder",
"^",
"rotr34",
".",
"lowOrder",
"^",
"rotr39",
".",
"lowOrder",
")",
";",
"}"
] | 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 |
7,966 | 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_64",
"(",
"rotr14",
".",
"highOrder",
"^",
"rotr18",
".",
"highOrder",
"^",
"rotr41",
".",
"highOrder",
",",
"rotr14",
".",
"lowOrder",
"^",
"rotr18",
".",
"lowOrder",
"^",
"rotr41",
".",
"lowOrder",
")",
";",
"}"
] | 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 |
7,967 | 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",
"(",
"rotr1",
".",
"highOrder",
"^",
"rotr8",
".",
"highOrder",
"^",
"shr7",
".",
"highOrder",
",",
"rotr1",
".",
"lowOrder",
"^",
"rotr8",
".",
"lowOrder",
"^",
"shr7",
".",
"lowOrder",
")",
";",
"}"
] | 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 |
7,968 | 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",
"(",
"rotr19",
".",
"highOrder",
"^",
"rotr61",
".",
"highOrder",
"^",
"shr6",
".",
"highOrder",
",",
"rotr19",
".",
"lowOrder",
"^",
"rotr61",
".",
"lowOrder",
"^",
"shr6",
".",
"lowOrder",
")",
";",
"}"
] | 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 |
7,969 | 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",
">>>",
"16",
")",
";",
"return",
"(",
"(",
"msw",
"&",
"0xFFFF",
")",
"<<",
"16",
")",
"|",
"(",
"lsw",
"&",
"0xFFFF",
")",
";",
"}"
] | 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 |
7,970 | 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",
")",
",",
"msw",
"=",
"(",
"a",
">>>",
"16",
")",
"+",
"(",
"b",
">>>",
"16",
")",
"+",
"(",
"c",
">>>",
"16",
")",
"+",
"(",
"d",
">>>",
"16",
")",
"+",
"(",
"lsw",
">>>",
"16",
")",
";",
"return",
"(",
"(",
"msw",
"&",
"0xFFFF",
")",
"<<",
"16",
")",
"|",
"(",
"lsw",
"&",
"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 to be added
@param {number} d The fourth 32-bit integer argument to be added
@return {number} The sum of a + b + c + d | [
"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 |
7,971 | 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",
")",
"+",
"(",
"e",
"&",
"0xFFFF",
")",
",",
"msw",
"=",
"(",
"a",
">>>",
"16",
")",
"+",
"(",
"b",
">>>",
"16",
")",
"+",
"(",
"c",
">>>",
"16",
")",
"+",
"(",
"d",
">>>",
"16",
")",
"+",
"(",
"e",
">>>",
"16",
")",
"+",
"(",
"lsw",
">>>",
"16",
")",
";",
"return",
"(",
"(",
"msw",
"&",
"0xFFFF",
")",
"<<",
"16",
")",
"|",
"(",
"lsw",
"&",
"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 to be added
@param {number} d The fourth 32-bit integer argument to be added
@param {number} e The fifth 32-bit integer argument to be added
@return {number} The sum of a + b + c + d + e | [
"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 |
7,972 | 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);
msw = (x.highOrder >>> 16) + (y.highOrder >>> 16) + (lsw >>> 16);
highOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
return new Int_64(highOrder, lowOrder);
} | 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);
msw = (x.highOrder >>> 16) + (y.highOrder >>> 16) + (lsw >>> 16);
highOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
return new Int_64(highOrder, lowOrder);
} | [
"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",
")",
";",
"msw",
"=",
"(",
"x",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"y",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"lsw",
">>>",
"16",
")",
";",
"highOrder",
"=",
"(",
"(",
"msw",
"&",
"0xFFFF",
")",
"<<",
"16",
")",
"|",
"(",
"lsw",
"&",
"0xFFFF",
")",
";",
"return",
"new",
"Int_64",
"(",
"highOrder",
",",
"lowOrder",
")",
";",
"}"
] | 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 |
7,973 | 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 & 0xFFFF) << 16) | (lsw & 0xFFFF);
lsw = (a.highOrder & 0xFFFF) + (b.highOrder & 0xFFFF) +
(c.highOrder & 0xFFFF) + (d.highOrder & 0xFFFF) + (msw >>> 16);
msw = (a.highOrder >>> 16) + (b.highOrder >>> 16) +
(c.highOrder >>> 16) + (d.highOrder >>> 16) + (lsw >>> 16);
highOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
return new Int_64(highOrder, lowOrder);
} | 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 & 0xFFFF) << 16) | (lsw & 0xFFFF);
lsw = (a.highOrder & 0xFFFF) + (b.highOrder & 0xFFFF) +
(c.highOrder & 0xFFFF) + (d.highOrder & 0xFFFF) + (msw >>> 16);
msw = (a.highOrder >>> 16) + (b.highOrder >>> 16) +
(c.highOrder >>> 16) + (d.highOrder >>> 16) + (lsw >>> 16);
highOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
return new Int_64(highOrder, lowOrder);
} | [
"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",
"&",
"0xFFFF",
")",
"<<",
"16",
")",
"|",
"(",
"lsw",
"&",
"0xFFFF",
")",
";",
"lsw",
"=",
"(",
"a",
".",
"highOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"b",
".",
"highOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"c",
".",
"highOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"d",
".",
"highOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"msw",
">>>",
"16",
")",
";",
"msw",
"=",
"(",
"a",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"b",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"c",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"d",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"lsw",
">>>",
"16",
")",
";",
"highOrder",
"=",
"(",
"(",
"msw",
"&",
"0xFFFF",
")",
"<<",
"16",
")",
"|",
"(",
"lsw",
"&",
"0xFFFF",
")",
";",
"return",
"new",
"Int_64",
"(",
"highOrder",
",",
"lowOrder",
")",
";",
"}"
] | 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 to be added
@param {Int_64} d The fouth 64-bit integer argument to be added
@return {Int_64} The sum of a + b + c + d | [
"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 |
7,974 | 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.lowOrder >>> 16) +
(lsw >>> 16);
lowOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
lsw = (a.highOrder & 0xFFFF) + (b.highOrder & 0xFFFF) +
(c.highOrder & 0xFFFF) + (d.highOrder & 0xFFFF) +
(e.highOrder & 0xFFFF) + (msw >>> 16);
msw = (a.highOrder >>> 16) + (b.highOrder >>> 16) +
(c.highOrder >>> 16) + (d.highOrder >>> 16) +
(e.highOrder >>> 16) + (lsw >>> 16);
highOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
return new Int_64(highOrder, lowOrder);
} | 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.lowOrder >>> 16) +
(lsw >>> 16);
lowOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
lsw = (a.highOrder & 0xFFFF) + (b.highOrder & 0xFFFF) +
(c.highOrder & 0xFFFF) + (d.highOrder & 0xFFFF) +
(e.highOrder & 0xFFFF) + (msw >>> 16);
msw = (a.highOrder >>> 16) + (b.highOrder >>> 16) +
(c.highOrder >>> 16) + (d.highOrder >>> 16) +
(e.highOrder >>> 16) + (lsw >>> 16);
highOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
return new Int_64(highOrder, lowOrder);
} | [
"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",
".",
"lowOrder",
">>>",
"16",
")",
"+",
"(",
"lsw",
">>>",
"16",
")",
";",
"lowOrder",
"=",
"(",
"(",
"msw",
"&",
"0xFFFF",
")",
"<<",
"16",
")",
"|",
"(",
"lsw",
"&",
"0xFFFF",
")",
";",
"lsw",
"=",
"(",
"a",
".",
"highOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"b",
".",
"highOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"c",
".",
"highOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"d",
".",
"highOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"e",
".",
"highOrder",
"&",
"0xFFFF",
")",
"+",
"(",
"msw",
">>>",
"16",
")",
";",
"msw",
"=",
"(",
"a",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"b",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"c",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"d",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"e",
".",
"highOrder",
">>>",
"16",
")",
"+",
"(",
"lsw",
">>>",
"16",
")",
";",
"highOrder",
"=",
"(",
"(",
"msw",
"&",
"0xFFFF",
")",
"<<",
"16",
")",
"|",
"(",
"lsw",
"&",
"0xFFFF",
")",
";",
"return",
"new",
"Int_64",
"(",
"highOrder",
",",
"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 to be added
@param {Int_64} d The fouth 64-bit integer argument to be added
@param {Int_64} e The fouth 64-bit integer argument to be added
@return {Int_64} The sum of a + b + c + d + e | [
"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 |
7,975 | 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 |
7,976 | 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",
".",
"highOrder",
",",
"a",
".",
"lowOrder",
"^",
"b",
".",
"lowOrder",
"^",
"c",
".",
"lowOrder",
"^",
"d",
".",
"lowOrder",
"^",
"e",
".",
"lowOrder",
")",
";",
"}"
] | 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 |
7,977 | 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",
"]",
".",
"slice",
"(",
")",
";",
"}",
"return",
"clone",
";",
"}"
] | 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 |
7,978 | 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_trunc = [
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
];
H_full = [
0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19
];
switch (variant)
{
case "SHA-224":
retVal = H_trunc;
break;
case "SHA-256":
retVal = H_full;
break;
case "SHA-384":
retVal = [
new Int_64(0xcbbb9d5d, H_trunc[0]),
new Int_64(0x0629a292a, H_trunc[1]),
new Int_64(0x9159015a, H_trunc[2]),
new Int_64(0x0152fecd8, H_trunc[3]),
new Int_64(0x67332667, H_trunc[4]),
new Int_64(0x98eb44a87, H_trunc[5]),
new Int_64(0xdb0c2e0d, H_trunc[6]),
new Int_64(0x047b5481d, H_trunc[7])
];
break;
case "SHA-512":
retVal = [
new Int_64(H_full[0], 0xf3bcc908),
new Int_64(H_full[1], 0x84caa73b),
new Int_64(H_full[2], 0xfe94f82b),
new Int_64(H_full[3], 0x5f1d36f1),
new Int_64(H_full[4], 0xade682d1),
new Int_64(H_full[5], 0x2b3e6c1f),
new Int_64(H_full[6], 0xfb41bd6b),
new Int_64(H_full[7], 0x137e2179)
];
break;
default:
throw new Error("Unknown SHA variant");
}
}
else if (((variant.lastIndexOf("SHA3-", 0) === 0) || (variant.lastIndexOf("SHAKE", 0) === 0)) &&
((8 & SUPPORTED_ALGS) !== 0))
{
for (i = 0; i < 5; i += 1)
{
retVal[i] = [new Int_64(0, 0), new Int_64(0, 0), new Int_64(0, 0), new Int_64(0, 0), new Int_64(0, 0)];
}
}
else
{
throw new Error("No SHA variants supported");
}
return retVal;
} | 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_trunc = [
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
];
H_full = [
0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19
];
switch (variant)
{
case "SHA-224":
retVal = H_trunc;
break;
case "SHA-256":
retVal = H_full;
break;
case "SHA-384":
retVal = [
new Int_64(0xcbbb9d5d, H_trunc[0]),
new Int_64(0x0629a292a, H_trunc[1]),
new Int_64(0x9159015a, H_trunc[2]),
new Int_64(0x0152fecd8, H_trunc[3]),
new Int_64(0x67332667, H_trunc[4]),
new Int_64(0x98eb44a87, H_trunc[5]),
new Int_64(0xdb0c2e0d, H_trunc[6]),
new Int_64(0x047b5481d, H_trunc[7])
];
break;
case "SHA-512":
retVal = [
new Int_64(H_full[0], 0xf3bcc908),
new Int_64(H_full[1], 0x84caa73b),
new Int_64(H_full[2], 0xfe94f82b),
new Int_64(H_full[3], 0x5f1d36f1),
new Int_64(H_full[4], 0xade682d1),
new Int_64(H_full[5], 0x2b3e6c1f),
new Int_64(H_full[6], 0xfb41bd6b),
new Int_64(H_full[7], 0x137e2179)
];
break;
default:
throw new Error("Unknown SHA variant");
}
}
else if (((variant.lastIndexOf("SHA3-", 0) === 0) || (variant.lastIndexOf("SHAKE", 0) === 0)) &&
((8 & SUPPORTED_ALGS) !== 0))
{
for (i = 0; i < 5; i += 1)
{
retVal[i] = [new Int_64(0, 0), new Int_64(0, 0), new Int_64(0, 0), new Int_64(0, 0), new Int_64(0, 0)];
}
}
else
{
throw new Error("No SHA variants supported");
}
return retVal;
} | [
"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_trunc",
"=",
"[",
"0xc1059ed8",
",",
"0x367cd507",
",",
"0x3070dd17",
",",
"0xf70e5939",
",",
"0xffc00b31",
",",
"0x68581511",
",",
"0x64f98fa7",
",",
"0xbefa4fa4",
"]",
";",
"H_full",
"=",
"[",
"0x6A09E667",
",",
"0xBB67AE85",
",",
"0x3C6EF372",
",",
"0xA54FF53A",
",",
"0x510E527F",
",",
"0x9B05688C",
",",
"0x1F83D9AB",
",",
"0x5BE0CD19",
"]",
";",
"switch",
"(",
"variant",
")",
"{",
"case",
"\"SHA-224\"",
":",
"retVal",
"=",
"H_trunc",
";",
"break",
";",
"case",
"\"SHA-256\"",
":",
"retVal",
"=",
"H_full",
";",
"break",
";",
"case",
"\"SHA-384\"",
":",
"retVal",
"=",
"[",
"new",
"Int_64",
"(",
"0xcbbb9d5d",
",",
"H_trunc",
"[",
"0",
"]",
")",
",",
"new",
"Int_64",
"(",
"0x0629a292a",
",",
"H_trunc",
"[",
"1",
"]",
")",
",",
"new",
"Int_64",
"(",
"0x9159015a",
",",
"H_trunc",
"[",
"2",
"]",
")",
",",
"new",
"Int_64",
"(",
"0x0152fecd8",
",",
"H_trunc",
"[",
"3",
"]",
")",
",",
"new",
"Int_64",
"(",
"0x67332667",
",",
"H_trunc",
"[",
"4",
"]",
")",
",",
"new",
"Int_64",
"(",
"0x98eb44a87",
",",
"H_trunc",
"[",
"5",
"]",
")",
",",
"new",
"Int_64",
"(",
"0xdb0c2e0d",
",",
"H_trunc",
"[",
"6",
"]",
")",
",",
"new",
"Int_64",
"(",
"0x047b5481d",
",",
"H_trunc",
"[",
"7",
"]",
")",
"]",
";",
"break",
";",
"case",
"\"SHA-512\"",
":",
"retVal",
"=",
"[",
"new",
"Int_64",
"(",
"H_full",
"[",
"0",
"]",
",",
"0xf3bcc908",
")",
",",
"new",
"Int_64",
"(",
"H_full",
"[",
"1",
"]",
",",
"0x84caa73b",
")",
",",
"new",
"Int_64",
"(",
"H_full",
"[",
"2",
"]",
",",
"0xfe94f82b",
")",
",",
"new",
"Int_64",
"(",
"H_full",
"[",
"3",
"]",
",",
"0x5f1d36f1",
")",
",",
"new",
"Int_64",
"(",
"H_full",
"[",
"4",
"]",
",",
"0xade682d1",
")",
",",
"new",
"Int_64",
"(",
"H_full",
"[",
"5",
"]",
",",
"0x2b3e6c1f",
")",
",",
"new",
"Int_64",
"(",
"H_full",
"[",
"6",
"]",
",",
"0xfb41bd6b",
")",
",",
"new",
"Int_64",
"(",
"H_full",
"[",
"7",
"]",
",",
"0x137e2179",
")",
"]",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Error",
"(",
"\"Unknown SHA variant\"",
")",
";",
"}",
"}",
"else",
"if",
"(",
"(",
"(",
"variant",
".",
"lastIndexOf",
"(",
"\"SHA3-\"",
",",
"0",
")",
"===",
"0",
")",
"||",
"(",
"variant",
".",
"lastIndexOf",
"(",
"\"SHAKE\"",
",",
"0",
")",
"===",
"0",
")",
")",
"&&",
"(",
"(",
"8",
"&",
"SUPPORTED_ALGS",
")",
"!==",
"0",
")",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"5",
";",
"i",
"+=",
"1",
")",
"{",
"retVal",
"[",
"i",
"]",
"=",
"[",
"new",
"Int_64",
"(",
"0",
",",
"0",
")",
",",
"new",
"Int_64",
"(",
"0",
",",
"0",
")",
",",
"new",
"Int_64",
"(",
"0",
",",
"0",
")",
",",
"new",
"Int_64",
"(",
"0",
",",
"0",
")",
",",
"new",
"Int_64",
"(",
"0",
",",
"0",
")",
"]",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"No SHA variants supported\"",
")",
";",
"}",
"return",
"retVal",
";",
"}"
] | 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 |
7,979 | 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[t];
}
else
{
W[t] = rotl(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
}
if (t < 20)
{
T = safeAdd_5(rotl(a, 5), ch(b, c, d), e, 0x5a827999, W[t]);
}
else if (t < 40)
{
T = safeAdd_5(rotl(a, 5), parity(b, c, d), e, 0x6ed9eba1, W[t]);
}
else if (t < 60)
{
T = safeAdd_5(rotl(a, 5), maj(b, c, d), e, 0x8f1bbcdc, W[t]);
} else {
T = safeAdd_5(rotl(a, 5), parity(b, c, d), e, 0xca62c1d6, W[t]);
}
e = d;
d = c;
c = rotl(b, 30);
b = a;
a = T;
}
H[0] = safeAdd_2(a, H[0]);
H[1] = safeAdd_2(b, H[1]);
H[2] = safeAdd_2(c, H[2]);
H[3] = safeAdd_2(d, H[3]);
H[4] = safeAdd_2(e, H[4]);
return H;
} | 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[t];
}
else
{
W[t] = rotl(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
}
if (t < 20)
{
T = safeAdd_5(rotl(a, 5), ch(b, c, d), e, 0x5a827999, W[t]);
}
else if (t < 40)
{
T = safeAdd_5(rotl(a, 5), parity(b, c, d), e, 0x6ed9eba1, W[t]);
}
else if (t < 60)
{
T = safeAdd_5(rotl(a, 5), maj(b, c, d), e, 0x8f1bbcdc, W[t]);
} else {
T = safeAdd_5(rotl(a, 5), parity(b, c, d), e, 0xca62c1d6, W[t]);
}
e = d;
d = c;
c = rotl(b, 30);
b = a;
a = T;
}
H[0] = safeAdd_2(a, H[0]);
H[1] = safeAdd_2(b, H[1]);
H[2] = safeAdd_2(c, H[2]);
H[3] = safeAdd_2(d, H[3]);
H[4] = safeAdd_2(e, H[4]);
return H;
} | [
"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",
"[",
"t",
"]",
";",
"}",
"else",
"{",
"W",
"[",
"t",
"]",
"=",
"rotl",
"(",
"W",
"[",
"t",
"-",
"3",
"]",
"^",
"W",
"[",
"t",
"-",
"8",
"]",
"^",
"W",
"[",
"t",
"-",
"14",
"]",
"^",
"W",
"[",
"t",
"-",
"16",
"]",
",",
"1",
")",
";",
"}",
"if",
"(",
"t",
"<",
"20",
")",
"{",
"T",
"=",
"safeAdd_5",
"(",
"rotl",
"(",
"a",
",",
"5",
")",
",",
"ch",
"(",
"b",
",",
"c",
",",
"d",
")",
",",
"e",
",",
"0x5a827999",
",",
"W",
"[",
"t",
"]",
")",
";",
"}",
"else",
"if",
"(",
"t",
"<",
"40",
")",
"{",
"T",
"=",
"safeAdd_5",
"(",
"rotl",
"(",
"a",
",",
"5",
")",
",",
"parity",
"(",
"b",
",",
"c",
",",
"d",
")",
",",
"e",
",",
"0x6ed9eba1",
",",
"W",
"[",
"t",
"]",
")",
";",
"}",
"else",
"if",
"(",
"t",
"<",
"60",
")",
"{",
"T",
"=",
"safeAdd_5",
"(",
"rotl",
"(",
"a",
",",
"5",
")",
",",
"maj",
"(",
"b",
",",
"c",
",",
"d",
")",
",",
"e",
",",
"0x8f1bbcdc",
",",
"W",
"[",
"t",
"]",
")",
";",
"}",
"else",
"{",
"T",
"=",
"safeAdd_5",
"(",
"rotl",
"(",
"a",
",",
"5",
")",
",",
"parity",
"(",
"b",
",",
"c",
",",
"d",
")",
",",
"e",
",",
"0xca62c1d6",
",",
"W",
"[",
"t",
"]",
")",
";",
"}",
"e",
"=",
"d",
";",
"d",
"=",
"c",
";",
"c",
"=",
"rotl",
"(",
"b",
",",
"30",
")",
";",
"b",
"=",
"a",
";",
"a",
"=",
"T",
";",
"}",
"H",
"[",
"0",
"]",
"=",
"safeAdd_2",
"(",
"a",
",",
"H",
"[",
"0",
"]",
")",
";",
"H",
"[",
"1",
"]",
"=",
"safeAdd_2",
"(",
"b",
",",
"H",
"[",
"1",
"]",
")",
";",
"H",
"[",
"2",
"]",
"=",
"safeAdd_2",
"(",
"c",
",",
"H",
"[",
"2",
"]",
")",
";",
"H",
"[",
"3",
"]",
"=",
"safeAdd_2",
"(",
"d",
",",
"H",
"[",
"3",
"]",
")",
";",
"H",
"[",
"4",
"]",
"=",
"safeAdd_2",
"(",
"e",
",",
"H",
"[",
"4",
"]",
")",
";",
"return",
"H",
";",
"}"
] | 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 |
7,980 | 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 = 0,
"shorting" the addition is OK. */
offset = (((remainderBinLen + 65) >>> 9) << 4) + 15;
while (remainder.length <= offset)
{
remainder.push(0);
}
/* Append '1' at the end of the binary string */
remainder[remainderBinLen >>> 5] |= 0x80 << (24 - (remainderBinLen % 32));
/* Append length of binary string in the position such that the new
* length is a multiple of 512. Logic does not work for even multiples
* of 512 but there can never be even multiples of 512. JavaScript
* numbers are limited to 2^53 so it's "safe" to treat the totalLen as
* a 64-bit integer. */
totalLen = remainderBinLen + processedBinLen;
remainder[offset] = totalLen & 0xFFFFFFFF;
/* Bitwise operators treat the operand as a 32-bit number so need to
* use hacky division and round to get access to upper 32-ish bits */
remainder[offset - 1] = (totalLen / TWO_PWR_32) | 0;
appendedMessageLength = remainder.length;
/* This will always be at least 1 full chunk */
for (i = 0; i < appendedMessageLength; i += 16)
{
H = roundSHA1(remainder.slice(i, i + 16), H);
}
return H;
} | 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 = 0,
"shorting" the addition is OK. */
offset = (((remainderBinLen + 65) >>> 9) << 4) + 15;
while (remainder.length <= offset)
{
remainder.push(0);
}
/* Append '1' at the end of the binary string */
remainder[remainderBinLen >>> 5] |= 0x80 << (24 - (remainderBinLen % 32));
/* Append length of binary string in the position such that the new
* length is a multiple of 512. Logic does not work for even multiples
* of 512 but there can never be even multiples of 512. JavaScript
* numbers are limited to 2^53 so it's "safe" to treat the totalLen as
* a 64-bit integer. */
totalLen = remainderBinLen + processedBinLen;
remainder[offset] = totalLen & 0xFFFFFFFF;
/* Bitwise operators treat the operand as a 32-bit number so need to
* use hacky division and round to get access to upper 32-ish bits */
remainder[offset - 1] = (totalLen / TWO_PWR_32) | 0;
appendedMessageLength = remainder.length;
/* This will always be at least 1 full chunk */
for (i = 0; i < appendedMessageLength; i += 16)
{
H = roundSHA1(remainder.slice(i, i + 16), H);
}
return H;
} | [
"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\n\t\t actually 72 (64 + 8) but the below math fails if\n\t\t remainderBinLen + 72 % 512 = 0. Since remainderBinLen % 8 = 0,\n\t\t \"shorting\" the addition is OK. */",
"offset",
"=",
"(",
"(",
"(",
"remainderBinLen",
"+",
"65",
")",
">>>",
"9",
")",
"<<",
"4",
")",
"+",
"15",
";",
"while",
"(",
"remainder",
".",
"length",
"<=",
"offset",
")",
"{",
"remainder",
".",
"push",
"(",
"0",
")",
";",
"}",
"/* Append '1' at the end of the binary string */",
"remainder",
"[",
"remainderBinLen",
">>>",
"5",
"]",
"|=",
"0x80",
"<<",
"(",
"24",
"-",
"(",
"remainderBinLen",
"%",
"32",
")",
")",
";",
"/* Append length of binary string in the position such that the new\n\t\t * length is a multiple of 512. Logic does not work for even multiples\n\t\t * of 512 but there can never be even multiples of 512. JavaScript\n\t\t * numbers are limited to 2^53 so it's \"safe\" to treat the totalLen as\n\t\t * a 64-bit integer. */",
"totalLen",
"=",
"remainderBinLen",
"+",
"processedBinLen",
";",
"remainder",
"[",
"offset",
"]",
"=",
"totalLen",
"&",
"0xFFFFFFFF",
";",
"/* Bitwise operators treat the operand as a 32-bit number so need to\n\t\t * use hacky division and round to get access to upper 32-ish bits */",
"remainder",
"[",
"offset",
"-",
"1",
"]",
"=",
"(",
"totalLen",
"/",
"TWO_PWR_32",
")",
"|",
"0",
";",
"appendedMessageLength",
"=",
"remainder",
".",
"length",
";",
"/* This will always be at least 1 full chunk */",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"appendedMessageLength",
";",
"i",
"+=",
"16",
")",
"{",
"H",
"=",
"roundSHA1",
"(",
"remainder",
".",
"slice",
"(",
"i",
",",
"i",
"+",
"16",
")",
",",
"H",
")",
";",
"}",
"return",
"H",
";",
"}"
] | 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 from a previous
round
@param {number} outputLen Unused for this variant
@return {Array<number>} The array of integers representing the SHA-1
hash of message | [
"Finalizes",
"the",
"SHA",
"-",
"1",
"hash"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1343-L1378 |
7,981 | 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
with SHAKE
*/
for (i = 0; i < remainderIntLen && remainderBinLen >= blockSize; i += binaryStringInc)
{
state = roundSHA3(remainder.slice(i, i + binaryStringInc), state);
remainderBinLen -= blockSize;
}
remainder = remainder.slice(i);
remainderBinLen = remainderBinLen % blockSize;
/* Pad out the remainder to a full block */
while (remainder.length < binaryStringInc)
{
remainder.push(0);
}
/* Find the next "empty" byte for the 0x80 and append it via an xor */
i = remainderBinLen >>> 3;
remainder[i >> 2] ^= delimiter << (8 * (i % 4));
remainder[binaryStringInc - 1] ^= 0x80000000;
state = roundSHA3(remainder, state);
while (retVal.length * 32 < outputLen)
{
temp = state[state_offset % 5][(state_offset / 5) | 0];
retVal.push(temp.lowOrder);
if (retVal.length * 32 >= outputLen)
{
break;
}
retVal.push(temp.highOrder);
state_offset += 1;
if (0 === ((state_offset * 64) % blockSize))
{
roundSHA3(null, state);
}
}
return retVal;
} | 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
with SHAKE
*/
for (i = 0; i < remainderIntLen && remainderBinLen >= blockSize; i += binaryStringInc)
{
state = roundSHA3(remainder.slice(i, i + binaryStringInc), state);
remainderBinLen -= blockSize;
}
remainder = remainder.slice(i);
remainderBinLen = remainderBinLen % blockSize;
/* Pad out the remainder to a full block */
while (remainder.length < binaryStringInc)
{
remainder.push(0);
}
/* Find the next "empty" byte for the 0x80 and append it via an xor */
i = remainderBinLen >>> 3;
remainder[i >> 2] ^= delimiter << (8 * (i % 4));
remainder[binaryStringInc - 1] ^= 0x80000000;
state = roundSHA3(remainder, state);
while (retVal.length * 32 < outputLen)
{
temp = state[state_offset % 5][(state_offset / 5) | 0];
retVal.push(temp.lowOrder);
if (retVal.length * 32 >= outputLen)
{
break;
}
retVal.push(temp.highOrder);
state_offset += 1;
if (0 === ((state_offset * 64) % blockSize))
{
roundSHA3(null, state);
}
}
return retVal;
} | [
"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\n\t\t with SHAKE\n\t\t*/",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"remainderIntLen",
"&&",
"remainderBinLen",
">=",
"blockSize",
";",
"i",
"+=",
"binaryStringInc",
")",
"{",
"state",
"=",
"roundSHA3",
"(",
"remainder",
".",
"slice",
"(",
"i",
",",
"i",
"+",
"binaryStringInc",
")",
",",
"state",
")",
";",
"remainderBinLen",
"-=",
"blockSize",
";",
"}",
"remainder",
"=",
"remainder",
".",
"slice",
"(",
"i",
")",
";",
"remainderBinLen",
"=",
"remainderBinLen",
"%",
"blockSize",
";",
"/* Pad out the remainder to a full block */",
"while",
"(",
"remainder",
".",
"length",
"<",
"binaryStringInc",
")",
"{",
"remainder",
".",
"push",
"(",
"0",
")",
";",
"}",
"/* Find the next \"empty\" byte for the 0x80 and append it via an xor */",
"i",
"=",
"remainderBinLen",
">>>",
"3",
";",
"remainder",
"[",
"i",
">>",
"2",
"]",
"^=",
"delimiter",
"<<",
"(",
"8",
"*",
"(",
"i",
"%",
"4",
")",
")",
";",
"remainder",
"[",
"binaryStringInc",
"-",
"1",
"]",
"^=",
"0x80000000",
";",
"state",
"=",
"roundSHA3",
"(",
"remainder",
",",
"state",
")",
";",
"while",
"(",
"retVal",
".",
"length",
"*",
"32",
"<",
"outputLen",
")",
"{",
"temp",
"=",
"state",
"[",
"state_offset",
"%",
"5",
"]",
"[",
"(",
"state_offset",
"/",
"5",
")",
"|",
"0",
"]",
";",
"retVal",
".",
"push",
"(",
"temp",
".",
"lowOrder",
")",
";",
"if",
"(",
"retVal",
".",
"length",
"*",
"32",
">=",
"outputLen",
")",
"{",
"break",
";",
"}",
"retVal",
".",
"push",
"(",
"temp",
".",
"highOrder",
")",
";",
"state_offset",
"+=",
"1",
";",
"if",
"(",
"0",
"===",
"(",
"(",
"state_offset",
"*",
"64",
")",
"%",
"blockSize",
")",
")",
"{",
"roundSHA3",
"(",
"null",
",",
"state",
")",
";",
"}",
"}",
"return",
"retVal",
";",
"}"
] | 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 a previous round
@param {number} blockSize The block size/rate of the variant in bits
@param {number} delimiter The delimiter value for the variant
@param {number} outputLen The output length for the variant in bits
@return {Array<number>} The array of integers representing the SHA-3
hash of message | [
"Finalizes",
"the",
"SHA",
"-",
"3",
"hash"
] | 766f8ff7d926347b008a252a41b06565df747ac5 | https://github.com/Caligatio/jsSHA/blob/766f8ff7d926347b008a252a41b06565df747ac5/src/sha_dev.js#L1799-L1848 |
7,982 | 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, newDescriptor)
}
} | 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, newDescriptor)
}
} | [
"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",
",",
"newDescriptor",
")",
"}",
"}"
] | 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 |
7,983 | 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 |
7,984 | 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 = node.children.map((c) => mapping[c.id]);
});
if (this.id === undefined) {
const root = new Node(undefined, undefined);
root.children = this.children.map((c) => mapping[c.id]);
} else {
return mapping[this.id];
}
} | 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 = node.children.map((c) => mapping[c.id]);
});
if (this.id === undefined) {
const root = new Node(undefined, undefined);
root.children = this.children.map((c) => mapping[c.id]);
} else {
return mapping[this.id];
}
} | [
"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",
"=",
"node",
".",
"children",
".",
"map",
"(",
"(",
"c",
")",
"=>",
"mapping",
"[",
"c",
".",
"id",
"]",
")",
";",
"}",
")",
";",
"if",
"(",
"this",
".",
"id",
"===",
"undefined",
")",
"{",
"const",
"root",
"=",
"new",
"Node",
"(",
"undefined",
",",
"undefined",
")",
";",
"root",
".",
"children",
"=",
"this",
".",
"children",
".",
"map",
"(",
"(",
"c",
")",
"=>",
"mapping",
"[",
"c",
".",
"id",
"]",
")",
";",
"}",
"else",
"{",
"return",
"mapping",
"[",
"this",
".",
"id",
"]",
";",
"}",
"}"
] | 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 |
7,985 | 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-XLM')
.then(data => {
return parseFloat(JSON.parse(data).result.Last);
})
.catch(() => {
return null;
})
,
rp('https://api.kraken.com/0/public/Ticker?pair=XLMXBT')
.then(data => {
return parseFloat(JSON.parse(data).result.XXLMXXBT.c[0]);
})
.catch(() => {
return null;
})
])
.then(allPrices => {
return _.round(_.mean(_.filter(allPrices, price => price !== null)), 8);
})
} | 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-XLM')
.then(data => {
return parseFloat(JSON.parse(data).result.Last);
})
.catch(() => {
return null;
})
,
rp('https://api.kraken.com/0/public/Ticker?pair=XLMXBT')
.then(data => {
return parseFloat(JSON.parse(data).result.XXLMXXBT.c[0]);
})
.catch(() => {
return null;
})
])
.then(allPrices => {
return _.round(_.mean(_.filter(allPrices, price => price !== null)), 8);
})
} | [
"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-XLM'",
")",
".",
"then",
"(",
"data",
"=>",
"{",
"return",
"parseFloat",
"(",
"JSON",
".",
"parse",
"(",
"data",
")",
".",
"result",
".",
"Last",
")",
";",
"}",
")",
".",
"catch",
"(",
"(",
")",
"=>",
"{",
"return",
"null",
";",
"}",
")",
",",
"rp",
"(",
"'https://api.kraken.com/0/public/Ticker?pair=XLMXBT'",
")",
".",
"then",
"(",
"data",
"=>",
"{",
"return",
"parseFloat",
"(",
"JSON",
".",
"parse",
"(",
"data",
")",
".",
"result",
".",
"XXLMXXBT",
".",
"c",
"[",
"0",
"]",
")",
";",
"}",
")",
".",
"catch",
"(",
"(",
")",
"=>",
"{",
"return",
"null",
";",
"}",
")",
"]",
")",
".",
"then",
"(",
"allPrices",
"=>",
"{",
"return",
"_",
".",
"round",
"(",
"_",
".",
"mean",
"(",
"_",
".",
"filter",
"(",
"allPrices",
",",
"price",
"=>",
"price",
"!==",
"null",
")",
")",
",",
"8",
")",
";",
"}",
")",
"}"
] | 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 |
7,986 | 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) {
var EOL = require('os').EOL;
if (optIn) {
console.log(EOL + 'Thanks for opting into telemetry to help us improve cordova.');
module.exports.track('telemetry', 'on', 'via-cli-prompt-choice', 'successful');
} else {
console.log(EOL + 'You have been opted out of telemetry. To change this, run: cordova telemetry on.');
// Always track telemetry opt-outs! (whether opted-in or opted-out)
module.exports.track('telemetry', 'off', 'via-cli-prompt-choice', 'successful');
}
resolve(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) {
var EOL = require('os').EOL;
if (optIn) {
console.log(EOL + 'Thanks for opting into telemetry to help us improve cordova.');
module.exports.track('telemetry', 'on', 'via-cli-prompt-choice', 'successful');
} else {
console.log(EOL + 'You have been opted out of telemetry. To change this, run: cordova telemetry on.');
// Always track telemetry opt-outs! (whether opted-in or opted-out)
module.exports.track('telemetry', 'off', 'via-cli-prompt-choice', 'successful');
}
resolve(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",
"=",
"module",
".",
"exports",
".",
"timeoutInSecs",
"||",
"30",
";",
"insight",
".",
"askPermission",
"(",
"msg",
",",
"function",
"(",
"unused",
",",
"optIn",
")",
"{",
"var",
"EOL",
"=",
"require",
"(",
"'os'",
")",
".",
"EOL",
";",
"if",
"(",
"optIn",
")",
"{",
"console",
".",
"log",
"(",
"EOL",
"+",
"'Thanks for opting into telemetry to help us improve cordova.'",
")",
";",
"module",
".",
"exports",
".",
"track",
"(",
"'telemetry'",
",",
"'on'",
",",
"'via-cli-prompt-choice'",
",",
"'successful'",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"EOL",
"+",
"'You have been opted out of telemetry. To change this, run: cordova telemetry on.'",
")",
";",
"// Always track telemetry opt-outs! (whether opted-in or opted-out)",
"module",
".",
"exports",
".",
"track",
"(",
"'telemetry'",
",",
"'off'",
",",
"'via-cli-prompt-choice'",
",",
"'successful'",
")",
";",
"}",
"resolve",
"(",
"optIn",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | 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 |
7,987 | 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 slot overlaps with b's end slot.",
"(",
"b",
".",
"start",
">",
"a",
".",
"start",
"&&",
"b",
".",
"start",
"<",
"a",
".",
"end",
")",
")",
"}"
] | 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 |
7,988 | 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 => <WrappedComponent theme={theme} {...this.props} />}
</ThemeConsumer>
)
}
}
} | javascript | function withTheme(WrappedComponent) {
const displayName =
WrappedComponent.displayName || WrappedComponent.name || 'Component'
return class extends React.Component {
static displayName = `withTheme(${displayName})`
render() {
return (
<ThemeConsumer>
{theme => <WrappedComponent theme={theme} {...this.props} />}
</ThemeConsumer>
)
}
}
} | [
"function",
"withTheme",
"(",
"WrappedComponent",
")",
"{",
"const",
"displayName",
"=",
"WrappedComponent",
".",
"displayName",
"||",
"WrappedComponent",
".",
"name",
"||",
"'Component'",
"return",
"class",
"extends",
"React",
".",
"Component",
"{",
"static",
"displayName",
"=",
"`",
"${",
"displayName",
"}",
"`",
"render",
"(",
")",
"{",
"return",
"(",
"<",
"ThemeConsumer",
">",
"\n ",
"{",
"theme",
"=>",
"<",
"WrappedComponent",
"theme",
"=",
"{",
"theme",
"}",
"{",
"...",
"this",
".",
"props",
"}",
"/",
">",
"}",
"\n ",
"<",
"/",
"ThemeConsumer",
">",
")",
"}",
"}",
"}"
] | 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 |
7,989 | 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",
"===",
"0x22",
"||",
"a",
"===",
"0x27",
")",
"?",
"str",
".",
"slice",
"(",
"1",
",",
"-",
"1",
")",
":",
"str",
"}"
] | 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 |
7,990 | 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: // -
return 'ident'
case 0x09: // Tab
case 0x0A: // Newline
case 0x0D: // Return
case 0xA0: // No-break space
case 0xFEFF: // Byte Order Mark
case 0x2028: // Line Separator
case 0x2029: // Paragraph Separator
return 'ws'
}
return 'ident'
} | 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: // -
return 'ident'
case 0x09: // Tab
case 0x0A: // Newline
case 0x0D: // Return
case 0xA0: // No-break space
case 0xFEFF: // Byte Order Mark
case 0x2028: // Line Separator
case 0x2029: // Paragraph Separator
return 'ws'
}
return 'ident'
} | [
"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",
":",
"// -",
"return",
"'ident'",
"case",
"0x09",
":",
"// Tab",
"case",
"0x0A",
":",
"// Newline",
"case",
"0x0D",
":",
"// Return",
"case",
"0xA0",
":",
"// No-break space",
"case",
"0xFEFF",
":",
"// Byte Order Mark",
"case",
"0x2028",
":",
"// Line Separator",
"case",
"0x2029",
":",
"// Paragraph Separator",
"return",
"'ws'",
"}",
"return",
"'ident'",
"}"
] | 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 |
7,991 | 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);
key = undefined;
}
};
actions[APPEND] = function () {
if (key === undefined) {
key = newChar;
} else {
key += newChar;
}
};
actions[INC_SUB_PATH_DEPTH] = function () {
actions[APPEND]();
subPathDepth++;
};
actions[PUSH_SUB_PATH] = function () {
if (subPathDepth > 0) {
subPathDepth--;
mode = IN_SUB_PATH;
actions[APPEND]();
} else {
subPathDepth = 0;
key = formatSubPath(key);
if (key === false) {
return false
} else {
actions[PUSH]();
}
}
};
function maybeUnescapeQuote () {
const nextChar = path[index + 1];
if ((mode === IN_SINGLE_QUOTE && nextChar === "'") ||
(mode === IN_DOUBLE_QUOTE && nextChar === '"')) {
index++;
newChar = '\\' + nextChar;
actions[APPEND]();
return true
}
}
while (mode !== null) {
index++;
c = path[index];
if (c === '\\' && maybeUnescapeQuote()) {
continue
}
type = getPathCharType(c);
typeMap = pathStateMachine[mode];
transition = typeMap[type] || typeMap['else'] || ERROR;
if (transition === ERROR) {
return // parse error
}
mode = transition[0];
action = actions[transition[1]];
if (action) {
newChar = transition[2];
newChar = newChar === undefined
? c
: newChar;
if (action() === false) {
return
}
}
if (mode === AFTER_PATH) {
return keys
}
}
} | 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);
key = undefined;
}
};
actions[APPEND] = function () {
if (key === undefined) {
key = newChar;
} else {
key += newChar;
}
};
actions[INC_SUB_PATH_DEPTH] = function () {
actions[APPEND]();
subPathDepth++;
};
actions[PUSH_SUB_PATH] = function () {
if (subPathDepth > 0) {
subPathDepth--;
mode = IN_SUB_PATH;
actions[APPEND]();
} else {
subPathDepth = 0;
key = formatSubPath(key);
if (key === false) {
return false
} else {
actions[PUSH]();
}
}
};
function maybeUnescapeQuote () {
const nextChar = path[index + 1];
if ((mode === IN_SINGLE_QUOTE && nextChar === "'") ||
(mode === IN_DOUBLE_QUOTE && nextChar === '"')) {
index++;
newChar = '\\' + nextChar;
actions[APPEND]();
return true
}
}
while (mode !== null) {
index++;
c = path[index];
if (c === '\\' && maybeUnescapeQuote()) {
continue
}
type = getPathCharType(c);
typeMap = pathStateMachine[mode];
transition = typeMap[type] || typeMap['else'] || ERROR;
if (transition === ERROR) {
return // parse error
}
mode = transition[0];
action = actions[transition[1]];
if (action) {
newChar = transition[2];
newChar = newChar === undefined
? c
: newChar;
if (action() === false) {
return
}
}
if (mode === AFTER_PATH) {
return keys
}
}
} | [
"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",
")",
";",
"key",
"=",
"undefined",
";",
"}",
"}",
";",
"actions",
"[",
"APPEND",
"]",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"key",
"===",
"undefined",
")",
"{",
"key",
"=",
"newChar",
";",
"}",
"else",
"{",
"key",
"+=",
"newChar",
";",
"}",
"}",
";",
"actions",
"[",
"INC_SUB_PATH_DEPTH",
"]",
"=",
"function",
"(",
")",
"{",
"actions",
"[",
"APPEND",
"]",
"(",
")",
";",
"subPathDepth",
"++",
";",
"}",
";",
"actions",
"[",
"PUSH_SUB_PATH",
"]",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"subPathDepth",
">",
"0",
")",
"{",
"subPathDepth",
"--",
";",
"mode",
"=",
"IN_SUB_PATH",
";",
"actions",
"[",
"APPEND",
"]",
"(",
")",
";",
"}",
"else",
"{",
"subPathDepth",
"=",
"0",
";",
"key",
"=",
"formatSubPath",
"(",
"key",
")",
";",
"if",
"(",
"key",
"===",
"false",
")",
"{",
"return",
"false",
"}",
"else",
"{",
"actions",
"[",
"PUSH",
"]",
"(",
")",
";",
"}",
"}",
"}",
";",
"function",
"maybeUnescapeQuote",
"(",
")",
"{",
"const",
"nextChar",
"=",
"path",
"[",
"index",
"+",
"1",
"]",
";",
"if",
"(",
"(",
"mode",
"===",
"IN_SINGLE_QUOTE",
"&&",
"nextChar",
"===",
"\"'\"",
")",
"||",
"(",
"mode",
"===",
"IN_DOUBLE_QUOTE",
"&&",
"nextChar",
"===",
"'\"'",
")",
")",
"{",
"index",
"++",
";",
"newChar",
"=",
"'\\\\'",
"+",
"nextChar",
";",
"actions",
"[",
"APPEND",
"]",
"(",
")",
";",
"return",
"true",
"}",
"}",
"while",
"(",
"mode",
"!==",
"null",
")",
"{",
"index",
"++",
";",
"c",
"=",
"path",
"[",
"index",
"]",
";",
"if",
"(",
"c",
"===",
"'\\\\'",
"&&",
"maybeUnescapeQuote",
"(",
")",
")",
"{",
"continue",
"}",
"type",
"=",
"getPathCharType",
"(",
"c",
")",
";",
"typeMap",
"=",
"pathStateMachine",
"[",
"mode",
"]",
";",
"transition",
"=",
"typeMap",
"[",
"type",
"]",
"||",
"typeMap",
"[",
"'else'",
"]",
"||",
"ERROR",
";",
"if",
"(",
"transition",
"===",
"ERROR",
")",
"{",
"return",
"// parse error",
"}",
"mode",
"=",
"transition",
"[",
"0",
"]",
";",
"action",
"=",
"actions",
"[",
"transition",
"[",
"1",
"]",
"]",
";",
"if",
"(",
"action",
")",
"{",
"newChar",
"=",
"transition",
"[",
"2",
"]",
";",
"newChar",
"=",
"newChar",
"===",
"undefined",
"?",
"c",
":",
"newChar",
";",
"if",
"(",
"action",
"(",
")",
"===",
"false",
")",
"{",
"return",
"}",
"}",
"if",
"(",
"mode",
"===",
"AFTER_PATH",
")",
"{",
"return",
"keys",
"}",
"}",
"}"
] | 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 |
7,992 | 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 = nodeSize[0];
wt.y_size = nodeSize[1];
}
else { // use nodeSize function
var ns = nodeSize(t);
wt.x_size = ns[0];
wt.y_size = ns[1];
}
if (setNodeSizes) {
t.x_size = wt.x_size;
t.y_size = wt.y_size;
}
var children = [];
var num_children = t.children ? t.children.length : 0;
for (var i = 0; i < num_children; ++i) {
children.push(wrapTree(t.children[i]));
}
wt.children = children;
wt.num_children = num_children;
return wt;
} | 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 = nodeSize[0];
wt.y_size = nodeSize[1];
}
else { // use nodeSize function
var ns = nodeSize(t);
wt.x_size = ns[0];
wt.y_size = ns[1];
}
if (setNodeSizes) {
t.x_size = wt.x_size;
t.y_size = wt.y_size;
}
var children = [];
var num_children = t.children ? t.children.length : 0;
for (var i = 0; i < num_children; ++i) {
children.push(wrapTree(t.children[i]));
}
wt.children = children;
wt.num_children = num_children;
return wt;
} | [
"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",
"=",
"nodeSize",
"[",
"0",
"]",
";",
"wt",
".",
"y_size",
"=",
"nodeSize",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"// use nodeSize function",
"var",
"ns",
"=",
"nodeSize",
"(",
"t",
")",
";",
"wt",
".",
"x_size",
"=",
"ns",
"[",
"0",
"]",
";",
"wt",
".",
"y_size",
"=",
"ns",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"setNodeSizes",
")",
"{",
"t",
".",
"x_size",
"=",
"wt",
".",
"x_size",
";",
"t",
".",
"y_size",
"=",
"wt",
".",
"y_size",
";",
"}",
"var",
"children",
"=",
"[",
"]",
";",
"var",
"num_children",
"=",
"t",
".",
"children",
"?",
"t",
".",
"children",
".",
"length",
":",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"num_children",
";",
"++",
"i",
")",
"{",
"children",
".",
"push",
"(",
"wrapTree",
"(",
"t",
".",
"children",
"[",
"i",
"]",
")",
")",
";",
"}",
"wt",
".",
"children",
"=",
"children",
";",
"wt",
".",
"num_children",
"=",
"num_children",
";",
"return",
"wt",
";",
"}"
] | 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 |
7,993 | 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 |
7,994 | 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",
".",
"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",
";",
"}"
] | Symmetrical to setLeftThread. | [
"Symmetrical",
"to",
"setLeftThread",
"."
] | c09614be60676725ccbc1cfd161f07aa7269e5c9 | https://github.com/dundalek/markmap/blob/c09614be60676725ccbc1cfd161f07aa7269e5c9/lib/d3-flextree.js#L250-L258 |
7,995 | 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 - 1].x_size/2) / 2;
} | 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 - 1].x_size/2) / 2;
} | [
"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",
"-",
"1",
"]",
".",
"x_size",
"/",
"2",
")",
"/",
"2",
";",
"}"
] | 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 |
7,996 | 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;
wt.children[i].mod += modsumdelta;
}
} | 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;
wt.children[i].mod += modsumdelta;
}
} | [
"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",
";",
"wt",
".",
"children",
"[",
"i",
"]",
".",
"mod",
"+=",
"modsumdelta",
";",
"}",
"}"
] | 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 |
7,997 | 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;
while (node = toVisit.pop()) {
var t = node.t;
if (t.x < left.t.x) left = node;
if (t.x > right.t.x) right = node;
if (t.depth > bottom.t.depth) bottom = node;
if (node.children)
toVisit = toVisit.concat(node.children);
}
var sep = separation == null ? 0.5 : separation(left.t, right.t)/2;
var tx = sep - left.t.x;
var kx = size[0] / (right.t.x + sep + tx);
var ky = size[1] / (bottom.t.depth > 0 ? bottom.t.depth : 1);
toVisit = [wt];
while (node = toVisit.pop()) {
var t = node.t;
t.x = (t.x + tx) * kx;
t.y = t.depth * ky;
if (setNodeSizes) {
t.x_size *= kx;
t.y_size *= ky;
}
if (node.children)
toVisit = toVisit.concat(node.children);
}
}
// Else either a fixed node size, or node size function was specified.
// In this case, we translate such that the root node is at x = 0.
else {
var rootX = wt.t.x;
moveRight(wt, -rootX);
}
} | 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;
while (node = toVisit.pop()) {
var t = node.t;
if (t.x < left.t.x) left = node;
if (t.x > right.t.x) right = node;
if (t.depth > bottom.t.depth) bottom = node;
if (node.children)
toVisit = toVisit.concat(node.children);
}
var sep = separation == null ? 0.5 : separation(left.t, right.t)/2;
var tx = sep - left.t.x;
var kx = size[0] / (right.t.x + sep + tx);
var ky = size[1] / (bottom.t.depth > 0 ? bottom.t.depth : 1);
toVisit = [wt];
while (node = toVisit.pop()) {
var t = node.t;
t.x = (t.x + tx) * kx;
t.y = t.depth * ky;
if (setNodeSizes) {
t.x_size *= kx;
t.y_size *= ky;
}
if (node.children)
toVisit = toVisit.concat(node.children);
}
}
// Else either a fixed node size, or node size function was specified.
// In this case, we translate such that the root node is at x = 0.
else {
var rootX = wt.t.x;
moveRight(wt, -rootX);
}
} | [
"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",
";",
"while",
"(",
"node",
"=",
"toVisit",
".",
"pop",
"(",
")",
")",
"{",
"var",
"t",
"=",
"node",
".",
"t",
";",
"if",
"(",
"t",
".",
"x",
"<",
"left",
".",
"t",
".",
"x",
")",
"left",
"=",
"node",
";",
"if",
"(",
"t",
".",
"x",
">",
"right",
".",
"t",
".",
"x",
")",
"right",
"=",
"node",
";",
"if",
"(",
"t",
".",
"depth",
">",
"bottom",
".",
"t",
".",
"depth",
")",
"bottom",
"=",
"node",
";",
"if",
"(",
"node",
".",
"children",
")",
"toVisit",
"=",
"toVisit",
".",
"concat",
"(",
"node",
".",
"children",
")",
";",
"}",
"var",
"sep",
"=",
"separation",
"==",
"null",
"?",
"0.5",
":",
"separation",
"(",
"left",
".",
"t",
",",
"right",
".",
"t",
")",
"/",
"2",
";",
"var",
"tx",
"=",
"sep",
"-",
"left",
".",
"t",
".",
"x",
";",
"var",
"kx",
"=",
"size",
"[",
"0",
"]",
"/",
"(",
"right",
".",
"t",
".",
"x",
"+",
"sep",
"+",
"tx",
")",
";",
"var",
"ky",
"=",
"size",
"[",
"1",
"]",
"/",
"(",
"bottom",
".",
"t",
".",
"depth",
">",
"0",
"?",
"bottom",
".",
"t",
".",
"depth",
":",
"1",
")",
";",
"toVisit",
"=",
"[",
"wt",
"]",
";",
"while",
"(",
"node",
"=",
"toVisit",
".",
"pop",
"(",
")",
")",
"{",
"var",
"t",
"=",
"node",
".",
"t",
";",
"t",
".",
"x",
"=",
"(",
"t",
".",
"x",
"+",
"tx",
")",
"*",
"kx",
";",
"t",
".",
"y",
"=",
"t",
".",
"depth",
"*",
"ky",
";",
"if",
"(",
"setNodeSizes",
")",
"{",
"t",
".",
"x_size",
"*=",
"kx",
";",
"t",
".",
"y_size",
"*=",
"ky",
";",
"}",
"if",
"(",
"node",
".",
"children",
")",
"toVisit",
"=",
"toVisit",
".",
"concat",
"(",
"node",
".",
"children",
")",
";",
"}",
"}",
"// Else either a fixed node size, or node size function was specified.",
"// In this case, we translate such that the root node is at x = 0.",
"else",
"{",
"var",
"rootX",
"=",
"wt",
".",
"t",
".",
"x",
";",
"moveRight",
"(",
"wt",
",",
"-",
"rootX",
")",
";",
"}",
"}"
] | Renormalize the coordinates | [
"Renormalize",
"the",
"coordinates"
] | c09614be60676725ccbc1cfd161f07aa7269e5c9 | https://github.com/dundalek/markmap/blob/c09614be60676725ccbc1cfd161f07aa7269e5c9/lib/d3-flextree.js#L313-L357 |
7,998 | 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.initial
delete query.type
delete query.content_type
}
return http.get('sync', createRequestConfig({query: query}))
.then((response) => {
const data = response.data
items = items.concat(data.items)
if (data.nextPageUrl) {
if (paginate) {
delete query.initial
query.sync_token = getToken(data.nextPageUrl)
return getSyncPage(http, items, query, { paginate })
}
return {
items: items,
nextPageToken: getToken(data.nextPageUrl)
}
} else if (data.nextSyncUrl) {
return {
items: items,
nextSyncToken: getToken(data.nextSyncUrl)
}
}
})
} | 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.initial
delete query.type
delete query.content_type
}
return http.get('sync', createRequestConfig({query: query}))
.then((response) => {
const data = response.data
items = items.concat(data.items)
if (data.nextPageUrl) {
if (paginate) {
delete query.initial
query.sync_token = getToken(data.nextPageUrl)
return getSyncPage(http, items, query, { paginate })
}
return {
items: items,
nextPageToken: getToken(data.nextPageUrl)
}
} else if (data.nextSyncUrl) {
return {
items: items,
nextSyncToken: getToken(data.nextSyncUrl)
}
}
})
} | [
"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",
".",
"initial",
"delete",
"query",
".",
"type",
"delete",
"query",
".",
"content_type",
"}",
"return",
"http",
".",
"get",
"(",
"'sync'",
",",
"createRequestConfig",
"(",
"{",
"query",
":",
"query",
"}",
")",
")",
".",
"then",
"(",
"(",
"response",
")",
"=>",
"{",
"const",
"data",
"=",
"response",
".",
"data",
"items",
"=",
"items",
".",
"concat",
"(",
"data",
".",
"items",
")",
"if",
"(",
"data",
".",
"nextPageUrl",
")",
"{",
"if",
"(",
"paginate",
")",
"{",
"delete",
"query",
".",
"initial",
"query",
".",
"sync_token",
"=",
"getToken",
"(",
"data",
".",
"nextPageUrl",
")",
"return",
"getSyncPage",
"(",
"http",
",",
"items",
",",
"query",
",",
"{",
"paginate",
"}",
")",
"}",
"return",
"{",
"items",
":",
"items",
",",
"nextPageToken",
":",
"getToken",
"(",
"data",
".",
"nextPageUrl",
")",
"}",
"}",
"else",
"if",
"(",
"data",
".",
"nextSyncUrl",
")",
"{",
"return",
"{",
"items",
":",
"items",
",",
"nextSyncToken",
":",
"getToken",
"(",
"data",
".",
"nextSyncUrl",
")",
"}",
"}",
"}",
")",
"}"
] | 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 returned in the end
@private
@param {Object} http
@param {Array<Entities.Entry|Entities.Array|Sync.DeletedEntry|Sync.DeletedAsset>} items
@param {Object} query
@param {Object} options - Sync page options object
@param {boolean} [options.paginate = true] - If further sync pages should automatically be crawled
@return {Promise<{items: Array, nextSyncToken: string}>} | [
"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",
"returned",
"in",
"the",
"end"
] | 0a3cd39b0b39b554129ec699024bfd09558c29a9 | https://github.com/contentful/contentful.js/blob/0a3cd39b0b39b554129ec699024bfd09558c29a9/lib/paged-sync.js#L128-L166 |
7,999 | 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",
":",
"'nearest'",
",",
"scrollMode",
":",
"'if-needed'",
",",
"}",
")",
"actions",
".",
"forEach",
"(",
"(",
"{",
"el",
",",
"top",
",",
"left",
"}",
")",
"=>",
"{",
"el",
".",
"scrollTop",
"=",
"top",
"el",
".",
"scrollLeft",
"=",
"left",
"}",
")",
"}"
] | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.