Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
perf: use node: prefix to bypass require.cache call for builtins (#824
)
  • Loading branch information
Fdawgs committed Sep 25, 2023
1 parent ff173ce commit 2a27a0e
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion benchmarks/node/speed-benchmark.js
@@ -1,5 +1,5 @@
#!/usr/bin/env node
const path = require('path');
const path = require('node:path');
const { createWorker } = require('../../');

(async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/node/detect.js
@@ -1,5 +1,5 @@
#!/usr/bin/env node
const path = require('path');
const path = require('node:path');
const Tesseract = require('../../');

const [,, imagePath] = process.argv;
Expand Down
4 changes: 2 additions & 2 deletions examples/node/download-pdf.js
@@ -1,6 +1,6 @@
#!/usr/bin/env node
const path = require('path');
const fs = require('fs');
const path = require('node:path');
const fs = require('node:fs');
const { createWorker } = require('../../');

const [,, imagePath] = process.argv;
Expand Down
4 changes: 2 additions & 2 deletions examples/node/image-processing.js
@@ -1,6 +1,6 @@
#!/usr/bin/env node
const path = require('path');
const fs = require('fs');
const path = require('node:path');
const fs = require('node:fs');
const { createWorker } = require('../../');

const [,, imagePath] = process.argv;
Expand Down
2 changes: 1 addition & 1 deletion examples/node/recognize.js
@@ -1,5 +1,5 @@
#!/usr/bin/env node
const path = require('path');
const path = require('node:path');
const { createWorker } = require('../../');

const [,, imagePath] = process.argv;
Expand Down
2 changes: 1 addition & 1 deletion scripts/server.js
@@ -1,7 +1,7 @@
const webpack = require('webpack');
const middleware = require('webpack-dev-middleware');
const express = require('express');
const path = require('path');
const path = require('node:path');
const cors = require('cors');
const webpackConfig = require('./webpack.config.dev');

Expand Down
4 changes: 2 additions & 2 deletions scripts/test-helper.js
@@ -1,7 +1,7 @@
const constants = require('../tests/constants');
global.expect = require('expect.js');
global.fs = require('fs');
global.path = require('path');
global.fs = require('node:fs');
global.path = require('node:path');
global.Tesseract = require('../src');

Object.keys(constants).forEach((key) => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/webpack.config.dev.js
@@ -1,4 +1,4 @@
const path = require('path');
const path = require('node:path');
const webpack = require('webpack');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const common = require('./webpack.config.common');
Expand Down
2 changes: 1 addition & 1 deletion scripts/webpack.config.prod.js
@@ -1,4 +1,4 @@
const path = require('path');
const path = require('node:path');
const common = require('./webpack.config.common');
const webpack = require('webpack');

Expand Down
4 changes: 2 additions & 2 deletions src/worker-script/node/cache.js
@@ -1,5 +1,5 @@
const util = require('util');
const fs = require('fs');
const util = require('node:util');
const fs = require('node:fs');

module.exports = {
readCache: util.promisify(fs.readFile),
Expand Down
2 changes: 1 addition & 1 deletion src/worker-script/node/gunzip.js
@@ -1 +1 @@
module.exports = require('zlib').gunzipSync;
module.exports = require('node:zlib').gunzipSync;
2 changes: 1 addition & 1 deletion src/worker-script/node/index.js
Expand Up @@ -9,7 +9,7 @@
*/

const fetch = require('node-fetch');
const { parentPort } = require('worker_threads');
const { parentPort } = require('node:worker_threads');
const worker = require('..');
const getCore = require('./getCore');
const gunzip = require('./gunzip');
Expand Down
2 changes: 1 addition & 1 deletion src/worker/node/defaultOptions.js
@@ -1,4 +1,4 @@
const path = require('path');
const path = require('node:path');
const defaultOptions = require('../../constants/defaultOptions');

/*
Expand Down
4 changes: 2 additions & 2 deletions src/worker/node/loadImage.js
@@ -1,5 +1,5 @@
const util = require('util');
const fs = require('fs');
const util = require('node:util');
const fs = require('node:fs');
const fetch = require('node-fetch');
const isURL = require('is-url');

Expand Down
2 changes: 1 addition & 1 deletion src/worker/node/spawnWorker.js
@@ -1,4 +1,4 @@
const { Worker } = require('worker_threads');
const { Worker } = require('node:worker_threads');

/**
* spawnWorker
Expand Down

0 comments on commit 2a27a0e

Please sign in to comment.