https://github.com/hattya/otto.module
An implementation of the Node.js module loading system for otto
https://github.com/hattya/otto.module
go javascript module nodejs otto
Last synced: 8 months ago
JSON representation
An implementation of the Node.js module loading system for otto
- Host: GitHub
- URL: https://github.com/hattya/otto.module
- Owner: hattya
- License: mit
- Created: 2017-11-18T01:53:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-06T12:41:09.000Z (over 1 year ago)
- Last Synced: 2024-11-27T19:28:03.023Z (over 1 year ago)
- Topics: go, javascript, module, nodejs, otto
- Language: JavaScript
- Size: 104 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# otto.module
An implementation of the [Node.js module loading system](https://nodejs.org/api/modules.html) for [otto](https://github.com/robertkrimen/otto).
[](https://pkg.go.dev/github.com/hattya/otto.module)
[](https://github.com/hattya/otto.module/actions/workflows/ci.yml)
[](https://ci.appveyor.com/project/hattya/otto-module)
[](https://codecov.io/gh/hattya/otto.module)
## Installation
```console
$ go get github.com/hattya/otto.module
```
## Usage
```go
package main
import (
"fmt"
"os"
"github.com/hattya/otto.module"
)
func main() {
vm, err := module.New()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
file := new(module.FileLoader)
folder := &module.FolderLoader{File: file}
vm.Register(file)
vm.Register(folder)
vm.Register(&module.NodeModulesLoader{
File: file,
Folder: folder,
})
vm.Run(`
var path = require('path');
console.log(path.extname('module.go'));
`)
}
```
## License
otto.module is distributed under the terms of the MIT License.