Permalink
Browse files

Support Montage Require

Add `bootstrap` boilerplate so Montage Require can use Q with script
injection during its bootstrapping process.

Move `define` below the check for `exports` since Montage Require uses
both globals.
  • Loading branch information...
kriskowal committed Aug 22, 2012
1 parent 939b7ca commit 234ab99981d060e2143ee74050308a04a2bc4f08
Showing with 10 additions and 6 deletions.
  1. +10 −6 q.js
View
16 q.js
@@ -67,14 +67,18 @@
// Common/Node/RequireJS, the module exports the Q API and when
// executed as a simple <script>, it creates a Q global instead.
- // RequireJS
- if (typeof define === "function") {
- define(definition);
+ // Montage Require
+ if (typeof bootstrap === "function") {
+ bootstrap("promise", definition);
// CommonJS
} else if (typeof exports === "object") {
definition(void 0, exports);
+ // RequireJS
+ } else if (typeof define === "function") {
+ define(definition);
+
// SES (Secure EcmaScript)
} else if (typeof ses !== "undefined") {
if (!ses.ok()) {
@@ -425,7 +429,7 @@ function captureLine(objectWithStack) {
function deprecate(fn, name, alternative) {
return function () {
if (typeof console !== "undefined" && typeof console.warn === "function") {
- console.warn(name + " is deprecated, use " + alternative + " instead.");
+ console.warn(name + " is deprecated, use " + alternative + " instead.", new Error("").stack);
}
return fn.apply(fn, arguments);
};
@@ -1420,7 +1424,7 @@ function delay(promise, timeout) {
* Passes a continuation to a Node function, which is called with a given
* `this` value and arguments provided as an array, and returns a promise.
*
- * var FS = require("fs");
+ * var FS = (require)("fs");
* Q.napply(FS.readFile, FS, [__filename])
* .then(function (content) {
* })
@@ -1435,7 +1439,7 @@ function napply(callback, thisp, args) {
* Passes a continuation to a Node function, which is called with a given
* `this` value and arguments provided individually, and returns a promise.
*
- * var FS = require("fs");
+ * var FS = (require)("fs");
* Q.ncall(FS.readFile, FS, __filename)
* .then(function (content) {
* })

0 comments on commit 234ab99

Please sign in to comment.