regenerator

package
v0.0.0-...-f4c7a8f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2014 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

This package wrap the npm module regenerator from Facebook to allow more people to use ES6 without having to compile lot's of files every new deploy.

If the user-agent is capable of handling es6 files, then no compilation is made.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

type Compiler struct {
	// Prefix to remove from incoming http request
	// before searching for files
	Prefix string

	// List of directories to search for a given
	// file. The first match is used
	Dir []string

	// Command used to activate NPM
	//
	// When empty the env var "WEBVIEW_REGENERATOR"
	Regenerator string

	// Default parameters
	RegeneratorParams []string

	// Cache for regenerated files
	Cache CompilerCache
	// contains filtered or unexported fields
}

Compiler is responsible for calling npm

func (*Compiler) Compile

func (c *Compiler) Compile(out io.Writer, input string) error

Compile will read the input file and output the result of callin regenerator on it.

input should be separated by "/" instead of "\\" on Windows,

func (*Compiler) FindFile

func (c *Compiler) FindFile(in string) (string, error)

type CompilerCache

type CompilerCache map[string]string

CompilerCache links a source file to a regenerated file

func (*CompilerCache) Open

func (cc *CompilerCache) Open(source string) (io.ReadCloser, error)

Open will try to open a regenerated file for the given source file if the mtime from source is after the regenerated, then this will result in a error.

If source isn't found, an error is also returned.

func (*CompilerCache) Store

func (cc *CompilerCache) Store(source, regen string)

Store will link source file to the regenerated one

type Regenerator

type Regenerator struct {
	Compiler
}

Regenerator wrap the compiler under the net/http.Handler interface

func New

func New(prefix, regenerator string, dirs []string, args ...string) *Regenerator

func (*Regenerator) ServeHTTP

func (r *Regenerator) ServeHTTP(w http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL