Skip to content

Conversation

@simon-id
Copy link
Member

@simon-id simon-id commented Oct 10, 2024

Add polyfill for a bugfix in node core: nodejs/node#55116

Comment on lines +29 to +34
ch.unsubscribe = function () {
// TODO: update me
this._subscribers = ArrayPrototypeSlice(this._subscribers);

return subscribe.apply(this, arguments);
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Unexpected unnamed function. (...read more)

It is easier to debug your application code when you avoid anonymous functions so that the stack trace can show you meaningful error messages. This rule enforces all your function to be consistently declared with a name.

View in Datadog  Leave us feedback  Documentation

Comment on lines +16 to +45
dc.channel = function () {
const ch = dc_channel.apply(this, arguments);

if (channels.has(ch)) return ch;

const { subscribe, unsubscribe, publish } = ch;

ch.subscribe = function () {
this._subscribers = ArrayPrototypeSlice(this._subscribers);

return subscribe.apply(this, arguments);
};

ch.unsubscribe = function () {
// TODO: update me
this._subscribers = ArrayPrototypeSlice(this._subscribers);

return subscribe.apply(this, arguments);
};

ch.publish = function () {
const self = Object.assign({}, this);

return publish.apply(self, arguments)
};

channels.add(ch);

return ch;
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Unexpected unnamed function. (...read more)

It is easier to debug your application code when you avoid anonymous functions so that the stack trace can show you meaningful error messages. This rule enforces all your function to be consistently declared with a name.

View in Datadog  Leave us feedback  Documentation

Comment on lines +9 to +48
module.exports = function (unpatched) {
const channels = new WeakSet();

const dc_channel = unpatched.channel;

const dc = { ...unpatched };

dc.channel = function () {
const ch = dc_channel.apply(this, arguments);

if (channels.has(ch)) return ch;

const { subscribe, unsubscribe, publish } = ch;

ch.subscribe = function () {
this._subscribers = ArrayPrototypeSlice(this._subscribers);

return subscribe.apply(this, arguments);
};

ch.unsubscribe = function () {
// TODO: update me
this._subscribers = ArrayPrototypeSlice(this._subscribers);

return subscribe.apply(this, arguments);
};

ch.publish = function () {
const self = Object.assign({}, this);

return publish.apply(self, arguments)
};

channels.add(ch);

return ch;
};

return dc;
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Unexpected unnamed function. (...read more)

It is easier to debug your application code when you avoid anonymous functions so that the stack trace can show you meaningful error messages. This rule enforces all your function to be consistently declared with a name.

View in Datadog  Leave us feedback  Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants