Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rsvp.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
rsvp.js
Commits
3c4b86aa
Commit
3c4b86aa
authored
Oct 17, 2012
by
Yehuda Katz
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6 from rpflorence/amd
added AMD build to browser/ with `rake dist`
parents
d8eb418c
5f1b7b78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
217 additions
and
2 deletions
+217
-2
Rakefile
Rakefile
+9
-2
browser/rsvp-amd.js
browser/rsvp-amd.js
+208
-0
No files found.
Rakefile
View file @
3c4b86aa
...
...
@@ -50,6 +50,13 @@ file "browser/rsvp.js" => ["browser", "lib/rsvp.js"] do
end
end
file
"browser/rsvp-amd.js"
=>
[
"browser"
,
"lib/rsvp.js"
]
do
library
=
File
.
read
(
"lib/rsvp.js"
)
open
"browser/rsvp-amd.js"
,
"w"
do
|
file
|
file
.
puts
"define(function(require, exports, module) {
#{
library
}
});"
end
end
file
"browser/rsvp.min.js"
=>
"browser/rsvp.js"
do
output
=
`cat browser/rsvp.js | uglifyjs`
...
...
@@ -58,10 +65,10 @@ file "browser/rsvp.min.js" => "browser/rsvp.js" do
end
end
task
:dist
=>
[
"browser/rsvp.js"
,
"browser/rsvp.min.js"
]
task
:dist
=>
[
"browser/rsvp.js"
,
"browser/rsvp.min.js"
,
"browser/rsvp-amd.js"
]
task
:push
=>
:dist
do
sh
"git add browser/rsvp.js browser/rsvp.min.js"
sh
"git add browser/rsvp.js browser/rsvp.min.js
browser/rsvp-amd.js
"
sh
"git commit -m 'Updates build artifacts'"
end
...
...
browser/rsvp-amd.js
0 → 100644
View file @
3c4b86aa
define
(
function
(
require
,
exports
,
module
)
{
"
use strict
"
;
var
browserGlobal
=
(
typeof
window
!==
'
undefined
'
)
?
window
:
{};
var
MutationObserver
=
browserGlobal
.
MutationObserver
||
browserGlobal
.
WebKitMutationObserver
;
var
async
;
if
(
typeof
process
!==
'
undefined
'
)
{
async
=
function
(
callback
,
binding
)
{
process
.
nextTick
(
function
()
{
callback
.
call
(
binding
);
});
};
}
else
if
(
MutationObserver
)
{
var
queue
=
[];
var
observer
=
new
MutationObserver
(
function
()
{
var
toProcess
=
queue
.
slice
();
queue
=
[];
toProcess
.
forEach
(
function
(
tuple
)
{
var
callback
=
tuple
[
0
],
binding
=
tuple
[
1
];
callback
.
call
(
binding
);
});
});
var
element
=
document
.
createElement
(
'
div
'
);
observer
.
observe
(
element
,
{
attributes
:
true
});
async
=
function
(
callback
,
binding
)
{
queue
.
push
([
callback
,
binding
]);
element
.
setAttribute
(
'
drainQueue
'
,
'
drainQueue
'
);
};
}
else
{
async
=
function
(
callback
,
binding
)
{
setTimeout
(
function
()
{
callback
.
call
(
binding
);
},
1
);
};
}
exports
.
async
=
async
;
var
Event
=
exports
.
Event
=
function
(
type
,
options
)
{
this
.
type
=
type
;
for
(
var
option
in
options
)
{
if
(
!
options
.
hasOwnProperty
(
option
))
{
continue
;
}
this
[
option
]
=
options
[
option
];
}
};
var
indexOf
=
function
(
callbacks
,
callback
)
{
for
(
var
i
=
0
,
l
=
callbacks
.
length
;
i
<
l
;
i
++
)
{
if
(
callbacks
[
i
][
0
]
===
callback
)
{
return
i
;
}
}
return
-
1
;
};
var
callbacksFor
=
function
(
object
)
{
var
callbacks
=
object
.
_promiseCallbacks
;
if
(
!
callbacks
)
{
callbacks
=
object
.
_promiseCallbacks
=
{};
}
return
callbacks
;
};
var
EventTarget
=
exports
.
EventTarget
=
{
mixin
:
function
(
object
)
{
object
.
on
=
this
.
on
;
object
.
off
=
this
.
off
;
object
.
trigger
=
this
.
trigger
;
return
object
;
},
on
:
function
(
eventName
,
callback
,
binding
)
{
var
allCallbacks
=
callbacksFor
(
this
),
callbacks
;
binding
=
binding
||
this
;
callbacks
=
allCallbacks
[
eventName
];
if
(
!
callbacks
)
{
callbacks
=
allCallbacks
[
eventName
]
=
[];
}
if
(
indexOf
(
callbacks
,
callback
)
===
-
1
)
{
callbacks
.
push
([
callback
,
binding
]);
}
},
off
:
function
(
eventName
,
callback
)
{
var
allCallbacks
=
callbacksFor
(
this
),
callbacks
;
if
(
!
callback
)
{
allCallbacks
[
eventName
]
=
[];
return
;
}
callbacks
=
allCallbacks
[
eventName
];
var
index
=
indexOf
(
callbacks
,
callback
);
if
(
index
!==
-
1
)
{
callbacks
.
splice
(
index
,
1
);
}
},
trigger
:
function
(
eventName
,
options
)
{
var
allCallbacks
=
callbacksFor
(
this
),
callbacks
,
callbackTuple
,
callback
,
binding
,
event
;
if
(
callbacks
=
allCallbacks
[
eventName
])
{
for
(
var
i
=
0
,
l
=
callbacks
.
length
;
i
<
l
;
i
++
)
{
callbackTuple
=
callbacks
[
i
];
callback
=
callbackTuple
[
0
];
binding
=
callbackTuple
[
1
];
if
(
typeof
options
!==
'
object
'
)
{
options
=
{
detail
:
options
};
}
event
=
new
Event
(
eventName
,
options
);
callback
.
call
(
binding
,
event
);
}
}
}
};
var
Promise
=
exports
.
Promise
=
function
()
{
this
.
on
(
'
promise:resolved
'
,
function
(
event
)
{
this
.
trigger
(
'
success
'
,
{
detail
:
event
.
detail
});
},
this
);
this
.
on
(
'
promise:failed
'
,
function
(
event
)
{
this
.
trigger
(
'
error
'
,
{
detail
:
event
.
detail
});
},
this
);
};
var
noop
=
function
()
{};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
value
,
error
;
if
(
callback
)
{
try
{
value
=
callback
(
event
.
detail
);
}
catch
(
e
)
{
error
=
e
;
}
}
else
{
value
=
event
.
detail
;
}
if
(
value
instanceof
Promise
)
{
value
.
then
(
function
(
value
)
{
promise
.
resolve
(
value
);
},
function
(
error
)
{
promise
.
reject
(
error
);
});
}
else
if
(
callback
&&
value
)
{
promise
.
resolve
(
value
);
}
else
if
(
error
)
{
promise
.
reject
(
error
);
}
else
{
promise
[
type
](
value
);
}
};
Promise
.
prototype
=
{
then
:
function
(
done
,
fail
)
{
var
thenPromise
=
new
Promise
();
this
.
on
(
'
promise:resolved
'
,
function
(
event
)
{
invokeCallback
(
'
resolve
'
,
thenPromise
,
done
,
event
);
});
this
.
on
(
'
promise:failed
'
,
function
(
event
)
{
invokeCallback
(
'
reject
'
,
thenPromise
,
fail
,
event
);
});
return
thenPromise
;
},
resolve
:
function
(
value
)
{
exports
.
async
(
function
()
{
this
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
this
.
isResolved
=
value
;
},
this
);
this
.
resolve
=
noop
;
this
.
reject
=
noop
;
},
reject
:
function
(
value
)
{
exports
.
async
(
function
()
{
this
.
trigger
(
'
promise:failed
'
,
{
detail
:
value
});
this
.
isRejected
=
value
;
},
this
);
this
.
resolve
=
noop
;
this
.
reject
=
noop
;
}
};
EventTarget
.
mixin
(
Promise
.
prototype
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment