_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q22900 | runStep | train | function runStep(step)
{
switch (step) {
case 1 :
trace("-- Beginning benchmark --");
initializeDB();
initializeUnique();
setTimeout(function() { runStep(2); }, 100);
break;
case 2 :
benchGet();
setTimeout(function() { runStep(3); }, 100);
break;
case 3 :... | javascript | {
"resource": ""
} |
q22901 | databaseInitialize | train | function databaseInitialize() {
// on the first load of (non-existent database), we will have no collections so we can
// detect the absence of our collections and add (and configure) them now.
var entries = db.getCollection("entries");
if (entries === null) {
entries = db.addCollection("entries");
}
... | javascript | {
"resource": ""
} |
q22902 | runProgramLogic | train | function runProgramLogic() {
var entries = db.getCollection("entries");
var entryCount = entries.count();
var now = new Date();
console.log("old number of entries in database : " + entryCount);
entries.insert({ x: now.getTime(), y: 100 - entryCount });
entryCount = entries.count();
console.log("new num... | javascript | {
"resource": ""
} |
q22903 | databaseInitialize | train | function databaseInitialize() {
var entries = db.getCollection("entries");
var messages = db.getCollection("messages");
// Since our LokiFsStructuredAdapter is partitioned, the default 'quickstart3.db'
// file will actually contain only the loki database shell and each of the collections
// will be saved int... | javascript | {
"resource": ""
} |
q22904 | Balance | train | function Balance(amount, balanceDate, description, affectingActor) {
this.amount = amount;
this.balanceDate = balanceDate;
this.description = description;
this.affectingActor = affectingActor;
} | javascript | {
"resource": ""
} |
q22905 | fdmap | train | 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 | {
"resource": ""
} |
q22906 | createDatabase | train | 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 | {
"resource": ""
} |
q22907 | initializeDatabase | train | function initializeDatabase(silent, docCount) {
var start, end, totalTime;
var totalTimes = [];
var totalMS = 0.0;
if (typeof docCount === "undefined") {
docCount = 5000;
}
arraySize = docCount;
for (var idx = 0; idx < arraySize; idx++) {
var v1 = genRandomVal();
var v2 = genRandomVal();
... | javascript | {
"resource": ""
} |
q22908 | perfFindInterlacedInserts | train | function perfFindInterlacedInserts(multiplier) {
var start, end;
var totalTimes = [];
var totalMS = 0;
var loopIterations = arraySize;
if (typeof (multiplier) != "undefined") {
loopIterations = loopIterations * multiplier;
}
for (var idx = 0; idx < loopIterations; idx++) {
var customidx = Math.f... | javascript | {
"resource": ""
} |
q22909 | seedData | train | function seedData() {
var users = db.getCollection("users");
users.insert({ name: "odin", gender: "m", age: 1000, tags : ["woden", "knowlege", "sorcery", "frenzy", "runes"], items: ["gungnir"], attributes: { eyes: 1} });
users.insert({ name: "frigg", gender: "f", age: 800, tags: ["foreknowlege"], items: ["eski"]... | javascript | {
"resource": ""
} |
q22910 | readTemplate | train | async function readTemplate (filename) {
const templateDir = path.join(__dirname, 'template')
return readFile(path.join(templateDir, filename), 'utf8')
} | javascript | {
"resource": ""
} |
q22911 | createDockerfile | train | 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 | {
"resource": ""
} |
q22912 | createPackageJson | train | function createPackageJson (name) {
const { version, devDependencies } = require('../package.json')
return {
name,
private: true,
main: 'index.js',
scripts: {
start: 'node ./index.js',
test: 'jest'
},
dependencies: {
'actions-toolkit': `^${version}`
},
devDependenci... | javascript | {
"resource": ""
} |
q22913 | train | function() {
if (isExpressInstallActive) {
var obj = getElementById(EXPRESS_INSTALL_ID);
if (obj && storedAltContent) {
obj.parentNode.replaceChild(storedAltContent, obj);
if (storedAltContentId) {
setVisibility(storedAltContentId, true);
if (ua.ie && ua.win) { storedAltContent.style.di... | javascript | {
"resource": ""
} | |
q22914 | Loader | train | 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 | {
"resource": ""
} |
q22915 | processMultiGeometry | train | function processMultiGeometry() {
const subType = type.replace(Constants.geojsonTypes.MULTI_PREFIX, '');
coordinates.forEach((subCoordinates, index) => {
const subFeature = {
type: Constants.geojsonTypes.FEATURE,
properties: geojson.properties,
geometry: {
type: subType,
... | javascript | {
"resource": ""
} |
q22916 | sortFeatures | train | function sortFeatures(features) {
return features.map(feature => {
if (feature.geometry.type === Constants.geojsonTypes.POLYGON) {
feature.area = area.geometry({
type: Constants.geojsonTypes.FEATURE,
property: {},
geometry: feature.geometry
});
}
return feature;
}).so... | javascript | {
"resource": ""
} |
q22917 | train | function() {
ctx.options.styles.forEach(style => {
if (ctx.map.getLayer(style.id)) {
ctx.map.removeLayer(style.id);
}
});
if (ctx.map.getSource(Constants.sources.COLD)) {
ctx.map.removeSource(Constants.sources.COLD);
}
if (ctx.map.getSource(Constants.sou... | javascript | {
"resource": ""
} | |
q22918 | mouseEventPoint | train | 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 | {
"resource": ""
} |
q22919 | mapEventToBoundingBox | train | function mapEventToBoundingBox(mapEvent, buffer = 0) {
return [
[mapEvent.point.x - buffer, mapEvent.point.y - buffer],
[mapEvent.point.x + buffer, mapEvent.point.y + buffer]
];
} | javascript | {
"resource": ""
} |
q22920 | handleEvent | train | function handleEvent(event) {
if (event.replyToken && event.replyToken.match(/^(.)\1*$/)) {
return console.log("Test hook recieved: " + JSON.stringify(event.message));
}
switch (event.type) {
case 'message':
const message = event.message;
switch (message.type) {
case 'text':
... | javascript | {
"resource": ""
} |
q22921 | activeLinks | train | function activeLinks(sidebarContainer) {
const linksContainer = sidebarContainer.querySelector('ul');
linksContainer.addEventListener('click', e => {
if (e.target.tagName === 'A') {
Array.from(linksContainer.querySelectorAll('a')).forEach(item =>
item.classList.remove('active')
);
e.t... | javascript | {
"resource": ""
} |
q22922 | Field | train | function Field({ id, children }) {
const fieldProps = useField(id);
return <FieldContext.Provider value={fieldProps}>{children}</FieldContext.Provider>;
} | javascript | {
"resource": ""
} |
q22923 | Ellipsis | train | function Ellipsis({ children, title, tag, ...other }) {
const CustomTagEllipsis = StyledEllipsis.withComponent(tag);
let textContent = null;
if (title !== undefined) {
textContent = title;
} else if (typeof children === 'string') {
textContent = children;
}
return (
<CustomTagEllipsis title={... | javascript | {
"resource": ""
} |
q22924 | train | 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 | {
"resource": ""
} | |
q22925 | train | 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 | {
"resource": ""
} | |
q22926 | Pool | train | function Pool(script, options) {
if (typeof script === 'string') {
this.script = script || null;
}
else {
this.script = null;
options = script;
}
this.workers = []; // queue with all workers
this.tasks = []; // queue with tasks awaiting execution
options = options || {};
this.forkArgs... | javascript | {
"resource": ""
} |
q22927 | getDefaultWorker | train | function getDefaultWorker() {
if (environment.platform == 'browser') {
// test whether the browser supports all features that we need
if (typeof Blob === 'undefined') {
throw new Error('Blob not supported by the browser');
}
if (!window.URL || typeof window.URL.createObjectURL !== 'function') {
... | javascript | {
"resource": ""
} |
q22928 | resolveForkOptions | train | function resolveForkOptions(opts) {
opts = opts || {};
var processExecArgv = process.execArgv.join(' ');
var inspectorActive = processExecArgv.indexOf('--inspect') !== -1;
var debugBrk = processExecArgv.indexOf('--debug-brk') !== -1;
var execArgv = [];
if (inspectorActive) {
execArgv.push('--inspect='... | javascript | {
"resource": ""
} |
q22929 | objectToError | train | 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 | {
"resource": ""
} |
q22930 | onError | train | function onError(error) {
me.terminated = true;
if (me.terminating && me.terminationHandler) {
me.terminationHandler(me);
}
me.terminating = false;
for (var id in me.processing) {
if (me.processing[id] !== undefined) {
me.processing[id].resolver.reject(error);
}
}
... | javascript | {
"resource": ""
} |
q22931 | dispatchQueuedRequests | train | function dispatchQueuedRequests()
{
me.requestQueue.forEach(me.worker.send.bind(me.worker));
me.requestQueue = [];
} | javascript | {
"resource": ""
} |
q22932 | hex2packed | train | function hex2packed(str, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, length = str.length, i, num, intOffset, byteOffset,
existingByteLen, shiftModifier;
if (0 !== (length % 2))
{
throw new Error("String of HEX type must be in byte increments");
}
packed = existingPacked || [0];
e... | javascript | {
"resource": ""
} |
q22933 | bytes2packed | train | function bytes2packed(str, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, codePnt, i, existingByteLen, intOffset,
byteOffset, shiftModifier;
packed = existingPacked || [0];
existingPackedLen = existingPackedLen || 0;
existingByteLen = existingPackedLen >>> 3;
shiftModifier = (bigEndianMod... | javascript | {
"resource": ""
} |
q22934 | b642packed | train | function b642packed(str, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, byteCnt = 0, index, i, j, tmpInt, strPart, firstEqual,
b64Tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
existingByteLen, intOffset, byteOffset, shiftModifier;
if (-1 === str.search(/^[a-zA-Z0-... | javascript | {
"resource": ""
} |
q22935 | arraybuffer2packed | train | function arraybuffer2packed(arr, existingPacked, existingPackedLen, bigEndianMod)
{
var packed, i, existingByteLen, intOffset, byteOffset, shiftModifier, arrView;
packed = existingPacked || [0];
existingPackedLen = existingPackedLen || 0;
existingByteLen = existingPackedLen >>> 3;
shiftModifier = (bigEndian... | javascript | {
"resource": ""
} |
q22936 | packed2b64 | train | function packed2b64(packed, outputLength, bigEndianMod, formatOpts)
{
var str = "", length = outputLength / 8, i, j, triplet, int1, int2, shiftModifier,
b64Tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 3)... | javascript | {
"resource": ""
} |
q22937 | packed2bytes | train | function packed2bytes(packed, outputLength, bigEndianMod)
{
var str = "", length = outputLength / 8, i, srcByte, shiftModifier;
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 1)
{
srcByte = (packed[i >>> 2] >>> (8 * (shiftModifier + bigEndianMod * (i % 4)))) & 0xFF;
str += ... | javascript | {
"resource": ""
} |
q22938 | packed2arraybuffer | train | function packed2arraybuffer(packed, outputLength, bigEndianMod)
{
var length = outputLength / 8, i, retVal = new ArrayBuffer(length), shiftModifier, arrView;
arrView = new Uint8Array(retVal);
shiftModifier = (bigEndianMod === -1) ? 3 : 0;
for (i = 0; i < length; i += 1)
{
arrView[i] = (packed[i >>> 2] >... | javascript | {
"resource": ""
} |
q22939 | getOutputOpts | train | function getOutputOpts(options)
{
var retVal = {"outputUpper" : false, "b64Pad" : "=", "shakeLen" : -1},
outputOptions;
outputOptions = options || {};
retVal["outputUpper"] = outputOptions["outputUpper"] || false;
if (true === outputOptions.hasOwnProperty("b64Pad"))
{
retVal["b64Pad"] = outputOptions... | javascript | {
"resource": ""
} |
q22940 | rotl_64 | train | function rotl_64(x, n)
{
if (n > 32)
{
n = n - 32;
return new Int_64(
x.lowOrder << n | x.highOrder >>> (32 - n),
x.highOrder << n | x.lowOrder >>> (32 - n)
);
}
else if (0 !== n)
{
return new Int_64(
x.highOrder << n | x.lowOrder >>> (32 - n),
x.lowOrder << n | x.highOrder >>> (3... | javascript | {
"resource": ""
} |
q22941 | rotr_64 | train | function rotr_64(x, n)
{
var retVal = null, tmp = new Int_64(x.highOrder, x.lowOrder);
if (32 >= n)
{
retVal = new Int_64(
(tmp.highOrder >>> n) | ((tmp.lowOrder << (32 - n)) & 0xFFFFFFFF),
(tmp.lowOrder >>> n) | ((tmp.highOrder << (32 - n)) & 0xFFFFFFFF)
);
}
else
{
retVal = new Int_6... | javascript | {
"resource": ""
} |
q22942 | shr_64 | train | 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 | {
"resource": ""
} |
q22943 | ch_64 | train | 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 | {
"resource": ""
} |
q22944 | maj_32 | train | function maj_32(x, y, z)
{
return (x & y) ^ (x & z) ^ (y & z);
} | javascript | {
"resource": ""
} |
q22945 | maj_64 | train | 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 | {
"resource": ""
} |
q22946 | sigma0_64 | train | 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 | {
"resource": ""
} |
q22947 | sigma1_64 | train | 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 | {
"resource": ""
} |
q22948 | gamma0_64 | train | 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 | {
"resource": ""
} |
q22949 | gamma1_64 | train | 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 | {
"resource": ""
} |
q22950 | safeAdd_32_2 | train | 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 | {
"resource": ""
} |
q22951 | safeAdd_32_4 | train | 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 | {
"resource": ""
} |
q22952 | safeAdd_32_5 | train | 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 | {
"resource": ""
} |
q22953 | safeAdd_64_2 | train | function safeAdd_64_2(x, y)
{
var lsw, msw, lowOrder, highOrder;
lsw = (x.lowOrder & 0xFFFF) + (y.lowOrder & 0xFFFF);
msw = (x.lowOrder >>> 16) + (y.lowOrder >>> 16) + (lsw >>> 16);
lowOrder = ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
lsw = (x.highOrder & 0xFFFF) + (y.highOrder & 0xFFFF) + (msw >>> 16);
m... | javascript | {
"resource": ""
} |
q22954 | safeAdd_64_4 | train | function safeAdd_64_4(a, b, c, d)
{
var lsw, msw, lowOrder, highOrder;
lsw = (a.lowOrder & 0xFFFF) + (b.lowOrder & 0xFFFF) +
(c.lowOrder & 0xFFFF) + (d.lowOrder & 0xFFFF);
msw = (a.lowOrder >>> 16) + (b.lowOrder >>> 16) +
(c.lowOrder >>> 16) + (d.lowOrder >>> 16) + (lsw >>> 16);
lowOrder = ((msw & 0xFFF... | javascript | {
"resource": ""
} |
q22955 | safeAdd_64_5 | train | function safeAdd_64_5(a, b, c, d, e)
{
var lsw, msw, lowOrder, highOrder;
lsw = (a.lowOrder & 0xFFFF) + (b.lowOrder & 0xFFFF) +
(c.lowOrder & 0xFFFF) + (d.lowOrder & 0xFFFF) +
(e.lowOrder & 0xFFFF);
msw = (a.lowOrder >>> 16) + (b.lowOrder >>> 16) +
(c.lowOrder >>> 16) + (d.lowOrder >>> 16) + (e.lowOrde... | javascript | {
"resource": ""
} |
q22956 | xor_64_2 | train | function xor_64_2(a, b)
{
return new Int_64(
a.highOrder ^ b.highOrder,
a.lowOrder ^ b.lowOrder
);
} | javascript | {
"resource": ""
} |
q22957 | xor_64_5 | train | 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 | {
"resource": ""
} |
q22958 | cloneSHA3State | train | function cloneSHA3State(state) {
var clone = [], i;
for (i = 0; i < 5; i += 1)
{
clone[i] = state[i].slice();
}
return clone;
} | javascript | {
"resource": ""
} |
q22959 | getNewState | train | function getNewState(variant)
{
var retVal = [], H_trunc, H_full, i;
if (("SHA-1" === variant) && ((1 & SUPPORTED_ALGS) !== 0))
{
retVal = [
0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0
];
}
else if ((variant.lastIndexOf("SHA-", 0) === 0) && ((6 & SUPPORTED_ALGS) !== 0))
{
H_tru... | javascript | {
"resource": ""
} |
q22960 | roundSHA1 | train | function roundSHA1(block, H)
{
var W = [], a, b, c, d, e, T, ch = ch_32, parity = parity_32,
maj = maj_32, rotl = rotl_32, safeAdd_2 = safeAdd_32_2, t,
safeAdd_5 = safeAdd_32_5;
a = H[0];
b = H[1];
c = H[2];
d = H[3];
e = H[4];
for (t = 0; t < 80; t += 1)
{
if (t < 16)
{
W[t] = block[... | javascript | {
"resource": ""
} |
q22961 | finalizeSHA1 | train | function finalizeSHA1(remainder, remainderBinLen, processedBinLen, H, outputLen)
{
var i, appendedMessageLength, offset, totalLen;
/* The 65 addition is a hack but it works. The correct number is
actually 72 (64 + 8) but the below math fails if
remainderBinLen + 72 % 512 = 0. Since remainderBinLen % 8 ... | javascript | {
"resource": ""
} |
q22962 | finalizeSHA3 | train | function finalizeSHA3(remainder, remainderBinLen, processedBinLen, state, blockSize, delimiter, outputLen)
{
var i, retVal = [], binaryStringInc = blockSize >>> 5, state_offset = 0,
remainderIntLen = remainderBinLen >>> 5, temp;
/* Process as many blocks as possible, some may be here for multiple rounds
... | javascript | {
"resource": ""
} |
q22963 | batchMethod | train | function batchMethod (obj, method) {
const descriptor = Object.getOwnPropertyDescriptor(obj, method)
if (descriptor) {
const newDescriptor = Object.assign({}, descriptor, {
set (value) {
return descriptor.set.call(this, batchFn(value))
}
})
Object.defineProperty(obj, method, newDescr... | javascript | {
"resource": ""
} |
q22964 | toSet | train | function toSet(arr) {
const set = {};
arr.forEach((e) => (set[e] = true));
return set;
} | javascript | {
"resource": ""
} |
q22965 | copy | train | function copy() {
const nodes = [];
const cnodes = [];
const mapping = {};
this.each((node) => {
nodes.push(node);
const cnode = new Node(node.id, node.data);
cnodes.push(cnode);
mapping[cnode.id] = cnode;
});
cnodes.forEach((cnode, i) => {
const node = nodes[i];
cnode.children = no... | javascript | {
"resource": ""
} |
q22966 | getLumenPrice | train | function getLumenPrice() {
return Promise.all([
rp('https://poloniex.com/public?command=returnTicker')
.then(data => {
return parseFloat(JSON.parse(data).BTC_STR.last);
})
.catch(() => {
return null;
})
,
rp('https://bittrex.com/api/v1.1/public/getticker?market=BTC-... | javascript | {
"resource": ""
} |
q22967 | showPrompt | train | function showPrompt () {
return new Promise(function (resolve, reject) {
var msg = 'May Cordova anonymously report usage statistics to improve the tool over time?';
insight._permissionTimeout = module.exports.timeoutInSecs || 30;
insight.askPermission(msg, function (unused, optIn) {
... | javascript | {
"resource": ""
} |
q22968 | onSameRow | train | 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 | {
"resource": ""
} |
q22969 | withTheme | train | function withTheme(WrappedComponent) {
const displayName =
WrappedComponent.displayName || WrappedComponent.name || 'Component'
return class extends React.Component {
static displayName = `withTheme(${displayName})`
render() {
return (
<ThemeConsumer>
{theme => <WrappedComponen... | javascript | {
"resource": ""
} |
q22970 | stripQuotes | train | 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 | {
"resource": ""
} |
q22971 | getPathCharType | train | function getPathCharType (ch) {
if (ch === undefined || ch === null) { return 'eof' }
const code = ch.charCodeAt(0);
switch (code) {
case 0x5B: // [
case 0x5D: // ]
case 0x2E: // .
case 0x22: // "
case 0x27: // '
return ch
case 0x5F: // _
case 0x24: // $
case 0x2D: // -
... | javascript | {
"resource": ""
} |
q22972 | parse$1 | train | function parse$1 (path) {
const keys = [];
let index = -1;
let mode = BEFORE_PATH;
let subPathDepth = 0;
let c;
let key;
let newChar;
let type;
let transition;
let action;
let typeMap;
const actions = [];
actions[PUSH] = function () {
if (key !== undefined) {
keys.push(key);
k... | javascript | {
"resource": ""
} |
q22973 | wrapTree | train | function wrapTree(t) {
var wt = {
t: t,
prelim: 0,
mod: 0,
shift: 0,
change: 0,
msel: 0,
mser: 0,
};
t.x = 0;
t.y = 0;
if (size) {
wt.x_size = 1;
wt.y_size = 1;
}
else if (typeof nodeSize == "object") { // fixed array
wt.x_size =... | javascript | {
"resource": ""
} |
q22974 | zerothWalk | train | function zerothWalk(wt, initial) {
wt.t.y = initial;
wt.t.depth = 0;
_zerothWalk(wt);
} | javascript | {
"resource": ""
} |
q22975 | setRightThread | train | 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 | {
"resource": ""
} |
q22976 | positionRoot | train | function positionRoot(wt) {
wt.prelim = ( wt.children[0].prelim +
wt.children[0].mod -
wt.children[0].x_size/2 +
wt.children[wt.num_children - 1].mod +
wt.children[wt.num_children - 1].prelim +
wt.children[wt.num_children - ... | javascript | {
"resource": ""
} |
q22977 | addChildSpacing | train | function addChildSpacing(wt) {
var d = 0, modsumdelta = 0;
for (var i = 0; i < wt.num_children; i++) {
d += wt.children[i].shift;
modsumdelta += d + wt.children[i].change; ... | javascript | {
"resource": ""
} |
q22978 | renormalize | train | function renormalize(wt) {
// If a fixed tree size is specified, scale x and y based on the extent.
// Compute the left-most, right-most, and depth-most nodes for extents.
if (size != null) {
var left = wt,
right = wt,
bottom = wt;
var toVisit = [wt],
node;
w... | javascript | {
"resource": ""
} |
q22979 | getSyncPage | train | function getSyncPage (http, items, query, { paginate }) {
if (query.nextSyncToken) {
query.sync_token = query.nextSyncToken
delete query.nextSyncToken
}
if (query.nextPageToken) {
query.sync_token = query.nextPageToken
delete query.nextPageToken
}
if (query.sync_token) {
delete query.ini... | javascript | {
"resource": ""
} |
q22980 | scrollIntoView | train | 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 | {
"resource": ""
} |
q22981 | debounce | train | function debounce(fn, time) {
let timeoutId
function cancel() {
if (timeoutId) {
clearTimeout(timeoutId)
}
}
function wrapper(...args) {
cancel()
timeoutId = setTimeout(() => {
timeoutId = null
fn(...args)
}, time)
}
wrapper.cancel = cancel
return wrapper
} | javascript | {
"resource": ""
} |
q22982 | callAllEventHandlers | train | function callAllEventHandlers(...fns) {
return (event, ...args) =>
fns.some(fn => {
if (fn) {
fn(event, ...args)
}
return (
event.preventDownshiftDefault ||
(event.hasOwnProperty('nativeEvent') &&
event.nativeEvent.preventDownshiftDefault)
)
})
} | javascript | {
"resource": ""
} |
q22983 | getNextWrappingIndex | train | function getNextWrappingIndex(moveAmount, baseIndex, itemCount) {
const itemsLastIndex = itemCount - 1
if (
typeof baseIndex !== 'number' ||
baseIndex < 0 ||
baseIndex >= itemCount
) {
baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1
}
let newIndex = baseIndex + moveAmount
if (newIndex ... | javascript | {
"resource": ""
} |
q22984 | getStatusDiv | train | function getStatusDiv() {
if (statusDiv) {
return statusDiv
}
statusDiv = document.createElement('div')
statusDiv.setAttribute('id', 'a11y-status-message')
statusDiv.setAttribute('role', 'status')
statusDiv.setAttribute('aria-live', 'polite')
statusDiv.setAttribute('aria-relevant', 'additions text')
... | javascript | {
"resource": ""
} |
q22985 | train | function(controller) {
// TODO listening?
this.__ul.removeChild(controller.__li);
this.__controllers.splice(this.__controllers.indexOf(controller), 1);
const _this = this;
common.defer(function() {
_this.onResize();
});
} | javascript | {
"resource": ""
} | |
q22986 | getEyeMatrices | train | function getEyeMatrices( frameData ) {
// Compute the matrix for the position of the head based on the pose
if ( frameData.pose.orientation ) {
poseOrientation.fromArray( frameData.pose.orientation );
headMatrix.makeRotationFromQuaternion( poseOrientation );
} else {
headMatrix.identity();
}
if... | javascript | {
"resource": ""
} |
q22987 | rng_seed_int | train | function rng_seed_int(x) {
rng_pool[rng_pptr++] ^= x & 255;
rng_pool[rng_pptr++] ^= (x >> 8) & 255;
rng_pool[rng_pptr++] ^= (x >> 16) & 255;
rng_pool[rng_pptr++] ^= (x >> 24) & 255;
if(rng_pptr >= rng_psize) rng_pptr -= rng_psize;
} | javascript | {
"resource": ""
} |
q22988 | curveFpDecodePointHex | train | function curveFpDecodePointHex(s) {
switch(parseInt(s.substr(0,2), 16)) { // first byte
case 0:
return this.infinity;
case 2:
case 3:
// point compression not supported yet
return null;
case 4:
case 6:
case 7:
var len = (s.length - 2) / 2;
var xHex = s.substr(2, len);
var yHex = s.subs... | javascript | {
"resource": ""
} |
q22989 | build_lib_sourcemap | train | function build_lib_sourcemap(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'development',
entry: npmEntry,
output: {
filename:'oidc-client.js',
libraryTarget:'umd',
// Workaround for https://github.com/webpack/webpack/issues/6642
... | javascript | {
"resource": ""
} |
q22990 | build_lib_min | train | function build_lib_min(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'production',
entry: npmEntry,
output: {
filename:'oidc-client.min.js',
libraryTarget:'umd',
// Workaround for https://github.com/webpack/webpack/issues/6642
... | javascript | {
"resource": ""
} |
q22991 | build_dist_sourcemap | train | function build_dist_sourcemap(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'development',
entry: classicEntry,
output: {
filename:'oidc-client.js',
libraryTarget:'var',
library:'Oidc'
},
plugins: [],
devtool:'inline-sour... | javascript | {
"resource": ""
} |
q22992 | build_dist_min | train | function build_dist_min(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'production',
entry: classicEntry,
output: {
filename:'oidc-client.min.js',
libraryTarget:'var',
library:'Oidc'
},
plugins: [],
devtool: false,
opt... | javascript | {
"resource": ""
} |
q22993 | share | train | function share(elem, options) {
var data = mixin({}, defaults, options || {}, dataset(elem));
if (data.imageSelector) {
data.image = querySelectorAlls(data.imageSelector).map(function(item) {
return item.src;
}).join('||');
}
addClass(elem, 'shar... | javascript | {
"resource": ""
} |
q22994 | makeUrl | train | function makeUrl(name, data) {
if (! data['summary']){
data['summary'] = data['description'];
}
return templates[name].replace(/\{\{(\w)(\w*)\}\}/g, function (m, fix, key) {
var nameKey = name + fix + key.toLowerCase();
key = (fix + key).toLowerCase();
... | javascript | {
"resource": ""
} |
q22995 | querySelectorAlls | train | function querySelectorAlls(str) {
return (document.querySelectorAll || window.jQuery || window.Zepto || selector).call(document, str);
} | javascript | {
"resource": ""
} |
q22996 | selector | train | function selector(str) {
var elems = [];
each(str.split(/\s*,\s*/), function(s) {
var m = s.match(/([#.])(\w+)/);
if (m === null) {
throw Error('Supports only simple single #ID or .CLASS selector.');
}
if (m[1]) {
var elem... | javascript | {
"resource": ""
} |
q22997 | addClass | train | function addClass(elem, value) {
if (value && typeof value === "string") {
var classNames = (elem.className + ' ' + value).split(/\s+/);
var setClass = ' ';
each(classNames, function (className) {
if (setClass.indexOf(' ' + className + ' ') < 0) {
... | javascript | {
"resource": ""
} |
q22998 | getElementsByClassName | train | function getElementsByClassName(elem, name, tag) {
if (elem.getElementsByClassName) {
return elem.getElementsByClassName(name);
}
var elements = [];
var elems = elem.getElementsByTagName(tag || '*');
name = ' ' + name + ' ';
each(elems, function (elem) {
... | javascript | {
"resource": ""
} |
q22999 | createElementByString | train | function createElementByString(str) {
var div = document.createElement('div');
div.innerHTML = str;
return div.childNodes;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.