repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
Leaflet/Leaflet.markercluster
src/MarkerCluster.Spiderfier.js
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
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...
[ "function", "(", "layer", ")", "{", "if", "(", "layer", ".", "_spiderLeg", ")", "{", "this", ".", "_featureGroup", ".", "removeLayer", "(", "layer", ")", ";", "if", "(", "layer", ".", "clusterShow", ")", "{", "layer", ".", "clusterShow", "(", ")", ";...
If the given layer is currently being spiderfied then we unspiderfy it so it isn't on the map anymore etc
[ "If", "the", "given", "layer", "is", "currently", "being", "spiderfied", "then", "we", "unspiderfy", "it", "so", "it", "isn", "t", "on", "the", "map", "anymore", "etc" ]
93bf5408ad84b74ea42f55ccb6ca0450daa41427
https://github.com/Leaflet/Leaflet.markercluster/blob/93bf5408ad84b74ea42f55ccb6ca0450daa41427/src/MarkerCluster.Spiderfier.js#L461-L476
train
Leaflet/Leaflet.markercluster
src/DistanceGrid.js
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
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] =...
[ "function", "(", "obj", ",", "point", ")", "{", "var", "x", "=", "this", ".", "_getCoord", "(", "point", ".", "x", ")", ",", "y", "=", "this", ".", "_getCoord", "(", "point", ".", "y", ")", ",", "grid", "=", "this", ".", "_grid", ",", "row", ...
Returns true if the object was found
[ "Returns", "true", "if", "the", "object", "was", "found" ]
93bf5408ad84b74ea42f55ccb6ca0450daa41427
https://github.com/Leaflet/Leaflet.markercluster/blob/93bf5408ad84b74ea42f55ccb6ca0450daa41427/src/DistanceGrid.js#L30-L53
train
bitpay/cordova-plugin-qrscanner
src/common/src/createQRScannerAdapter.js
clearBackground
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
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...
[ "function", "clearBackground", "(", ")", "{", "var", "body", "=", "document", ".", "body", ";", "if", "(", "body", ".", "style", ")", "{", "body", ".", "style", ".", "backgroundColor", "=", "'rgba(0,0,0,0.01)'", ";", "body", ".", "style", ".", "backgroun...
Simple utility method to ensure the background is transparent. Used by the plugin to force re-rendering immediately after the native webview background is made transparent.
[ "Simple", "utility", "method", "to", "ensure", "the", "background", "is", "transparent", ".", "Used", "by", "the", "plugin", "to", "force", "re", "-", "rendering", "immediately", "after", "the", "native", "webview", "background", "is", "made", "transparent", "...
b62efb64801ba0b830f0aac556935c0978d2fb98
https://github.com/bitpay/cordova-plugin-qrscanner/blob/b62efb64801ba0b830f0aac556935c0978d2fb98/src/common/src/createQRScannerAdapter.js#L36-L49
train
bitpay/cordova-plugin-qrscanner
src/browser/src/createQRScannerInternal.js
getCameraSpecsById
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
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}; ...
[ "function", "getCameraSpecsById", "(", "deviceId", ")", "{", "// return a getUserMedia Constraints", "function", "getConstraintObj", "(", "deviceId", ",", "facingMode", ",", "width", ",", "height", ")", "{", "var", "obj", "=", "{", "audio", ":", "false", ",", "v...
For performance, we test best-to-worst constraints. Once we find a match, we move to the next test. Since `ConstraintNotSatisfiedError`s are thrown much faster than streams can be started and stopped, the scan is much faster, even though it may iterate through more constraint objects.
[ "For", "performance", "we", "test", "best", "-", "to", "-", "worst", "constraints", ".", "Once", "we", "find", "a", "match", "we", "move", "to", "the", "next", "test", ".", "Since", "ConstraintNotSatisfiedError", "s", "are", "thrown", "much", "faster", "th...
b62efb64801ba0b830f0aac556935c0978d2fb98
https://github.com/bitpay/cordova-plugin-qrscanner/blob/b62efb64801ba0b830f0aac556935c0978d2fb98/src/browser/src/createQRScannerInternal.js#L51-L129
train
bitpay/cordova-plugin-qrscanner
src/browser/src/createQRScannerInternal.js
getConstraintObj
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
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...
[ "function", "getConstraintObj", "(", "deviceId", ",", "facingMode", ",", "width", ",", "height", ")", "{", "var", "obj", "=", "{", "audio", ":", "false", ",", "video", ":", "{", "}", "}", ";", "obj", ".", "video", ".", "deviceId", "=", "{", "exact", ...
return a getUserMedia Constraints
[ "return", "a", "getUserMedia", "Constraints" ]
b62efb64801ba0b830f0aac556935c0978d2fb98
https://github.com/bitpay/cordova-plugin-qrscanner/blob/b62efb64801ba0b830f0aac556935c0978d2fb98/src/browser/src/createQRScannerInternal.js#L54-L67
train
bitpay/cordova-plugin-qrscanner
src/browser/src/createQRScannerInternal.js
getFirstResolvingConstraint
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
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)...
[ "function", "getFirstResolvingConstraint", "(", "constraintsBestToWorst", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolveBestConstraints", ")", "{", "// build a chain of promises which either resolves or continues searching", "return", "constraintsBestToWorst",...
create a promise which tries to resolve the best constraints for this deviceId rather than reject, failures return a value of `null`
[ "create", "a", "promise", "which", "tries", "to", "resolve", "the", "best", "constraints", "for", "this", "deviceId", "rather", "than", "reject", "failures", "return", "a", "value", "of", "null" ]
b62efb64801ba0b830f0aac556935c0978d2fb98
https://github.com/bitpay/cordova-plugin-qrscanner/blob/b62efb64801ba0b830f0aac556935c0978d2fb98/src/browser/src/createQRScannerInternal.js#L81-L115
train
openpgpjs/openpgpjs
src/openpgp.js
convertStream
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
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...
[ "async", "function", "convertStream", "(", "data", ",", "streaming", ")", "{", "if", "(", "!", "streaming", "&&", "util", ".", "isStream", "(", "data", ")", ")", "{", "return", "stream", ".", "readToEnd", "(", "data", ")", ";", "}", "if", "(", "strea...
Convert data to or from Stream @param {Object} data the data to convert @param {'web'|'node'|false} streaming (optional) whether to return a ReadableStream @returns {Object} the data in the respective format
[ "Convert", "data", "to", "or", "from", "Stream" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/openpgp.js#L622-L638
train
openpgpjs/openpgpjs
src/openpgp.js
convertStreams
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
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...
[ "async", "function", "convertStreams", "(", "obj", ",", "streaming", ",", "keys", "=", "[", "]", ")", "{", "if", "(", "Object", ".", "prototype", ".", "isPrototypeOf", "(", "obj", ")", "&&", "!", "Uint8Array", ".", "prototype", ".", "isPrototypeOf", "(",...
Convert object properties from Stream @param {Object} obj the data to convert @param {'web'|'node'|false} streaming (optional) whether to return ReadableStreams @param {Array<String>} keys (optional) which keys to return as streams, if possible @returns {Object} t...
[ "Convert", "object", "properties", "from", "Stream" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/openpgp.js#L647-L658
train
openpgpjs/openpgpjs
src/openpgp.js
linkStreams
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
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...
[ "function", "linkStreams", "(", "result", ",", "message", ",", "erroringStream", ")", "{", "result", ".", "data", "=", "stream", ".", "transformPair", "(", "message", ".", "packets", ".", "stream", ",", "async", "(", "readable", ",", "writable", ")", "=>",...
Link result.data to the message stream for cancellation. Also, forward errors in the message to result.data. @param {Object} result the data to convert @param {Message} message message object @param {ReadableStream} erroringStream (optional) stream which either errors or gets closed ...
[ "Link", "result", ".", "data", "to", "the", "message", "stream", "for", "cancellation", ".", "Also", "forward", "errors", "in", "the", "message", "to", "result", ".", "data", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/openpgp.js#L668-L682
train
openpgpjs/openpgpjs
src/openpgp.js
prepareSignatures
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
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...
[ "async", "function", "prepareSignatures", "(", "signatures", ")", "{", "await", "Promise", ".", "all", "(", "signatures", ".", "map", "(", "async", "signature", "=>", "{", "signature", ".", "signature", "=", "await", "signature", ".", "signature", ";", "try"...
Wait until signature objects have been verified @param {Object} signatures list of signatures
[ "Wait", "until", "signature", "objects", "have", "been", "verified" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/openpgp.js#L688-L699
train
openpgpjs/openpgpjs
src/openpgp.js
onError
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
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; }
[ "function", "onError", "(", "message", ",", "error", ")", "{", "// log the stack trace", "util", ".", "print_debug_error", "(", "error", ")", ";", "// update error message", "try", "{", "error", ".", "message", "=", "message", "+", "': '", "+", "error", ".", ...
Global error handler that logs the stack trace and rethrows a high lvl error message. @param {String} message A human readable high level error Message @param {Error} error The internal error that caused the failure
[ "Global", "error", "handler", "that", "logs", "the", "stack", "trace", "and", "rethrows", "a", "high", "lvl", "error", "message", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/openpgp.js#L707-L717
train
openpgpjs/openpgpjs
src/openpgp.js
nativeAEAD
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
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()) ); }
[ "function", "nativeAEAD", "(", ")", "{", "return", "config", ".", "aead_protect", "&&", "(", "(", "(", "config", ".", "aead_protect_version", "!==", "4", "||", "config", ".", "aead_mode", "===", "enums", ".", "aead", ".", "experimental_gcm", ")", "&&", "ut...
Check for native AEAD support and configuration by the user. Only browsers that implement the current WebCrypto specification support native GCM. Native EAX is built on CTR and CBC, which current browsers support. OCB and CFB are not natively supported. @returns {Boolean} If authenticated encryption should be used
[ "Check", "for", "native", "AEAD", "support", "and", "configuration", "by", "the", "user", ".", "Only", "browsers", "that", "implement", "the", "current", "WebCrypto", "specification", "support", "native", "GCM", ".", "Native", "EAX", "is", "built", "on", "CTR"...
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/openpgp.js#L726-L731
train
openpgpjs/openpgpjs
src/crypto/public_key/rsa.js
promisifyIE11Op
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
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); }; ...
[ "function", "promisifyIE11Op", "(", "keyObj", ",", "err", ")", "{", "if", "(", "typeof", "keyObj", ".", "then", "!==", "'function'", ")", "{", "// IE11 KeyOperation", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "ke...
Helper for IE11 KeyOperation objects
[ "Helper", "for", "IE11", "KeyOperation", "objects" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/public_key/rsa.js#L35-L47
train
openpgpjs/openpgpjs
src/crypto/public_key/rsa.js
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
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;...
[ "async", "function", "(", "m", ",", "n", ",", "e", ",", "d", ",", "p", ",", "q", ",", "u", ")", "{", "if", "(", "n", ".", "cmp", "(", "m", ")", "<=", "0", ")", "{", "throw", "new", "Error", "(", "'Data too large.'", ")", ";", "}", "const", ...
Decrypt RSA message @param {BN} m message @param {BN} n RSA public modulus @param {BN} e RSA public exponent @param {BN} d RSA private exponent @param {BN} p RSA private prime p @param {BN} q RSA private prime q @param {BN} u RSA private inverse of prime q @returns {BN} RSA Plaintext @async
[ "Decrypt", "RSA", "message" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/public_key/rsa.js#L110-L140
train
openpgpjs/openpgpjs
src/crypto/public_key/rsa.js
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
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 ...
[ "async", "function", "(", "B", ",", "E", ")", "{", "let", "key", ";", "E", "=", "new", "BN", "(", "E", ",", "16", ")", ";", "const", "webCrypto", "=", "util", ".", "getWebCryptoAll", "(", ")", ";", "// Native RSA keygen using Web Crypto", "if", "(", ...
Generate a new random private key B bits long with public exponent E. When possible, webCrypto is used. Otherwise, primes are generated using 40 rounds of the Miller-Rabin probabilistic random prime generation algorithm. @see module:crypto/public_key/prime @param {Integer} B RSA bit length @param {String} E RSA publi...
[ "Generate", "a", "new", "random", "private", "key", "B", "bits", "long", "with", "public", "exponent", "E", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/public_key/rsa.js#L155-L233
train
openpgpjs/openpgpjs
src/crypto/cipher/des.js
DES
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
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...
[ "function", "DES", "(", "key", ")", "{", "this", ".", "key", "=", "key", ";", "this", ".", "encrypt", "=", "function", "(", "block", ",", "padding", ")", "{", "const", "keys", "=", "des_createKeys", "(", "this", ".", "key", ")", ";", "return", "des...
This is "original" DES
[ "This", "is", "original", "DES" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/cipher/des.js#L462-L474
train
openpgpjs/openpgpjs
src/crypto/crypto.js
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
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...
[ "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)...
Returns the types comprising the private key of an algorithm @param {String} algo The public key algorithm @returns {Array<String>} The array of types
[ "Returns", "the", "types", "comprising", "the", "private", "key", "of", "an", "algorithm" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/crypto.js#L154-L182
train
openpgpjs/openpgpjs
src/crypto/crypto.js
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
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...
[ "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", ".", "pu...
Returns the types comprising the encrypted session key of an algorithm @param {String} algo The public key algorithm @returns {Array<String>} The array of types
[ "Returns", "the", "types", "comprising", "the", "encrypted", "session", "key", "of", "an", "algorithm" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/crypto.js#L231-L252
train
openpgpjs/openpgpjs
src/crypto/crypto.js
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
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...
[ "function", "(", "algo", ",", "bits", ",", "oid", ")", "{", "const", "types", "=", "[", "]", ".", "concat", "(", "this", ".", "getPubKeyParamTypes", "(", "algo", ")", ",", "this", ".", "getPrivKeyParamTypes", "(", "algo", ")", ")", ";", "switch", "("...
Generate algorithm-specific key parameters @param {String} algo The public key algorithm @param {Integer} bits Bit length for RSA keys @param {module:type/oid} oid Object identifier for ECC keys @returns {Array} The array of parameters @async
[ "Generate", "algorithm", "-", "specific", "key", "parameters" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/crypto.js#L261-L288
train
openpgpjs/openpgpjs
src/crypto/eax.js
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
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...
[ "async", "function", "(", "plaintext", ",", "nonce", ",", "adata", ")", "{", "const", "[", "omacNonce", ",", "omacAdata", "]", "=", "await", "Promise", ".", "all", "(", "[", "omac", "(", "zero", ",", "nonce", ")", ",", "omac", "(", "one", ",", "ada...
Encrypt plaintext input. @param {Uint8Array} plaintext The cleartext input to be encrypted @param {Uint8Array} nonce The nonce (16 bytes) @param {Uint8Array} adata Associated data to sign @returns {Promise<Uint8Array>} The ciphertext output
[ "Encrypt", "plaintext", "input", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/eax.js#L106-L121
train
openpgpjs/openpgpjs
src/worker/worker.js
randomCallback
function randomCallback() { if (!randomQueue.length) { self.postMessage({ event: 'request-seed', amount: MAX_SIZE_RANDOM_BUFFER }); } return new Promise(function(resolve) { randomQueue.push(resolve); }); }
javascript
function randomCallback() { if (!randomQueue.length) { self.postMessage({ event: 'request-seed', amount: MAX_SIZE_RANDOM_BUFFER }); } return new Promise(function(resolve) { randomQueue.push(resolve); }); }
[ "function", "randomCallback", "(", ")", "{", "if", "(", "!", "randomQueue", ".", "length", ")", "{", "self", ".", "postMessage", "(", "{", "event", ":", "'request-seed'", ",", "amount", ":", "MAX_SIZE_RANDOM_BUFFER", "}", ")", ";", "}", "return", "new", ...
Handle random buffer exhaustion by requesting more random bytes from the main window @returns {Promise<Object>} Empty promise whose resolution indicates that the buffer has been refilled
[ "Handle", "random", "buffer", "exhaustion", "by", "requesting", "more", "random", "bytes", "from", "the", "main", "window" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/worker/worker.js#L43-L52
train
openpgpjs/openpgpjs
src/worker/worker.js
configure
function configure(config) { Object.keys(config).forEach(function(key) { openpgp.config[key] = config[key]; }); }
javascript
function configure(config) { Object.keys(config).forEach(function(key) { openpgp.config[key] = config[key]; }); }
[ "function", "configure", "(", "config", ")", "{", "Object", ".", "keys", "(", "config", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "openpgp", ".", "config", "[", "key", "]", "=", "config", "[", "key", "]", ";", "}", ")", ";", "}"...
Set config from main context to worker context. @param {Object} config The openpgp configuration
[ "Set", "config", "from", "main", "context", "to", "worker", "context", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/worker/worker.js#L88-L92
train
openpgpjs/openpgpjs
src/worker/worker.js
seedRandom
function seedRandom(buffer) { if (!(buffer instanceof Uint8Array)) { buffer = new Uint8Array(buffer); } openpgp.crypto.random.randomBuffer.set(buffer); }
javascript
function seedRandom(buffer) { if (!(buffer instanceof Uint8Array)) { buffer = new Uint8Array(buffer); } openpgp.crypto.random.randomBuffer.set(buffer); }
[ "function", "seedRandom", "(", "buffer", ")", "{", "if", "(", "!", "(", "buffer", "instanceof", "Uint8Array", ")", ")", "{", "buffer", "=", "new", "Uint8Array", "(", "buffer", ")", ";", "}", "openpgp", ".", "crypto", ".", "random", ".", "randomBuffer", ...
Seed the library with entropy gathered window.crypto.getRandomValues as this api is only avalible in the main window. @param {ArrayBuffer} buffer Some random bytes
[ "Seed", "the", "library", "with", "entropy", "gathered", "window", ".", "crypto", ".", "getRandomValues", "as", "this", "api", "is", "only", "avalible", "in", "the", "main", "window", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/worker/worker.js#L99-L104
train
openpgpjs/openpgpjs
src/worker/worker.js
delegate
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
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...
[ "function", "delegate", "(", "id", ",", "method", ",", "options", ")", "{", "if", "(", "typeof", "openpgp", "[", "method", "]", "!==", "'function'", ")", "{", "response", "(", "{", "id", ":", "id", ",", "event", ":", "'method-return'", ",", "err", ":...
Generic proxy function that handles all commands from the public api. @param {String} method The public api function to be delegated to the worker thread @param {Object} options The api function's options
[ "Generic", "proxy", "function", "that", "handles", "all", "commands", "from", "the", "public", "api", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/worker/worker.js#L111-L129
train
openpgpjs/openpgpjs
src/worker/worker.js
response
function response(event) { self.postMessage(event, openpgp.util.getTransferables(event.data, true)); }
javascript
function response(event) { self.postMessage(event, openpgp.util.getTransferables(event.data, true)); }
[ "function", "response", "(", "event", ")", "{", "self", ".", "postMessage", "(", "event", ",", "openpgp", ".", "util", ".", "getTransferables", "(", "event", ".", "data", ",", "true", ")", ")", ";", "}" ]
Respond to the main window. @param {Object} event Contains event type and data
[ "Respond", "to", "the", "main", "window", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/worker/worker.js#L135-L137
train
openpgpjs/openpgpjs
src/keyring/localstore.js
LocalStore
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
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...
[ "function", "LocalStore", "(", "prefix", ")", "{", "prefix", "=", "prefix", "||", "'openpgp-'", ";", "this", ".", "publicKeysItem", "=", "prefix", "+", "this", ".", "publicKeysItem", ";", "this", ".", "privateKeysItem", "=", "prefix", "+", "this", ".", "pr...
The class that deals with storage of the keyring. Currently the only option is to use HTML5 local storage. @constructor @param {String} prefix prefix for itemnames in localstore
[ "The", "class", "that", "deals", "with", "storage", "of", "the", "keyring", ".", "Currently", "the", "only", "option", "is", "to", "use", "HTML5", "local", "storage", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/keyring/localstore.js#L38-L47
train
openpgpjs/openpgpjs
src/hkp.js
HKP
function HKP(keyServerBaseUrl) { this._baseUrl = keyServerBaseUrl || config.keyserver; this._fetch = typeof window !== 'undefined' ? window.fetch : require('node-fetch'); }
javascript
function HKP(keyServerBaseUrl) { this._baseUrl = keyServerBaseUrl || config.keyserver; this._fetch = typeof window !== 'undefined' ? window.fetch : require('node-fetch'); }
[ "function", "HKP", "(", "keyServerBaseUrl", ")", "{", "this", ".", "_baseUrl", "=", "keyServerBaseUrl", "||", "config", ".", "keyserver", ";", "this", ".", "_fetch", "=", "typeof", "window", "!==", "'undefined'", "?", "window", ".", "fetch", ":", "require", ...
Initialize the HKP client and configure it with the key server url and fetch function. @constructor @param {String} keyServerBaseUrl (optional) The HKP key server base url including the protocol to use, e.g. 'https://pgp.mit.edu'; defaults to openpgp.config.keyserver (https://keyserver.ubuntu.com)
[ "Initialize", "the", "HKP", "client", "and", "configure", "it", "with", "the", "key", "server", "url", "and", "fetch", "function", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/hkp.js#L33-L36
train
openpgpjs/openpgpjs
src/crypto/pkcs1.js
getPkcs1Padding
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
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]); } ...
[ "async", "function", "getPkcs1Padding", "(", "length", ")", "{", "let", "result", "=", "''", ";", "while", "(", "result", ".", "length", "<", "length", ")", "{", "const", "randomBytes", "=", "await", "random", ".", "getRandomBytes", "(", "length", "-", "...
Create padding with secure random data @private @param {Integer} length Length of the padding in bytes @returns {String} Padding as string @async
[ "Create", "padding", "with", "secure", "random", "data" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/pkcs1.js#L63-L74
train
openpgpjs/openpgpjs
src/crypto/random.js
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
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...
[ "async", "function", "(", "length", ")", "{", "const", "buf", "=", "new", "Uint8Array", "(", "length", ")", ";", "if", "(", "typeof", "window", "!==", "'undefined'", "&&", "window", ".", "crypto", "&&", "window", ".", "crypto", ".", "getRandomValues", ")...
Retrieve secure random byte array of the specified length @param {Integer} length Length in bytes to generate @returns {Uint8Array} Random byte array @async
[ "Retrieve", "secure", "random", "byte", "array", "of", "the", "specified", "length" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/random.js#L40-L55
train
openpgpjs/openpgpjs
src/crypto/random.js
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
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...
[ "async", "function", "(", "min", ",", "max", ")", "{", "if", "(", "max", ".", "cmp", "(", "min", ")", "<=", "0", ")", "{", "throw", "new", "Error", "(", "'Illegal parameter value: max <= min'", ")", ";", "}", "const", "modulus", "=", "max", ".", "sub...
Create a secure random MPI that is greater than or equal to min and less than max. @param {module:type/mpi} min Lower bound, included @param {module:type/mpi} max Upper bound, excluded @returns {module:BN} Random MPI @async
[ "Create", "a", "secure", "random", "MPI", "that", "is", "greater", "than", "or", "equal", "to", "min", "and", "less", "than", "max", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/random.js#L64-L77
train
openpgpjs/openpgpjs
src/cleartext.js
verifyHeaders
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
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...
[ "function", "verifyHeaders", "(", "headers", ",", "packetlist", ")", "{", "const", "checkHashAlgos", "=", "function", "(", "hashAlgos", ")", "{", "const", "check", "=", "packet", "=>", "algo", "=>", "packet", ".", "hashAlgorithm", "===", "algo", ";", "for", ...
Compare hash algorithm specified in the armor header with signatures @param {Array<String>} headers Armor headers @param {module:packet.List} packetlist The packetlist with signature packets @private
[ "Compare", "hash", "algorithm", "specified", "in", "the", "armor", "header", "with", "signatures" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/cleartext.js#L173-L211
train
openpgpjs/openpgpjs
src/message.js
createVerificationObject
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
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...
[ "async", "function", "createVerificationObject", "(", "signature", ",", "literalDataList", ",", "keys", ",", "date", "=", "new", "Date", "(", ")", ")", "{", "let", "primaryKey", "=", "null", ";", "let", "signingKey", "=", "null", ";", "await", "Promise", "...
Create object containing signer's keyid and validity of signature @param {module:packet.Signature} signature signature packets @param {Array<module:packet.Literal>} literalDataList array of literal data packets @param {Array<module:key.Key>} keys array of keys to verify signatures @param {Date} date Verify the signatur...
[ "Create", "object", "containing", "signer", "s", "keyid", "and", "validity", "of", "signature" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/message.js#L635-L683
train
openpgpjs/openpgpjs
src/packet/secret_key.js
SecretKey
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
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...
[ "function", "SecretKey", "(", "date", "=", "new", "Date", "(", ")", ")", "{", "publicKey", ".", "call", "(", "this", ",", "date", ")", ";", "/**\n * Packet type\n * @type {module:enums.packet}\n */", "this", ".", "tag", "=", "enums", ".", "packet", ".", ...
A Secret-Key packet contains all the information that is found in a Public-Key packet, including the public-key material, but also includes the secret-key material after all the public-key fields. @memberof module:packet @constructor @extends module:packet.PublicKey
[ "A", "Secret", "-", "Key", "packet", "contains", "all", "the", "information", "that", "is", "found", "in", "a", "Public", "-", "Key", "packet", "including", "the", "public", "-", "key", "material", "but", "also", "includes", "the", "secret", "-", "key", ...
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/packet/secret_key.js#L42-L57
train
openpgpjs/openpgpjs
src/worker/async_proxy.js
AsyncProxy
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
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 '...
[ "function", "AsyncProxy", "(", "{", "path", "=", "'openpgp.worker.js'", ",", "n", "=", "1", ",", "workers", "=", "[", "]", ",", "config", "}", "=", "{", "}", ")", "{", "/**\n * Message handling\n */", "const", "handleMessage", "=", "workerId", "=>", "e...
Initializes a new proxy and loads the web worker @param {String} path The path to the worker or 'openpgp.worker.js' by default @param {Number} n number of workers to initialize if path given @param {Object} config config The worker configuration @param {Array<Object>} worker alternat...
[ "Initializes", "a", "new", "proxy", "and", "loads", "the", "web", "worker" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/worker/async_proxy.js#L45-L108
train
openpgpjs/openpgpjs
src/key.js
isDataRevoked
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
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...
[ "async", "function", "isDataRevoked", "(", "primaryKey", ",", "signatureType", ",", "dataToVerify", ",", "revocations", ",", "signature", ",", "key", ",", "date", "=", "new", "Date", "(", ")", ")", "{", "key", "=", "key", "||", "primaryKey", ";", "const", ...
Checks if a given certificate or binding signature is revoked @param {module:packet.SecretKey| module:packet.PublicKey} primaryKey The primary key packet @param {Object} dataToVerify The data to check @param {Array<module:packet.Signature>} revocations The revocation signatures to ch...
[ "Checks", "if", "a", "given", "certificate", "or", "binding", "signature", "is", "revoked" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/key.js#L1611-L1642
train
openpgpjs/openpgpjs
src/crypto/public_key/prime.js
randomProbablePrime
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
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...
[ "async", "function", "randomProbablePrime", "(", "bits", ",", "e", ",", "k", ")", "{", "const", "min", "=", "new", "BN", "(", "1", ")", ".", "shln", "(", "bits", "-", "1", ")", ";", "const", "thirty", "=", "new", "BN", "(", "30", ")", ";", "/*\...
Probabilistic random number generator @param {Integer} bits Bit length of the prime @param {BN} e Optional RSA exponent to check against the prime @param {Integer} k Optional number of iterations of Miller-Rabin test @returns BN @async
[ "Probabilistic", "random", "number", "generator" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/public_key/prime.js#L40-L64
train
openpgpjs/openpgpjs
src/crypto/public_key/prime.js
isProbablePrime
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
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:/...
[ "async", "function", "isProbablePrime", "(", "n", ",", "e", ",", "k", ")", "{", "if", "(", "e", "&&", "!", "n", ".", "subn", "(", "1", ")", ".", "gcd", "(", "e", ")", ".", "eqn", "(", "1", ")", ")", "{", "return", "false", ";", "}", "if", ...
Probabilistic primality testing @param {BN} n Number to test @param {BN} e Optional RSA exponent to check against the prime @param {Integer} k Optional number of iterations of Miller-Rabin test @returns {boolean} @async
[ "Probabilistic", "primality", "testing" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/public_key/prime.js#L74-L90
train
openpgpjs/openpgpjs
src/encoding/armor.js
getType
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
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...
[ "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", ...
Finds out which Ascii Armoring type is used. Throws error if unknown type. @private @param {String} text [String] ascii armored text @returns {Integer} 0 = MESSAGE PART n of m 1 = MESSAGE PART n 2 = SIGNED MESSAGE 3 = PGP MESSAGE 4 = PUBLIC KEY BLOCK 5 = PRIVATE KEY BLOCK 6 = SIGNATURE
[ "Finds", "out", "which", "Ascii", "Armoring", "type", "is", "used", ".", "Throws", "error", "if", "unknown", "type", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/encoding/armor.js#L45-L93
train
openpgpjs/openpgpjs
src/encoding/armor.js
addheader
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
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'; } ...
[ "function", "addheader", "(", "customComment", ")", "{", "let", "result", "=", "\"\"", ";", "if", "(", "config", ".", "show_version", ")", "{", "result", "+=", "\"Version: \"", "+", "config", ".", "versionstring", "+", "'\\r\\n'", ";", "}", "if", "(", "c...
Add additional information to the armor version of an OpenPGP binary packet block. @author Alex @version 2011-12-16 @param {String} customComment (optional) additional comment to add to the armored string @returns {String} The header information
[ "Add", "additional", "information", "to", "the", "armor", "version", "of", "an", "OpenPGP", "binary", "packet", "block", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/encoding/armor.js#L103-L116
train
openpgpjs/openpgpjs
src/encoding/armor.js
splitChecksum
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
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...
[ "function", "splitChecksum", "(", "text", ")", "{", "let", "body", "=", "text", ";", "let", "checksum", "=", "\"\"", ";", "const", "lastEquals", "=", "text", ".", "lastIndexOf", "(", "\"=\"", ")", ";", "if", "(", "lastEquals", ">=", "0", "&&", "lastEqu...
Splits a message into two parts, the body and the checksum. This is an internal function @param {String} text OpenPGP armored message part @returns {Object} An object with attribute "body" containing the body and an attribute "checksum" containing the checksum.
[ "Splits", "a", "message", "into", "two", "parts", "the", "body", "and", "the", "checksum", ".", "This", "is", "an", "internal", "function" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/encoding/armor.js#L201-L213
train
openpgpjs/openpgpjs
src/encoding/armor.js
armor
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
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...
[ "function", "armor", "(", "messagetype", ",", "body", ",", "partindex", ",", "parttotal", ",", "customComment", ")", "{", "let", "text", ";", "let", "hash", ";", "if", "(", "messagetype", "===", "enums", ".", "armor", ".", "signed", ")", "{", "text", "...
Armor an OpenPGP binary packet block @param {Integer} messagetype type of the message @param body @param {Integer} partindex @param {Integer} parttotal @param {String} customComment (optional) additional comment to add to the armored string @returns {String | ReadableStream<String>} Armored text @static
[ "Armor", "an", "OpenPGP", "binary", "packet", "block" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/encoding/armor.js#L349-L415
train
openpgpjs/openpgpjs
src/crypto/hash/index.js
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
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...
[ "function", "(", "algo", ",", "data", ")", "{", "switch", "(", "algo", ")", "{", "case", "1", ":", "// - MD5 [HAC]", "return", "this", ".", "md5", "(", "data", ")", ";", "case", "2", ":", "// - SHA-1 [FIPS180]", "return", "this", ".", "sha1", "(", "d...
Create a hash on the specified data using the specified algorithm @param {module:enums.hash} algo Hash algorithm type (see {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4}) @param {Uint8Array} data Data to be hashed @returns {Promise<Uint8Array>} hash value
[ "Create", "a", "hash", "on", "the", "specified", "data", "using", "the", "specified", "algorithm" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/hash/index.js#L111-L137
train
openpgpjs/openpgpjs
src/encoding/base64.js
s2r
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
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...
[ "function", "s2r", "(", "t", ",", "u", "=", "false", ")", "{", "// TODO check btoa alternative", "const", "b64", "=", "u", "?", "b64u", ":", "b64s", ";", "let", "a", ";", "let", "c", ";", "let", "l", "=", "0", ";", "let", "s", "=", "0", ";", "r...
Convert binary array to radix-64 @param {Uint8Array | ReadableStream<Uint8Array>} t Uint8Array to convert @param {bool} u if true, output is URL-safe @returns {String | ReadableStream<String>} radix-64 version of input string @static
[ "Convert", "binary", "array", "to", "radix", "-", "64" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/encoding/base64.js#L38-L97
train
openpgpjs/openpgpjs
src/encoding/base64.js
r2s
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
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 ...
[ "function", "r2s", "(", "t", ",", "u", ")", "{", "// TODO check atob alternative", "let", "c", ";", "let", "s", "=", "0", ";", "let", "a", "=", "0", ";", "return", "stream", ".", "transform", "(", "t", ",", "value", "=>", "{", "const", "tl", "=", ...
Convert radix-64 to binary array @param {String | ReadableStream<String>} t radix-64 string to convert @param {bool} u if true, input is interpreted as URL-safe @returns {Uint8Array | ReadableStream<Uint8Array>} binary array version of input string @static
[ "Convert", "radix", "-", "64", "to", "binary", "array" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/encoding/base64.js#L106-L129
train
openpgpjs/openpgpjs
src/crypto/public_key/elliptic/ecdh.js
genPublicEphemeralKey
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
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(...
[ "async", "function", "genPublicEphemeralKey", "(", "curve", ",", "Q", ")", "{", "if", "(", "curve", ".", "name", "===", "'curve25519'", ")", "{", "const", "{", "secretKey", ":", "d", "}", "=", "nacl", ".", "box", ".", "keyPair", "(", ")", ";", "const...
Generate ECDHE ephemeral key and secret from public key @param {Curve} curve Elliptic curve object @param {Uint8Array} Q Recipient public key @returns {Promise<{V: Uint8Array, S: BN}>} Returns public part of ephemeral key and generated ephemeral secret @async
[ "Generate", "ECDHE", "ephemeral", "key", "and", "secret", "from", "public", "key" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/public_key/elliptic/ecdh.js#L86-L101
train
openpgpjs/openpgpjs
src/crypto/public_key/elliptic/ecdh.js
encrypt
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
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...
[ "async", "function", "encrypt", "(", "oid", ",", "cipher_algo", ",", "hash_algo", ",", "m", ",", "Q", ",", "fingerprint", ")", "{", "const", "curve", "=", "new", "Curve", "(", "oid", ")", ";", "const", "{", "publicKey", ",", "sharedKey", "}", "=", "a...
Encrypt and wrap a session key @param {module:type/oid} oid Elliptic curve object identifier @param {module:enums.symmetric} cipher_algo Symmetric cipher to use @param {module:enums.hash} hash_algo Hash algorithm to use @param {module:type/mpi} m Value derived from sessio...
[ "Encrypt", "and", "wrap", "a", "session", "key" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/public_key/elliptic/ecdh.js#L115-L123
train
openpgpjs/openpgpjs
src/crypto/public_key/elliptic/ecdh.js
genPrivateEphemeralKey
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
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...
[ "async", "function", "genPrivateEphemeralKey", "(", "curve", ",", "V", ",", "d", ")", "{", "if", "(", "curve", ".", "name", "===", "'curve25519'", ")", "{", "const", "one", "=", "new", "BN", "(", "1", ")", ";", "const", "mask", "=", "one", ".", "us...
Generate ECDHE secret from private key and public part of ephemeral key @param {Curve} curve Elliptic curve object @param {Uint8Array} V Public part of ephemeral key @param {Uint8Array} d Recipient private key @returns {Promise<BN>} ...
[ "Generate", "ECDHE", "secret", "from", "private", "key", "and", "public", "part", "of", "ephemeral", "key" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/public_key/elliptic/ecdh.js#L134-L152
train
openpgpjs/openpgpjs
src/crypto/public_key/elliptic/ecdh.js
decrypt
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
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...
[ "async", "function", "decrypt", "(", "oid", ",", "cipher_algo", ",", "hash_algo", ",", "V", ",", "C", ",", "d", ",", "fingerprint", ")", "{", "const", "curve", "=", "new", "Curve", "(", "oid", ")", ";", "const", "{", "sharedKey", "}", "=", "await", ...
Decrypt and unwrap the value derived from session key @param {module:type/oid} oid Elliptic curve object identifier @param {module:enums.symmetric} cipher_algo Symmetric cipher to use @param {module:enums.hash} hash_algo Hash algorithm to use @param {Uint8Array} V Pu...
[ "Decrypt", "and", "unwrap", "the", "value", "derived", "from", "session", "key" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/public_key/elliptic/ecdh.js#L167-L183
train
openpgpjs/openpgpjs
src/keyring/keyring.js
emailCheck
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
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++) { ...
[ "function", "emailCheck", "(", "email", ",", "key", ")", "{", "email", "=", "email", ".", "toLowerCase", "(", ")", ";", "// escape email before using in regular expression", "const", "emailEsc", "=", "email", ".", "replace", "(", "/", "[.*+?^${}()|[\\]\\\\]", "/",...
Checks a key to see if it matches the specified email address @private @param {String} email email address to search for @param {module:key.Key} key The key to be checked. @returns {Boolean} True if the email address is defined in the specified key
[ "Checks", "a", "key", "to", "see", "if", "it", "matches", "the", "specified", "email", "address" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/keyring/keyring.js#L130-L143
train
openpgpjs/openpgpjs
src/keyring/keyring.js
keyIdCheck
function keyIdCheck(keyId, key) { if (keyId.length === 16) { return keyId === key.getKeyId().toHex(); } return keyId === key.getFingerprint(); }
javascript
function keyIdCheck(keyId, key) { if (keyId.length === 16) { return keyId === key.getKeyId().toHex(); } return keyId === key.getFingerprint(); }
[ "function", "keyIdCheck", "(", "keyId", ",", "key", ")", "{", "if", "(", "keyId", ".", "length", "===", "16", ")", "{", "return", "keyId", "===", "key", ".", "getKeyId", "(", ")", ".", "toHex", "(", ")", ";", "}", "return", "keyId", "===", "key", ...
Checks a key to see if it matches the specified keyid @private @param {String} keyId provided as string of lowercase hex number withouth 0x prefix (can be 16-character key ID or fingerprint) @param {module:key.Key|module:key.SubKey} key The key to be checked @returns {Boolean} True if key has the specified keyid
[ "Checks", "a", "key", "to", "see", "if", "it", "matches", "the", "specified", "keyid" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/keyring/keyring.js#L153-L158
train
openpgpjs/openpgpjs
src/packet/signature.js
write_sub_packet
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
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); }
[ "function", "write_sub_packet", "(", "type", ",", "data", ")", "{", "const", "arr", "=", "[", "]", ";", "arr", ".", "push", "(", "packet", ".", "writeSimpleLength", "(", "data", ".", "length", "+", "1", ")", ")", ";", "arr", ".", "push", "(", "new"...
Creates a string representation of a sub signature packet @see {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.1|RFC4880 5.2.3.1} @see {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.2|RFC4880 5.2.3.2} @param {Integer} type subpacket signature type. @param {String} data data to be included @returns {S...
[ "Creates", "a", "string", "representation", "of", "a", "sub", "signature", "packet" ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/packet/signature.js#L337-L343
train
openpgpjs/openpgpjs
src/crypto/cipher/cast5.js
f1
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
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]; }
[ "function", "f1", "(", "d", ",", "m", ",", "r", ")", "{", "const", "t", "=", "m", "+", "d", ";", "const", "I", "=", "(", "t", "<<", "r", ")", "|", "(", "t", ">>>", "(", "32", "-", "r", ")", ")", ";", "return", "(", "(", "sBox", "[", "...
These are the three 'f' functions. See RFC 2144, section 2.2.
[ "These", "are", "the", "three", "f", "functions", ".", "See", "RFC", "2144", "section", "2", ".", "2", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/cipher/cast5.js#L298-L302
train
openpgpjs/openpgpjs
src/crypto/pkcs5.js
decode
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
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); } ...
[ "function", "decode", "(", "msg", ")", "{", "const", "len", "=", "msg", ".", "length", ";", "if", "(", "len", ">", "0", ")", "{", "const", "c", "=", "msg", ".", "charCodeAt", "(", "len", "-", "1", ")", ";", "if", "(", "c", ">=", "1", "&&", ...
Remove pkcs5 padding from a string. @param {String} msg Text to remove padding from @returns {String} Text with padding removed
[ "Remove", "pkcs5", "padding", "from", "a", "string", "." ]
54f3eb5870e4e0611965003e276af786ec419470
https://github.com/openpgpjs/openpgpjs/blob/54f3eb5870e4e0611965003e276af786ec419470/src/crypto/pkcs5.js#L40-L53
train
balderdashy/waterline
lib/waterline/utils/query/get-query-modifier-methods.js
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
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...
[ "function", "(", "batchSizeOrIteratee", ",", "iteratee", ")", "{", "assert", "(", "this", ".", "_wlQueryInfo", ".", "method", "===", "'stream'", ",", "'Cannot chain `.eachBatch()` onto the `.'", "+", "this", ".", "_wlQueryInfo", ".", "method", "+", "'()` method. Th...
Add an iteratee to the query @param {Number|Function} batchSizeOrIteratee @param {Function} iteratee @returns {Query}
[ "Add", "an", "iteratee", "to", "the", "query" ]
1d5a3dc6e65fe69c061a72249019adfcf3c52cb6
https://github.com/balderdashy/waterline/blob/1d5a3dc6e65fe69c061a72249019adfcf3c52cb6/lib/waterline/utils/query/get-query-modifier-methods.js#L83-L107
train
balderdashy/waterline
lib/waterline/utils/query/get-query-modifier-methods.js
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
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...
[ "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 su...
Add values to be used in update or create query @param {Dictionary} values @returns {Query}
[ "Add", "values", "to", "be", "used", "in", "update", "or", "create", "query" ]
1d5a3dc6e65fe69c061a72249019adfcf3c52cb6
https://github.com/balderdashy/waterline/blob/1d5a3dc6e65fe69c061a72249019adfcf3c52cb6/lib/waterline/utils/query/get-query-modifier-methods.js#L120-L148
train
balderdashy/waterline
lib/waterline/utils/query/get-query-modifier-methods.js
function(limit) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.limit = limit; return this; }
javascript
function(limit) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.limit = limit; return this; }
[ "function", "(", "limit", ")", "{", "if", "(", "!", "this", ".", "_alreadyInitiallyExpandedCriteria", ")", "{", "this", ".", "_wlQueryInfo", ".", "criteria", "=", "expandWhereShorthand", "(", "this", ".", "_wlQueryInfo", ".", "criteria", ")", ";", "this", "....
Add a `limit` clause to the query's criteria. @param {Number} number to limit @returns {Query}
[ "Add", "a", "limit", "clause", "to", "the", "query", "s", "criteria", "." ]
1d5a3dc6e65fe69c061a72249019adfcf3c52cb6
https://github.com/balderdashy/waterline/blob/1d5a3dc6e65fe69c061a72249019adfcf3c52cb6/lib/waterline/utils/query/get-query-modifier-methods.js#L274-L284
train
balderdashy/waterline
lib/waterline/utils/query/get-query-modifier-methods.js
function(skip) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.skip = skip; return this; }
javascript
function(skip) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.skip = skip; return this; }
[ "function", "(", "skip", ")", "{", "if", "(", "!", "this", ".", "_alreadyInitiallyExpandedCriteria", ")", "{", "this", ".", "_wlQueryInfo", ".", "criteria", "=", "expandWhereShorthand", "(", "this", ".", "_wlQueryInfo", ".", "criteria", ")", ";", "this", "."...
Add a `skip` clause to the query's criteria. @param {Number} number to skip @returns {Query}
[ "Add", "a", "skip", "clause", "to", "the", "query", "s", "criteria", "." ]
1d5a3dc6e65fe69c061a72249019adfcf3c52cb6
https://github.com/balderdashy/waterline/blob/1d5a3dc6e65fe69c061a72249019adfcf3c52cb6/lib/waterline/utils/query/get-query-modifier-methods.js#L293-L303
train
balderdashy/waterline
lib/waterline/utils/query/get-query-modifier-methods.js
function(sortClause) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.sort = sortClause; return this; }
javascript
function(sortClause) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.sort = sortClause; return this; }
[ "function", "(", "sortClause", ")", "{", "if", "(", "!", "this", ".", "_alreadyInitiallyExpandedCriteria", ")", "{", "this", ".", "_wlQueryInfo", ".", "criteria", "=", "expandWhereShorthand", "(", "this", ".", "_wlQueryInfo", ".", "criteria", ")", ";", "this",...
Add a `sort` clause to the criteria object @param {Ref} sortClause @returns {Query}
[ "Add", "a", "sort", "clause", "to", "the", "criteria", "object" ]
1d5a3dc6e65fe69c061a72249019adfcf3c52cb6
https://github.com/balderdashy/waterline/blob/1d5a3dc6e65fe69c061a72249019adfcf3c52cb6/lib/waterline/utils/query/get-query-modifier-methods.js#L432-L442
train
balderdashy/waterline
lib/waterline/utils/query/get-query-modifier-methods.js
function(selectAttributes) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.select = selectAttributes; return this; }
javascript
function(selectAttributes) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.select = selectAttributes; return this; }
[ "function", "(", "selectAttributes", ")", "{", "if", "(", "!", "this", ".", "_alreadyInitiallyExpandedCriteria", ")", "{", "this", ".", "_wlQueryInfo", ".", "criteria", "=", "expandWhereShorthand", "(", "this", ".", "_wlQueryInfo", ".", "criteria", ")", ";", "...
Add projections to the query. @param {Array} attributes to select @returns {Query}
[ "Add", "projections", "to", "the", "query", "." ]
1d5a3dc6e65fe69c061a72249019adfcf3c52cb6
https://github.com/balderdashy/waterline/blob/1d5a3dc6e65fe69c061a72249019adfcf3c52cb6/lib/waterline/utils/query/get-query-modifier-methods.js#L457-L467
train
balderdashy/waterline
lib/waterline/utils/query/get-query-modifier-methods.js
function(omitAttributes) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.omit = omitAttributes; return this; }
javascript
function(omitAttributes) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.omit = omitAttributes; return this; }
[ "function", "(", "omitAttributes", ")", "{", "if", "(", "!", "this", ".", "_alreadyInitiallyExpandedCriteria", ")", "{", "this", ".", "_wlQueryInfo", ".", "criteria", "=", "expandWhereShorthand", "(", "this", ".", "_wlQueryInfo", ".", "criteria", ")", ";", "th...
Add an omit clause to the query's criteria. @param {Array} attributes to select @returns {Query}
[ "Add", "an", "omit", "clause", "to", "the", "query", "s", "criteria", "." ]
1d5a3dc6e65fe69c061a72249019adfcf3c52cb6
https://github.com/balderdashy/waterline/blob/1d5a3dc6e65fe69c061a72249019adfcf3c52cb6/lib/waterline/utils/query/get-query-modifier-methods.js#L475-L485
train
balderdashy/waterline
lib/waterline/utils/query/get-query-modifier-methods.js
function(whereCriteria) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.where = whereCriteria; return this; }
javascript
function(whereCriteria) { if (!this._alreadyInitiallyExpandedCriteria) { this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria); this._alreadyInitiallyExpandedCriteria = true; }//>- this._wlQueryInfo.criteria.where = whereCriteria; return this; }
[ "function", "(", "whereCriteria", ")", "{", "if", "(", "!", "this", ".", "_alreadyInitiallyExpandedCriteria", ")", "{", "this", ".", "_wlQueryInfo", ".", "criteria", "=", "expandWhereShorthand", "(", "this", ".", "_wlQueryInfo", ".", "criteria", ")", ";", "thi...
Add a `where` clause to the query's criteria. @param {Dictionary} criteria to append @returns {Query}
[ "Add", "a", "where", "clause", "to", "the", "query", "s", "criteria", "." ]
1d5a3dc6e65fe69c061a72249019adfcf3c52cb6
https://github.com/balderdashy/waterline/blob/1d5a3dc6e65fe69c061a72249019adfcf3c52cb6/lib/waterline/utils/query/get-query-modifier-methods.js#L501-L511
train
ampproject/worker-dom
demo/preact-dbmon/dbmon.js
extend
function extend(obj, props) { for (var i in props) { obj[i] = props[i]; } return obj; }
javascript
function extend(obj, props) { for (var i in props) { obj[i] = props[i]; } return obj; }
[ "function", "extend", "(", "obj", ",", "props", ")", "{", "for", "(", "var", "i", "in", "props", ")", "{", "obj", "[", "i", "]", "=", "props", "[", "i", "]", ";", "}", "return", "obj", ";", "}" ]
Copy all properties from `props` onto `obj`. @param {Object} obj Object onto which properties should be copied. @param {Object} props Object from which to copy properties. @return obj @private
[ "Copy", "all", "properties", "from", "props", "onto", "obj", "." ]
d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4
https://github.com/ampproject/worker-dom/blob/d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4/demo/preact-dbmon/dbmon.js#L136-L141
train
ampproject/worker-dom
demo/preact-dbmon/dbmon.js
isNamedNode
function isNamedNode(node, nodeName) { return node.normalizedNodeName === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase(); }
javascript
function isNamedNode(node, nodeName) { return node.normalizedNodeName === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase(); }
[ "function", "isNamedNode", "(", "node", ",", "nodeName", ")", "{", "return", "node", ".", "normalizedNodeName", "===", "nodeName", "||", "node", ".", "nodeName", ".", "toLowerCase", "(", ")", "===", "nodeName", ".", "toLowerCase", "(", ")", ";", "}" ]
Check if an Element has a given nodeName, case-insensitively. @param {Element} node A DOM Element to inspect the name of. @param {String} nodeName Unnormalized name to compare against.
[ "Check", "if", "an", "Element", "has", "a", "given", "nodeName", "case", "-", "insensitively", "." ]
d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4
https://github.com/ampproject/worker-dom/blob/d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4/demo/preact-dbmon/dbmon.js#L198-L200
train
ampproject/worker-dom
demo/preact-dbmon/dbmon.js
createNode
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
function createNode(nodeName, isSvg) { var node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName); node.normalizedNodeName = nodeName; return node; }
[ "function", "createNode", "(", "nodeName", ",", "isSvg", ")", "{", "var", "node", "=", "isSvg", "?", "document", ".", "createElementNS", "(", "'http://www.w3.org/2000/svg'", ",", "nodeName", ")", ":", "document", ".", "createElement", "(", "nodeName", ")", ";"...
Create an element with the given nodeName. @param {String} nodeName @param {Boolean} [isSvg=false] If `true`, creates an element within the SVG namespace. @return {Element} node
[ "Create", "an", "element", "with", "the", "given", "nodeName", "." ]
d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4
https://github.com/ampproject/worker-dom/blob/d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4/demo/preact-dbmon/dbmon.js#L231-L235
train
ampproject/worker-dom
demo/preact-dbmon/dbmon.js
eventProxy
function eventProxy(e) { return this._listeners[e.type]((options.event && options.event(e)) || e); }
javascript
function eventProxy(e) { return this._listeners[e.type]((options.event && options.event(e)) || e); }
[ "function", "eventProxy", "(", "e", ")", "{", "return", "this", ".", "_listeners", "[", "e", ".", "type", "]", "(", "(", "options", ".", "event", "&&", "options", ".", "event", "(", "e", ")", ")", "||", "e", ")", ";", "}" ]
Proxy an event to hooked event handlers @private
[ "Proxy", "an", "event", "to", "hooked", "event", "handlers" ]
d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4
https://github.com/ampproject/worker-dom/blob/d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4/demo/preact-dbmon/dbmon.js#L316-L318
train
ampproject/worker-dom
demo/preact-dbmon/dbmon.js
collectComponent
function collectComponent(component) { var name = component.constructor.name; (components[name] || (components[name] = [])).push(component); }
javascript
function collectComponent(component) { var name = component.constructor.name; (components[name] || (components[name] = [])).push(component); }
[ "function", "collectComponent", "(", "component", ")", "{", "var", "name", "=", "component", ".", "constructor", ".", "name", ";", "(", "components", "[", "name", "]", "||", "(", "components", "[", "name", "]", "=", "[", "]", ")", ")", ".", "push", "...
Reclaim a component for later re-use by the recycler.
[ "Reclaim", "a", "component", "for", "later", "re", "-", "use", "by", "the", "recycler", "." ]
d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4
https://github.com/ampproject/worker-dom/blob/d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4/demo/preact-dbmon/dbmon.js#L629-L632
train
ampproject/worker-dom
demo/preact-dbmon/dbmon.js
createComponent
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
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...
[ "function", "createComponent", "(", "Ctor", ",", "props", ",", "context", ")", "{", "var", "list", "=", "components", "[", "Ctor", ".", "name", "]", ",", "inst", ";", "if", "(", "Ctor", ".", "prototype", "&&", "Ctor", ".", "prototype", ".", "render", ...
Create a component. Normalizes differences between PFC's and classful Components.
[ "Create", "a", "component", ".", "Normalizes", "differences", "between", "PFC", "s", "and", "classful", "Components", "." ]
d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4
https://github.com/ampproject/worker-dom/blob/d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4/demo/preact-dbmon/dbmon.js#L635-L658
train
ampproject/worker-dom
demo/preact-dbmon/dbmon.js
buildComponentFromVNode
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
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 ...
[ "function", "buildComponentFromVNode", "(", "dom", ",", "vnode", ",", "context", ",", "mountAll", ")", "{", "var", "c", "=", "dom", "&&", "dom", ".", "_component", ",", "originalComponent", "=", "c", ",", "oldDom", "=", "dom", ",", "isDirectOwner", "=", ...
Apply the Component referenced by a VNode to the DOM. @param {Element} dom The DOM node to mutate @param {VNode} vnode A Component-referencing VNode @return {Element} dom The created/mutated element @private
[ "Apply", "the", "Component", "referenced", "by", "a", "VNode", "to", "the", "DOM", "." ]
d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4
https://github.com/ampproject/worker-dom/blob/d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4/demo/preact-dbmon/dbmon.js#L850-L886
train
ampproject/worker-dom
demo/preact-dbmon/dbmon.js
unmountComponent
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
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...
[ "function", "unmountComponent", "(", "component", ")", "{", "if", "(", "options", ".", "beforeUnmount", ")", "options", ".", "beforeUnmount", "(", "component", ")", ";", "var", "base", "=", "component", ".", "base", ";", "component", ".", "_disable", "=", ...
Remove a component from the DOM and recycle it. @param {Component} component The Component instance to unmount @private
[ "Remove", "a", "component", "from", "the", "DOM", "and", "recycle", "it", "." ]
d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4
https://github.com/ampproject/worker-dom/blob/d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4/demo/preact-dbmon/dbmon.js#L892-L919
train
ampproject/worker-dom
demo/preact-dbmon/dbmon.js
setState
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
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); ...
[ "function", "setState", "(", "state", ",", "callback", ")", "{", "var", "s", "=", "this", ".", "state", ";", "if", "(", "!", "this", ".", "prevState", ")", "this", ".", "prevState", "=", "extend", "(", "{", "}", ",", "s", ")", ";", "extend", "(",...
Returns a `boolean` indicating if the component should re-render when receiving the given `props` and `state`. @param {object} nextProps @param {object} nextState @param {object} nextContext @return {Boolean} should the component re-render @name shouldComponentUpdate @function Update component state by copying propert...
[ "Returns", "a", "boolean", "indicating", "if", "the", "component", "should", "re", "-", "render", "when", "receiving", "the", "given", "props", "and", "state", "." ]
d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4
https://github.com/ampproject/worker-dom/blob/d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4/demo/preact-dbmon/dbmon.js#L965-L971
train
ampproject/worker-dom
demo/preact-todomvc/app.js
linkState
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
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, ...
[ "function", "linkState", "(", "component", ",", "key", ",", "eventPath", ")", "{", "var", "path", "=", "key", ".", "split", "(", "'.'", ")", ",", "cache", "=", "component", ".", "__lsc", "||", "(", "component", ".", "__lsc", "=", "{", "}", ")", ";"...
Create an Event handler function that sets a given state property. @param {Component} component The component whose state should be updated @param {string} key A dot-notated key path to update in the component's state @param {string} eventPath A dot-notated key path to the value that should be retrieved from the Ev...
[ "Create", "an", "Event", "handler", "function", "that", "sets", "a", "given", "state", "property", "." ]
d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4
https://github.com/ampproject/worker-dom/blob/d1c7bee8c2259c61e25eb4d27606ff70e2f02fd4/demo/preact-todomvc/app.js#L1052-L1072
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
pagesCount
function pagesCount() { var quotient = Math.floor(this.total / this.currentPerPage); var remainder = this.total % this.currentPerPage; return remainder === 0 ? quotient : quotient + 1; }
javascript
function pagesCount() { var quotient = Math.floor(this.total / this.currentPerPage); var remainder = this.total % this.currentPerPage; return remainder === 0 ? quotient : quotient + 1; }
[ "function", "pagesCount", "(", ")", "{", "var", "quotient", "=", "Math", ".", "floor", "(", "this", ".", "total", "/", "this", ".", "currentPerPage", ")", ";", "var", "remainder", "=", "this", ".", "total", "%", "this", ".", "currentPerPage", ";", "ret...
Number of pages
[ "Number", "of", "pages" ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L372-L376
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
paginatedInfo
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
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...
[ "function", "paginatedInfo", "(", ")", "{", "var", "first", "=", "(", "this", ".", "currentPage", "-", "1", ")", "*", "this", ".", "currentPerPage", "+", "1", ";", "var", "last", "=", "Math", ".", "min", "(", "this", ".", "total", ",", "this", ".",...
Current displayed items
[ "Current", "displayed", "items" ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L378-L387
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
changePage
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
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...
[ "function", "changePage", "(", "pageNumber", ")", "{", "var", "emit", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "true", ";", "if", "(", "pageNumber", ">", "0...
Change current page
[ "Change", "current", "page" ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L399-L407
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
handlePerPage
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
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 { ...
[ "function", "handlePerPage", "(", ")", "{", "//* if there's a custom dropdown then we use that", "if", "(", "this", ".", "customRowsPerPageDropdown", "!==", "null", "&&", "Array", ".", "isArray", "(", "this", ".", "customRowsPerPageDropdown", ")", "&&", "this", ".", ...
Handle per page changing
[ "Handle", "per", "page", "changing" ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L440-L467
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
hasFilterRow
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
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; }
[ "function", "hasFilterRow", "(", ")", "{", "// if (this.mode === 'remote' || !this.globalSearchEnabled) {", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "columns", ".", "length", ";", "i", "++", ")", "{", "var", "col", "=", "this", ".", "c...
to create a filter row, we need to make sure that there is atleast 1 column that requires filtering
[ "to", "create", "a", "filter", "row", "we", "need", "to", "make", "sure", "that", "there", "is", "atleast", "1", "column", "that", "requires", "filtering" ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L609-L621
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
getPlaceholder
function getPlaceholder(column) { var placeholder = this.isFilterable(column) && column.filterOptions.placeholder || "Filter ".concat(column.label); return placeholder; }
javascript
function getPlaceholder(column) { var placeholder = this.isFilterable(column) && column.filterOptions.placeholder || "Filter ".concat(column.label); return placeholder; }
[ "function", "getPlaceholder", "(", "column", ")", "{", "var", "placeholder", "=", "this", ".", "isFilterable", "(", "column", ")", "&&", "column", ".", "filterOptions", ".", "placeholder", "||", "\"Filter \"", ".", "concat", "(", "column", ".", "label", ")",...
get column's defined placeholder or default one
[ "get", "column", "s", "defined", "placeholder", "or", "default", "one" ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L645-L648
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
updateFilters
function updateFilters(column, value) { var _this = this; if (this.timer) clearTimeout(this.timer); this.timer = setTimeout(function () { _this.updateFiltersImmediately(column, value); }, 400); }
javascript
function updateFilters(column, value) { var _this = this; if (this.timer) clearTimeout(this.timer); this.timer = setTimeout(function () { _this.updateFiltersImmediately(column, value); }, 400); }
[ "function", "updateFilters", "(", "column", ",", "value", ")", "{", "var", "_this", "=", "this", ";", "if", "(", "this", ".", "timer", ")", "clearTimeout", "(", "this", ".", "timer", ")", ";", "this", ".", "timer", "=", "setTimeout", "(", "function", ...
since vue doesn't detect property addition and deletion, we need to create helper function to set property etc
[ "since", "vue", "doesn", "t", "detect", "property", "addition", "and", "deletion", "we", "need", "to", "create", "helper", "function", "to", "set", "property", "etc" ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L660-L667
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
onCheckboxClicked
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
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 }); }
[ "function", "onCheckboxClicked", "(", "row", ",", "index$$1", ",", "event", ")", "{", "this", ".", "$set", "(", "row", ",", "'vgtSelected'", ",", "!", "row", ".", "vgtSelected", ")", ";", "this", ".", "$emit", "(", "'on-row-click'", ",", "{", "row", ":...
checkbox click should always do the following
[ "checkbox", "click", "should", "always", "do", "the", "following" ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L1864-L1872
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
dig
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
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]]; } ...
[ "function", "dig", "(", "obj", ",", "selector", ")", "{", "var", "result", "=", "obj", ";", "var", "splitter", "=", "selector", ".", "split", "(", "'.'", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "splitter", ".", "length", ";", ...
utility function to get nested property
[ "utility", "function", "to", "get", "nested", "property" ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L1947-L1960
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
isSortableColumn
function isSortableColumn(index$$1) { var sortable = this.columns[index$$1].sortable; var isSortable = typeof sortable === 'boolean' ? sortable : this.sortable; return isSortable; }
javascript
function isSortableColumn(index$$1) { var sortable = this.columns[index$$1].sortable; var isSortable = typeof sortable === 'boolean' ? sortable : this.sortable; return isSortable; }
[ "function", "isSortableColumn", "(", "index$$1", ")", "{", "var", "sortable", "=", "this", ".", "columns", "[", "index$$1", "]", ".", "sortable", ";", "var", "isSortable", "=", "typeof", "sortable", "===", "'boolean'", "?", "sortable", ":", "this", ".", "s...
Check if a column is sortable.
[ "Check", "if", "a", "column", "is", "sortable", "." ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L2009-L2013
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
getClasses
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
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...
[ "function", "getClasses", "(", "index$$1", ",", "element", ",", "row", ")", "{", "var", "_this$typedColumns$in", "=", "this", ".", "typedColumns", "[", "index$$1", "]", ",", "typeDef", "=", "_this$typedColumns$in", ".", "typeDef", ",", "custom", "=", "_this$ty...
Get classes for the given column index & element.
[ "Get", "classes", "for", "the", "given", "column", "index", "&", "element", "." ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L2015-L2035
train
xaksis/vue-good-table
dist/vue-good-table.cjs.js
filterRows
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
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...
[ "function", "filterRows", "(", "columnFilters", ")", "{", "var", "_this4", "=", "this", ";", "var", "fromFilter", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "tr...
method to filter rows
[ "method", "to", "filter", "rows" ]
bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6
https://github.com/xaksis/vue-good-table/blob/bc13a5bb90ce1d14d07bb71e70a63bc8c8936ae6/dist/vue-good-table.cjs.js#L2037-L2105
train
Microsoft/tsdoc
common/scripts/install-run.js
findRushJsonFolder
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
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...
[ "function", "findRushJsonFolder", "(", ")", "{", "if", "(", "!", "_rushJsonFolder", ")", "{", "let", "basePath", "=", "__dirname", ";", "let", "tempPath", "=", "__dirname", ";", "do", "{", "const", "testRushJsonPath", "=", "path", ".", "join", "(", "basePa...
Find the absolute path to the folder containing rush.json
[ "Find", "the", "absolute", "path", "to", "the", "folder", "containing", "rush", ".", "json" ]
8f3440ae388c3a33af7781ba2faf59e4644464fb
https://github.com/Microsoft/tsdoc/blob/8f3440ae388c3a33af7781ba2faf59e4644464fb/common/scripts/install-run.js#L132-L151
train
Microsoft/tsdoc
common/scripts/install-run.js
ensureAndJoinPath
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
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)) { ...
[ "function", "ensureAndJoinPath", "(", "baseFolder", ",", "...", "pathSegments", ")", "{", "let", "joinedPath", "=", "baseFolder", ";", "try", "{", "for", "(", "let", "pathSegment", "of", "pathSegments", ")", "{", "pathSegment", "=", "pathSegment", ".", "replac...
Create missing directories under the specified base directory, and return the resolved directory. Does not support "." or ".." path segments. Assumes the baseFolder exists.
[ "Create", "missing", "directories", "under", "the", "specified", "base", "directory", "and", "return", "the", "resolved", "directory", "." ]
8f3440ae388c3a33af7781ba2faf59e4644464fb
https://github.com/Microsoft/tsdoc/blob/8f3440ae388c3a33af7781ba2faf59e4644464fb/common/scripts/install-run.js#L159-L174
train
Microsoft/tsdoc
common/scripts/install-run.js
isPackageAlreadyInstalled
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
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...
[ "function", "isPackageAlreadyInstalled", "(", "packageInstallFolder", ")", "{", "try", "{", "const", "flagFilePath", "=", "path", ".", "join", "(", "packageInstallFolder", ",", "INSTALLED_FLAG_FILENAME", ")", ";", "if", "(", "!", "fs", ".", "existsSync", "(", "f...
Detects if the package in the specified directory is installed
[ "Detects", "if", "the", "package", "in", "the", "specified", "directory", "is", "installed" ]
8f3440ae388c3a33af7781ba2faf59e4644464fb
https://github.com/Microsoft/tsdoc/blob/8f3440ae388c3a33af7781ba2faf59e4644464fb/common/scripts/install-run.js#L236-L248
train
Microsoft/tsdoc
common/scripts/install-run.js
installPackage
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
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...
[ "function", "installPackage", "(", "packageInstallFolder", ",", "name", ",", "version", ")", "{", "try", "{", "console", ".", "log", "(", "`", "${", "name", "}", "`", ")", ";", "const", "npmPath", "=", "getNpmPath", "(", ")", ";", "const", "result", "=...
Run "npm install" in the package install folder.
[ "Run", "npm", "install", "in", "the", "package", "install", "folder", "." ]
8f3440ae388c3a33af7781ba2faf59e4644464fb
https://github.com/Microsoft/tsdoc/blob/8f3440ae388c3a33af7781ba2faf59e4644464fb/common/scripts/install-run.js#L297-L314
train
Microsoft/tsdoc
common/scripts/install-run.js
getBinPath
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
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); }
[ "function", "getBinPath", "(", "packageInstallFolder", ",", "binName", ")", "{", "const", "binFolderPath", "=", "path", ".", "resolve", "(", "packageInstallFolder", ",", "NODE_MODULES_FOLDER_NAME", ",", "'.bin'", ")", ";", "const", "resolvedBinName", "=", "(", "os...
Get the ".bin" path for the package.
[ "Get", "the", ".", "bin", "path", "for", "the", "package", "." ]
8f3440ae388c3a33af7781ba2faf59e4644464fb
https://github.com/Microsoft/tsdoc/blob/8f3440ae388c3a33af7781ba2faf59e4644464fb/common/scripts/install-run.js#L318-L322
train
Microsoft/tsdoc
common/scripts/install-run.js
writeFlagFile
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
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}`); }...
[ "function", "writeFlagFile", "(", "packageInstallFolder", ")", "{", "try", "{", "const", "flagFilePath", "=", "path", ".", "join", "(", "packageInstallFolder", ",", "INSTALLED_FLAG_FILENAME", ")", ";", "fs", ".", "writeFileSync", "(", "flagFilePath", ",", "process...
Write a flag file to the package's install directory, signifying that the install was successful.
[ "Write", "a", "flag", "file", "to", "the", "package", "s", "install", "directory", "signifying", "that", "the", "install", "was", "successful", "." ]
8f3440ae388c3a33af7781ba2faf59e4644464fb
https://github.com/Microsoft/tsdoc/blob/8f3440ae388c3a33af7781ba2faf59e4644464fb/common/scripts/install-run.js#L326-L334
train
node-pinus/pinus
examples/websocket-chat-ts-run/web-server/public/js/client.js
addMessage
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
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...
[ "function", "addMessage", "(", "from", ",", "target", ",", "text", ",", "time", ")", "{", "var", "name", "=", "(", "target", "==", "'*'", "?", "'all'", ":", "target", ")", ";", "if", "(", "text", "===", "null", ")", "return", ";", "if", "(", "tim...
add message on board
[ "add", "message", "on", "board" ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/examples/websocket-chat-ts-run/web-server/public/js/client.js#L52-L76
train
node-pinus/pinus
examples/websocket-chat-ts-run/web-server/public/js/client.js
initUserList
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
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); } }
[ "function", "initUserList", "(", "data", ")", "{", "users", "=", "data", ".", "users", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "users", ".", "length", ";", "i", "++", ")", "{", "var", "slElement", "=", "$", "(", "document", ".", "...
init user list
[ "init", "user", "list" ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/examples/websocket-chat-ts-run/web-server/public/js/client.js#L99-L107
train
node-pinus/pinus
examples/websocket-chat-ts-run/web-server/public/js/client.js
addUser
function addUser(user) { var slElement = $(document.createElement("option")); slElement.attr("value", user); slElement.text(user); $("#usersList").append(slElement); }
javascript
function addUser(user) { var slElement = $(document.createElement("option")); slElement.attr("value", user); slElement.text(user); $("#usersList").append(slElement); }
[ "function", "addUser", "(", "user", ")", "{", "var", "slElement", "=", "$", "(", "document", ".", "createElement", "(", "\"option\"", ")", ")", ";", "slElement", ".", "attr", "(", "\"value\"", ",", "user", ")", ";", "slElement", ".", "text", "(", "user...
add user in user list
[ "add", "user", "in", "user", "list" ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/examples/websocket-chat-ts-run/web-server/public/js/client.js#L110-L115
train
node-pinus/pinus
tools/pinus-admin-web/public/front/TimelineOverviewPane.js
markPercentagesForRecord
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
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...
[ "function", "markPercentagesForRecord", "(", "record", ")", "{", "if", "(", "!", "(", "this", ".", "_showShortEvents", "||", "record", ".", "isLong", "(", ")", ")", ")", "return", ";", "var", "percentages", "=", "this", ".", "_overviewCalculator", ".", "co...
Create sparse arrays with 101 cells each to fill with chunks for a given category.
[ "Create", "sparse", "arrays", "with", "101", "cells", "each", "to", "fill", "with", "chunks", "for", "a", "given", "category", "." ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/tools/pinus-admin-web/public/front/TimelineOverviewPane.js#L219-L229
train
node-pinus/pinus
examples/websocket-chat-ts-run/web-server/public/js/lib/build/build.js
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
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...
[ "function", "(", "data", ")", "{", "if", "(", "!", "data", "||", "!", "data", ".", "sys", ")", "{", "return", ";", "}", "dict", "=", "data", ".", "sys", ".", "dict", ";", "var", "protos", "=", "data", ".", "sys", ".", "protos", ";", "//Init com...
Initilize data used in pomelo client
[ "Initilize", "data", "used", "in", "pomelo", "client" ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/examples/websocket-chat-ts-run/web-server/public/js/lib/build/build.js#L1776-L1810
train
node-pinus/pinus
tools/pinus-admin-web/public/front/TextViewer.js
forwardWheelEvent
function forwardWheelEvent(event) { var clone = document.createEvent("WheelEvent"); clone.initWebKitWheelEvent(event.wheelDeltaX, event.wheelDeltaY, event.view, event.screenX, event.screenY, even...
javascript
function forwardWheelEvent(event) { var clone = document.createEvent("WheelEvent"); clone.initWebKitWheelEvent(event.wheelDeltaX, event.wheelDeltaY, event.view, event.screenX, event.screenY, even...
[ "function", "forwardWheelEvent", "(", "event", ")", "{", "var", "clone", "=", "document", ".", "createEvent", "(", "\"WheelEvent\"", ")", ";", "clone", ".", "initWebKitWheelEvent", "(", "event", ".", "wheelDeltaX", ",", "event", ".", "wheelDeltaY", ",", "event...
Forward mouse wheel events from the unscrollable gutter to the main panel.
[ "Forward", "mouse", "wheel", "events", "from", "the", "unscrollable", "gutter", "to", "the", "main", "panel", "." ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/tools/pinus-admin-web/public/front/TextViewer.js#L59-L68
train
node-pinus/pinus
tools/pinus-admin-web/public/front/TextViewer.js
function(oldRange, newRange, oldText, newText) { if (!this._internalTextChangeMode) this._textModel.resetUndoStack(); this._mainPanel.textChanged(oldRange, newRange); this._gutterPanel.textChanged(oldRange, newRange); this._updatePanelOffsets(); }
javascript
function(oldRange, newRange, oldText, newText) { if (!this._internalTextChangeMode) this._textModel.resetUndoStack(); this._mainPanel.textChanged(oldRange, newRange); this._gutterPanel.textChanged(oldRange, newRange); this._updatePanelOffsets(); }
[ "function", "(", "oldRange", ",", "newRange", ",", "oldText", ",", "newText", ")", "{", "if", "(", "!", "this", ".", "_internalTextChangeMode", ")", "this", ".", "_textModel", ".", "resetUndoStack", "(", ")", ";", "this", ".", "_mainPanel", ".", "textChang...
WebInspector.TextModel listener
[ "WebInspector", ".", "TextModel", "listener" ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/tools/pinus-admin-web/public/front/TextViewer.js#L180-L187
train
node-pinus/pinus
examples/simple-example/web-server/public/js/lib/build/build.js
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
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...
[ "function", "(", "data", ")", "{", "if", "(", "!", "data", "||", "!", "data", ".", "sys", ")", "{", "return", ";", "}", "pinus", ".", "data", "=", "pinus", ".", "data", "||", "{", "}", ";", "var", "dict", "=", "data", ".", "sys", ".", "dict",...
Initilize data used in pinus client
[ "Initilize", "data", "used", "in", "pinus", "client" ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/examples/simple-example/web-server/public/js/lib/build/build.js#L1667-L1695
train
node-pinus/pinus
tools/pinus-admin-web/public/front/TextPrompt.js
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
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); }
[ "function", "(", "text", ")", "{", "if", "(", "this", ".", "_uncommittedIsTop", ")", "{", "this", ".", "_data", ".", "pop", "(", ")", ";", "delete", "this", ".", "_uncommittedIsTop", ";", "}", "this", ".", "_historyOffset", "=", "1", ";", "if", "(", ...
Pushes a committed text into the history. @param {string} text
[ "Pushes", "a", "committed", "text", "into", "the", "history", "." ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/tools/pinus-admin-web/public/front/TextPrompt.js#L799-L810
train
node-pinus/pinus
tools/pinus-robot/dist/lib/console/js/ui/webclient.jquery.js
calc_screen_size
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
function calc_screen_size(scount) { if (!scount) { scount = $("#screens .screen").length; } var ssize = (($(window).height() - bottom_height - 20) / scount) - (bar_height + 53); return ssize; }
[ "function", "calc_screen_size", "(", "scount", ")", "{", "if", "(", "!", "scount", ")", "{", "scount", "=", "$", "(", "\"#screens .screen\"", ")", ".", "length", ";", "}", "var", "ssize", "=", "(", "(", "$", "(", "window", ")", ".", "height", "(", ...
Calculate individual screen size
[ "Calculate", "individual", "screen", "size" ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/tools/pinus-robot/dist/lib/console/js/ui/webclient.jquery.js#L113-L118
train
node-pinus/pinus
tools/pinus-admin-web/public/js/socket.io.js
SocketNamespace
function SocketNamespace (socket, name) { this.socket = socket; this.name = name || ''; this.flags = {}; this.json = new Flag(this, 'json'); this.ackPackets = 0; this.acks = {}; }
javascript
function SocketNamespace (socket, name) { this.socket = socket; this.name = name || ''; this.flags = {}; this.json = new Flag(this, 'json'); this.ackPackets = 0; this.acks = {}; }
[ "function", "SocketNamespace", "(", "socket", ",", "name", ")", "{", "this", ".", "socket", "=", "socket", ";", "this", ".", "name", "=", "name", "||", "''", ";", "this", ".", "flags", "=", "{", "}", ";", "this", ".", "json", "=", "new", "Flag", ...
Socket namespace constructor. @constructor @api public
[ "Socket", "namespace", "constructor", "." ]
985ba74bc4ef4bab12d4b0cc677c8c07c557d8de
https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/tools/pinus-admin-web/public/js/socket.io.js#L2011-L2018
train