Skip to content

Conversation

Trott
Copy link
Member

@Trott Trott commented Feb 6, 2019

First commit:

assert: refactor internal assert.js

Move lib/internal/assert.js to lib/internal/assert/assertion_error.js.
This is in preparation for making lib/internal/assert.js a tiny module
for use in Node.js built-ins so that we can use `assert()` without
having to load the entire ~1200 line `assert` module.

Second commit:

assert: create internal/assert micro-module

For use in built-in modules that could benefit from `assert()` without
having to load the entire module (unless an AssertionError actually
occurs): lib/internal/assert.js.

Third commit:

lib: replace 'assert' with 'internal/assert' for many built-ins

Replace large 'assert' module with tiny 'internal/assert' module for
many built-in uses.
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Trott added 3 commits February 5, 2019 20:46
Move lib/internal/assert.js to lib/internal/assert/assertion_error.js.
This is in preparation for making lib/internal/assert.js a tiny module
for use in Node.js built-ins so that we can use `assert()` without
having to load the entire ~1200 line `assert` module.
For use in built-in modules that could benefit from `assert()` without
having to load the entire module (unless an AssertionError actually
occurs): lib/internal/assert.js.
Replace large 'assert' module with tiny 'internal/assert' module for
many built-in uses.
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Feb 6, 2019
@Trott
Copy link
Member Author

Trott commented Feb 6, 2019


assert.throws(() => { internalAssert(false); }, assert.AssertionError);
assert.throws(() => { internalAssert(false, 'fhqwhgads'); },
{ code: 'ERR_ASSERTION', message: 'fhqwhgads' });
Copy link
Member

Choose a reason for hiding this comment

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

Hint: it is possible to check for the name field as well. That is a good alternative to checking for instanceof assert.AssertionError above (but it's off course not the same strict check).

@Trott
Copy link
Member Author

Trott commented Feb 6, 2019

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 6, 2019
@Trott
Copy link
Member Author

Trott commented Feb 8, 2019

Landed in 7182aca...62942e9

@Trott Trott closed this Feb 8, 2019
Trott added a commit to Trott/io.js that referenced this pull request Feb 8, 2019
Move lib/internal/assert.js to lib/internal/assert/assertion_error.js.
This is in preparation for making lib/internal/assert.js a tiny module
for use in Node.js built-ins so that we can use `assert()` without
having to load the entire ~1200 line `assert` module.

PR-URL: nodejs#25956
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Trott added a commit to Trott/io.js that referenced this pull request Feb 8, 2019
For use in built-in modules that could benefit from `assert()` without
having to load the entire module (unless an AssertionError actually
occurs): lib/internal/assert.js.

PR-URL: nodejs#25956
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Trott added a commit to Trott/io.js that referenced this pull request Feb 8, 2019
Replace large 'assert' module with tiny 'internal/assert' module for
many built-in uses.

PR-URL: nodejs#25956
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
addaleax pushed a commit that referenced this pull request Feb 8, 2019
Move lib/internal/assert.js to lib/internal/assert/assertion_error.js.
This is in preparation for making lib/internal/assert.js a tiny module
for use in Node.js built-ins so that we can use `assert()` without
having to load the entire ~1200 line `assert` module.

PR-URL: #25956
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
addaleax pushed a commit that referenced this pull request Feb 8, 2019
For use in built-in modules that could benefit from `assert()` without
having to load the entire module (unless an AssertionError actually
occurs): lib/internal/assert.js.

PR-URL: #25956
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
targos pushed a commit that referenced this pull request Feb 10, 2019
Replace large 'assert' module with tiny 'internal/assert' module for
many built-in uses.

PR-URL: #25956
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
@targos targos mentioned this pull request Feb 14, 2019
@Trott Trott deleted the small-internal-assert branch January 13, 2022 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants