Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renamed cinch.transformSource() to cinch.transform(). Updated readme.…

… Removed debug statements.
  • Loading branch information...
commit 1dec743cf723a63103fad74a2eecda3075657660 1 parent 35631ed
@pguillory authored
Showing with 21 additions and 21 deletions.
  1. +13 −9 README.md
  2. +7 −10 lib/cinch.js
  3. +1 −2  package.json
View
22 README.md
@@ -30,18 +30,22 @@ Since `fileLength_()` ends with an underscore, Cinch will convert it into the fo
});
};
-Features
---------
-* All language features are mapped to async equivalents.
-* Compiles to pure Javascript with no run-time component.
-* Libraries built with Cinch can be used without it installed.
-* Mix and match Cinch and non-Cinch functions.
-
Running Cinch code
------------------
-Use included script `node-cinch` instead of `node` to run `.js_` files directly. Or you can call `require('cinch').registerExtension()` from a running script to enable `.js_` modules to be `require()`-ed.
+ npm install cinch
+ node-cinch myfile.js_
+
+As `.js_` modules are loaded, Cinch will save pure-Javascript versions with the `.js` extension. These are regular modules and can be used without Cinch present.
+
+API
+---
+`cinch.registerExtension()`
+
+Hooks into `require()` functionality to allow `.js_` modules to be loaded.
+
+`cinch.transform(source)`
-As `.js_` modules are loaded, Cinch will save pure-Javascript versions with the `.js` extension. These are regular Javascript modules and can be used without Cinch.
+Transforms a single script and returns the pure-JS version.
History
-------
View
17 lib/cinch.js
@@ -15,7 +15,7 @@ var function_vars
/**
* Transform a block of Cinch source code into pure Javascript.
*/
-exports.transformSource = function(source) {
+exports.transform = function(source) {
var script = Narcissus.parser.parse(source)
transform_script(script)
return pp(script) + '\n'
@@ -45,12 +45,17 @@ exports.registerExtension = function(options) {
var source = fs.readFileSync(filename_, 'utf8');
try {
- Narcissus.parser.parse(source)
+ var script = Narcissus.parser.parse(source)
} catch (err) {
module._compile(source, filename_)
throw err
}
+ transform_script(script)
+ var transformed = options.preamble + pp(script) + '\n'
+
+ fs.writeFileSync(filename, transformed, 'utf8');
+
if (options.saveParseTree) {
var script = Narcissus.parser.parse(source)
strip(script)
@@ -62,12 +67,6 @@ exports.registerExtension = function(options) {
fs.writeFileSync(filename + '.parsed.json', JSON.stringify(script), 'utf8')
}
- var script = Narcissus.parser.parse(source)
- transform_script(script)
- var transformed = options.preamble + pp(script) + '\n'
-
- fs.writeFileSync(filename, transformed, 'utf8');
-
module._compile(transformed, filename)
}
@@ -441,7 +440,6 @@ var statement_transformations = {
var child = statement.children[i]
var name = child.name
if (function_vars[name]) {
- util.debug('duplicate var ' + name)
statement.children.splice(i, 1)
if (child.initializer) {
var assign = snippets.assign(snippets.ident(name), child.initializer)
@@ -456,7 +454,6 @@ var statement_transformations = {
return transform_statement(statement, subsequent_statements)
}
}
- util.debug('var ' + name)
function_vars[name] = name
}
},
View
3  package.json
@@ -1,7 +1,7 @@
{
"name": "cinch",
"description": "Async control flow made easy",
- "version": "0.1.0",
+ "version": "0.1.1",
"repository": {
"type": "git",
"url": "git://github.com/pguillory/cinch.git"
@@ -16,6 +16,5 @@
},
"bin": {
"node-cinch": "./bin/node-cinch",
- "node-cinch-save": "./bin/node-cinch-save"
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.