From 7e70f80dba16d78ed76d038c99904a55689b2a0a Mon Sep 17 00:00:00 2001 From: BYVoid Date: Wed, 10 Oct 2012 14:23:26 +0800 Subject: [PATCH] Bump version to 0.0.5 and update readme and changelog --- CHANGELOG.md | 13 ++++++++- License | 29 ++++++++++++++++++++ README.md | 53 +++++++++---------------------------- package.json | 7 ++--- test/cases/try_if.js | 14 ++++++++++ test/results/continue.js | 2 +- test/results/defer.js | 2 +- test/results/diskusage.js | 2 +- test/results/factor.js | 2 +- test/results/fib.js | 2 +- test/results/for.js | 2 +- test/results/forin.js | 2 +- test/results/if.js | 2 +- test/results/ifvar.js | 2 +- test/results/list.js | 2 +- test/results/loop.js | 2 +- test/results/pi.js | 2 +- test/results/readfile.js | 2 +- test/results/switch.js | 2 +- test/results/switchbreak.js | 2 +- test/results/try_body.js | 2 +- test/results/try_both.js | 2 +- test/results/try_catch.js | 2 +- test/results/try_if.js | 42 +++++++++++++++++++++++++++++ test/results/whilebreak.js | 2 +- test/test.js | 1 + 26 files changed, 134 insertions(+), 63 deletions(-) create mode 100644 License create mode 100644 test/cases/try_if.js create mode 100644 test/results/try_if.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 30a5d35..49a7a96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,22 @@ #Change Log +## 0.0.5 + +2012-10-10 + +* Compile source code only if needed +* Add 'explicit' and 'verbose' options for compilation and loading +* Implemented script loading cache +* Supported LogicalExpression,RegExp, etc +* Fixed a bug if no 'catch' clause found in try statement +* Fixed a bug about nested try and if statements + ## 0.0.4 2012-10-02 * Loading and automatically compiling by require() is working -* Support Coffee Script +* Supported Coffee Script * Implemented 'defer' statement * Added browser and node.js examples diff --git a/License b/License new file mode 100644 index 0000000..19b614b --- /dev/null +++ b/License @@ -0,0 +1,29 @@ +BSD License + + Copyright 2012 (c) Carbo KUO + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. diff --git a/README.md b/README.md index 3d11724..9f007a5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Continuation.js -Continuation.js is a compiler for asynchronous [Continuation-Passing Style](http://en.wikipedia.org/wiki/Continuation-passing_style) transformation, which simplifies asynchronous programming. +Continuation.js is a compiler for asynchronous [Continuation-Passing Style](http://en.wikipedia.org/wiki/Continuation-passing_style) transformation, which simplifies asynchronous JavaScript programming. -Typically writing with asynchronous control flow is a pain because you will easily write nested callbacks like below: +Typically, writing with asynchronous control flow is a pain because you will easily write nested callbacks like below: ```javascript function textProcessing(callback) { @@ -26,7 +26,7 @@ textProcessing(function (err, contents) { }); ``` -While using Continuation.js, you write: +This kind of coding style is called 'callback hells' or 'callback pyramids'. While using Continuation.js, you directly write: ```javascript function textProcessing(ret) { @@ -71,29 +71,34 @@ try { * Flexible coding style * Readable and debuggable compiled code * Compatible with CoffeeScript -* Supports both Node.js and browser JavaScript +* Supports both Node.js and browser-side JavaScript * Parallel execution supported ## Installation +Install Continuation.js with [NPM](https://npmjs.org/package/continuation): + npm install -g continuation ## Usage - continuation [options] [arguments] + Usage: continuation [options] [arguments] Options: -h, --help output usage information -V, --version output the version number - -c, --compile only compile script file and print it - -o, --output compile script file and save as , implies --compile + -p, --print compile script file and print it + -o, --output compile script file and save as + -e, --explicit compile only if "use continuation" is explicitly declared + -c, --cache [directory] run and cache compiled sources to [directory], by default [directory] is /tmp/continuation + -v, --verbose print verbosal information to stderr ## Documentation Continuation.js is still under development. Most functionalities are not fully implemented or tested. -More details are to be written. See examples below. +More details are to be written. ## Examples @@ -127,35 +132,3 @@ console.log('Done'); ``` More examples are available in 'examples' directory. - -## License - -BSD License - - Copyright 2012 (c) Carbo KUO - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. diff --git a/package.json b/package.json index e71e6d6..7a9cf90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "continuation", - "version": "0.0.4", + "version": "0.0.5", "description": "Continuation.js is a compiler for asynchronous JavaScript Continuation-Passing style transformation", "author": "BYVoid", "license": "BSD", @@ -27,8 +27,9 @@ "keywords": [ "compiler", "continuation", - "coffeescript", - "monad" + "monad", + "cps", + "coffeescript" ], "dependencies": { "esprima": "0.9.9", diff --git a/test/cases/try_if.js b/test/cases/try_if.js new file mode 100644 index 0000000..e4b1447 --- /dev/null +++ b/test/cases/try_if.js @@ -0,0 +1,14 @@ +try { + if (true) { + setTimeout(cont(), 100); + console.log('throw err'); + throw 'Err'; + } else {throw 'Else Err';} + console.log('after if'); +} catch (err) { + console.error(err); + return; +} + +console.log('Done'); + diff --git a/test/results/continue.js b/test/results/continue.js index e2cf8aa..3f79596 100644 --- a/test/results/continue.js +++ b/test/results/continue.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var i; i = 0; function loop_0(loop_0_cont) { diff --git a/test/results/defer.js b/test/results/defer.js index c1e6f6a..6e1a663 100644 --- a/test/results/defer.js +++ b/test/results/defer.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var fs, err, text, util; fs = require('fs'); (function (cont) { diff --git a/test/results/diskusage.js b/test/results/diskusage.js index 4ad391e..e25dc99 100644 --- a/test/results/diskusage.js +++ b/test/results/diskusage.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var fs, path, err, totalSize, totalBlockSize; fs = require('fs'); function calcDirSize(path, callback) { diff --git a/test/results/factor.js b/test/results/factor.js index f2ddc2e..9cbf47a 100644 --- a/test/results/factor.js +++ b/test/results/factor.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var factor; factor = function (n, callback) { var rest; diff --git a/test/results/fib.js b/test/results/fib.js index 77e1870..9c83c5d 100644 --- a/test/results/fib.js +++ b/test/results/fib.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var fib; fib = function () { var a, current, b; diff --git a/test/results/for.js b/test/results/for.js index 0ca6a67..2cd72e2 100644 --- a/test/results/for.js +++ b/test/results/for.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var e, list, _i, _len; list = [ 1, diff --git a/test/results/forin.js b/test/results/forin.js index 287a14b..4961a5a 100644 --- a/test/results/forin.js +++ b/test/results/forin.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ for (var key in [1, 2, 3]) { console.log(key); } diff --git a/test/results/if.js b/test/results/if.js index 26a81c5..a8d6b6d 100644 --- a/test/results/if.js +++ b/test/results/if.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var err, text, a; (function (cont) { if (bool) { diff --git a/test/results/ifvar.js b/test/results/ifvar.js index c27f407..31e0d78 100644 --- a/test/results/ifvar.js +++ b/test/results/ifvar.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var b, c, i, j, k, p; (function (cont) { if (true) { diff --git a/test/results/list.js b/test/results/list.js index 1753780..023737e 100644 --- a/test/results/list.js +++ b/test/results/list.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var list, i; function delay(num, callback) { setTimeout(function () { diff --git a/test/results/loop.js b/test/results/loop.js index 31c7317..ce90c12 100644 --- a/test/results/loop.js +++ b/test/results/loop.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var fs, i, err, text; fs = require('fs'); i = 0; diff --git a/test/results/pi.js b/test/results/pi.js index c2f7c36..2997950 100644 --- a/test/results/pi.js +++ b/test/results/pi.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var calcPi, pi; calcPi = function (callback) { var f; diff --git a/test/results/readfile.js b/test/results/readfile.js index b026be6..ce949cf 100644 --- a/test/results/readfile.js +++ b/test/results/readfile.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var fs, a, err, text; fs = require('fs'); a = 1; diff --git a/test/results/switch.js b/test/results/switch.js index 29aa93e..f4e1ab5 100644 --- a/test/results/switch.js +++ b/test/results/switch.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var err, text, end; (function (cont) { function case_0(cont) { diff --git a/test/results/switchbreak.js b/test/results/switchbreak.js index 2064858..f495ad4 100644 --- a/test/results/switchbreak.js +++ b/test/results/switchbreak.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var val, num; val = 'a'; num = 1; diff --git a/test/results/try_body.js b/test/results/try_body.js index d8f3c3f..e9b0114 100644 --- a/test/results/try_body.js +++ b/test/results/try_body.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var a, err; (function (cont) { try { diff --git a/test/results/try_both.js b/test/results/try_both.js index cf428e6..4e0a73f 100644 --- a/test/results/try_both.js +++ b/test/results/try_both.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ (function (cont) { (function (cont) { try { diff --git a/test/results/try_catch.js b/test/results/try_catch.js index 9cae6d0..6b41976 100644 --- a/test/results/try_catch.js +++ b/test/results/try_catch.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ (function (cont) { try { throw new Error('my error'); diff --git a/test/results/try_if.js b/test/results/try_if.js new file mode 100644 index 0000000..32681e0 --- /dev/null +++ b/test/results/try_if.js @@ -0,0 +1,42 @@ +/* Generated by Continuation.js v0.0.5 */ +(function (cont) { + try { + (function (cont) { + try { + if (true) { + setTimeout(function () { + try { + console.log('throw err'); + throw 'Err'; + cont(); + } catch (err) { + cont(err); + } + }, 100); + } else { + throw 'Else Err'; + cont(); + } + } catch (err) { + cont(err); + } + }(function (err) { + try { + if (err !== undefined) + return cont(err); + console.log('after if'); + cont(); + } catch (err) { + cont(err); + } + })); + } catch (err) { + cont(err); + } +}(function (err) { + if (err !== undefined) { + console.error(err); + return; + } + console.log('Done'); +})); \ No newline at end of file diff --git a/test/results/whilebreak.js b/test/results/whilebreak.js index aa86480..63d4a88 100644 --- a/test/results/whilebreak.js +++ b/test/results/whilebreak.js @@ -1,4 +1,4 @@ -/* Generated by Continuation.js v0.0.4 */ +/* Generated by Continuation.js v0.0.5 */ var i; i = 0; function loop_0(loop_0_cont) { diff --git a/test/test.js b/test/test.js index 9ac5ec9..428b0b0 100644 --- a/test/test.js +++ b/test/test.js @@ -23,6 +23,7 @@ var files = [ 'defer.js', 'for.js', 'forin.js', + 'try_if.js', ]; var test = function(filename, done) {