Class: Namespace

.nodejs. Namespace


new Namespace(dir, allowedFileExts [, ignoredDirs] [, ignoredFiles])

A namespace constructor for getting an object that mimicks namespaces/packages in languages like Java and Actionscript. Classes are loaded on a per request basis.
Parameters:
Name Type Argument Description
dir String Directory to scan.
allowedFileExts Array.<String> Allowed file extensions (with preceding '.').
ignoredDirs Array.<String> <optional>
Directories to ignore on `dir` scan.
ignoredFiles Array.<String> <optional>
Directories to ignore on `dir` scan.
Examples
// Example 1
let sjl = require('sjljs'),
    ns = new sjl.nodejs.Namespace(__dirname),

    // Fetches './some/namespace/some/where/SomeConstructor(.js|.json)' by default.
    SomeConstructor = ns.some.namespace.some.where.SomeConstructor,

    // Fetches './some-data-dir/someJsonFile(.js|.json)' by default.
    someJsonFile = ns['some-data-dir'].someJsonFile;
// Example 2
// `sjl` uses this constructor internally to expose it's class library so you don't
// have to include them manually;  E.g.,

 // Exposed functionality
let Optionable = sjl.stdlib.Optionable;

// With out exposed functionality (assume in some './src' folder)
let Optionable = require('../node_modules/sjljs/src/stdlib/Optionable');