_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q22400 | train | function (layer) {
if (layer._spiderLeg) {
this._featureGroup.removeLayer(layer);
if (layer.clusterShow) {
layer.clusterShow();
}
//Position will be fixed up immediately in _animationUnspiderfy
if (layer.setZIndexOffset) {
layer.setZIndexOffset(0);
}
this._map.removeLayer(layer._spider... | javascript | {
"resource": ""
} | |
q22401 | train | function (obj, point) {
var x = this._getCoord(point.x),
y = this._getCoord(point.y),
grid = this._grid,
row = grid[y] = grid[y] || {},
cell = row[x] = row[x] || [],
i, len;
delete this._objectPoint[L.Util.stamp(obj)];
for (i = 0, len = cell.length; i < len; i++) {
if (cell[i] =... | javascript | {
"resource": ""
} | |
q22402 | clearBackground | train | function clearBackground() {
var body = document.body;
if (body.style) {
body.style.backgroundColor = 'rgba(0,0,0,0.01)';
body.style.backgroundImage = '';
setTimeout(function() {
body.style.backgroundColor = 'transparent';
}, 1);
if (body.parentNode && body.parentNode.style) {
body.p... | javascript | {
"resource": ""
} |
q22403 | getCameraSpecsById | train | function getCameraSpecsById(deviceId){
// return a getUserMedia Constraints
function getConstraintObj(deviceId, facingMode, width, height){
var obj = { audio: false, video: {} };
obj.video.deviceId = {exact: deviceId};
if(facingMode) {
obj.video.facingMode = {exact: facingMode};
... | javascript | {
"resource": ""
} |
q22404 | getConstraintObj | train | function getConstraintObj(deviceId, facingMode, width, height){
var obj = { audio: false, video: {} };
obj.video.deviceId = {exact: deviceId};
if(facingMode) {
obj.video.facingMode = {exact: facingMode};
}
if(width) {
obj.video.width = {exact: width};
}
if(heigh... | javascript | {
"resource": ""
} |
q22405 | getFirstResolvingConstraint | train | function getFirstResolvingConstraint(constraintsBestToWorst){
return new Promise(function(resolveBestConstraints){
// build a chain of promises which either resolves or continues searching
return constraintsBestToWorst.reduce(function(chain, next){
return chain.then(function(searchState)... | javascript | {
"resource": ""
} |
q22406 | convertStream | train | async function convertStream(data, streaming) {
if (!streaming && util.isStream(data)) {
return stream.readToEnd(data);
}
if (streaming && !util.isStream(data)) {
data = new ReadableStream({
start(controller) {
controller.enqueue(data);
controller.close();
}
});
}
if (s... | javascript | {
"resource": ""
} |
q22407 | convertStreams | train | async function convertStreams(obj, streaming, keys=[]) {
if (Object.prototype.isPrototypeOf(obj) && !Uint8Array.prototype.isPrototypeOf(obj)) {
await Promise.all(Object.entries(obj).map(async ([key, value]) => { // recursively search all children
if (util.isStream(value) || keys.includes(key)) {
obj... | javascript | {
"resource": ""
} |
q22408 | linkStreams | train | function linkStreams(result, message, erroringStream) {
result.data = stream.transformPair(message.packets.stream, async (readable, writable) => {
await stream.pipe(result.data, writable, {
preventClose: true
});
const writer = stream.getWriter(writable);
try {
// Forward errors in errorin... | javascript | {
"resource": ""
} |
q22409 | prepareSignatures | train | async function prepareSignatures(signatures) {
await Promise.all(signatures.map(async signature => {
signature.signature = await signature.signature;
try {
signature.valid = await signature.verified;
} catch(e) {
signature.valid = null;
signature.error = e;
util.print_debug_error(e... | javascript | {
"resource": ""
} |
q22410 | onError | train | function onError(message, error) {
// log the stack trace
util.print_debug_error(error);
// update error message
try {
error.message = message + ': ' + error.message;
} catch(e) {}
throw error;
} | javascript | {
"resource": ""
} |
q22411 | nativeAEAD | train | function nativeAEAD() {
return config.aead_protect && (
((config.aead_protect_version !== 4 || config.aead_mode === enums.aead.experimental_gcm) && util.getWebCrypto()) ||
(config.aead_protect_version === 4 && config.aead_mode === enums.aead.eax && util.getWebCrypto())
);
} | javascript | {
"resource": ""
} |
q22412 | promisifyIE11Op | train | function promisifyIE11Op(keyObj, err) {
if (typeof keyObj.then !== 'function') { // IE11 KeyOperation
return new Promise(function(resolve, reject) {
keyObj.onerror = function () {
reject(new Error(err));
};
keyObj.oncomplete = function (e) {
resolve(e.target.result);
};
... | javascript | {
"resource": ""
} |
q22413 | train | async function(m, n, e, d, p, q, u) {
if (n.cmp(m) <= 0) {
throw new Error('Data too large.');
}
const dq = d.mod(q.subn(1)); // d mod (q-1)
const dp = d.mod(p.subn(1)); // d mod (p-1)
const pred = new BN.red(p);
const qred = new BN.red(q);
const nred = new BN.red(n);
let blinder;... | javascript | {
"resource": ""
} | |
q22414 | train | async function(B, E) {
let key;
E = new BN(E, 16);
const webCrypto = util.getWebCryptoAll();
// Native RSA keygen using Web Crypto
if (webCrypto) {
let keyPair;
let keyGenOpt;
if ((window.crypto && window.crypto.subtle) || window.msCrypto) {
// current standard spec
... | javascript | {
"resource": ""
} | |
q22415 | DES | train | function DES(key) {
this.key = key;
this.encrypt = function(block, padding) {
const keys = des_createKeys(this.key);
return des(keys, block, true, 0, null, padding);
};
this.decrypt = function(block, padding) {
const keys = des_createKeys(this.key);
return des(keys, block, false, 0, null, padd... | javascript | {
"resource": ""
} |
q22416 | train | function(algo) {
switch (algo) {
// Algorithm-Specific Fields for RSA secret keys:
// - multiprecision integer (MPI) of RSA secret exponent d.
// - MPI of RSA secret prime value p.
// - MPI of RSA secret prime value q (p < q).
// - MPI of u, the multiplicative... | javascript | {
"resource": ""
} | |
q22417 | train | function(algo) {
switch (algo) {
// Algorithm-Specific Fields for RSA encrypted session keys:
// - MPI of RSA encrypted value m**e mod n.
case enums.publicKey.rsa_encrypt:
case enums.publicKey.rsa_encrypt_sign:
return [type_mpi];
// Algorithm-Specific Fields for Elga... | javascript | {
"resource": ""
} | |
q22418 | train | function(algo, bits, oid) {
const types = [].concat(this.getPubKeyParamTypes(algo), this.getPrivKeyParamTypes(algo));
switch (algo) {
case enums.publicKey.rsa_encrypt:
case enums.publicKey.rsa_encrypt_sign:
case enums.publicKey.rsa_sign: {
return publicKey.rsa.generate(bits, "10001").t... | javascript | {
"resource": ""
} | |
q22419 | train | async function(plaintext, nonce, adata) {
const [
omacNonce,
omacAdata
] = await Promise.all([
omac(zero, nonce),
omac(one, adata)
]);
const ciphered = await ctr(plaintext, omacNonce);
const omacCiphered = await omac(two, ciphered);
const tag = omacCip... | javascript | {
"resource": ""
} | |
q22420 | randomCallback | train | function randomCallback() {
if (!randomQueue.length) {
self.postMessage({ event: 'request-seed', amount: MAX_SIZE_RANDOM_BUFFER });
}
return new Promise(function(resolve) {
randomQueue.push(resolve);
});
} | javascript | {
"resource": ""
} |
q22421 | configure | train | function configure(config) {
Object.keys(config).forEach(function(key) {
openpgp.config[key] = config[key];
});
} | javascript | {
"resource": ""
} |
q22422 | seedRandom | train | function seedRandom(buffer) {
if (!(buffer instanceof Uint8Array)) {
buffer = new Uint8Array(buffer);
}
openpgp.crypto.random.randomBuffer.set(buffer);
} | javascript | {
"resource": ""
} |
q22423 | delegate | train | function delegate(id, method, options) {
if (typeof openpgp[method] !== 'function') {
response({ id:id, event:'method-return', err:'Unknown Worker Event' });
return;
}
// construct ReadableStreams from MessagePorts
openpgp.util.restoreStreams(options);
// parse cloned packets
options = openpgp.packe... | javascript | {
"resource": ""
} |
q22424 | response | train | function response(event) {
self.postMessage(event, openpgp.util.getTransferables(event.data, true));
} | javascript | {
"resource": ""
} |
q22425 | LocalStore | train | function LocalStore(prefix) {
prefix = prefix || 'openpgp-';
this.publicKeysItem = prefix + this.publicKeysItem;
this.privateKeysItem = prefix + this.privateKeysItem;
if (typeof window !== 'undefined' && window.localStorage) {
this.storage = window.localStorage;
} else {
this.storage = new (require('n... | javascript | {
"resource": ""
} |
q22426 | HKP | train | function HKP(keyServerBaseUrl) {
this._baseUrl = keyServerBaseUrl || config.keyserver;
this._fetch = typeof window !== 'undefined' ? window.fetch : require('node-fetch');
} | javascript | {
"resource": ""
} |
q22427 | getPkcs1Padding | train | async function getPkcs1Padding(length) {
let result = '';
while (result.length < length) {
const randomBytes = await random.getRandomBytes(length - result.length);
for (let i = 0; i < randomBytes.length; i++) {
if (randomBytes[i] !== 0) {
result += String.fromCharCode(randomBytes[i]);
}
... | javascript | {
"resource": ""
} |
q22428 | train | async function(length) {
const buf = new Uint8Array(length);
if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
window.crypto.getRandomValues(buf);
} else if (typeof window !== 'undefined' && typeof window.msCrypto === 'object' && typeof window.msCrypto.getRandomVal... | javascript | {
"resource": ""
} | |
q22429 | train | async function(min, max) {
if (max.cmp(min) <= 0) {
throw new Error('Illegal parameter value: max <= min');
}
const modulus = max.sub(min);
const bytes = modulus.byteLength();
// Using a while loop is necessary to avoid bias introduced by the mod operation.
// However, we request 64 extr... | javascript | {
"resource": ""
} | |
q22430 | verifyHeaders | train | function verifyHeaders(headers, packetlist) {
const checkHashAlgos = function(hashAlgos) {
const check = packet => algo => packet.hashAlgorithm === algo;
for (let i = 0; i < packetlist.length; i++) {
if (packetlist[i].tag === enums.packet.signature && !hashAlgos.some(check(packetlist[i]))) {
re... | javascript | {
"resource": ""
} |
q22431 | createVerificationObject | train | async function createVerificationObject(signature, literalDataList, keys, date=new Date()) {
let primaryKey = null;
let signingKey = null;
await Promise.all(keys.map(async function(key) {
// Look for the unique key that matches issuerKeyId of signature
const result = await key.getSigningKey(signature.issu... | javascript | {
"resource": ""
} |
q22432 | SecretKey | train | function SecretKey(date=new Date()) {
publicKey.call(this, date);
/**
* Packet type
* @type {module:enums.packet}
*/
this.tag = enums.packet.secretKey;
/**
* Encrypted secret-key data
*/
this.encrypted = null;
/**
* Indicator if secret-key data is encrypted. `this.isEncrypted === false` me... | javascript | {
"resource": ""
} |
q22433 | AsyncProxy | train | function AsyncProxy({ path='openpgp.worker.js', n = 1, workers = [], config } = {}) {
/**
* Message handling
*/
const handleMessage = workerId => event => {
const msg = event.data;
switch (msg.event) {
case 'loaded':
this.workers[workerId].loadedResolve(true);
break;
case '... | javascript | {
"resource": ""
} |
q22434 | isDataRevoked | train | async function isDataRevoked(primaryKey, signatureType, dataToVerify, revocations, signature, key, date=new Date()) {
key = key || primaryKey;
const normDate = util.normalizeDate(date);
const revocationKeyIds = [];
await Promise.all(revocations.map(async function(revocationSignature) {
if (
// Note: a... | javascript | {
"resource": ""
} |
q22435 | randomProbablePrime | train | async function randomProbablePrime(bits, e, k) {
const min = new BN(1).shln(bits - 1);
const thirty = new BN(30);
/*
* We can avoid any multiples of 3 and 5 by looking at n mod 30
* n mod 30 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
* the next possible pri... | javascript | {
"resource": ""
} |
q22436 | isProbablePrime | train | async function isProbablePrime(n, e, k) {
if (e && !n.subn(1).gcd(e).eqn(1)) {
return false;
}
if (!divisionTest(n)) {
return false;
}
if (!fermat(n)) {
return false;
}
if (!await millerRabin(n, k)) {
return false;
}
// TODO implement the Lucas test
// See Section C.3.3 here: https:/... | javascript | {
"resource": ""
} |
q22437 | getType | train | function getType(text) {
const reHeader = /^-----BEGIN PGP (MESSAGE, PART \d+\/\d+|MESSAGE, PART \d+|SIGNED MESSAGE|MESSAGE|PUBLIC KEY BLOCK|PRIVATE KEY BLOCK|SIGNATURE)-----$/m;
const header = text.match(reHeader);
if (!header) {
throw new Error('Unknown ASCII armor type');
}
// BEGIN PGP MESSAGE, PAR... | javascript | {
"resource": ""
} |
q22438 | addheader | train | function addheader(customComment) {
let result = "";
if (config.show_version) {
result += "Version: " + config.versionstring + '\r\n';
}
if (config.show_comment) {
result += "Comment: " + config.commentstring + '\r\n';
}
if (customComment) {
result += "Comment: " + customComment + '\r\n';
}
... | javascript | {
"resource": ""
} |
q22439 | splitChecksum | train | function splitChecksum(text) {
let body = text;
let checksum = "";
const lastEquals = text.lastIndexOf("=");
if (lastEquals >= 0 && lastEquals !== text.length - 1) { // '=' as the last char means no checksum
body = text.slice(0, lastEquals);
checksum = text.slice(lastEquals + 1).substr(0, 4);
}
r... | javascript | {
"resource": ""
} |
q22440 | armor | train | function armor(messagetype, body, partindex, parttotal, customComment) {
let text;
let hash;
if (messagetype === enums.armor.signed) {
text = body.text;
hash = body.hash;
body = body.data;
}
const bodyClone = stream.passiveClone(body);
const result = [];
switch (messagetype) {
case enums.a... | javascript | {
"resource": ""
} |
q22441 | train | function(algo, data) {
switch (algo) {
case 1:
// - MD5 [HAC]
return this.md5(data);
case 2:
// - SHA-1 [FIPS180]
return this.sha1(data);
case 3:
// - RIPE-MD/160 [HAC]
return this.ripemd(data);
case 8:
// - SHA256 [FIPS180]
ret... | javascript | {
"resource": ""
} | |
q22442 | s2r | train | function s2r(t, u = false) {
// TODO check btoa alternative
const b64 = u ? b64u : b64s;
let a;
let c;
let l = 0;
let s = 0;
return stream.transform(t, value => {
const r = [];
const tl = value.length;
for (let n = 0; n < tl; n++) {
if (l && (l % 60) === 0 && !u) {
r.push("\r\n... | javascript | {
"resource": ""
} |
q22443 | r2s | train | function r2s(t, u) {
// TODO check atob alternative
let c;
let s = 0;
let a = 0;
return stream.transform(t, value => {
const tl = value.length;
const r = new Uint8Array(Math.ceil(0.75 * tl));
let index = 0;
for (let n = 0; n < tl; n++) {
c = b64toByte[value.charCodeAt(n)];
if (c ... | javascript | {
"resource": ""
} |
q22444 | genPublicEphemeralKey | train | async function genPublicEphemeralKey(curve, Q) {
if (curve.name === 'curve25519') {
const { secretKey: d } = nacl.box.keyPair();
const { secretKey, sharedKey } = await genPrivateEphemeralKey(curve, Q, d);
let { publicKey } = nacl.box.keyPair.fromSecretKey(secretKey);
publicKey = util.concatUint8Array(... | javascript | {
"resource": ""
} |
q22445 | encrypt | train | async function encrypt(oid, cipher_algo, hash_algo, m, Q, fingerprint) {
const curve = new Curve(oid);
const { publicKey, sharedKey } = await genPublicEphemeralKey(curve, Q);
const param = buildEcdhParam(enums.publicKey.ecdh, oid, cipher_algo, hash_algo, fingerprint);
cipher_algo = enums.read(enums.symmetric, c... | javascript | {
"resource": ""
} |
q22446 | genPrivateEphemeralKey | train | async function genPrivateEphemeralKey(curve, V, d) {
if (curve.name === 'curve25519') {
const one = new BN(1);
const mask = one.ushln(255 - 3).sub(one).ushln(3);
let secretKey = new BN(d);
secretKey = secretKey.or(one.ushln(255 - 1));
secretKey = secretKey.and(mask);
secretKey = secretKey.toAr... | javascript | {
"resource": ""
} |
q22447 | decrypt | train | async function decrypt(oid, cipher_algo, hash_algo, V, C, d, fingerprint) {
const curve = new Curve(oid);
const { sharedKey } = await genPrivateEphemeralKey(curve, V, d);
const param = buildEcdhParam(enums.publicKey.ecdh, oid, cipher_algo, hash_algo, fingerprint);
cipher_algo = enums.read(enums.symmetric, ciphe... | javascript | {
"resource": ""
} |
q22448 | emailCheck | train | function emailCheck(email, key) {
email = email.toLowerCase();
// escape email before using in regular expression
const emailEsc = email.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const emailRegex = new RegExp('<' + emailEsc + '>');
const userIds = key.getUserIds();
for (let i = 0; i < userIds.length; i++) {
... | javascript | {
"resource": ""
} |
q22449 | keyIdCheck | train | function keyIdCheck(keyId, key) {
if (keyId.length === 16) {
return keyId === key.getKeyId().toHex();
}
return keyId === key.getFingerprint();
} | javascript | {
"resource": ""
} |
q22450 | write_sub_packet | train | function write_sub_packet(type, data) {
const arr = [];
arr.push(packet.writeSimpleLength(data.length + 1));
arr.push(new Uint8Array([type]));
arr.push(data);
return util.concat(arr);
} | javascript | {
"resource": ""
} |
q22451 | f1 | train | function f1(d, m, r) {
const t = m + d;
const I = (t << r) | (t >>> (32 - r));
return ((sBox[0][I >>> 24] ^ sBox[1][(I >>> 16) & 255]) - sBox[2][(I >>> 8) & 255]) + sBox[3][I & 255];
} | javascript | {
"resource": ""
} |
q22452 | decode | train | function decode(msg) {
const len = msg.length;
if (len > 0) {
const c = msg.charCodeAt(len - 1);
if (c >= 1 && c <= 8) {
const provided = msg.substr(len - c);
const computed = String.fromCharCode(c).repeat(c);
if (provided === computed) {
return msg.substr(0, len - c);
}
... | javascript | {
"resource": ""
} |
q22453 | train | function(batchSizeOrIteratee, iteratee) {
assert(this._wlQueryInfo.method === 'stream', 'Cannot chain `.eachBatch()` onto the `.'+this._wlQueryInfo.method+'()` method. The `.eachBatch()` method is only chainable to `.stream()`. (In fact, this shouldn\'t even be possible! So the fact that you are seeing this mess... | javascript | {
"resource": ""
} | |
q22454 | train | function(values) {
if (this._wlQueryInfo.method === 'create') {
console.warn(
'Deprecation warning: In future versions of Waterline, the use of .set() with .create()\n'+
'will no longer be supported. In the past, you could use .set() to provide the initial\n'+
'skeleton of a new reco... | javascript | {
"resource": ""
} | |
q22455 | train | function(limit) {
if (!this._alreadyInitiallyExpandedCriteria) {
this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
this._alreadyInitiallyExpandedCriteria = true;
}//>-
this._wlQueryInfo.criteria.limit = limit;
return this;
} | javascript | {
"resource": ""
} | |
q22456 | train | function(skip) {
if (!this._alreadyInitiallyExpandedCriteria) {
this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
this._alreadyInitiallyExpandedCriteria = true;
}//>-
this._wlQueryInfo.criteria.skip = skip;
return this;
} | javascript | {
"resource": ""
} | |
q22457 | train | function(sortClause) {
if (!this._alreadyInitiallyExpandedCriteria) {
this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
this._alreadyInitiallyExpandedCriteria = true;
}//>-
this._wlQueryInfo.criteria.sort = sortClause;
return this;
} | javascript | {
"resource": ""
} | |
q22458 | train | function(selectAttributes) {
if (!this._alreadyInitiallyExpandedCriteria) {
this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
this._alreadyInitiallyExpandedCriteria = true;
}//>-
this._wlQueryInfo.criteria.select = selectAttributes;
return this;
} | javascript | {
"resource": ""
} | |
q22459 | train | function(omitAttributes) {
if (!this._alreadyInitiallyExpandedCriteria) {
this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
this._alreadyInitiallyExpandedCriteria = true;
}//>-
this._wlQueryInfo.criteria.omit = omitAttributes;
return this;
} | javascript | {
"resource": ""
} | |
q22460 | train | function(whereCriteria) {
if (!this._alreadyInitiallyExpandedCriteria) {
this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
this._alreadyInitiallyExpandedCriteria = true;
}//>-
this._wlQueryInfo.criteria.where = whereCriteria;
return this;
} | javascript | {
"resource": ""
} | |
q22461 | extend | train | function extend(obj, props) {
for (var i in props) {
obj[i] = props[i];
}
return obj;
} | javascript | {
"resource": ""
} |
q22462 | isNamedNode | train | function isNamedNode(node, nodeName) {
return node.normalizedNodeName === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase();
} | javascript | {
"resource": ""
} |
q22463 | createNode | train | function createNode(nodeName, isSvg) {
var node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);
node.normalizedNodeName = nodeName;
return node;
} | javascript | {
"resource": ""
} |
q22464 | eventProxy | train | function eventProxy(e) {
return this._listeners[e.type]((options.event && options.event(e)) || e);
} | javascript | {
"resource": ""
} |
q22465 | collectComponent | train | function collectComponent(component) {
var name = component.constructor.name;
(components[name] || (components[name] = [])).push(component);
} | javascript | {
"resource": ""
} |
q22466 | createComponent | train | function createComponent(Ctor, props, context) {
var list = components[Ctor.name],
inst;
if (Ctor.prototype && Ctor.prototype.render) {
inst = new Ctor(props, context);
Component.call(inst, props, context);
} else {
inst = new Component(props, context);
inst.constructor = Ctor... | javascript | {
"resource": ""
} |
q22467 | buildComponentFromVNode | train | function buildComponentFromVNode(dom, vnode, context, mountAll) {
var c = dom && dom._component,
originalComponent = c,
oldDom = dom,
isDirectOwner = c && dom._componentConstructor === vnode.nodeName,
isOwner = isDirectOwner,
props = getNodeProps(vnode);
while (c && !isOwner && (c ... | javascript | {
"resource": ""
} |
q22468 | unmountComponent | train | function unmountComponent(component) {
if (options.beforeUnmount) options.beforeUnmount(component);
var base = component.base;
component._disable = true;
if (component.componentWillUnmount) component.componentWillUnmount();
component.base = null;
// recursively tear down & recollect high-or... | javascript | {
"resource": ""
} |
q22469 | setState | train | function setState(state, callback) {
var s = this.state;
if (!this.prevState) this.prevState = extend({}, s);
extend(s, typeof state === 'function' ? state(s, this.props) : state);
if (callback) (this._renderCallbacks = this._renderCallbacks || []).push(callback);
enqueueRender(this);
... | javascript | {
"resource": ""
} |
q22470 | linkState | train | function linkState(component, key, eventPath) {
var path = key.split('.'),
cache = component.__lsc || (component.__lsc = {});
return (
cache[key + eventPath] ||
(cache[key + eventPath] = function(e) {
var t = (e && e.target) || this,
state = {},
obj = state,
... | javascript | {
"resource": ""
} |
q22471 | pagesCount | train | function pagesCount() {
var quotient = Math.floor(this.total / this.currentPerPage);
var remainder = this.total % this.currentPerPage;
return remainder === 0 ? quotient : quotient + 1;
} | javascript | {
"resource": ""
} |
q22472 | paginatedInfo | train | function paginatedInfo() {
var first = (this.currentPage - 1) * this.currentPerPage + 1;
var last = Math.min(this.total, this.currentPage * this.currentPerPage);
if (last === 0) {
first = 0;
}
return "".concat(first, " - ").concat(last, " ").concat(this.ofText, " ").concat(this.t... | javascript | {
"resource": ""
} |
q22473 | changePage | train | function changePage(pageNumber) {
var emit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (pageNumber > 0 && this.total > this.currentPerPage * (pageNumber - 1)) {
this.prevPage = this.currentPage;
this.currentPage = pageNumber;
if (emit) this.pageCha... | javascript | {
"resource": ""
} |
q22474 | handlePerPage | train | function handlePerPage() {
//* if there's a custom dropdown then we use that
if (this.customRowsPerPageDropdown !== null && Array.isArray(this.customRowsPerPageDropdown) && this.customRowsPerPageDropdown.length !== 0) {
this.rowsPerPageOptions = this.customRowsPerPageDropdown;
} else {
... | javascript | {
"resource": ""
} |
q22475 | hasFilterRow | train | function hasFilterRow() {
// if (this.mode === 'remote' || !this.globalSearchEnabled) {
for (var i = 0; i < this.columns.length; i++) {
var col = this.columns[i];
if (col.filterOptions && col.filterOptions.enabled) {
return true;
}
} // }
return false;
} | javascript | {
"resource": ""
} |
q22476 | getPlaceholder | train | function getPlaceholder(column) {
var placeholder = this.isFilterable(column) && column.filterOptions.placeholder || "Filter ".concat(column.label);
return placeholder;
} | javascript | {
"resource": ""
} |
q22477 | updateFilters | train | function updateFilters(column, value) {
var _this = this;
if (this.timer) clearTimeout(this.timer);
this.timer = setTimeout(function () {
_this.updateFiltersImmediately(column, value);
}, 400);
} | javascript | {
"resource": ""
} |
q22478 | onCheckboxClicked | train | function onCheckboxClicked(row, index$$1, event) {
this.$set(row, 'vgtSelected', !row.vgtSelected);
this.$emit('on-row-click', {
row: row,
pageIndex: index$$1,
selected: !!row.vgtSelected,
event: event
});
} | javascript | {
"resource": ""
} |
q22479 | dig | train | function dig(obj, selector) {
var result = obj;
var splitter = selector.split('.');
for (var i = 0; i < splitter.length; i++) {
if (typeof result === 'undefined' || result === null) {
return undefined;
}
result = result[splitter[i]];
}
... | javascript | {
"resource": ""
} |
q22480 | isSortableColumn | train | function isSortableColumn(index$$1) {
var sortable = this.columns[index$$1].sortable;
var isSortable = typeof sortable === 'boolean' ? sortable : this.sortable;
return isSortable;
} | javascript | {
"resource": ""
} |
q22481 | getClasses | train | function getClasses(index$$1, element, row) {
var _this$typedColumns$in = this.typedColumns[index$$1],
typeDef = _this$typedColumns$in.typeDef,
custom = _this$typedColumns$in["".concat(element, "Class")];
var isRight = typeDef.isRight;
if (this.rtl) isRight = true;
var class... | javascript | {
"resource": ""
} |
q22482 | filterRows | train | function filterRows(columnFilters) {
var _this4 = this;
var fromFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
// if (!this.rows.length) return;
// this is invoked either as a result of changing filters
// or as a result of modifying rows.
this.co... | javascript | {
"resource": ""
} |
q22483 | findRushJsonFolder | train | function findRushJsonFolder() {
if (!_rushJsonFolder) {
let basePath = __dirname;
let tempPath = __dirname;
do {
const testRushJsonPath = path.join(basePath, exports.RUSH_JSON_FILENAME);
if (fs.existsSync(testRushJsonPath)) {
_rushJsonFolder = basePath... | javascript | {
"resource": ""
} |
q22484 | ensureAndJoinPath | train | function ensureAndJoinPath(baseFolder, ...pathSegments) {
let joinedPath = baseFolder;
try {
for (let pathSegment of pathSegments) {
pathSegment = pathSegment.replace(/[\\\/]/g, '+');
joinedPath = path.join(joinedPath, pathSegment);
if (!fs.existsSync(joinedPath)) {
... | javascript | {
"resource": ""
} |
q22485 | isPackageAlreadyInstalled | train | function isPackageAlreadyInstalled(packageInstallFolder) {
try {
const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);
if (!fs.existsSync(flagFilePath)) {
return false;
}
const fileContents = fs.readFileSync(flagFilePath).toString();
retur... | javascript | {
"resource": ""
} |
q22486 | installPackage | train | function installPackage(packageInstallFolder, name, version) {
try {
console.log(`Installing ${name}...`);
const npmPath = getNpmPath();
const result = childProcess.spawnSync(npmPath, ['install'], {
stdio: 'inherit',
cwd: packageInstallFolder,
env: process... | javascript | {
"resource": ""
} |
q22487 | getBinPath | train | function getBinPath(packageInstallFolder, binName) {
const binFolderPath = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin');
const resolvedBinName = (os.platform() === 'win32') ? `${binName}.cmd` : binName;
return path.resolve(binFolderPath, resolvedBinName);
} | javascript | {
"resource": ""
} |
q22488 | writeFlagFile | train | function writeFlagFile(packageInstallFolder) {
try {
const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);
fs.writeFileSync(flagFilePath, process.version);
}
catch (e) {
throw new Error(`Unable to create installed.flag file in ${packageInstallFolder}`);
}... | javascript | {
"resource": ""
} |
q22489 | addMessage | train | function addMessage(from, target, text, time) {
var name = (target == '*' ? 'all' : target);
if(text === null) return;
if(time == null) {
// if the time is null or undefined, use the current time.
time = new Date();
} else if((time instanceof Date) === false) {
// if it's a timestamp, interpret it
time = ne... | javascript | {
"resource": ""
} |
q22490 | initUserList | train | function initUserList(data) {
users = data.users;
for(var i = 0; i < users.length; i++) {
var slElement = $(document.createElement("option"));
slElement.attr("value", users[i]);
slElement.text(users[i]);
$("#usersList").append(slElement);
}
} | javascript | {
"resource": ""
} |
q22491 | addUser | train | function addUser(user) {
var slElement = $(document.createElement("option"));
slElement.attr("value", user);
slElement.text(user);
$("#usersList").append(slElement);
} | javascript | {
"resource": ""
} |
q22492 | markPercentagesForRecord | train | function markPercentagesForRecord(record)
{
if (!(this._showShortEvents || record.isLong()))
return;
var percentages = this._overviewCalculator.computeBarGraphPercentages(record);
var end = Math.round(percentages.end);
var categoryName = record.ca... | javascript | {
"resource": ""
} |
q22493 | train | function(data) {
if(!data || !data.sys) {
return;
}
dict = data.sys.dict;
var protos = data.sys.protos;
//Init compress dict
if(dict) {
dict = dict;
abbrs = {};
for(var route in dict) {
abbrs[dict[route]] = route;
}
}
//Init protobuf protos
if... | javascript | {
"resource": ""
} | |
q22494 | forwardWheelEvent | train | function forwardWheelEvent(event)
{
var clone = document.createEvent("WheelEvent");
clone.initWebKitWheelEvent(event.wheelDeltaX, event.wheelDeltaY,
event.view,
event.screenX, event.screenY,
even... | javascript | {
"resource": ""
} |
q22495 | train | function(oldRange, newRange, oldText, newText)
{
if (!this._internalTextChangeMode)
this._textModel.resetUndoStack();
this._mainPanel.textChanged(oldRange, newRange);
this._gutterPanel.textChanged(oldRange, newRange);
this._updatePanelOffsets();
} | javascript | {
"resource": ""
} | |
q22496 | train | function(data){
if(!data || !data.sys) {
return;
}
pinus.data = pinus.data || {};
var dict = data.sys.dict;
var protos = data.sys.protos;
//Init compress dict
if(dict){
pinus.data.dict = dict;
pinus.data.abbrs = {};
for(var route in dict){
pinus.data.abbrs[d... | javascript | {
"resource": ""
} | |
q22497 | train | function(text)
{
if (this._uncommittedIsTop) {
this._data.pop();
delete this._uncommittedIsTop;
}
this._historyOffset = 1;
if (this._coalesceHistoryDupes && text === this._currentHistoryItem())
return;
this._data.push(text);
} | javascript | {
"resource": ""
} | |
q22498 | calc_screen_size | train | function calc_screen_size(scount) {
if (!scount) { scount = $("#screens .screen").length; }
var ssize = (($(window).height() - bottom_height - 20) / scount)
- (bar_height + 53);
return ssize;
} | javascript | {
"resource": ""
} |
q22499 | SocketNamespace | train | function SocketNamespace (socket, name) {
this.socket = socket;
this.name = name || '';
this.flags = {};
this.json = new Flag(this, 'json');
this.ackPackets = 0;
this.acks = {};
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.