mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
lib: refactor to use validate function
Throwing error after checking type is repeated. So replace it with validate function. PR-URL: https://github.com/nodejs/node/pull/46101 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
This commit is contained in:
parent
d7d9811407
commit
be93b7a582
3 changed files with 12 additions and 21 deletions
|
@ -18,7 +18,6 @@ const {
|
|||
const {
|
||||
ERR_ASYNC_CALLBACK,
|
||||
ERR_ASYNC_TYPE,
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
ERR_INVALID_ASYNC_ID
|
||||
} = require('internal/errors').codes;
|
||||
const { kEmptyObject } = require('internal/util');
|
||||
|
@ -280,10 +279,8 @@ class AsyncLocalStorage {
|
|||
validateObject(options, 'options');
|
||||
|
||||
const { onPropagate = null } = options;
|
||||
if (onPropagate !== null && typeof onPropagate !== 'function') {
|
||||
throw new ERR_INVALID_ARG_TYPE('options.onPropagate',
|
||||
'function',
|
||||
onPropagate);
|
||||
if (onPropagate !== null) {
|
||||
validateFunction(onPropagate, 'options.onPropagate');
|
||||
}
|
||||
|
||||
this.kResourceStore = Symbol('kResourceStore');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue