• Stars
    star
    114
  • Rank 298,307 (Top 7 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 14 years ago
  • Updated almost 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Namespacing library for javascript

Namespace.js

Namespace.js is a small javascript script which provide namespacing utilities. It is framework independent. It also allows you to remotely include files.

Features:

  • Simple API
  • Framework independent
  • Remote file loading (synchronously or async)
  • Tested against Firefox 3.x, Safari 3.x, IE 6/7 and Opera 9.5
  • Highly configurable
  • Events
  • Optionally add methods to native objects

Documentation available at http://maximebf.github.io/Namespace.js/

Examples

Namespace('foo.bar');
foo.bar.myFunction = function() {};

Namespace('com.example', {
    MyClass: function() { return {}; }
});
var obj = new com.example.MyClass();

Namespace.use('com.example.MyClass');
var obj2 = new MyClass();

// include com/example/RemoteClass.js
Namespace.include('com.example.RemoteClass');
var obj3 = new com.example.RemoteClass();

Namespace.registerNativeExtensions();
'com.foo.bar'.namespace();