hattya / otto.module

An implementation of the Node.js module loading system for otto

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

otto.module

An implementation of the Node.js module loading system for otto.

pkg.go.dev GitHub Actions Appveyor Codecov

Installation

$ go get -u github.com/hattya/otto.module

Usage

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.

About

An implementation of the Node.js module loading system for otto

License:MIT License


Languages

Language:JavaScript 56.2%Language:Go 43.8%