Documentation ¶
Overview ¶
Copyright 2014 dong<ddliuhb@gmail.com>. Licensed under the MIT license.
Motto - Modular Javascript environment.
Copyright 2014 dong<ddliuhb@gmail.com>. Licensed under the MIT license.
Motto - Modular Javascript environment.
Copyright 2014 dong<ddliuhb@gmail.com>. Licensed under the MIT license.
Motto - Modular Javascript environment.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddModule ¶ added in v0.3.0
func AddModule(id string, m ModuleLoader)
AddModule registers global module
func FindFileModule ¶ added in v0.3.0
Find a file module by name.
If name starts with "." or "/", we search the module in the according locations (name and name.js and name.json).
Otherwise we search the module in the "node_modules" sub-directory of "pwd" and "paths"
It basicly follows the rules of Node.js module api: http://nodejs.org/api/modules.html
Types ¶
type ModuleLoader ¶ added in v0.3.0
ModuleLoader is declared to load a module.
func CreateLoaderFromFile ¶ added in v0.3.0
func CreateLoaderFromFile(filename string) ModuleLoader
Create module loader from javascript file.
Filename can be a javascript file or a json file.
func CreateLoaderFromSource ¶ added in v0.3.0
func CreateLoaderFromSource(source, filename string) ModuleLoader
Create module loader from javascript source code.
When the loader is called, the javascript source is executed in Motto.
"pwd" indicates current working directory, which might be used to search for modules.
type Motto ¶
type Motto struct { // Motto is based on otto *otto.Otto // try to read source map SourceMapEnabled bool // contains filtered or unexported fields }
Motto is modular vm environment
func (*Motto) AddModule ¶
func (m *Motto) AddModule(id string, l ModuleLoader)
AddModule registers a new module to current vm.
func (*Motto) ClearModule ¶ added in v0.3.1
func (m *Motto) ClearModule()
ClearModule clear all registered module from current vm