Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Static {analysis,slicing,dicing} of your coffee. # "imbecile! freeze it, then cut it"
CoffeeScript JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
src
test
.gitignore
Cakefile
LICENSE.txt
README.md
index.js
package.json

README.md

coffeesurgeon

Static {analysis,slicing,dicing} of your .coffee

{
  bodystitch,
  parseImportsExports,
  findSourceFile

} = require 'coffeesurgeon'

Def: prop 1

A .coffee satisfies "Property 1" if ALL of its imports and exports are of the form:

{x, y} = require 'misc'
{...} = require '...'

...body, wherein foo and bar are defined...

module.exports = {foo, bar}

bodystitch

Like stitch, but

  • assumes prop 1
  • stitches bodies directly together in a dependency-satisfying ordering, discarding import/export statements
    • ...thereby being hella minification-friendly
    • ...and letting you expose your stuff (with coffee --bare) to your REPL and unit tests
bodystitch {
  main: 'mymainfile'
  codepath: [
    '...'
    '...'
  ]
}, (e, {coffee, deps_map, deps_chain}) ->

FAQ

  • What about name conflicts?
    • TODO: error when they exist

parseImportsExports (assumes prop 1)

info = parseImportsExports coffee
# info:
{
  imports: [[["x", "y"], "misc"], ...]
  exported_names: ["foo", "bar"]
  body_coffee: "..."
}

findSourceFile

findSourceFile {query:"widgets/foo", fromDir:"...", codepath:[...]}, (e, path) ->
  # not found => path is null
  # FS error  => e is not null
Something went wrong with that request. Please try again.