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

recaster

v0.3.20

Published

Clone this project to scaffold a new (npm/node) project.

Downloads

6

Readme

recaster

Transform files in various formats to the formats a browser can understand: html, js and css, and then minify and compress it for transmission to the client.

 npm install recaster
 var recast = require('recaster').init({
	transpile: ['jade', 'less', 'stylus', 'sweetjs', 'typescript', 
				'coffeescript', 'markdown', 'regenerators'],
	minify: ['js', 'css', 'html'],
	compress: true,
	markdown: 
	 { gfm: true,
	   tables: true,
	   breaks: false,
	   pedantic: false,
	   sanitize: true,
	   smartLists: true,
	   langPrefix: 'language-'},
	verbose: true }
 });

recast({ srcPath: somePath, destPath: somePath2, 
         srcData: 'bla', type: 'html', encoding: 'gzip'}).when(
	function(data) {
	   //data= { destData: 'xxx', type: 'html', encoding: 'gzip'}
	},
	function(error) {
	   //deal with error
	}
});

The various formats are transpiled to the corresponding html, css and js formats. If 'regenerators' is added to transpile, any es6 generators in (transpiled) javascript get converted to working es5 script.

Options for the individual converters can be added as objects under their own name. Markdown is included as an example above.

The function returns a promise of the recast source. See example above for format of the returned data object.

If srcData and type is passed in, this data is being used instead of reading a file from disk.

If reading the file from disk fails, the promise fails.

If a file is not transpilable (no type or there is no transform function defined fot the particular type) the original data gets returned, after possibly being zipped, keeping the promise.

if there's an error transpiling, the promise breaks.

If there's an error minifying, this step gets skipped.

if there's an error compressing, the promise is broken, however still returning the source data. The encoding property of the returned object will be undefined.

If 'destPath' is passed as a parameter the recast source code gets written to it when the promise is fullfilled, this feature is temporarily disabled however.

The source is easily expanded and/or modified to include more transpilers or to change the libraries that do the work.

You can use this module to transpile for node, however coffeescript and sweetjs can be required directly. I imagine you can set this up for the other transpilers as well.

TODO:

  • pass source maps from transpilers to minifiers
  • add default options for all transformers
  • add more transformers (clojurescript, sass, lispyscript, sibilant, dart, parenscript, wisp )
  • use streaming when possible?
  • use more standard Q instead of Crockford's vow.js
  • make a distiction between libs that run on node and that are dependant on some native executable
  • incorporate image processing/optimizing?
  • write docs using doccoh
  • add a commandline version