Skip to content
Browse files

* First step in porting to non-node.js runtimes.

  Also, don't depend on jscex-async-powerpack anymore.
  • Loading branch information...
1 parent d580587 commit e8c3fcbe53932ef835db20509896d6dc2b516e8d @audreyt committed Jun 10, 2012
Showing with 28 additions and 21 deletions.
  1. +18 −10 jscex-jquery.js
  2. +2 −3 package.json
  3. +8 −8 src/jscex-jquery.ls
View
28 jscex-jquery.js
@@ -1,17 +1,26 @@
(function(){
- var Jscex, XMLHttpRequest, $, AsyncBuilder;
+ var Jscex, $, XMLHttpRequest, AsyncBuilder, __ref;
Jscex = require('jscex');
require('jscex-jit').init(Jscex);
require('jscex-async').init(Jscex);
- require('jscex-async-powerpack').init(Jscex);
- XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
- $ = require('jquery');
- $.support.cors = true;
- $.ajaxSettings.xhr = function(){
- return new XMLHttpRequest;
- };
+ if (typeof module != 'undefined' && module !== null) {
+ module.exports = $ = require('jquery');
+ XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
+ $.support.cors = true;
+ $.ajaxSettings.xhr = function(){
+ return new XMLHttpRequest;
+ };
+ } else {
+ ($ != null
+ ? $
+ : $ = typeof jQuery != 'undefined' && jQuery !== null
+ ? jQuery
+ : {}).Deferred == null && (function(){
+ throw new Error("$.Deferred not available -- Please include jQuery 1.5+");
+ }());
+ }
/* Convert a Promise (Q, jQuery, Dojo) object into a Task */
- Jscex.Async.Binding.fromPromise = function(p){
+ ((__ref = Jscex.Async).Binding || (__ref.Binding = {})).fromPromise = function(p){
return Jscex.Async.Task.create(function(t){
p.then(function(it){
return t.complete('success', it);
@@ -79,7 +88,6 @@
Jscex.logger.level = 999;
/* Export the $ object extended with $.Jscex */
$.Jscex = Jscex;
- module.exports = $;
function __importAll(obj, src){
for (var key in src) obj[key] = src[key];
return obj;
View
5 package.json
@@ -1,13 +1,12 @@
{ "name" : "jscex-jquery"
, "description" : "Async/Await support for jQuery 1.5+"
- , "version" : "0.0.1"
+ , "version" : "0.0.2"
, "main": "jscex-jquery.js"
, "dependencies": {
"jquery": "*",
"jscex": "*",
"jscex-jit": "*",
- "jscex-async": "*",
- "jscex-async-powerpack": "*"
+ "jscex-async": "*"
}
, "devDependencies": {
"LiveScript": "0.9.7"
View
16 src/jscex-jquery.ls
@@ -1,16 +1,17 @@
Jscex = require \jscex
require \jscex-jit .init Jscex
require \jscex-async .init Jscex
-require \jscex-async-powerpack .init Jscex
-{ XMLHttpRequest } = require \xmlhttprequest
-
-$ = require \jquery
-$.support.cors = yes
-$.ajaxSettings.xhr = -> new XMLHttpRequest
+if module?
+ module.exports = $ = require \jquery
+ { XMLHttpRequest } = require \xmlhttprequest
+ $.support.cors = yes
+ $.ajaxSettings.xhr = -> new XMLHttpRequest
+else
+ ($ ?= jQuery ? {}).Deferred ? throw new Error "$.Deferred not available -- Please include jQuery 1.5+"
/* Convert a Promise (Q, jQuery, Dojo) object into a Task */
-Jscex.Async.Binding.fromPromise = (p) ->
+Jscex.Async.@Binding.fromPromise = (p) ->
t <- Jscex.Async.Task.create
p.then(
-> t.complete \success, it
@@ -55,4 +56,3 @@ Jscex.logger.level = 999
/* Export the $ object extended with $.Jscex */
$.Jscex = Jscex
-module.exports = $

0 comments on commit e8c3fcb

Please sign in to comment.
Something went wrong with that request. Please try again.