From 0646eda4fc0affb98e13c30acb522e63b7fd6dde Mon Sep 17 00:00:00 2001 From: Michaƫl Zasso Date: Fri, 22 Nov 2019 18:04:46 +0100 Subject: 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 Reviewed-By: Matteo Collina Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat --- lib/url.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/url.js') diff --git a/lib/url.js b/lib/url.js index fc3863f6ef..316b2a12ee 100644 --- a/lib/url.js +++ b/lib/url.js @@ -21,7 +21,11 @@ 'use strict'; -const { Object, SafeSet } = primordials; +const { + ObjectCreate, + ObjectKeys, + SafeSet, +} = primordials; const { toASCII } = require('internal/idna'); const { encodeStr, hexTable } = require('internal/querystring'); @@ -248,7 +252,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { } } else if (parseQueryString) { this.search = null; - this.query = Object.create(null); + this.query = ObjectCreate(null); } return this; } @@ -437,7 +441,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { } else if (parseQueryString) { // No query string, but parseQueryString still requested this.search = null; - this.query = Object.create(null); + this.query = ObjectCreate(null); } const useQuestionIdx = @@ -677,7 +681,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { } const result = new Url(); - const tkeys = Object.keys(this); + const tkeys = ObjectKeys(this); for (let tk = 0; tk < tkeys.length; tk++) { const tkey = tkeys[tk]; result[tkey] = this[tkey]; @@ -696,7 +700,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { // Hrefs like //foo/bar always cut to the protocol. if (relative.slashes && !relative.protocol) { // Take everything except the protocol from relative - const rkeys = Object.keys(relative); + const rkeys = ObjectKeys(relative); for (let rk = 0; rk < rkeys.length; rk++) { const rkey = rkeys[rk]; if (rkey !== 'protocol') @@ -723,7 +727,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { // because that's known to be hostless. // anything else is assumed to be absolute. if (!slashedProtocol.has(relative.protocol)) { - const keys = Object.keys(relative); + const keys = ObjectKeys(relative); for (let v = 0; v < keys.length; v++) { const k = keys[v]; result[k] = relative[k]; -- cgit v1.2.3