Many times this program could be used in the context of a much larger application which uses namespaces (custom, google closures, ExtJS, etc...)
Having no namespace can severely impact the ability to use this library... Fortunately there is an easy solution:
(function (ns) {
// here is the entirety of 2D.js (or any other library)
// .
// .
// .
// end of library
// export functions/classes
// using very limited list
ns.Path = Path;
ns.Shape = Shape;
ns.Intersection = Intersection
}) (ns);
The reason to wrap this in an immediate executable is to provide closure and variable hiding. We just want to export the publicly accessible objects, functions, etc...
Many times this program could be used in the context of a much larger application which uses namespaces (custom, google closures, ExtJS, etc...)
Having no namespace can severely impact the ability to use this library... Fortunately there is an easy solution:
The reason to wrap this in an immediate executable is to provide closure and variable hiding. We just want to export the publicly accessible objects, functions, etc...