util.promisify.custom
- <symbol> 可用于声明自定义的 promise 化的函数变体,参阅自定义的 promise 化函数。
除了可以通过 util.promisify.custom
访问之外,此符号是全局地注册,可以在任何环境中作为 Symbol.for('nodejs.util.promisify.custom')
访问。
例如,对于接受 (foo, onSuccessCallback, onErrorCallback)
的函数:
const kCustomPromisifiedSymbol = Symbol.for('nodejs.util.promisify.custom');
doSomething[kCustomPromisifiedSymbol] = (foo) => {
return new Promise((resolve, reject) => {
doSomething(foo, resolve, reject);
});
};
- <symbol> that can be used to declare custom promisified variants of functions, see Custom promisified functions.
In addition to being accessible through util.promisify.custom
, this
symbol is registered globally and can be
accessed in any environment as Symbol.for('nodejs.util.promisify.custom')
.
For example, with a function that takes in
(foo, onSuccessCallback, onErrorCallback)
:
const kCustomPromisifiedSymbol = Symbol.for('nodejs.util.promisify.custom');
doSomething[kCustomPromisifiedSymbol] = (foo) => {
return new Promise((resolve, reject) => {
doSomething(foo, resolve, reject);
});
};