Skip to content
Browse files

suspend() is better as an alias for suspend.fn(), instead of suspend.…

…async()
  • Loading branch information...
1 parent 929028d commit b7ccb5ab603ca6a2bdb8f22169c3ef739fbf79fa @jmar777 committed
Showing with 21 additions and 21 deletions.
  1. +21 −21 lib/suspend.js
View
42 lib/suspend.js
@@ -1,11 +1,28 @@
/**
- * Our suspend namespace, which doubles as an alias for `suspend.async`
- * (although at the code level it may be more accurate to say that
- * `suspend.async` is an alias for `suspend`...
+ * Our suspend namespace, which doubles as an alias for `suspend.fn` (although
+ * at the code level it may be more accurate to say that `suspend.fn` is an
+ * alias for `suspend`...
+ * Accepts a generator and returns a new function that makes no assumptions
+ * regarding callback and/or error conventions.
+ */
+var suspend = module.exports = function fn(generator) {
+ if (!isGeneratorFunction(generator)) {
+ throw new Error('First .fn() argument must be a GeneratorFunction.');
+ }
+
+ return function() {
+ var suspender = new Suspender(generator);
+ // preserve `this` context
+ suspender.start(this, Array.prototype.slice.call(arguments));
+ };
+};
+suspend.fn = suspend;
+
+/**
* Accepts a generator, and returns a new function that follows Node's callback
* conventions. The callback is required.
*/
-var suspend = module.exports = function async(generator) {
+ suspend.async = function async(generator) {
if (!isGeneratorFunction(generator)) {
throw new Error('First .async() argument must be a GeneratorFunction.');
}
@@ -23,23 +40,6 @@ var suspend = module.exports = function async(generator) {
suspender.start(this, args);
};
};
-suspend.async = suspend;
-
-/**
- * Accepts a generator and returns a new function that makes no assumptions
- * regarding callback and/or error conventions.
- */
-suspend.fn = function fn(generator) {
- if (!isGeneratorFunction(generator)) {
- throw new Error('First .fn() argument must be a GeneratorFunction.');
- }
-
- return function() {
- var suspender = new Suspender(generator);
- // preserve `this` context
- suspender.start(this, Array.prototype.slice.call(arguments));
- };
-};
/**
* Accepts a generator and an optional callback. The generator is invoked

0 comments on commit b7ccb5a

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