code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
fromBits(arr) {
const bl = bitArray.bitLength(arr);
const byteLength = bl / 8;
const out = new Uint8Array(byteLength);
let tmp;
for (let i = 0; i < byteLength; i++) {
if ((i & 3) === 0) {
tmp = arr[i / 4];
}
out[i] = tmp >>> 24;
tmp <<= 8;
}
return out;
} | Convert from a bitArray to an array of bytes. | fromBits | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
toBits(bytes) {
const out = [];
let i;
let tmp = 0;
for (i = 0; i < bytes.length; i++) {
tmp = tmp << 8 | bytes[i];
if ((i & 3) === 3) {
out.push(tmp);
tmp = 0;
}
}
if (i & 3) {
out.push(bitArray.partial(8 * (i & 3), tmp));
}
return out;
} | Convert from an array of bytes to a bitArray. | toBits | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
constructor(hash) {
const sha1 = this;
/**
* The hash's block size, in bits.
* @constant
*/
sha1.blockSize = 512;
/**
* The SHA-1 initialization vector.
* @private
*/
sha1._init = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
/**
* The SHA-1 hash key.
* @private
*/... | Context for a SHA-1 operation in progress.
@constructor | constructor | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
reset() {
const sha1 = this;
sha1._h = sha1._init.slice(0);
sha1._buffer = [];
sha1._length = 0;
return sha1;
} | Reset the hash state.
@return this | reset | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
update(data) {
const sha1 = this;
if (typeof data === "string") {
data = codec.utf8String.toBits(data);
}
const b = sha1._buffer = bitArray.concat(sha1._buffer, data);
const ol = sha1._length;
const nl = sha1._length = ol + bitArray.bitLength(data);
if (nl > 9007199254740991) {
throw new Error("Cann... | Input several words to the hash.
@param {bitArray|String} data the data to hash.
@return this | update | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
finalize() {
const sha1 = this;
let b = sha1._buffer;
const h = sha1._h;
// Round out and push the buffer
b = bitArray.concat(b, [bitArray.partial(1, 1)]);
// Round out the buffer to a multiple of 16 words, less the 2 length words.
for (let i = b.length + 2; i & 15; i++) {
b.push(0);
}
// append ... | Complete hashing and output the hash value.
@return {bitArray} The hash value, an array of 5 big-endian words. TODO | finalize | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
_block(words) {
const sha1 = this;
const h = sha1._h;
// When words is passed to _block, it has 16 elements. SHA1 _block
// function extends words with new elements (at the end there are 80 elements).
// The problem is that if we use Uint32Array instead of Array,
// the length of Uint32Array cannot be cha... | Perform one cycle of SHA-1.
@param {Uint32Array|bitArray} words one block of words.
@private | _block | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
constructor(key) {
/**
* The expanded S-box and inverse S-box tables. These will be computed
* on the client so that we don't have to send them down the wire.
*
* There are two tables, _tables[0] is for encryption and
* _tables[1] is for decryption.
*
* The first 4 sub-tables are the expanded S-... | Schedule out an AES key for both encryption and decryption. This
is a low-level class. Use a cipher mode to do bulk encryption.
@constructor
@param {Array} key The key as an array of 4, 6 or 8 words. | constructor | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
encrypt(data) {
return this._crypt(data, 0);
} | Encrypt an array of 4 big-endian words.
@param {Array} data The plaintext.
@return {Array} The ciphertext. | encrypt | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
decrypt(data) {
return this._crypt(data, 1);
} | Decrypt an array of 4 big-endian words.
@param {Array} data The ciphertext.
@return {Array} The plaintext. | decrypt | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
_crypt(input, dir) {
if (input.length !== 4) {
throw new Error("invalid aes block size");
}
const key = this._key[dir];
const nInnerRounds = key.length / 4 - 2;
const out = [0, 0, 0, 0];
const table = this._tables[dir];
// load up the tables
const t0 = table[0];
const t1 = table[1];
const t2 =... | Encryption and decryption core.
@param {Array} input Four words to be encrypted or decrypted.
@param dir The direction, 0 for encrypt and 1 for decrypt.
@return {Array} The four encrypted or decrypted words.
@private | _crypt | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
getRandomValues(typedArray) {
const words = new Uint32Array(typedArray.buffer);
const r = (m_w) => {
let m_z = 0x3ade68b1;
const mask = 0xffffffff;
return function () {
m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
const result =... | Generate random words with pure js, cryptographically not as strong & safe as native implementation.
@param {TypedArray} typedArray The array to fill.
@return {TypedArray} The random values. | getRandomValues | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
r = (m_w) => {
let m_z = 0x3ade68b1;
const mask = 0xffffffff;
return function () {
m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
const result = ((((m_z << 0x10) + m_w) & mask) / 0x100000000) + .5;
return result * (Math.random() >... | Generate random words with pure js, cryptographically not as strong & safe as native implementation.
@param {TypedArray} typedArray The array to fill.
@return {TypedArray} The random values. | r | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
r = (m_w) => {
let m_z = 0x3ade68b1;
const mask = 0xffffffff;
return function () {
m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
const result = ((((m_z << 0x10) + m_w) & mask) / 0x100000000) + .5;
return result * (Math.random() >... | Generate random words with pure js, cryptographically not as strong & safe as native implementation.
@param {TypedArray} typedArray The array to fill.
@return {TypedArray} The random values. | r | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
update(data) {
return this.calculate(this._prf, data, this._iv);
} | Input some data to calculate.
@param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last. | update | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
incWord(word) {
if (((word >> 24) & 0xff) === 0xff) { //overflow
let b1 = (word >> 16) & 0xff;
let b2 = (word >> 8) & 0xff;
let b3 = word & 0xff;
if (b1 === 0xff) { // overflow b1
b1 = 0;
if (b2 === 0xff) {
b2 = 0;
if (b3 === 0xff) {
b3 = 0;
} else {
++b3;
}
... | Input some data to calculate.
@param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last. | incWord | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
incCounter(counter) {
if ((counter[0] = this.incWord(counter[0])) === 0) {
// encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
counter[1] = this.incWord(counter[1]);
}
} | Input some data to calculate.
@param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last. | incCounter | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
calculate(prf, data, iv) {
let l;
if (!(l = data.length)) {
return [];
}
const bl = bitArray.bitLength(data);
for (let i = 0; i < l; i += 4) {
this.incCounter(iv);
const e = prf.encrypt(iv);
data[i] ^= e[0];
data[i + 1] ^= e[1];
data[i + 2] ^= e[2];
data[i + 3] ^= e[3];
}
return bitAr... | Input some data to calculate.
@param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last. | calculate | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
importKey(password) {
return new misc.hmacSha1(codec.bytes.toBits(password));
} | Input some data to calculate.
@param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last. | importKey | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
pbkdf2(prf, salt, count, length) {
count = count || 10000;
if (length < 0 || count < 0) {
throw new Error("invalid params to pbkdf2");
}
const byteLength = ((length >> 5) + 1) << 2;
let u, ui, i, j, k;
const arrayBuffer = new ArrayBuffer(byteLength);
const out = new DataView(arrayBuffer);
let outLeng... | Input some data to calculate.
@param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last. | pbkdf2 | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
constructor(key) {
const hmac = this;
const Hash = hmac._hash = hash.sha1;
const exKey = [[], []];
hmac._baseHash = [new Hash(), new Hash()];
const bs = hmac._baseHash[0].blockSize / 32;
if (key.length > bs) {
key = new Hash().update(key).finalize();
}
for (let i = 0; i < bs; i++) {
exKey[0][i] ... | HMAC with the specified hash function.
@constructor
@param {bitArray} key the key for HMAC.
@param {Object} [Hash=hash.sha1] The hash function to use. | constructor | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
reset() {
const hmac = this;
hmac._resultHash = new hmac._hash(hmac._baseHash[0]);
hmac._updated = false;
} | HMAC with the specified hash function.
@constructor
@param {bitArray} key the key for HMAC.
@param {Object} [Hash=hash.sha1] The hash function to use. | reset | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
update(data) {
const hmac = this;
hmac._updated = true;
hmac._resultHash.update(data);
} | HMAC with the specified hash function.
@constructor
@param {bitArray} key the key for HMAC.
@param {Object} [Hash=hash.sha1] The hash function to use. | update | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
digest() {
const hmac = this;
const w = hmac._resultHash.finalize();
const result = new (hmac._hash)(hmac._baseHash[1]).update(w).finalize();
hmac.reset();
return result;
} | HMAC with the specified hash function.
@constructor
@param {bitArray} key the key for HMAC.
@param {Object} [Hash=hash.sha1] The hash function to use. | digest | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
encrypt(data) {
if (!this._updated) {
this.update(data);
return this.digest(data);
} else {
throw new Error("encrypt on already updated hmac called!");
}
} | HMAC with the specified hash function.
@constructor
@param {bitArray} key the key for HMAC.
@param {Object} [Hash=hash.sha1] The hash function to use. | encrypt | javascript | gildas-lormeau/zip.js | lib/core/streams/codecs/sjcl.js | https://github.com/gildas-lormeau/zip.js/blob/master/lib/core/streams/codecs/sjcl.js | BSD-3-Clause |
function benchmark(s, d) {
log(s + "," + (new Date().getTime() - d.getTime()) + "ms");
} | @description Create a sortable table with multi-column sorting capabilitys
@example $('table').tablesorter();
@desc Create a simple tablesorter interface.
@example $('table').tablesorter({ sortList:[[0,0],[1,0]] });
@desc Create a tablesorter interface and sort on the first and secound column column headers.
@exampl... | benchmark | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function log(s) {
if (typeof console != "undefined" && typeof console.debug != "undefined") {
console.log(s);
} else {
alert(s);
}
} | @description Create a sortable table with multi-column sorting capabilitys
@example $('table').tablesorter();
@desc Create a simple tablesorter interface.
@example $('table').tablesorter({ sortList:[[0,0],[1,0]] });
@desc Create a tablesorter interface and sort on the first and secound column column headers.
@exampl... | log | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function buildParserCache(table, $headers) {
if (table.config.debug) {
var parsersDebug = "";
}
if (table.tBodies.length == 0) return; // In the case of empty tables
var rows = table.tBodies[0].rows;
if (rows[0]) {
... | @description Create a sortable table with multi-column sorting capabilitys
@example $('table').tablesorter();
@desc Create a simple tablesorter interface.
@example $('table').tablesorter({ sortList:[[0,0],[1,0]] });
@desc Create a tablesorter interface and sort on the first and secound column column headers.
@exampl... | buildParserCache | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function detectParserForColumn(table, rows, rowIndex, cellIndex) {
var l = parsers.length,
node = false,
nodeValue = false,
keepLooking = true;
while (nodeValue == '' && keepLooking) {
rowIndex++;
... | @description Create a sortable table with multi-column sorting capabilitys
@example $('table').tablesorter();
@desc Create a simple tablesorter interface.
@example $('table').tablesorter({ sortList:[[0,0],[1,0]] });
@desc Create a tablesorter interface and sort on the first and secound column column headers.
@exampl... | detectParserForColumn | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function getNodeFromRowAndCellIndex(rows, rowIndex, cellIndex) {
return rows[rowIndex].cells[cellIndex];
} | @description Create a sortable table with multi-column sorting capabilitys
@example $('table').tablesorter();
@desc Create a simple tablesorter interface.
@example $('table').tablesorter({ sortList:[[0,0],[1,0]] });
@desc Create a tablesorter interface and sort on the first and secound column column headers.
@exampl... | getNodeFromRowAndCellIndex | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function trimAndGetNodeText(config, node) {
return $.trim(getElementText(config, node));
} | @description Create a sortable table with multi-column sorting capabilitys
@example $('table').tablesorter();
@desc Create a simple tablesorter interface.
@example $('table').tablesorter({ sortList:[[0,0],[1,0]] });
@desc Create a tablesorter interface and sort on the first and secound column column headers.
@exampl... | trimAndGetNodeText | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function getParserById(name) {
var l = parsers.length;
for (var i = 0; i < l; i++) {
if (parsers[i].id.toLowerCase() == name.toLowerCase()) {
return parsers[i];
}
}
return false;
} | @description Create a sortable table with multi-column sorting capabilitys
@example $('table').tablesorter();
@desc Create a simple tablesorter interface.
@example $('table').tablesorter({ sortList:[[0,0],[1,0]] });
@desc Create a tablesorter interface and sort on the first and secound column column headers.
@exampl... | getParserById | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function buildCache(table) {
if (table.config.debug) {
var cacheTime = new Date();
}
var totalRows = (table.tBodies[0] && table.tBodies[0].rows.length) || 0,
totalCells = (table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells... | @description Create a sortable table with multi-column sorting capabilitys
@example $('table').tablesorter();
@desc Create a simple tablesorter interface.
@example $('table').tablesorter({ sortList:[[0,0],[1,0]] });
@desc Create a tablesorter interface and sort on the first and secound column column headers.
@exampl... | buildCache | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function getElementText(config, node) {
var text = "";
if (!node) return "";
if (!config.supportsTextContent) config.supportsTextContent = node.textContent || false;
if (config.textExtraction == "simple") {
if (config.supportsTextCo... | Add the table data to main data array | getElementText | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function appendToTable(table, cache) {
if (table.config.debug) {
var appendTime = new Date()
}
var c = cache,
r = c.row,
n = c.normalized,
totalRows = n.length,
checkCell... | Add the table data to main data array | appendToTable | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function buildHeaders(table) {
if (table.config.debug) {
var time = new Date();
}
var meta = ($.metadata) ? true : false;
var header_index = computeTableHeaderCellIndexes(table);
$tableHeaders = $(tab... | Add the table data to main data array | buildHeaders | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function computeTableHeaderCellIndexes(t) {
var matrix = [];
var lookup = {};
var thead = t.getElementsByTagName('THEAD')[0];
var trs = thead.getElementsByTagName('TR');
for (var i = 0; i < trs.length; i++) {
var cells ... | Add the table data to main data array | computeTableHeaderCellIndexes | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function checkCellColSpan(table, rows, row) {
var arr = [],
r = table.tHead.rows,
c = r[row].cells;
for (var i = 0; i < c.length; i++) {
var cell = c[i];
if (cell.colSpan > 1) {
arr ... | Add the table data to main data array | checkCellColSpan | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function checkHeaderMetadata(cell) {
if (($.metadata) && ($(cell).metadata().sorter === false)) {
return true;
};
return false;
} | Add the table data to main data array | checkHeaderMetadata | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function checkHeaderOptions(table, i) {
if ((table.config.headers[i]) && (table.config.headers[i].sorter === false)) {
return true;
};
return false;
} | Add the table data to main data array | checkHeaderOptions | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function checkHeaderOptionsSortingLocked(table, i) {
if ((table.config.headers[i]) && (table.config.headers[i].lockedOrder)) return table.config.headers[i].lockedOrder;
return false;
} | Add the table data to main data array | checkHeaderOptionsSortingLocked | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function applyWidget(table) {
var c = table.config.widgets;
var l = c.length;
for (var i = 0; i < l; i++) {
getWidgetById(c[i]).format(table);
}
} | Add the table data to main data array | applyWidget | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function getWidgetById(name) {
var l = widgets.length;
for (var i = 0; i < l; i++) {
if (widgets[i].id.toLowerCase() == name.toLowerCase()) {
return widgets[i];
}
}
} | Add the table data to main data array | getWidgetById | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function formatSortingOrder(v) {
if (typeof(v) != "Number") {
return (v.toLowerCase() == "desc") ? 1 : 0;
} else {
return (v == 1) ? 1 : 0;
}
} | Add the table data to main data array | formatSortingOrder | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function isValueInArray(v, a) {
var l = a.length;
for (var i = 0; i < l; i++) {
if (a[i][0] == v) {
return true;
}
}
return false;
} | Add the table data to main data array | isValueInArray | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function setHeadersCss(table, $headers, list, css) {
// remove all header information
$headers.removeClass(css[0]).removeClass(css[1]);
var h = [];
$headers.each(function (offset) {
if (!this.sortDisabled) {
h[t... | Add the table data to main data array | setHeadersCss | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function fixColumnWidth(table, $headers) {
var c = table.config;
if (c.widthFixed) {
var colgroup = $('<colgroup>');
$("tr:first td", table.tBodies[0]).each(function () {
colgroup.append($('<col>').css('width', $(this).width... | Add the table data to main data array | fixColumnWidth | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function updateHeaderSortCount(table, sortList) {
var c = table.config,
l = sortList.length;
for (var i = 0; i < l; i++) {
var s = sortList[i],
o = c.headerList[s[0]];
o.count = s[1];
... | Add the table data to main data array | updateHeaderSortCount | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function multisort(table, sortList, cache) {
if (table.config.debug) {
var sortTime = new Date();
}
var dynamicExp = "var sortWrapper = function(a,b) {",
l = sortList.length;
// TODO: inline functions.
... | Add the table data to main data array | multisort | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function makeSortFunction(type, direction, index) {
var a = "a[" + index + "]",
b = "b[" + index + "]";
if (type == 'text' && direction == 'asc') {
return "(" + a + " == " + b + " ? 0 : (" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " ==... | Add the table data to main data array | makeSortFunction | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function makeSortText(i) {
return "((a[" + i + "] < b[" + i + "]) ? -1 : ((a[" + i + "] > b[" + i + "]) ? 1 : 0));";
} | Add the table data to main data array | makeSortText | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function makeSortTextDesc(i) {
return "((b[" + i + "] < a[" + i + "]) ? -1 : ((b[" + i + "] > a[" + i + "]) ? 1 : 0));";
} | Add the table data to main data array | makeSortTextDesc | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function makeSortNumeric(i) {
return "a[" + i + "]-b[" + i + "];";
} | Add the table data to main data array | makeSortNumeric | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function makeSortNumericDesc(i) {
return "b[" + i + "]-a[" + i + "];";
} | Add the table data to main data array | makeSortNumericDesc | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function sortText(a, b) {
if (table.config.sortLocaleCompare) return a.localeCompare(b);
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
} | Add the table data to main data array | sortText | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function sortTextDesc(a, b) {
if (table.config.sortLocaleCompare) return b.localeCompare(a);
return ((b < a) ? -1 : ((b > a) ? 1 : 0));
} | Add the table data to main data array | sortTextDesc | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function sortNumeric(a, b) {
return a - b;
} | Add the table data to main data array | sortNumeric | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function sortNumericDesc(a, b) {
return b - a;
} | Add the table data to main data array | sortNumericDesc | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function getCachedSortType(parsers, i) {
return parsers[i].type;
} | Add the table data to main data array | getCachedSortType | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function empty() {
while (this.firstChild)
this.removeChild(this.firstChild);
} | Add the table data to main data array | empty | javascript | jmosbech/StickyTableHeaders | demo/js/jquery.tablesorter.js | https://github.com/jmosbech/StickyTableHeaders/blob/master/demo/js/jquery.tablesorter.js | MIT |
function normalizeIndent(strings) {
const codeLines = strings[0].split('\n');
const leftPadding = codeLines[1].match(/\s+/)[0];
return codeLines.map(line => line.slice(leftPadding.length)).join('\n');
} | A string template tag that removes padding from the left side of multi-line strings | normalizeIndent | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/scripts/eslint-plugin-react-hooks-test-cases.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/scripts/eslint-plugin-react-hooks-test-cases.js | MIT |
function Component({value}) {
const arr = [{value: 'foo'}, {value: 'bar'}, {value}];
useIdentity();
const derived = Array.from(arr, (x, idx) => ({...x, id: idx}));
return <Stringify>{derived.at(-1)}</Stringify>;
} | TODO: Note that this `Array.from` is inferred to be mutating its first
argument. This is because React Compiler's typing system does not yet support
annotating a function with a set of argument match cases + distinct
definitions (polymorphism).
In this case, we should be able to infer that the `Array.from` call is
not... | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-from-arg1-captures-arg0.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-from-arg1-captures-arg0.js | MIT |
function Component({value}) {
const arr = [{value: 'foo'}, {value: 'bar'}, {value}];
useIdentity();
const derived = Array.from(arr);
return <Stringify>{derived.at(-1)}</Stringify>;
} | TODO: Note that this `Array.from` is inferred to be mutating its first
argument. This is because React Compiler's typing system does not yet support
annotating a function with a set of argument match cases + distinct
definitions (polymorphism)
In this case, we should be able to infer that the `Array.from` call is
not ... | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-from-captures-arg0.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-from-captures-arg0.js | MIT |
function useBar({arg}) {
'use memo';
/**
* Note that mutableIterator is mutated by the later object spread. Therefore,
* `s.values()` should be memoized within the same block as the object spread.
* In terms of compiler internals, they should have the same reactive scope.
*/
const s = new Set([1, 5, ... | TODO: object spreads should have conditionally mutate semantics
Found differences in evaluator results
Non-forget (expected):
(kind: ok) [3,1,5,4]
[3,1,5,4]
[4,1,5,4]
Forget:
(kind: ok) [3,1,5,4]
[3,1,5,4]
[4] | useBar | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-spread-mutable-iterator.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-spread-mutable-iterator.js | MIT |
function useFoo({a, b}: {a: number, b: number}) {
const x = [];
const y = {value: a};
arrayPush(x, y); // x and y co-mutate
const y_alias = y;
const cb = () => y_alias.value;
setPropertyByKey(x[0], 'value', b); // might overwrite y.value
return <Stringify cb={cb} shouldInvokeFns={true} />;
} | 1. `InferMutableRanges` derives the mutable range of identifiers and their
aliases from `LoadLocal`, `PropertyLoad`, etc
- After this pass, y's mutable range only extends to `arrayPush(x, y)`
- We avoid assigning mutable ranges to loads after y's mutable range, as
these are working with an immutable value. ... | useFoo | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-aliased-capture-aliased-mutate.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-aliased-capture-aliased-mutate.js | MIT |
function useFoo({a}: {a: number, b: number}) {
const arr = [];
const obj = {value: a};
setPropertyByKey(obj, 'arr', arr);
const obj_alias = obj;
const cb = () => obj_alias.arr.length;
for (let i = 0; i < a; i++) {
arr.push(i);
}
return <Stringify cb={cb} shouldInvokeFns={true} />;
} | Variation of bug in `bug-aliased-capture-aliased-mutate`
Found differences in evaluator results
Non-forget (expected):
(kind: ok)
<div>{"cb":{"kind":"Function","result":2},"shouldInvokeFns":true}</div>
<div>{"cb":{"kind":"Function","result":3},"shouldInvokeFns":true}</div>
Forget:
(kind: ok)
<div>{"cb":{"kind... | useFoo | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-aliased-capture-mutate.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-aliased-capture-mutate.js | MIT |
function Component(props) {
const key = {};
const tmp = (mutate(key), key);
const context = {
// Here, `tmp` is frozen (as it's inferred to be a primitive/string)
[tmp]: identity([props.value]),
};
mutate(key);
return [context, key];
} | Bug: copy of error.todo-object-expression-computed-key-modified-during-after-construction-sequence-expr
with the mutation hoisted to a named variable instead of being directly
inlined into the Object key.
Found differences in evaluator results
Non-forget (expected):
(kind: ok) [{"[object Object]":[42]},{"wat0":"jo... | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-object-expression-computed-key-modified-during-after-construction-hoisted-sequence-expr.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-object-expression-computed-key-modified-during-after-construction-hoisted-sequence-expr.js | MIT |
function ComponentC(props) {
const a = [];
a.push(props.a);
if (props.b) {
a.push(props.c);
return null;
}
a.push(props.d);
return a;
} | props.b *does* influence `a`, but only in a way that is never observable | ComponentC | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/conditional-early-return.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/conditional-early-return.js | MIT |
function Component(props) {
let x = [];
if (ENABLE_FEATURE) {
x.push(42);
return x;
} else {
console.log('fallthrough');
}
return makeArray(props.a);
} | This fixture tests what happens when a reactive has no declarations (other than an early return),
no reassignments, and no dependencies. In this case the only thing we can use to decide if we
should take the if or else branch is the early return declaration. But if that uses the same
sentinel as the memo cache sentinel... | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/early-return-no-declarations-reassignments-dependencies.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/early-return-no-declarations-reassignments-dependencies.js | MIT |
function Component(props) {
const a = compute(props.a);
const b = compute(props.b);
if (props.c) {
mutate(a);
mutate(b);
}
return <Foo a={a} b={b} />;
} | Should produce 3 scopes:
a: inputs=props.a & props.c; outputs=a
a = compute(props.a);
if (props.c)
mutate(a)
b: inputs=props.b & props.c; outputs=b
b = compute(props.b);
if (props.c)
mutate(b)
return: inputs=a, b outputs=return
return = <Foo a={a} b={b} /> | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/independent-across-if.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/independent-across-if.js | MIT |
function Component(props) {
const a = compute(props.a);
const b = compute(props.b);
return <Foo a={a} b={b} />;
} | Should produce 3 scopes:
a: inputs=props.a, outputs=a
a = compute(props.a);
b: inputs=props.b, outputs=b
b = compute(props.b);
return: inputs=a, b outputs=return
return = <Foo a={a} b={b} /> | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/independent.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/independent.js | MIT |
function Component(props) {
const a = compute(props.a);
const b = compute(props.b);
if (props.c) {
foo(a, b);
}
return <Foo a={a} b={b} />;
} | Should produce 1 scope:
return: inputs=props.a & props.b & props.c; outputs=return
const a = compute(props.a);
const b = compute(props.b);
if (props.c)
foo(a, b);
return = <Foo a={a} b={b} /> | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/interdependent-across-if.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/interdependent-across-if.js | MIT |
function Component(props) {
const a = compute(props.a);
const b = compute(props.b);
foo(a, b);
return <Foo a={a} b={b} />;
} | Should produce 1 scope:
return: inputs=props.a & props.b; outputs=return
const a = compute(props.a);
const b = compute(props.b);
foo(a, b);
return = <Foo a={a} b={b} /> | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/interdependent.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/interdependent.js | MIT |
function MyApp() {
return <input pattern="\w" />;
} | Fixture showing `@babel/generator` bug with jsx attribute strings containing
escape sequences. Note that this is only a problem when generating jsx
literals.
When using the jsx transform to correctly lower jsx into
`React.createElement` calls, the escape sequences are preserved correctly
(see evaluator output). | MyApp | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-preserve-escape-character.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-preserve-escape-character.js | MIT |
function Component({extraJsx}) {
const x = makeArray();
const items = useFragment();
// This closure has the following effects that must be replayed:
// - MaybeFreeze / Capture of `items`
// - ConditionalMutate of x
const jsx = items.a.map((item, i) => {
arrayPush(x, 2);
return <Stringify item={... | Bug repro showing why it's invalid for function references to be annotated
with a `Read` effect when that reference might lead to the function being
invoked.
Note that currently, `Array.map` is annotated to have `Read` effects on its
operands. This is incorrect as function effects must be replayed when `map`
is called... | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mixedreadonly-mutating-map.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mixedreadonly-mutating-map.js | MIT |
function Foo({a, b}) {
'use memo';
const obj = {};
const updaterFactory = () => {
/**
* This returned function expression *is* a local value. But it might (1)
* capture and mutate its context environment and (2) be called during
* render.
* Typing it with `freeze` effects would be incorrec... | Example showing that returned inner function expressions should not be
typed with `freeze` effects. | Foo | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-mutates-context.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-mutates-context.js | MIT |
updaterFactory = () => {
/**
* This returned function expression *is* a local value. But it might (1)
* capture and mutate its context environment and (2) be called during
* render.
* Typing it with `freeze` effects would be incorrect as it would mean
* inferring that calls to updaterFactor... | Example showing that returned inner function expressions should not be
typed with `freeze` effects. | updaterFactory | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-mutates-context.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-mutates-context.js | MIT |
updaterFactory = () => {
/**
* This returned function expression *is* a local value. But it might (1)
* capture and mutate its context environment and (2) be called during
* render.
* Typing it with `freeze` effects would be incorrect as it would mean
* inferring that calls to updaterFactor... | Example showing that returned inner function expressions should not be
typed with `freeze` effects. | updaterFactory | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-mutates-context.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-mutates-context.js | MIT |
function Foo({b}) {
'use memo';
const fnFactory = () => {
/**
* This returned function expression *is* a local value. But it might (1)
* capture and mutate its context environment and (2) be called during
* render.
* Typing it with `freeze` effects would be incorrect as it would mean
*... | Example showing that returned inner function expressions should not be
typed with `freeze` effects.
Also see repro-returned-inner-fn-mutates-context | Foo | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-reassigns-context.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-reassigns-context.js | MIT |
fnFactory = () => {
/**
* This returned function expression *is* a local value. But it might (1)
* capture and mutate its context environment and (2) be called during
* render.
* Typing it with `freeze` effects would be incorrect as it would mean
* inferring that calls to updaterFactory()()... | Example showing that returned inner function expressions should not be
typed with `freeze` effects.
Also see repro-returned-inner-fn-mutates-context | fnFactory | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-reassigns-context.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-reassigns-context.js | MIT |
fnFactory = () => {
/**
* This returned function expression *is* a local value. But it might (1)
* capture and mutate its context environment and (2) be called during
* render.
* Typing it with `freeze` effects would be incorrect as it would mean
* inferring that calls to updaterFactory()()... | Example showing that returned inner function expressions should not be
typed with `freeze` effects.
Also see repro-returned-inner-fn-mutates-context | fnFactory | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-reassigns-context.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-reassigns-context.js | MIT |
function Validate({x, input}) {
'use no memo';
return (
<>
<ValidateMemoization inputs={[]} output={x[0]} onlyCheckCompiled={true} />
<ValidateMemoization
inputs={[input]}
output={x[1]}
onlyCheckCompiled={true}
/>
</>
);
} | Fixture for granular iterator semantics:
1. ConditionallyMutate the iterator itself, depending on whether the iterator
is a mutable iterator.
2. Capture effect on elements within the iterator. | Validate | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo-granular-iterator-semantics.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo-granular-iterator-semantics.js | MIT |
function useFoo(input) {
'use memo';
/**
* We should be able to memoize {} separately from `x`.
*/
const x = Array.from([{}]);
useIdentity();
x.push([input]);
return <Validate x={x} input={input} />;
} | Fixture for granular iterator semantics:
1. ConditionallyMutate the iterator itself, depending on whether the iterator
is a mutable iterator.
2. Capture effect on elements within the iterator. | useFoo | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo-granular-iterator-semantics.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo-granular-iterator-semantics.js | MIT |
function Validate({x, val1, val2}) {
'use no memo';
return (
<>
<ValidateMemoization
inputs={[val1]}
output={x[0]}
onlyCheckCompiled={true}
/>
<ValidateMemoization
inputs={[val2]}
output={x[1]}
onlyCheckCompiled={true}
/>
</>
);
} | Fixture to assert that we can infer the type and effects of an array created
with `Array.from`. | Validate | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/type-inference-array-from.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/type-inference-array-from.js | MIT |
function useFoo({val1, val2}) {
'use memo';
const x = Array.from([]);
useIdentity();
x.push([val1]);
x.push([val2]);
return <Validate x={x} val1={val1} val2={val2} />;
} | Fixture to assert that we can infer the type and effects of an array created
with `Array.from`. | useFoo | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/type-inference-array-from.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/type-inference-array-from.js | MIT |
function Component({prop}) {
const [cleanupCount, setCleanupCount] = useState(0);
useEffect(() => {
let cleanedUp = false;
setTimeout(() => {
if (!cleanedUp) {
cleanedUp = true;
setCleanupCount(c => c + 1);
}
}, 0);
// This return value should not have freeze effects
... | Example of a function expression whose return value shouldn't have
a "freeze" effect on all operands.
This is because the function expression is passed to `useEffect` and
thus is not a render function. `cleanedUp` is also created within
the effect and is not a render variable. | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-effect-cleanup-reassigns.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-effect-cleanup-reassigns.js | MIT |
function Foo(props) {
const getText1 = fbt =>
fbt(
`Hello, ${fbt.param('(key) name', identity(props.name))}!`,
'(description) Greeting'
);
const getText2 = fbt =>
fbt(
`Goodbye, ${fbt.param('(key) name', identity(props.name))}!`,
'(description) Greeting2'
);
return (
... | Note that the fbt transform looks for callsites with a `fbt`-named callee.
This is incompatible with react-compiler as we rename local variables in
HIRBuilder + RenameVariables.
See evaluator error:
Found differences in evaluator results
Non-forget (expected):
(kind: ok) <div>Hello, Sathya!Goodbye, Sathya!</div>... | Foo | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-as-local.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-as-local.js | MIT |
getText1 = fbt =>
fbt(
`Hello, ${fbt.param('(key) name', identity(props.name))}!`,
'(description) Greeting'
) | Note that the fbt transform looks for callsites with a `fbt`-named callee.
This is incompatible with react-compiler as we rename local variables in
HIRBuilder + RenameVariables.
See evaluator error:
Found differences in evaluator results
Non-forget (expected):
(kind: ok) <div>Hello, Sathya!Goodbye, Sathya!</div>... | getText1 | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-as-local.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-as-local.js | MIT |
getText1 = fbt =>
fbt(
`Hello, ${fbt.param('(key) name', identity(props.name))}!`,
'(description) Greeting'
) | Note that the fbt transform looks for callsites with a `fbt`-named callee.
This is incompatible with react-compiler as we rename local variables in
HIRBuilder + RenameVariables.
See evaluator error:
Found differences in evaluator results
Non-forget (expected):
(kind: ok) <div>Hello, Sathya!Goodbye, Sathya!</div>... | getText1 | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-as-local.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-as-local.js | MIT |
getText2 = fbt =>
fbt(
`Goodbye, ${fbt.param('(key) name', identity(props.name))}!`,
'(description) Greeting2'
) | Note that the fbt transform looks for callsites with a `fbt`-named callee.
This is incompatible with react-compiler as we rename local variables in
HIRBuilder + RenameVariables.
See evaluator error:
Found differences in evaluator results
Non-forget (expected):
(kind: ok) <div>Hello, Sathya!Goodbye, Sathya!</div>... | getText2 | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-as-local.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-as-local.js | MIT |
getText2 = fbt =>
fbt(
`Goodbye, ${fbt.param('(key) name', identity(props.name))}!`,
'(description) Greeting2'
) | Note that the fbt transform looks for callsites with a `fbt`-named callee.
This is incompatible with react-compiler as we rename local variables in
HIRBuilder + RenameVariables.
See evaluator error:
Found differences in evaluator results
Non-forget (expected):
(kind: ok) <div>Hello, Sathya!Goodbye, Sathya!</div>... | getText2 | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-as-local.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-as-local.js | MIT |
function Component({firstname, lastname}) {
'use memo';
return (
<Stringify>
{fbt(
[
'Name: ',
fbt.param('firstname', <Stringify key={0} name={firstname} />),
', ',
fbt.param(
'lastname',
<Stringify key={0} name={lastname}>
... | MemoizeFbtAndMacroOperands needs to account for nested fbt calls.
Expected fixture `fbt-param-call-arguments` to succeed but it failed with error:
/fbt-param-call-arguments.ts: Line 19 Column 11: fbt: unsupported babel node: Identifier
---
t3
--- | Component | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-param-nested-fbt.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-param-nested-fbt.js | MIT |
function NonReactiveDepInEffect() {
const obj = makeObject_Primitives();
useEffect(() => print(obj));
} | Note that `obj` is currently added to the effect dependency array, even
though it's non-reactive due to memoization.
This is a TODO in effect dependency inference. Note that we cannot simply
filter out non-reactive effect dependencies, as some non-reactive (by data
flow) values become reactive due to scope pruning. Se... | NonReactiveDepInEffect | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-dep.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-dep.js | MIT |
function NonReactiveEffectEvent() {
const fn = useEffectEvent(() => print('hello world'));
useEffect(() => fn());
} | We do not include effect events in dep arrays. | NonReactiveEffectEvent | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-effect-event.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-effect-event.js | MIT |
function RefsInEffects() {
const ref = useRefHelper();
const wrapped = useDeeperRefHelper();
useEffect(() => {
print(ref.current);
print(wrapped.foo.current);
});
} | We never include a .current access in a dep array because it may be a ref access.
This might over-capture objects that are not refs and happen to have fields named
current, but that should be a rare case and the result would still be correct
(assuming the effect is idempotent). In the worst case, you can always write a... | RefsInEffects | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-ref-helper.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-ref-helper.js | MIT |
function useRefHelper() {
return useRef(0);
} | We never include a .current access in a dep array because it may be a ref access.
This might over-capture objects that are not refs and happen to have fields named
current, but that should be a rare case and the result would still be correct
(assuming the effect is idempotent). In the worst case, you can always write a... | useRefHelper | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-ref-helper.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-ref-helper.js | MIT |
function useDeeperRefHelper() {
return {foo: useRefHelper()};
} | We never include a .current access in a dep array because it may be a ref access.
This might over-capture objects that are not refs and happen to have fields named
current, but that should be a rare case and the result would still be correct
(assuming the effect is idempotent). In the worst case, you can always write a... | useDeeperRefHelper | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-ref-helper.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-ref-helper.js | MIT |
function NonReactiveRefInEffect() {
const ref = useRef('initial value');
useEffect(() => print(ref.current));
} | Special case of `infer-effect-deps/nonreactive-dep`.
We know that local `useRef` return values are stable, regardless of
inferred memoization. | NonReactiveRefInEffect | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-ref.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-ref.js | MIT |
function NonReactiveSetStateInEffect() {
const [_, setState] = useState('initial value');
useEffect(() => print(setState));
} | Special case of `infer-effect-deps/nonreactive-dep`.
We know that local `useRef` return values are stable, regardless of
inferred memoization. | NonReactiveSetStateInEffect | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-setState.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-setState.js | MIT |
function OutlinedFunctionInEffect() {
useEffect(() => print('hello world!'));
} | This compiled output is technically incorrect but this is currently the same
case as a bailout (an effect that overfires).
To ensure an empty deps array is passed, we need special case
`InferEffectDependencies` for outlined functions (likely easier) or run it
before OutlineFunctions | OutlinedFunctionInEffect | javascript | facebook/react | compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/outlined-function.js | https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/outlined-function.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.