Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add full AMD load support #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dist/test
TODO.txt
node_modules
doc/public
/.idea
2 changes: 1 addition & 1 deletion lib/stomp-node.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 28 additions & 16 deletions lib/stomp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/stomp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 27 additions & 15 deletions src/stomp.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -510,18 +510,30 @@ Stomp =

# # `Stomp` object exportation

# export as CommonJS module
if exports?
exports.Stomp = Stomp

# export in the Web Browser
if window?
# in the Web browser, rely on `window.setInterval` to handle heart-beats
Stomp.setInterval= (interval, f) ->
window.setInterval f, interval
Stomp.clearInterval= (id) ->
window.clearInterval id
window.Stomp = Stomp
# or in the current object (e.g. a WebWorker)
else if !exports
self.Stomp = Stomp
((root, factory) ->
if typeof module is 'object' and module.exports
# Node, or CommonJS-Like environments
module.exports = factory()
else
if typeof define is 'function' and define.amd
# AMD. Register as an anonymous module.
define ->
factory(root)
else
# export in the Web Browser
if window?
# in the Web browser
root.Stomp = factory(root)
else if !exports
# or in the current object (e.g. a WebWorker)
self.Stomp = Stomp
)(@, (global) ->

if window?
# in the Web browser, rely on `window.setInterval` to handle heart-beats
Stomp.setInterval = (interval, f) ->
window.setInterval f, interval
Stomp.clearInterval = (id) ->
window.clearInterval id
Stomp
)