Sven K.: namespaced object für nodejs

Beitrag lesen

Servus,

Ich verstehe den Zweck hinter den Selbst-Zuweisungen nicht.
window.myObject = window.myObject

"... The first argument looks quite strange. What is window.myObject = window.myObject || new Object() doing? The code checks to see if myObject exists in the global namespace (window). If it does not exist, then window.myObject is assigned an empty object literal. Using this approach we can build a library across JavaScript files. If another script uses the same technique, then it will pass in the existing instance and append logic to it. Inside the Anonymous Function, if we want something to be public, then we append it to the myObject. Any other properties or methods will be considered private. ..." Nachzulesen hier:

Außerdem solltest du jQuery in die Abhängkeitsliste deines Moduls aufnahmen und mit require explizit für dein Modul zugänglich machen.

Die Abhaengigkeit wuerde ich ja noch in package.json aufnehmen. Mir geht es darum, eine lib zu haben, die ich sowohl mit nodejs als auch mit dem Browser nutzen kann und zudem einfach erweiterbar ist.

Gruss,
Sven