Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2019-11-22 20:04:46 +0300
committerMichaël Zasso <targos@protonmail.com>2019-11-25 12:28:15 +0300
commit0646eda4fc0affb98e13c30acb522e63b7fd6dde (patch)
tree078209f50b044e24ea2c72cbbe7dca6e34bb7e25 /lib/internal/worker
parent35c6e0cc2b56a5380e6808ef5603ecc2b167e032 (diff)
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/worker')
-rw-r--r--lib/internal/worker/io.js43
1 files changed, 25 insertions, 18 deletions
diff --git a/lib/internal/worker/io.js b/lib/internal/worker/io.js
index ba2150e530b..a672dac94ce 100644
--- a/lib/internal/worker/io.js
+++ b/lib/internal/worker/io.js
@@ -1,6 +1,13 @@
'use strict';
-const { Object } = primordials;
+const {
+ ObjectAssign,
+ ObjectCreate,
+ ObjectDefineProperty,
+ ObjectGetOwnPropertyDescriptors,
+ ObjectGetPrototypeOf,
+ ObjectSetPrototypeOf,
+} = primordials;
const {
handle_onclose: handleOnCloseSymbol,
@@ -48,12 +55,12 @@ const messageTypes = {
// not provide methods that are not present in the Browser and not documented
// on our side (e.g. hasRef).
// Save a copy of the original set of methods as a shallow clone.
-const MessagePortPrototype = Object.create(
- Object.getPrototypeOf(MessagePort.prototype),
- Object.getOwnPropertyDescriptors(MessagePort.prototype));
+const MessagePortPrototype = ObjectCreate(
+ ObjectGetPrototypeOf(MessagePort.prototype),
+ ObjectGetOwnPropertyDescriptors(MessagePort.prototype));
// Set up the new inheritance chain.
-Object.setPrototypeOf(MessagePort, EventEmitter);
-Object.setPrototypeOf(MessagePort.prototype, EventEmitter.prototype);
+ObjectSetPrototypeOf(MessagePort, EventEmitter);
+ObjectSetPrototypeOf(MessagePort.prototype, EventEmitter.prototype);
// Copy methods that are inherited from HandleWrap, because
// changing the prototype of MessagePort.prototype implicitly removed them.
MessagePort.prototype.ref = MessagePortPrototype.ref;
@@ -73,7 +80,7 @@ MessagePort.prototype[kOnMessageListener] = function onmessage(event) {
// This is for compatibility with the Web's MessagePort API. It makes sense to
// provide it as an `EventEmitter` in Node.js, but if somebody overrides
// `onmessage`, we'll switch over to the Web API model.
-Object.defineProperty(MessagePort.prototype, 'onmessage', {
+ObjectDefineProperty(MessagePort.prototype, 'onmessage', {
enumerable: true,
configurable: true,
get() {
@@ -96,7 +103,7 @@ function oninit() {
setupPortReferencing(this, this, 'message');
}
-Object.defineProperty(MessagePort.prototype, onInitSymbol, {
+ObjectDefineProperty(MessagePort.prototype, onInitSymbol, {
enumerable: true,
writable: false,
value: oninit
@@ -107,7 +114,7 @@ function onclose() {
this.emit('close');
}
-Object.defineProperty(MessagePort.prototype, handleOnCloseSymbol, {
+ObjectDefineProperty(MessagePort.prototype, handleOnCloseSymbol, {
enumerable: false,
writable: false,
value: onclose
@@ -119,7 +126,7 @@ MessagePort.prototype.close = function(cb) {
MessagePortPrototype.close.call(this);
};
-Object.defineProperty(MessagePort.prototype, inspect.custom, {
+ObjectDefineProperty(MessagePort.prototype, inspect.custom, {
enumerable: false,
writable: false,
value: function inspect() { // eslint-disable-line func-name-matching
@@ -129,14 +136,14 @@ Object.defineProperty(MessagePort.prototype, inspect.custom, {
// e.g. when accessing the prototype directly.
ref = MessagePortPrototype.hasRef.call(this);
} catch { return this; }
- return Object.assign(Object.create(MessagePort.prototype),
- ref === undefined ? {
- active: false,
- } : {
- active: true,
- refed: ref
- },
- this);
+ return ObjectAssign(ObjectCreate(MessagePort.prototype),
+ ref === undefined ? {
+ active: false,
+ } : {
+ active: true,
+ refed: ref
+ },
+ this);
}
});