Bobby
Bobby

Reputation: 141

Guidance on Node.js module

I am currently started learning with node js, as I am working With Intel WebRTC SDK. If I want to make some modifications or add feature to the existing library, what do I have to do? Do I need to create modules or directly change in the files? If there is any other solution, please guide me. I am currently changing the codes of library itself, which I need to do again for a new version of their library. Please guide me through it.

Upvotes: 2

Views: 31

Answers (1)

jfriend00
jfriend00

Reputation: 707456

It really depends upon what kind of changes you need to make and for you to get specific guidance, you will have to show the exact types of modifications you're trying to make (before/after code changes).

Additions to the library can likely be done without modifying the library itself by just adding new methods to the module or just making new methods available in your own module.

Replacement of existing methods with your own version can also likely be done without actually modifying the source by just replacing a given method with a reference to a new implementation in your own source file.

Fixing of bugs should likely be done via some sort of source control system (like GitHub) so that you can more easily apply patches you've already done to a new version of the source code.

Wholesale changing of existing code to do something different or work differently should probably be completely avoided because (as you have discovered), it creates a merging nightmare when you want to take a newer version of the original code. Instead, write a new function that does what you want and leave the current function in place. Then, your new function can live on, even after upgrading to a new version.

Upvotes: 2

Related Questions