You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exports.inherits=function(ctor,superCtor){if(ctor===undefined||ctor===null)thrownewTypeError('The constructor to "inherits" must not be '+'null or undefined');if(superCtor===undefined||superCtor===null)thrownewTypeError('The super constructor to "inherits" must not '+'be null or undefined');if(superCtor.prototype===undefined)thrownewTypeError('The super constructor to "inherits" must '+'have a prototype');ctor.super_=superCtor;Object.setPrototypeOf(ctor.prototype,superCtor.prototype);};
目的
最近初學node.js,
想要自己嘗試寫一個Map module讓其他module去繼承,
但是require module的cache機制導致inherits的module共用了同一個map,
請問應該如何修改才有辦法讓各module有自己的map?
使用的工具
ubuntu 12.04
node.js 4.4.3
操作流程
node server.js
遇到的問題
目的已詳述
嘗試過的解法
應該是架構問題, 完全不知道該從何處下手
(想過用不同的路徑載入Map Module, 但就捨棄了module cache的機制)
程式碼
-----server.js-----
-----map.js-----
-----Player_list_lib.js / Monster_list_lib.js-----
輸出
[ '1', '2', '3' ]
[ '1', '2', '3' ]
The text was updated successfully, but these errors were encountered: