summaryrefslogtreecommitdiff
path: root/lib/internal/assert
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/internal/assert
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/internal/assert')
-rw-r--r--lib/internal/assert/assertion_error.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/internal/assert/assertion_error.js b/lib/internal/assert/assertion_error.js
index 0b57bf2cb2..69a6d8afac 100644
--- a/lib/internal/assert/assertion_error.js
+++ b/lib/internal/assert/assertion_error.js
@@ -1,6 +1,12 @@
'use strict';
-const { Math, Object } = primordials;
+const {
+ MathMax,
+ ObjectCreate,
+ ObjectDefineProperty,
+ ObjectGetPrototypeOf,
+ ObjectKeys,
+} = primordials;
const { inspect } = require('internal/util/inspect');
const { codes: {
@@ -31,12 +37,12 @@ const kReadableOperator = {
const kMaxShortLength = 12;
function copyError(source) {
- const keys = Object.keys(source);
- const target = Object.create(Object.getPrototypeOf(source));
+ const keys = ObjectKeys(source);
+ const target = ObjectCreate(ObjectGetPrototypeOf(source));
for (const key of keys) {
target[key] = source[key];
}
- Object.defineProperty(target, 'message', { value: source.message });
+ ObjectDefineProperty(target, 'message', { value: source.message });
return target;
}
@@ -135,7 +141,7 @@ function createErrDiff(actual, expected, operator) {
b = expectedLines[expectedLines.length - 1];
}
- const maxLines = Math.max(actualLines.length, expectedLines.length);
+ const maxLines = MathMax(actualLines.length, expectedLines.length);
// Strict equal with identical objects that are not identical by reference.
// E.g., assert.deepStrictEqual({ a: Symbol() }, { a: Symbol() })
if (maxLines === 0) {
@@ -404,7 +410,7 @@ class AssertionError extends Error {
Error.stackTraceLimit = limit;
this.generatedMessage = !message;
- Object.defineProperty(this, 'name', {
+ ObjectDefineProperty(this, 'name', {
value: 'AssertionError [ERR_ASSERTION]',
enumerable: false,
writable: true,