mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Move additional worker-thread only functions from src/shared/util.js
and into a src/core/core_utils.js
instead
This moves the `log2`, `readInt8`, `readUint16`, `readUint32`, and `isSpace` functions since they are only used in the worker-thread.
This commit is contained in:
parent
794744c3fa
commit
3f031f69c2
12 changed files with 82 additions and 99 deletions
|
@ -132,6 +132,39 @@ function toRomanNumerals(number, lowerCase = false) {
|
|||
return lowerCase ? romanStr.toLowerCase() : romanStr;
|
||||
}
|
||||
|
||||
// Calculate the base 2 logarithm of the number `x`. This differs from the
|
||||
// native function in the sense that it returns the ceiling value and that it
|
||||
// returns 0 instead of `Infinity`/`NaN` for `x` values smaller than/equal to 0.
|
||||
function log2(x) {
|
||||
if (x <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.ceil(Math.log2(x));
|
||||
}
|
||||
|
||||
function readInt8(data, offset) {
|
||||
return (data[offset] << 24) >> 24;
|
||||
}
|
||||
|
||||
function readUint16(data, offset) {
|
||||
return (data[offset] << 8) | data[offset + 1];
|
||||
}
|
||||
|
||||
function readUint32(data, offset) {
|
||||
return (
|
||||
((data[offset] << 24) |
|
||||
(data[offset + 1] << 16) |
|
||||
(data[offset + 2] << 8) |
|
||||
data[offset + 3]) >>>
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
// Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
|
||||
function isSpace(ch) {
|
||||
return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
|
||||
}
|
||||
|
||||
export {
|
||||
getLookupTableFactory,
|
||||
MissingDataException,
|
||||
|
@ -139,4 +172,9 @@ export {
|
|||
XRefParseException,
|
||||
getInheritableProperty,
|
||||
toRomanNumerals,
|
||||
log2,
|
||||
readInt8,
|
||||
readUint16,
|
||||
readUint32,
|
||||
isSpace,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue