Socket
Socket
Sign inDemoInstall

jsloader

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jsloader

## Features:


Version published
Weekly downloads
64
decreased by-83.33%
Maintainers
1
Install size
66.3 kB
Created
Weekly downloads
 

Readme

Source

JsLoader

Features:

  1. Loading synchronously AMD modules inside Node.js
  2. Common API for loading AMD and CommonJs modules
  3. Namespacing JavaScript code

Examples

Loading modules

var auto = require("jsloader"),
    SomeAMDModule = auto.load("modules/amd/Some"), // loads Some.js files
    OtherCommonJSModule = auto.load("modules/commonjs/Other"); // loads Other.js file

Loading namespaced code

Autoloader scans for package.json files in every node module so namespaces are loaded automatically.

/node_modules/foo/package.json
{
    "name": "foo",
    "autoload": {
        "amd": {
            "SomeNamespace/Foo": "folder/with/Foo",
        },
        "commonjs": {
            "SomeNamespace/Foo/Bar": "folder/with/commonjs/Foo"
        }
    }
}
/node_modules/bar/package.json
{
    "name": "bar",
    "autoload": {
        "amd": {
            "SomeNamespace/Bar": "folder/with/Bar"
        }
    }
}
/yourscript.js
var auto = require("jsloader"),
    Foor = auto.load("SomeNamespace/Foo/Foor"), // loads "/node_modules/foo/folder/with/Foo/Foor.js" using AMD
    Boor = auto.load("SomeNamespace/Bar/Boor"), // loads "/node_modules/bar/folder/with/Bar/Boor.js" using AMD
    Booz = auto.load("SomeNamespace/Foo/Bar/Booz"); // loads "/node_modules/foo/folder/with/commonjs/Foo/Booz.js" using CommonJS

FAQs

Last updated on 11 Sep 2013

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc