javascript - How to inject other people's npm components in nodejs?
天蓬老师
天蓬老师 2017-05-16 13:36:41
0
2
458

For example, there is an npm package called redis-orm
It has a usage method,

const a = new Orm();
a.where('id','=','3')
  .getOne();

So, how can I add a new function to it without changing its source code:

const a = new Orm();
a.where('id','=','3')
  .getMany();    ------>  New Feature
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
Peter_Zhu

npm download this package and import it.
var redisOrm = require('redis-orm');

世界只因有你

This is really not easy to do if you don’t change its source code. You can take a look at its source code, and then optionally add it using a prototype.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template