Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node/util): adapt dynamic type checking to Node.js behavior #21014

Merged
merged 8 commits into from
Nov 1, 2023

Conversation

petamoriken
Copy link
Contributor

adapt util.isXXX functions to Node.js behavior

  1. util.isBoolean, util.isNumber, util.isString and util.isSymbol should return false for primitive wrapper objects

    util.isBoolean(new Boolean(true)); // => false
    util.isNumber(new Number(123)); // => false
    util.isString(new String("foo")); // => false
    util.isSymbol(Object(Symbol())); // => false
  2. util.isError should also check [[ErrorData]] internal slot

    // same as Object.setPrototypeOf(new Error(), Object.prototype)
    util.isError(Reflect.construct(Error, [], Object)); // => true

@petamoriken
Copy link
Contributor Author

ping @kt3k

Signed-off-by: Kenta Moriuchi <moriken@kimamass.com>
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@kt3k kt3k merged commit 841f215 into denoland:main Nov 1, 2023
@petamoriken petamoriken deleted the fix/node/util branch November 1, 2023 07:33
mmastrac added a commit that referenced this pull request Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants