summaryrefslogtreecommitdiff
path: root/lib/assert.js
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2019-11-22 18:04:46 +0100
committerMichaël Zasso <targos@protonmail.com>2019-11-25 10:28:15 +0100
commit0646eda4fc0affb98e13c30acb522e63b7fd6dde (patch)
tree078209f50b044e24ea2c72cbbe7dca6e34bb7e25 /lib/assert.js
parent35c6e0cc2b56a5380e6808ef5603ecc2b167e032 (diff)
downloadandroid-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.tar.gz
android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.tar.bz2
android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.zip
lib: flatten access to primordials
Store all primordials as properties of the primordials object. Static functions are prefixed by the constructor's name and prototype methods are prefixed by the constructor's name followed by "Prototype". For example: primordials.Object.keys becomes primordials.ObjectKeys. PR-URL: https://github.com/nodejs/node/pull/30610 Refs: https://github.com/nodejs/node/issues/29766 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'lib/assert.js')
-rw-r--r--lib/assert.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/assert.js b/lib/assert.js
index 4ce3c3bfde..c3faba0905 100644
--- a/lib/assert.js
+++ b/lib/assert.js
@@ -20,7 +20,12 @@
'use strict';
-const { Object, ObjectPrototype } = primordials;
+const {
+ ObjectAssign,
+ ObjectIs,
+ ObjectKeys,
+ ObjectPrototypeIsPrototypeOf,
+} = primordials;
const { Buffer } = require('buffer');
const {
@@ -494,7 +499,7 @@ assert.strictEqual = function strictEqual(actual, expected, message) {
if (arguments.length < 2) {
throw new ERR_MISSING_ARGS('actual', 'expected');
}
- if (!Object.is(actual, expected)) {
+ if (!ObjectIs(actual, expected)) {
innerFail({
actual,
expected,
@@ -509,7 +514,7 @@ assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
if (arguments.length < 2) {
throw new ERR_MISSING_ARGS('actual', 'expected');
}
- if (Object.is(actual, expected)) {
+ if (ObjectIs(actual, expected)) {
innerFail({
actual,
expected,
@@ -595,7 +600,7 @@ function expectedException(actual, expected, message, fn) {
throw err;
} else {
// Handle validation objects.
- const keys = Object.keys(expected);
+ const keys = ObjectKeys(expected);
// Special handle errors to make sure the name and the message are
// compared as well.
if (expected instanceof Error) {
@@ -619,7 +624,7 @@ function expectedException(actual, expected, message, fn) {
// Check for matching Error classes.
} else if (expected.prototype !== undefined && actual instanceof expected) {
return;
- } else if (ObjectPrototype.isPrototypeOf(Error, expected)) {
+ } else if (ObjectPrototypeIsPrototypeOf(Error, expected)) {
if (!message) {
generatedMessage = true;
message = 'The error is expected to be an instance of ' +
@@ -883,7 +888,7 @@ assert.ifError = function ifError(err) {
function strict(...args) {
innerOk(strict, args.length, ...args);
}
-assert.strict = Object.assign(strict, assert, {
+assert.strict = ObjectAssign(strict, assert, {
equal: assert.strictEqual,
deepEqual: assert.deepStrictEqual,
notEqual: assert.notStrictEqual,