Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from gkz/patch-1

Stylistic improvements from @gkz
  • Loading branch information...
commit 57fb029c68ed796190875e2384af813436598e85 2 parents 19c4ebc + 284e18c
@audreyt authored
Showing with 15 additions and 16 deletions.
  1. +9 −8 q-jscex.js
  2. +6 −8 src/q-jscex.ls
View
17 q-jscex.js
@@ -9,7 +9,7 @@
Q == null && (Q = (__ref = this.Q) != null
? __ref
: (function(){
- throw new Error("Q not available -- Please include it");
+ throw new Error("Q not available -- Please include q.min.js");
}()));
Jscex == null && (Jscex = (__ref = this.Jscex) != null
? __ref
@@ -18,9 +18,9 @@
}()));
}
/* Our own monad that runs on Q promises */
- AsyncBuilder = (function(){
+ AsyncBuilder = (function(superclass){
AsyncBuilder.displayName = 'AsyncBuilder';
- var prototype = AsyncBuilder.prototype, constructor = AsyncBuilder;
+ var prototype = __extend(AsyncBuilder, superclass).prototype, constructor = AsyncBuilder;
prototype.Start = function(_this, step){
var __;
__ = Q.defer();
@@ -58,8 +58,7 @@
};
function AsyncBuilder(){}
return AsyncBuilder;
- }());
- __importAll(AsyncBuilder.prototype, Jscex.BuilderBase.prototype);
+ }(Jscex.BuilderBase));
Jscex.binders['async-q'] = '$await';
Jscex.builders['async-q'] = new AsyncBuilder;
Jscex.modules['async-q'] = true;
@@ -74,8 +73,10 @@
/* Turn off Jscex logging by default */
Jscex.logger.level = 999;
Q.async.$.Jscex = Jscex;
- function __importAll(obj, src){
- for (var key in src) obj[key] = src[key];
- return obj;
+ function __extend(sub, sup){
+ function fun(){} fun.prototype = (sub.superclass = sup).prototype;
+ (sub.prototype = new fun).constructor = sub;
+ if (typeof sup.extended == 'function') sup.extended(sub);
+ return sub;
}
}).call(this);
View
14 src/q-jscex.ls
@@ -16,29 +16,27 @@ class AsyncBuilder extends Jscex.BuilderBase
| \normal \return => __.resolve value
| \throw => __.reject value
| otherwise => throw new Error "Unsupported type: #type"
- return __.promise
+ __.promise
Bind: (promise, generator) ->
- return next: (_this, cb) -> promise.then(
+ next: (_this, cb) -> promise.then do
!(result) ->
- try step = generator.call _this, result
+ try step = generator.call _this, result
catch return cb \throw, e
step.next _this, cb
!(error) -> cb \throw, error
- )
-Jscex.binders.\async-q = \$await
+Jscex.binders. \async-q = \$await
Jscex.builders.\async-q = new AsyncBuilder
-Jscex.modules.\async-q = true
+Jscex.modules. \async-q = true
/* Compile a function containing the special $await keyword.
Once invoked, we implicitly start the task, and return a
deferred Promise object representing its result.
*/
-Q.async.$ = (cb) -> Jscex.compile(\async-q, cb).replace(
+Q.async.$ = (cb) -> Jscex.compile(\async-q, cb).replace do
/(Jscex.builders\["async-q"\])/
'Q.async.$.$1'
-)
/* Turn off Jscex logging by default */
Jscex.logger.level = 999
Please sign in to comment.
Something went wrong with that request. Please try again.