Skip to content

Commit

Permalink
fixup! events: refactor to use more primordials
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Dec 18, 2020
1 parent 9863b29 commit df98f27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/events.js
Expand Up @@ -554,7 +554,7 @@ EventEmitter.prototype.removeListener =
return this;

if (position === 0)
ArrayPrototypeShift(list);
list.shift();
else {
if (spliceOne === undefined)
spliceOne = require('internal/util').spliceOne;
Expand Down Expand Up @@ -803,7 +803,7 @@ function on(emitter, event, options) {
const iterator = ObjectSetPrototypeOf({
next() {
// First, we consume all unread events
const value = ArrayPrototypeShift(unconsumedEvents);
const value = unconsumedEvents.shift();
if (value) {
return PromiseResolve(createIterResult(value, false));
}
Expand Down Expand Up @@ -885,7 +885,7 @@ function on(emitter, event, options) {
}

function eventHandler(...args) {
const promise = ArrayPrototypeShift(unconsumedPromises);
const promise = unconsumedPromises.shift();
if (promise) {
promise.resolve(createIterResult(args, false));
} else {
Expand All @@ -896,7 +896,7 @@ function on(emitter, event, options) {
function errorHandler(err) {
finished = true;

const toError = ArrayPrototypeShift(unconsumedPromises);
const toError = unconsumedPromises.shift();

if (toError) {
toError.reject(err);
Expand Down

0 comments on commit df98f27

Please sign in to comment.