mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
lib: extract validateString validator
Pulls out a common argument validator to `internal/validators` PR-URL: https://github.com/nodejs/node/pull/22101 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
080316b32a
commit
e570ae79f5
17 changed files with 52 additions and 85 deletions
|
@ -2,9 +2,9 @@
|
|||
|
||||
const {
|
||||
ERR_ASYNC_CALLBACK,
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
ERR_INVALID_ASYNC_ID
|
||||
} = require('internal/errors').codes;
|
||||
const { validateString } = require('internal/validators');
|
||||
const internal_async_hooks = require('internal/async_hooks');
|
||||
|
||||
// Get functions
|
||||
|
@ -140,8 +140,7 @@ function showEmitBeforeAfterWarning() {
|
|||
|
||||
class AsyncResource {
|
||||
constructor(type, opts = {}) {
|
||||
if (typeof type !== 'string')
|
||||
throw new ERR_INVALID_ARG_TYPE('type', 'string', type);
|
||||
validateString(type, 'type');
|
||||
|
||||
if (typeof opts === 'number') {
|
||||
opts = { triggerAsyncId: opts, requireManualDestroy: false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue