1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Change isNodeJS from a function to a constant

Given that this shouldn't change after the `pdf.js`/`pdf.worker.js` files have been loaded, it doesn't seems necessary to keep this as a function.
This commit is contained in:
Jonas Jenwald 2019-11-10 16:42:46 +01:00
parent 2817121bc1
commit 74e00ed93c
16 changed files with 49 additions and 50 deletions

View file

@ -30,14 +30,14 @@ function withZlib(isZlibRequired, callback) {
if (isZlibRequired) {
// We could try to polyfill zlib in the browser, e.g. using pako.
// For now, only support zlib functionality on Node.js
if (!isNodeJS()) {
if (!isNodeJS) {
throw new Error('zlib test can only be run in Node.js');
}
return callback();
}
if (!isNodeJS()) {
if (!isNodeJS) {
// Assume that require('zlib') is unavailable in non-Node.
return callback();
}
@ -94,14 +94,14 @@ describe('SVGGraphics', function () {
// This points to the XObject image in xobject-image.pdf.
var xobjectObjId = 'img_p0_1';
if (isNodeJS()) {
if (isNodeJS) {
setStubs(global);
}
try {
var imgData = svgGfx.objs.get(xobjectObjId);
svgGfx.paintInlineImageXObject(imgData, elementContainer);
} finally {
if (isNodeJS()) {
if (isNodeJS) {
unsetStubs(global);
}
}
@ -116,7 +116,7 @@ describe('SVGGraphics', function () {
// Verifies that the script loader replaces __non_webpack_require__ with
// require.
expect(testFunc.toString()).toMatch(/\srequire\(["']zlib["']\)/);
if (isNodeJS()) {
if (isNodeJS) {
expect(testFunc).not.toThrow();
} else {
// require not defined, require('zlib') not a module, etc.
@ -125,7 +125,7 @@ describe('SVGGraphics', function () {
});
it('should produce a reasonably small svg:image', function(done) {
if (!isNodeJS()) {
if (!isNodeJS) {
pending('zlib.deflateSync is not supported in non-Node environments.');
}
withZlib(true, getSVGImage).then(function(svgImg) {