npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

motors

v0.2.1

Published

Manages multiple transpilers with chaining

Downloads

8

Readme

Motors

Powerful chaining of pre- and post-processors, with dynamic dependency downloading.

Installation

$ npm install motors

Examples

var motors = new Motors();

// Simple engines (extension, name)
motors.addEngine("jade");
motors.addEngine("coffee");
motors.addEngine("js", "dust");

// Chained engines (extension, chain)
motors.addEngine("css", "css>clean-css");
motors.addEngine("js", "javascript>uglify-js");
motors.addEngine("jbs", "jade>handlebars");

function next(err, compiled) { console.log(compiled); }

// Compile
motors.compile("coffee", "console.log 'Hello'", next);
motors.compile("handlebars", "Hello {{ name }}", { name : "Donald" }, next);
motors.compileFile("./path-to/file.coffee", next);

API

MotorsMotors
.addEngine(ext, [chain])function
.compile(ext, str, [options], next)
.compileFile(filename, [options], next)
.createEngine(chain)function
.getEngine(chain)function
.hasEngine(ext)Boolean
.removeEngine(ext)

Motors ⇒ Motors

Constructor for Motors class. Automatically installs packages by default.

Returns: Motors - Instance of class.

| Param | Type | Description | | --- | --- | --- | | mappings | Object | Keys correspond to extensions, values to engine names. | | options | Object | Install directory dir, and whether to fetch if missing. |

Example

var motors = new Motors({ dir : process.cwd() });

motors.compile(ext, str, [options], next)

compiles a string using engine associated with ext

| Param | Type | Default | Description | | --- | --- | --- | --- | | ext | String | | The extension associated with string (e.g. "coffee"). | | str | String | | The string to be compiled. | | [options] | Object | {} | Options to be passed to rendering engine. | | next | function | | Callback of type fn(err, compiled). |

Example

motors.compile("coffee", "console.log 'Hello'", function(err, compiled) {
    console.log(compiled);
    // => console.log('Hello');
  });

motors.compileFile(filename, [options], next)

compiles a file using engine associated with file's extension

| Param | Type | Default | Description | | --- | --- | --- | --- | | filename | String | | Name of file. | | [options] | Object | {} | Options to be passed to rendering engine. | | next | function | | Callback of type fn(err, compiled). |

Example

motors.compileFile("app.coffee", function(err, compiled) {
    // Compiled version of app.coffee
  });

motors.createEngine(chain) ⇒ function

Returns a compilation function based on input chain.

Returns: function - Compilation function fn(str, options, next).

| Param | Type | Description | | --- | --- | --- | | chain | String | String containing names of engines to use. |

Example

motors.createEngine("jade");
  motors.createEngine("jade>handlebars");
  motors.createEngine("js>uglify-js");

motors.getEngine(chain) ⇒ function

Gets an engine based on chain, creating engine if necessary.

Returns: function - Compilation function fn(str, options, next).

| Param | Type | Description | | --- | --- | --- | | chain | String | Chain of engines. |

Example

motors.getEngine("jade>handlebars");

motors.addEngine(ext, [chain]) ⇒ function

Adds an engine for an extension, creating engine if necessary.

Returns: function - Compilation function fn(str, options, next).

| Param | Type | Description | | --- | --- | --- | | ext | String | File extension to be associated with engine. | | [chain] | String | Optional chain for creating engine. |

motors.removeEngine(ext)

Removes an engine by extension.

Kind: instance method of Motors

| Param | Type | Description | | --- | --- | --- | | ext | String | File extension to for removal. |

motors.hasEngine(ext) ⇒ Boolean

Determines if an engine currently exists for an extension.

Returns: Boolean - Whether engine exists.

| Param | Type | Description | | --- | --- | --- | | ext | String | File extension to check. |

License

MIT