Skip to content
This repository was archived by the owner on Dec 3, 2021. It is now read-only.
This repository was archived by the owner on Dec 3, 2021. It is now read-only.

Enforcing the usage of new #26

@AlexisTM

Description

@AlexisTM

As the new keyword is mandatory, the usage should be enforced.

The current stage is that the event dispatch fails if you forget the new but it is not clear why. Adding a check that new has been used can give a meaningful error instead.

The shortest way seems to be the following:

if (!(this instanceof RobustWebSocket))
    throw new Error('Constructor called without new');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions