Socket
Book a DemoInstallSign in
Socket

violin-autoloader

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

violin-autoloader

Simple class autoloader for Node.js

1.0.4
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

violin-autoloader

Simple class autoloader for Node.Js

Installation

npm install violin-autoloader

Will install the latest version of violin-autoloader (currently 1.0.2)

Documentation

Usage

var Autoloader = require("violin-autoloader"),
    autoloader = new Autoloader();

    // Register namespaces, bindings, ...

    // This will add namespaces to global context
    autoloader.register();

    // Unregister autoloader (this will remove namespaces from global context)
    autoloader.unregister();

Register a namespace

// Register a root namespace
autoloader.namespace("violin", "directory");

// Register a sub-namespace directly
autoloader.namespace("violin.autoloader", "another-directory");

// This can be done for multiple levels
autoloader.namespace("violin.sub.sub.sub", "sub-directory");

If a sub-namespace is registered before one of its parents, the directory for all non-existing namespace will be set to null. Registering one of his parents later will update the directory of the latter.

Load bindings

autoloader.binding("binding", "directory");

This method will load a binding and create namespaces if required. It will then add all the key-value pairs to the namespace as children.

Load files or directories

// Load a file
Autoloader.load("filename.js");

// Load a directory recursively
Autoloader.load("directory");

// Apply a callback for each loaded file
Autoloader.load("directory", (exp) => {
    // Do something
});

Load modules

// Require module-name/autoload.js
autoloader.module("module-name");
// module-name/autoload.js
module.exports = {
    namespaces: {
        "namespace": "directory"
    },
    bindings: {
        "binding": "directory"
    },
    loads: [
        "directory"
    ],
    modules: [
        "another-module"
    ]
};

FAQs

Package last updated on 27 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.