nce-amd
v0.0.1
Published
An AMD implemention for nce with requirejs
Downloads
1
Readme
AMD extension for NCE
Description
This is an nce extension for Asynchronous Module Definition support designed with require.js.
How to install
Install with npm: npm install --save nce-amd
Integrate in NCE with the extension-manager:
var NCE = require("nce");
var nce = new NCE(/*{}*/);
var extMgr = require("nce-extension-manager")(nce);
var amd = extMgr.getActivatedExtension("amd");
How to use
Config settings
You are able to use the following config-settings with their defaults:
route: "/amd"
: Sub-URL to listendumpPath: process.cwd() + "/amd"
: Directory to dump fileslogger: {}
: Settings for logger-extension
Basic methods
ext.define(name, code, cb, opts)
Define a module for amd.
Normally the code get minified. If you don't want to, set: opts.minify = false
.
Arguments
name
[String]: A name as identifiercode
[String]: JavaScript code, written in amd-style.cb
[Function]: Callback-function formfs.writeFile
with the arguments:error
[Error]: Used for exceptions
opts
[Object]: Options:minify
[Boolean]: Minify code (default true)
ext.defineCDN(name, url, cb)
Define a module from cdn.
Arguments
name
[String]: A name as identifierurl
[String]: URL to JS-Resource.cb
[Function]: Callback-function formfs.writeFile
with the arguments:error
[Error]: Used for exceptionssuccess
[Boolean]: True on success
ext.get = function(name, cb)
Get the content of a resource as buffer.
Arguments
name
[String]: A name as identifiercb
[Function]: Callback-function formfs.readFile
with the arguments:error
[Error]: Used for exceptionscode
[Buffer]: Content of file as buffer
ext.getStream = function(name)
Get a stream of a resource.
Arguments
name
[String]: A name as identifier
Returns a stream from fs.createReadStream
.
ext.undefine = function(name, cb)
Remove a script from defined functions by its name.
Arguments
name
[String]: A name as identifiercb
[Function]: Callback-function formfs.readFile
with the arguments:error
[Error]: Used for exceptions
ext.mkScriptTag = function(mainName)
Returns a html-script-tag with mainName
as start script for amd.
Arguments
mainName
[String]: A name as identifier
Returns a HTML-script tag with require.js and loads mainName
with its dependencies.