Skip to content
Browse files

es3

  • Loading branch information...
1 parent a388a9c commit be3c8b812e88289c4cf0b0679d05e4f3c03bdcc4 @douglascrockford committed Oct 29, 2012
Showing with 11 additions and 13 deletions.
  1. +11 −13 vow.js
View
24 vow.js
@@ -1,11 +1,9 @@
// vow.js
// Douglas Crockford
-// 2012-10-22
+// 2012-10-29
// Public Domain
-/*jslint es5: true */
-
/*global setTimeout, setImmediate */
@@ -115,7 +113,7 @@ var VOW = (function () {
// Construct and return the vow object.
return {
- break: function (value) {
+ 'break': function (value) {
// The break method breaks the promise.
@@ -147,23 +145,23 @@ var VOW = (function () {
// If this promise is still pending, then enqueue both kept and broken.
case 'pending':
- enqueue(keepers, kept, vow.keep, vow.break);
- enqueue(breakers, broken, vow.break, vow.break);
+ enqueue(keepers, kept, vow.keep, vow['break']);
+ enqueue(breakers, broken, vow['break'], vow['break']);
break;
// If the promise has already been kept, then enqueue only the kept function,
// and enlighten it.
case 'kept':
- enqueue(keepers, kept, vow.keep, vow.break);
+ enqueue(keepers, kept, vow.keep, vow['break']);
enlighten(keepers, fate);
break;
// If the promise has already been broken, then enqueue only the broken
// function, and enlighten it.
case 'broken':
- enqueue(breakers, broken, vow.break, vow.break);
+ enqueue(breakers, broken, vow['break'], vow['break']);
enlighten(breakers, fate);
break;
}
@@ -180,7 +178,7 @@ var VOW = (function () {
var remaining = array.length, results = [], vow = VOW.make();
if (!remaining) {
- vow.break(array);
+ vow['break'](array);
} else {
array.forEach(function (promise, i) {
promise.when(function (value) {
@@ -191,7 +189,7 @@ var VOW = (function () {
}
}, function (reason) {
remaining = NaN;
- vow.break(reason);
+ vow['break'](reason);
});
});
}
@@ -208,12 +206,12 @@ var VOW = (function () {
function check() {
remaining -= 1;
if (remaining === 0 && !found) {
- vow.break();
+ vow['break']();
}
}
if (remaining === 0) {
- vow.break(array);
+ vow['break'](array);
} else {
array.forEach(function (promise) {
promise.when(function (value) {
@@ -267,7 +265,7 @@ var VOW = (function () {
// Returns a new broken promise/
var vow = VOW.make();
- vow.break(reason);
+ vow['break'](reason);
return vow.promise;
}
};

0 comments on commit be3c8b8

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