mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Move IsLittleEndianCached
and IsEvalSupportedCached
to src/shared/util.js
Rather than duplicating the lookup and caching in multiple files, it seems easier to simply move all of this functionality into `src/shared/util.js` instead. This will also help avoid a bunch of ESLint errors once the `no-shadow` rule is eventually enabled.
This commit is contained in:
parent
6db8e085ee
commit
e4758beaaa
4 changed files with 16 additions and 26 deletions
|
@ -547,14 +547,18 @@ function string32(value) {
|
|||
);
|
||||
}
|
||||
|
||||
// Lazy test the endianness of the platform
|
||||
// NOTE: This will be 'true' for simulated TypedArrays
|
||||
// Checks the endianness of the platform.
|
||||
function isLittleEndian() {
|
||||
const buffer8 = new Uint8Array(4);
|
||||
buffer8[0] = 1;
|
||||
const view32 = new Uint32Array(buffer8.buffer, 0, 1);
|
||||
return view32[0] === 1;
|
||||
}
|
||||
const IsLittleEndianCached = {
|
||||
get value() {
|
||||
return shadow(this, "value", isLittleEndian());
|
||||
},
|
||||
};
|
||||
|
||||
// Checks if it's possible to eval JS expressions.
|
||||
function isEvalSupported() {
|
||||
|
@ -565,6 +569,11 @@ function isEvalSupported() {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
const IsEvalSupportedCached = {
|
||||
get value() {
|
||||
return shadow(this, "value", isEvalSupported());
|
||||
},
|
||||
};
|
||||
|
||||
const rgbBuf = ["rgb(", 0, ",", 0, ",", 0, ")"];
|
||||
|
||||
|
@ -918,8 +927,8 @@ export {
|
|||
isString,
|
||||
isSameOrigin,
|
||||
createValidAbsoluteUrl,
|
||||
isLittleEndian,
|
||||
isEvalSupported,
|
||||
IsLittleEndianCached,
|
||||
IsEvalSupportedCached,
|
||||
removeNullCharacters,
|
||||
setVerbosityLevel,
|
||||
shadow,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue