Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement setProrotypeOf function #277

Merged
merged 4 commits into from
May 28, 2024

Conversation

VenelinBakalov
Copy link
Collaborator

@VenelinBakalov VenelinBakalov commented May 28, 2024

Description

Implement Object.setPrototypeOf() method

Checklist

  • I have added relevant error handling and logging messages to help troubleshooting
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation, relevant usage information (if applicable)
  • I have updated CHANGELOG.md with a short summary of the changes introduced
  • I have tested against live environment, if applicable
  • I have synced any structure and/or content vRA-NG improvements with vra-ng and ts-vra-ng archetypes (if applicable)
  • I have my changes rebased and squashed to the minimal number of relevant commits. Notice: don't squash all commits
  • I have added a descriptive commit message with a short title, including a Fixed #XXX - or Closed #XXX - prefix to auto-close the issue

Testing

Release Notes

Related issues and PRs

#264

Signed-off-by: Venelin Bakalov <bakalovv@vmware.com>
@VenelinBakalov VenelinBakalov requested a review from a team as a code owner May 28, 2024 07:26
@VenelinBakalov
Copy link
Collaborator Author

Tested with the following code samples:

 var Animal = function () { }
        Animal.prototype.speak = function () {
            System.log(this.name + ' makes a noise.');
        }

        var Dog = function (name) {
            this.name = name
        }

        // set up prototype chain
        Object.setPrototypeOf(Dog.prototype, Animal.prototype);

        // Legacy approach
        // Dog.prototype.__proto__=Animal.prototype

        var d = new Dog('Mitzie');
        d.speak(); // Mitzie makes a noise.


        class NsxtError extends Error {
            public readonly cause: string
            constructor(message: string, service: string) {
                super(`Received error ${message} from NSX-T Service ${service}.`);
                Object.setPrototypeOf(this, new.target.prototype)
            }
        }

        const testError = new NsxtError("Object not found", "SecurityPolicyService");
        System.log(`Constructor name: ${testError.constructor.name}`);
        System.error("=========")
        class NsxtError2 extends Error {
            public readonly cause: string
            constructor(message: string, service: string) {
                super(`Received error ${message} from NSX-T Service ${service}.`);
            }
        }

        const testError2 = new NsxtError2("Object not found", "SecurityPolicyService");
        System.log(`Constructor name: ${testError2.constructor.name}`);

Signed-off-by: Venelin Bakalov <bakalovv@vmware.com>
Signed-off-by: Venelin Bakalov <bakalovv@vmware.com>
Copy link
Collaborator

@Michaelpalacce Michaelpalacce left a comment

Choose a reason for hiding this comment

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

Can you also make sure to use tabs?

Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
@akantchev akantchev merged commit bda0aeb into main May 28, 2024
12 checks passed
@akantchev akantchev deleted the 264-add-object-setProrotypeOf-implementation branch May 28, 2024 08:35
@Michaelpalacce Michaelpalacce restored the 264-add-object-setProrotypeOf-implementation branch June 12, 2024 14:01
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.

3 participants