Skip to content

nodejs modules, why make bind such a hassle? #42490

Closed
@andrewhodel

Description

@andrewhodel

Version

latest

Platform

Subsystem

module

What steps will reproduce the bug?

// nodejs has a complicated module system called core module
// that allows you to not need to keep track of a single object
// returned from an init function and pass it to each function called
// in the module
//
// it creates what you would call classes
//
// or you can use exports only

exports.init = function() {

	var o = {data_to_keep: 'asdf'};

	// return the object
	return o;

}

module.exports = class Junk {

	// this is so you can remember every language's super cool module system

	// see how powerful it is, you store an object automatically with all these extra
	// "how to module" requirements in your code
	// and you get to deal with functions and bind overwriting the this object that is the class!

	// this is ran when the class is "instantiated" is the word used now
	constructor() {

		this.data_to_keep = 'asdf';

	}

}

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

You would expect the core module system not to exist.

What do you see instead?

It exists.

Additional information

Can you please clean this?

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