fs: lazy load createPromise/promiseResolve
PR-URL: https://github.com/nodejs/node/pull/20766 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
11aea015ef
commit
fa0cac51b9
@ -44,7 +44,6 @@ const {
|
||||
const util = require('util');
|
||||
const pathModule = require('path');
|
||||
const { isUint8Array } = require('internal/util/types');
|
||||
const { createPromise, promiseResolve } = process.binding('util');
|
||||
|
||||
const binding = process.binding('fs');
|
||||
const fs = exports;
|
||||
@ -250,6 +249,7 @@ fs.exists = function(path, callback) {
|
||||
|
||||
Object.defineProperty(fs.exists, internalUtil.promisify.custom, {
|
||||
value: (path) => {
|
||||
const { createPromise, promiseResolve } = process.binding('util');
|
||||
const promise = createPromise();
|
||||
fs.exists(path, (exists) => promiseResolve(promise, exists));
|
||||
return promise;
|
||||
|
Loading…
x
Reference in New Issue
Block a user