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

[v12.x] multiple util and assert backports #31431

Closed
wants to merge 15 commits into from

Commits on Jan 20, 2020

  1. util: fix .format() not always calling toString when it should be

    This makes sure that `util.format('%s', object)` will always call
    a user defined `toString` function. It was formerly not the case
    when the object had the function declared on the super class.
    
    At the same time this also makes sure that getters won't be
    triggered accessing the `constructor` property.
    
    PR-URL: nodejs#30343
    Fixes: nodejs#30333
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Denys Otrishko <shishugi@gmail.com>
    Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
    BridgeAR committed Jan 20, 2020
    Configuration menu
    Copy the full SHA
    9d82b76 View commit details
    Browse the repository at this point in the history
  2. benchmark: add more util inspect and format benchmarks

    This adds a couple of benchmarks to check different options and code
    paths.
    
    PR-URL: nodejs#30767
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Denys Otrishko <shishugi@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    BridgeAR committed Jan 20, 2020
    Configuration menu
    Copy the full SHA
    2859667 View commit details
    Browse the repository at this point in the history
  3. util: improve performance inspecting proxies

    This makes sure we do not retrieve the handler in case it's not
    required. This improves the performance a tiny bit for these cases.
    
    PR-URL: nodejs#30767
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Denys Otrishko <shishugi@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    BridgeAR committed Jan 20, 2020
    Configuration menu
    Copy the full SHA
    e110449 View commit details
    Browse the repository at this point in the history
  4. util: never trigger any proxy traps using format()

    PR-URL: nodejs#30767
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Denys Otrishko <shishugi@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    BridgeAR committed Jan 20, 2020
    Configuration menu
    Copy the full SHA
    62ed6a2 View commit details
    Browse the repository at this point in the history
  5. util: fix built-in detection

    This makes sure that the regular expression matches all built-in
    objects properly. So far a couple where missed.
    
    PR-URL: nodejs#30768
    Fixes: nodejs#30183
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    BridgeAR committed Jan 20, 2020
    Configuration menu
    Copy the full SHA
    7d19aba View commit details
    Browse the repository at this point in the history
  6. util: inspect (user defined) prototype properties

    This is only active if the `showHidden` option is truthy.
    
    The implementation is a trade-off between accuracy and performance.
    This will miss properties such as properties added to built-in data
    types.
    
    The goal is mainly to visualize prototype getters and setters such as:
    
    class Foo {
      ownProperty = true
      get bar() {
        return 'Hello world!'
      }
    }
    
    const a = new Foo()
    
    The `bar` property is a non-enumerable property on the prototype while
    `ownProperty` will be set directly on the created instance.
    
    The output is similar to the one of Chromium when inspecting objects
    closer. The output from Firefox is difficult to compare, since it's
    always a structured interactive output and was therefore not taken
    into account.
    
    PR-URL: nodejs#30768
    Fixes: nodejs#30183
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    BridgeAR committed Jan 20, 2020
    Configuration menu
    Copy the full SHA
    a9d41b7 View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2020

  1. util: refactor inspect code for constistency

    This removes the special handling to inspect iterable objects with
    a null prototype. It is now handled together with the regular
    prototype.
    
    PR-URL: nodejs#30225
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    BridgeAR committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    0b08d32 View commit details
    Browse the repository at this point in the history
  2. util: add (typed) array length to the default output

    Align the inspect output with the one used in the Chrome dev tools.
    A recent survey outlined that most users prefer to see the number
    of set and map entries. This should count as well for array sizes.
    The size is only added to regular arrays in case the constructor is
    not the default constructor.
    Typed arrays always indicate their size.
    
    PR-URL: nodejs#31027
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
    BridgeAR committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    1e2c535 View commit details
    Browse the repository at this point in the history
  3. src: accept single argument in getProxyDetails

    This makes sure this function stays backwards compatible in case
    it's accessed through the binding directly.
    
    Refs: nodejs#29947 (comment)
    
    PR-URL: nodejs#30858
    Refs: nodejs#30767
    Reviewed-By: Richard Lau <riclau@uk.ibm.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: David Carlier <devnexen@gmail.com>
    Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    BridgeAR committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    a676531 View commit details
    Browse the repository at this point in the history
  4. util: improve prototype inspection using inspect() and showHidden

    The fast path for the prototype inspection had a bug that caused some
    prototype properties to be skipped that should in fact be inspected.
    
    PR-URL: nodejs#31113
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    BridgeAR committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    9c9b338 View commit details
    Browse the repository at this point in the history
  5. assert: fix generatedMessage property

    This makes sure the `generatedMessage` property is always set as
    expected. This was not the case some `assert.throws` and
    `assert.rejects` calls.
    
    PR-URL: nodejs#28263
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    BridgeAR committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    32dfdb8 View commit details
    Browse the repository at this point in the history
  6. assert: DRY .throws code

    This refactors some code for less duplication.
    
    PR-URL: nodejs#28263
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    BridgeAR committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    ad12514 View commit details
    Browse the repository at this point in the history
  7. doc: update assert.throws() examples

    This updates two outdated examples to the current implementation.
    
    PR-URL: nodejs#28263
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    BridgeAR committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    8b82c85 View commit details
    Browse the repository at this point in the history
  8. doc: make AssertionError a link

    This makes sure that `AssertionError` links to the correct place in
    the assert documentation.
    
    PR-URL: nodejs#28263
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    BridgeAR committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    ed2d864 View commit details
    Browse the repository at this point in the history
  9. assert: implement assert.match() and assert.doesNotMatch()

    This adds a new functionality to the assertion module: a dedicated
    check for regular expressions. So far it's possible to use
    `assert.ok(regexp.test(string))`. This is not ideal though when it
    comes to the error message, since it's not possible to know how
    either of the input values look like. It's just known that the
    assertion failed.
    This allows to pass through the regular expression and the input
    string. The string is then matched against the regular expression
    and reports a expressive error message in case of a failure.
    
    PR-URL: nodejs#30929
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
    BridgeAR committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    e2970ab View commit details
    Browse the repository at this point in the history