Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

-- lint

  • Loading branch information...
commit bfaef4bd9aff3639373b8f1d3908f6aa6834c602 1 parent cdbef26
@medikoo authored
Showing with 238 additions and 152 deletions.
  1. +99 −5 .lint
  2. +5 −6 lib/deferred.js
  3. +6 −8 lib/ext/_process-arguments.js
  4. +4 −4 lib/ext/array/map.js
  5. +8 −6 lib/ext/function/gate.js
  6. +5 −5 lib/ext/function/promisify-sync.js
  7. +1 −2  lib/ext/promise/_array.js
  8. +1 −1  lib/ext/promise/aside.js
  9. +1 −2  lib/ext/promise/cb.js
  10. +3 −3 lib/ext/promise/get.js
  11. +15 −16 lib/ext/promise/invoke-async.js
  12. +13 −15 lib/ext/promise/invoke.js
  13. +2 −4 lib/ext/promise/match.js
  14. +2 −1  lib/monitor.js
  15. +14 −11 lib/profiler.js
  16. +1 −2  lib/promise.js
  17. +4 −5 test/deferred.js
  18. +3 −4 test/ext/_process-arguments.js
  19. +3 −6 test/ext/array/map.js
  20. +4 −5 test/ext/array/reduce.js
  21. +1 −1  test/ext/array/some.js
  22. +5 −3 test/ext/function/gate.js
  23. +2 −2 test/ext/function/promisify-sync.js
  24. +4 −3 test/ext/function/promisify.js
  25. +1 −1  test/ext/promise/_array.js
  26. +4 −3 test/ext/promise/cb.js
  27. +1 −1  test/ext/promise/get.js
  28. +6 −5 test/ext/promise/invoke-async.js
  29. +7 −6 test/ext/promise/invoke.js
  30. +5 −9 test/index.js
  31. +1 −1  test/monitor.js
  32. +1 −1  test/profiler.js
  33. +6 −5 test/promise.js
View
104 .lint
@@ -1,8 +1,102 @@
@root
+
indent 2
maxlen 80
-bitwise
-nomen
-plusplus
-tabs
-predef clearTimeout, setTimeout
+es5
+
+jslint_medikoo.tabs
+jslint_medikoo.module
+jslint_medikoo.plusplus
+
+jshint.laxcomma
+jshint.camelcase
+jshint.curly
+jshint.eqeqeq
+jshint.forin
+jshint.immed
+jshint.latedef
+jshint.newcap
+jshint.noarg
+jshint.noempty
+jshint.nonew
+jshint.regexp
+jshint.undef
+jshint.unused
+jshint.strict
+jshint.trailing
+jshint.globalstrict
+jshint.global module, require, exports
+jshint.smarttabs
+jshint.eqnull
+jshint.expr
+
+./lib/deferred.js
+jslint_medikoo.predef+ clearTimeout
+jshint.global+ clearTimeout
+jslint_medikoo.nomen
+jshint.proto
+!jshint.camelcase
+
+./lib/ext/array/map.js
+jslint_medikoo.bitwise
+
+./lib/ext/array/reduce.js
+jslint_medikoo.bitwise
+
+./lib/ext/array/some.js
+jslint_medikoo.bitwise
+
+./lib/ext/function/delay.js
+jslint_medikoo.predef+ setTimeout
+jshint.global+ setTimeout
+
+./lib/ext/function/promisify-sync.js
+jslint_medikoo.bitwise
+
+./lib/ext/function/promisify.js
+jslint_medikoo.bitwise
+
+./lib/monitor.js
+jslint_medikoo.predef+ console, setTimeout
+jshint.global+ console, setTimeout
+
+./lib/profiler.js
+jslint_medikoo.predef+ console
+jslint_medikoo.nomen
+jshint.global+ console
+
+./lib/promise.js
+jslint_medikoo.nomen
+jslint_medikoo.predef+ setTimeout
+jshint.proto
+!jshint.camelcase
+jshint.global+ setTimeout
+
+./test/deferred.js
+jslint_medikoo.predef+ setTimeout
+jshint.global+ setTimeout
+
+./test/ext/function/delay.js
+jslint_medikoo.predef+ setTimeout
+jshint.global+ setTimeout
+
+./test/ext/function/promisify.js
+jslint_medikoo.predef+ setTimeout
+jshint.global+ setTimeout
+
+./test/ext/promise/invoke-async.js
+jslint_medikoo.predef+ setTimeout
+jshint.global+ setTimeout
+
+./test/ext/promise/invoke.js
+jslint_medikoo.predef+ setTimeout
+jshint.global+ setTimeout
+
+./test/index.js
+jslint_medikoo.nomen
+jslint_medikoo.predef+ setTimeout, __dirname
+jshint.global+ setTimeout
+
+./test/monitor.js
+jslint_medikoo.predef+ setTimeout
+jshint.global+ setTimeout
View
11 lib/deferred.js
@@ -13,7 +13,6 @@
var every = Array.prototype.every
, push = Array.prototype.push
- , getOwnPropertyNames = Object.getOwnPropertyNames
, isError = require('es5-ext/lib/Error/is-error')
, isPromise = require('./is-promise')
@@ -27,7 +26,7 @@ Deferred = function () {
Deferred.prototype = {
resolved: false,
resolve: function (value) {
- var i, name, args, data;
+ var i, name, data;
if (this.resolved) {
return this.promise;
}
@@ -92,8 +91,8 @@ Deferred.prototype = {
delete this.promise.dependencies;
}
if ((data = this.promise.pending)) {
- for (i = 0; name = data[i], args = data[++i]; ++i) {
- promise.onresolve[name].apply(this.promise, args);
+ for (i = 0; (name = data[i]); ++i) {
+ promise.onresolve[name].apply(this.promise, data[++i]);
}
delete this.promise.pending;
}
@@ -102,12 +101,12 @@ Deferred.prototype = {
};
module.exports = createDeferred = function (value) {
- var o, l, args, d, waiting, initialized, result
+ var l, d, waiting, initialized, result;
if ((l = arguments.length)) {
if (l > 1) {
d = new Deferred();
waiting = 0;
- result = new Array(arguments.length);
+ result = new Array(l);
every.call(arguments, function (value, index) {
if (isPromise(value)) {
++waiting;
View
14 lib/ext/_process-arguments.js
@@ -1,19 +1,17 @@
'use strict';
-var isArray = Array.isArray
- , push = Array.prototype.push
- , slice = Array.prototype.slice
- , some = Array.prototype.some
- , arrayOf = require('es5-ext/lib/Array/of')
+var arrayOf = require('es5-ext/lib/Array/of')
, deferred = require('../deferred')
- , isPromise = require('../is-promise');
+ , isPromise = require('../is-promise')
+
+ , push = Array.prototype.push, slice = Array.prototype.slice;
module.exports = function (args, length) {
- var i, l, promised;
+ var i, l;
if ((length != null) && (args.length !== length)) {
args = slice.call(args, 0, length);
if (args.length < length) {
- push.apply(args, Array(length - args.length));
+ push.apply(args, new Array(length - args.length));
}
}
for (i = 0, l = args.length; i < l; ++i) {
View
8 lib/ext/array/map.js
@@ -12,11 +12,11 @@ var isError = require('es5-ext/lib/Error/is-error')
, every = Array.prototype.every
, call = Function.prototype.call;
-var Map = function (list, cb, context) {
+var DMap = function (list, cb, context) {
this.list = list;
this.cb = cb;
this.context = context;
- this.result = new Array(list.length >>> 0)
+ this.result = new Array(list.length >>> 0);
extend(this, deferred());
every.call(list, this.process, this);
@@ -28,7 +28,7 @@ var Map = function (list, cb, context) {
return this.promise;
};
-Map.prototype = {
+DMap.prototype = {
waiting: 0,
initialized: false,
process: function (value, index) {
@@ -90,5 +90,5 @@ module.exports = function (cb/*, thisArg*/) {
value(this);
(cb == null) || callable(cb);
- return new Map(this, cb, arguments[1]);
+ return new DMap(this, cb, arguments[1]);
};
View
14 lib/ext/function/gate.js
@@ -3,6 +3,8 @@
// controlled with qLimit value, any calls that would reach over that limit
// would be discarded (its promise would resolve with "Too many calls" error)
+'use strict';
+
var apply = Function.prototype.apply
, max = Math.max
, toUint = require('es5-ext/lib/Number/to-uint')
@@ -29,10 +31,10 @@ module.exports = function (cLimit, qLimit) {
count = 0;
queue = [];
- run = function (thisArg, arguments, resolve) {
+ run = function (thisArg, args, resolve) {
var r;
try {
- r = apply.call(fn, thisArg, arguments);
+ r = apply.call(fn, thisArg, args);
} catch (e) {
r = e;
}
@@ -68,12 +70,12 @@ module.exports = function (cLimit, qLimit) {
};
result = function () {
- var r, d;
+ var def;
if (count >= cLimit) {
if (queue.length < qLimit) {
- d = deferred();
- queue.push([this, arguments, d.resolve]);
- return d.promise;
+ def = deferred();
+ queue.push([this, arguments, def.resolve]);
+ return def.promise;
} else {
return reject();
}
View
10 lib/ext/function/promisify-sync.js
@@ -1,14 +1,14 @@
// Promisify synchronous function
-var isArray = Array.isArray
- , slice = Array.prototype.slice
- , apply = Function.prototype.apply
- , toArray = require('es5-ext/lib/Array/from')
- , callable = require('es5-ext/lib/Object/valid-callable')
+'use strict';
+
+var callable = require('es5-ext/lib/Object/valid-callable')
, deferred = require('../../deferred')
, isPromise = require('../../is-promise')
, processArguments = require('../_process-arguments')
+ , apply = Function.prototype.apply
+
, applyFn;
applyFn = function (fn, args, resolve) {
View
3  lib/ext/promise/_array.js
@@ -4,7 +4,7 @@
var callable = require('es5-ext/lib/Object/valid-callable')
, deferred = require('../../deferred')
- , promise = require('../../promise')
+ , promise = require('../../promise');
module.exports = function (name, ext) {
deferred.extend(name, function (cb) {
@@ -29,7 +29,6 @@ module.exports = function (name, ext) {
resolve(result);
}
}, function (cb) {
- var result;
(cb == null) || callable(cb);
if (this.failed) {
return this;
View
2  lib/ext/promise/aside.js
@@ -9,7 +9,7 @@
'use strict';
var callable = require('es5-ext/lib/Object/valid-callable')
- , deferred = require('../../deferred')
+ , deferred = require('../../deferred');
deferred.extend('aside', function (win, fail) {
(win == null) || callable(win);
View
3  lib/ext/promise/cb.js
@@ -21,9 +21,8 @@
'use strict';
var callable = require('es5-ext/lib/Object/valid-callable')
- , isCallable = require('es5-ext/lib/Object/is-callable')
, nextTick = require('next-tick')
- , deferred = require('../../deferred')
+ , deferred = require('../../deferred');
deferred.extend('cb', function (cb) {
if (cb == null) {
View
6 lib/ext/promise/get.js
@@ -9,9 +9,9 @@
var reduce = Array.prototype.reduce
, value = require('es5-ext/lib/Object/valid-value')
, deferred = require('../../deferred')
- , promise = require('../../promise')
+ , promise = require('../../promise');
-deferred.extend('get', function (name) {
+deferred.extend('get', function (/*…name*/) {
var def;
if (!this.pending) {
this.pending = [];
@@ -33,7 +33,7 @@ deferred.extend('get', function (name) {
result = e;
}
return resolve(result);
-}, function (name) {
+}, function (/*…name*/) {
var result;
if (this.failed) {
return this;
View
31 lib/ext/promise/invoke-async.js
@@ -12,17 +12,16 @@
var slice = Array.prototype.slice
, apply = Function.prototype.apply
, toArray = require('es5-ext/lib/Array/from')
- , match = require('es5-ext/lib/Function/prototype/match')
, isCallable = require('es5-ext/lib/Object/is-callable')
, deferred = require('../../deferred')
, isPromise = require('../../is-promise')
, promise = require('../../promise')
, processArguments = require('../_process-arguments')
- , applyFn
+ , applyFn;
applyFn = function (fn, args, resolve) {
- var result
+ var result;
if (fn.returnsPromise) {
try {
result = apply.call(fn, this, args);
@@ -40,12 +39,12 @@ applyFn = function (fn, args, resolve) {
});
try {
apply.call(fn, this, args);
- } catch (e) {
- resolve(e);
+ } catch (e2) {
+ resolve(e2);
}
};
-deferred.extend('invokeAsync', function (name) {
+deferred.extend('invokeAsync', function (method/*, …args*/) {
var def;
if (!this.pending) {
this.pending = [];
@@ -87,7 +86,7 @@ deferred.extend('invokeAsync', function (name) {
} else {
applyFn.call(this.value, fn, args, resolve);
}
-}, function (fn) {
+}, function (method/*, …args*/) {
var args, def;
if (this.failed) {
return this;
@@ -97,12 +96,12 @@ deferred.extend('invokeAsync', function (name) {
return promise(new TypeError("Cannot use null or undefined"));
}
- if (!isCallable(fn)) {
- fn = String(fn);
- if (!isCallable(this.value[fn])) {
- return promise(new TypeError(fn + " is not a function"));
+ if (!isCallable(method)) {
+ method = String(method);
+ if (!isCallable(this.value[method])) {
+ return promise(new TypeError(method + " is not a function"));
}
- fn = this.value[fn];
+ method = this.value[method];
}
args = processArguments(slice.call(arguments, 1));
@@ -112,13 +111,13 @@ deferred.extend('invokeAsync', function (name) {
}
def = deferred();
args.end(function (args) {
- applyFn.call(this, fn, args, def.resolve);
+ applyFn.call(this, method, args, def.resolve);
}.bind(this.value), def.resolve);
- } else if (fn.returnsPromise) {
- return applyFn.call(this.value, fn, args, promise);
+ } else if (method.returnsPromise) {
+ return applyFn.call(this.value, method, args, promise);
} else {
def = deferred();
- applyFn.call(this.value, fn, args, def.resolve);
+ applyFn.call(this.value, method, args, def.resolve);
}
return def.promise;
});
View
28 lib/ext/promise/invoke.js
@@ -7,17 +7,15 @@
'use strict';
-var slice = Array.prototype.slice
- , apply = Function.prototype.apply
- , toArray = require('es5-ext/lib/Array/from')
- , match = require('es5-ext/lib/Function/prototype/match')
- , isCallable = require('es5-ext/lib/Object/is-callable')
+var isCallable = require('es5-ext/lib/Object/is-callable')
, deferred = require('../../deferred')
, isPromise = require('../../is-promise')
, promise = require('../../promise')
, processArguments = require('../_process-arguments')
- , applyFn
+ , slice = Array.prototype.slice, apply = Function.prototype.apply
+
+ , applyFn;
applyFn = function (fn, args) {
try {
@@ -27,7 +25,7 @@ applyFn = function (fn, args) {
}
};
-deferred.extend('invoke', function (name) {
+deferred.extend('invoke', function (method/*, …args*/) {
var def;
if (!this.pending) {
this.pending = [];
@@ -69,7 +67,7 @@ deferred.extend('invoke', function (name) {
} else {
resolve(applyFn.call(this.value, fn, args));
}
-}, function (fn) {
+}, function (method/*, …args*/) {
var args, def;
if (this.failed) {
return this;
@@ -79,12 +77,12 @@ deferred.extend('invoke', function (name) {
return promise(new TypeError("Cannot use null or undefined"));
}
- if (!isCallable(fn)) {
- fn = String(fn);
- if (!isCallable(this.value[fn])) {
- return promise(new TypeError(fn + " is not a function"));
+ if (!isCallable(method)) {
+ method = String(method);
+ if (!isCallable(this.value[method])) {
+ return promise(new TypeError(method + " is not a function"));
}
- fn = this.value[fn];
+ method = this.value[method];
}
args = processArguments(slice.call(arguments, 1));
@@ -94,10 +92,10 @@ deferred.extend('invoke', function (name) {
}
def = deferred();
args.end(function (args) {
- def.resolve(applyFn.call(this, fn, args));
+ def.resolve(applyFn.call(this, method, args));
}.bind(this.value), def.resolve);
return def.promise;
} else {
- return promise(applyFn.call(this.value, fn, args));
+ return promise(applyFn.call(this.value, method, args));
}
});
View
6 lib/ext/promise/match.js
@@ -7,14 +7,12 @@
'use strict';
-var defineProperty = Object.defineProperty
- , match = require('es5-ext/lib/Function/prototype/match')
- , d = require('es5-ext/lib/Object/descriptor')
+var match = require('es5-ext/lib/Function/prototype/match')
, callable = require('es5-ext/lib/Object/valid-callable')
, isCallable = require('es5-ext/lib/Object/is-callable')
, isPromise = require('../../is-promise')
, deferred = require('../../deferred')
- , promise = require('../../promise')
+ , promise = require('../../promise');
deferred.extend('match', function (win, fail) {
var def;
View
3  lib/monitor.js
@@ -1,11 +1,12 @@
// Run if you want to monitor unresolved promises (in properly working
// application there should be no promises that are never resolved)
+'use strict';
+
var max = Math.max
, callable = require('es5-ext/lib/Object/valid-callable')
, isCallable = require('es5-ext/lib/Object/is-callable')
, toUint = require('es5-ext/lib/Number/to-uint')
- , deferred = require('./deferred')
, promise = require('./promise');
exports = module.exports = function (timeout, cb) {
View
25 lib/profiler.js
@@ -7,7 +7,10 @@ var partial = require('es5-ext/lib/Function/prototype/partial')
, resolved, rStats, unresolved, uStats, profile;
exports.profile = function () {
- resolved = 0, rStats = {}, unresolved = 0, uStats = {};
+ resolved = 0;
+ rStats = {};
+ unresolved = 0;
+ uStats = {};
promise._profile = profile;
};
@@ -24,17 +27,17 @@ profile = function (isResolved) {
stack = (new Error()).stack;
if (!stack.split('\n').slice(3).some(function (line) {
- if ((line.indexOf('/deferred/') === -1) &&
- (line.indexOf('/es5-ext/') === -1) &&
- (line.indexOf(' (native)') === -1)) {
- line = line.replace(/\n/g, "\\n").trim();
- if (!data[line]) {
- data[line] = { count: 0 };
+ if ((line.indexOf('/deferred/') === -1) &&
+ (line.indexOf('/es5-ext/') === -1) &&
+ (line.indexOf(' (native)') === -1)) {
+ line = line.replace(/\n/g, "\\n").trim();
+ if (!data[line]) {
+ data[line] = { count: 0 };
+ }
+ ++data[line].count;
+ return true;
}
- ++data[line].count;
- return true;
- }
- })) {
+ })) {
if (!data.unknown) {
data.unknown = { count: 0, stack: stack };
}
View
3  lib/promise.js
@@ -99,7 +99,6 @@ resolved = ee(create(Function.prototype, {
}
}),
end: d(function (win, fail) {
- var cb;
(win == null) || callable(win);
(fail == null) || callable(fail);
if (this.failed) {
@@ -115,7 +114,7 @@ resolved = ee(create(Function.prototype, {
resolved: d(true),
returnsPromise: d(true),
valueOf: d(function () {
- return this.value
+ return this.value;
})
}));
View
9 test/deferred.js
@@ -1,7 +1,6 @@
'use strict';
-var noop = require('es5-ext/lib/Function/noop')
- , isPromise = require('../lib/is-promise')
+var isPromise = require('../lib/is-promise')
, x = {};
@@ -22,7 +21,7 @@ module.exports = {
d();
});
},
- "More than one argument": function (t, a) {
+ "More than one argument": function (t) {
var x = {}, y = {};
return {
"Success": function (a, d) {
@@ -109,10 +108,10 @@ module.exports = {
},
"Call all then callbacks in order": function (t, a, d) {
var def = t(), promise = def.promise, x = {}, count = 0;
- promise(function (result) {
+ promise(function () {
++count;
}, a.never).end();
- promise(function (result) {
+ promise(function () {
a(count, 1);
}, a.never).end(d, d);
def.resolve(x);
View
7 test/ext/_process-arguments.js
@@ -1,12 +1,11 @@
'use strict';
-var toArray = require('es5-ext/lib/Array/from')
- , isPromise = require('../../lib/is-promise')
+var isPromise = require('../../lib/is-promise')
, promise = require('../../lib/promise')
- , deferred = require('../../lib/deferred')
+ , deferred = require('../../lib/deferred');
module.exports = function (t) {
- var u = {}, x = {}, y = {}, z = {}, fn1 = function () {}, e = new Error();
+ var x = {}, y = {}, e = new Error();
return {
"Limit": function (a) {
a.deep(t([x, 34, 'raz'], 2), [x, 34]);
View
9 test/ext/array/map.js
@@ -1,12 +1,10 @@
'use strict';
-var call = Function.prototype.call
- , deferred = require('../../../lib/deferred')
+var deferred = require('../../../lib/deferred')
, promise = require('../../../lib/promise');
module.exports = function (t) {
- var x = {}, y = {}, z = {}, e = new Error("Error")
- , arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+ var x = {}, y = {}, z = {}, e = new Error("Error");
return {
"Empty": {
@@ -89,8 +87,7 @@ module.exports = function (t) {
}).end(d, d);
},
"Error via input": function (a, d) {
- var count = 0;
- t.call([x, y, promise(e), z], function (res) {
+ t.call([x, y, promise(e), z], function () {
return x;
})(a.never, function (res) {
a(res, e);
View
9 test/ext/array/reduce.js
@@ -1,7 +1,6 @@
'use strict';
-var deferred = require('../../../lib/deferred')
- , promise = require('../../../lib/promise');
+var promise = require('../../../lib/promise');
module.exports = function (t) {
var x = {}, y = {}, z = {}, e = new Error("Error"), e2 = new Error("Error2");
@@ -67,14 +66,14 @@ module.exports = function (t) {
}, a.never).end(d, d);
},
"Throw Error": function (a, d) {
- t.call([x], function (acc, arg) {
+ t.call([x], function () {
throw e;
}, null)(a.never, function (res) {
a(res, e);
}).end(d, d);
},
"Return Error": function (a, d) {
- t.call([promise(e)], function (acc, arg) {
+ t.call([promise(e)], function () {
return e;
}, null)(a.never, function (res) {
a(res, e);
@@ -239,7 +238,7 @@ module.exports = function (t) {
},
"Callback": {
"Error": function (a, d) {
- t.call([x, e, e2], function (acc, res) {
+ t.call([x, e, e2], function () {
return z;
})(function (res) {
a(res, z);
View
2  test/ext/array/some.js
@@ -20,7 +20,7 @@ module.exports = function (t, a) {
return true;
}, x).valueOf(), true, "One, falsy, cb truthy");
a(z, 1, "Callback called");
- a(t.call([1], function () { return false;}).valueOf(), false,
+ a(t.call([1], function () { return false; }).valueOf(), false,
"One, truthy, cb falsy");
a(t.call([1, 0], function (x) { ++z; return !x; }).valueOf(), true,
"Two, cb, Second truthy");
View
8 test/ext/function/gate.js
@@ -3,11 +3,13 @@
var toArray = require('es5-ext/lib/Array/from')
, deferred = require('../../../lib/deferred');
-module.exports = function (t, a) {
+module.exports = function (t) {
var fn, gfn, x = {}, y = {}, z = {}, args, dx, dy, dz, hz, resolved, released;
- fn = function (p) { // console.log("ARGS", arguments);
- args = toArray(arguments); return p; };
+ fn = function (p) {
+ args = toArray(arguments);
+ return p;
+ };
return {
"Limit": function (a) {
gfn = t.call(fn, 2);
View
4 test/ext/function/promisify-sync.js
@@ -7,7 +7,7 @@ module.exports = function (t) {
return {
"Promise arguments": function (a) {
- t.call(function (arg1, arg2, callback) {
+ t.call(function (arg1, arg2) {
a(this, u, "Context");
a.deep([arg1, arg2], [x, y], "Arguments");
return z;
@@ -16,7 +16,7 @@ module.exports = function (t) {
});
},
"Normal arguments": function (a) {
- t.call(function (arg1, arg2, callback) {
+ t.call(function (arg1, arg2) {
a(this, u, "Context");
a.deep([arg1, arg2], [x, undefined], "Arguments");
return z;
View
7 test/ext/function/promisify.js
@@ -28,8 +28,9 @@ module.exports = function (t) {
}, a.never).end(d, d);
},
"Do not promisify promisified function": function (a) {
- var fn = t.call(function () { });
- var fn1 = t.call(fn);
+ var fn, fn1;
+ fn = t.call(function () { });
+ fn1 = t.call(fn);
a(fn, fn1);
},
"Successful": function (a, d) {
@@ -66,7 +67,7 @@ module.exports = function (t) {
},
"Function crash": function (a) {
var x = new Error('Test'), fn;
- fn = t.call(function (callback) {
+ fn = t.call(function () {
throw x;
});
a.throws(function () {
View
2  test/ext/promise/_array.js
@@ -30,5 +30,5 @@ module.exports = function (t) {
a(isError(err), true, "Error");
}).end();
}
- }
+ };
};
View
7 test/ext/promise/cb.js
@@ -2,7 +2,7 @@
var deferred = require('../../../lib/deferred');
-module.exports = function (t) {
+module.exports = function () {
return {
"Unresolved": function (a, d) {
var x = {}, def = deferred(), p = def.promise, invoked = false;
@@ -23,7 +23,8 @@ module.exports = function (t) {
invoked = true;
d();
});
- a(invoked, false, "Callback not invoked immediatelly on resolved promise");
+ a(invoked, false,
+ "Callback not invoked immediatelly on resolved promise");
},
"Errorneus": function (a, d) {
var x = new Error("Error")
@@ -38,5 +39,5 @@ module.exports = function (t) {
});
a(invoked, false, "Called not invoked immediately");
}
- }
+ };
};
View
2  test/ext/promise/get.js
@@ -30,7 +30,7 @@ module.exports = {
x.promise.get('foo').end(function () {
throw new Error('Error');
});
- x.resolve({ foo: 'bar'});
+ x.resolve({ foo: 'bar' });
});
}
};
View
11 test/ext/promise/invoke-async.js
@@ -1,11 +1,11 @@
'use strict';
-var deferred = require('../../../lib/deferred')
+var deferred = require('../../../lib/deferred');
module.exports = function () {
return {
"Function": function (a, d) {
- var x = {}, fn, z = {};
+ var x = {}, z = {};
z.foo = function (y, cb) {
var self = this;
setTimeout(function () {
@@ -57,8 +57,9 @@ module.exports = function () {
}, a.never).end();
},
"Erroneous": function (a, d) {
- var x = new Error('Test');
- var fn = function (callback) {
+ var x, fn;
+ x = new Error('Test');
+ fn = function (callback) {
setTimeout(function () {
callback(x);
}, 0);
@@ -69,7 +70,7 @@ module.exports = function () {
},
"Function crash": function (a) {
var x = new Error('Test'), fn;
- fn = function (callback) {
+ fn = function () {
throw x;
};
deferred({}).invokeAsync(fn)(a.never, function (e) {
View
13 test/ext/promise/invoke.js
@@ -15,12 +15,12 @@ module.exports = function (t, a, d) {
}).end(d, d);
};
-var deferred = require('../../../lib/deferred')
+var deferred = require('../../../lib/deferred');
module.exports = function () {
return {
"Function": function (a, d) {
- var x = {}, fn, z = {};
+ var x = {}, z = {};
z.foo = function (y, cb) {
var self = this;
setTimeout(function () {
@@ -68,7 +68,7 @@ module.exports = function () {
}).end();
},
"Promise arguments": function (a) {
- var y = {}, z = {}, x = { foo: function (w, u, cb) {
+ var y = {}, z = {}, x = { foo: function (w, u) {
a(this, x, "Context");
a.deep([w, u], [y, z], "Arguments");
return 'foo';
@@ -78,8 +78,9 @@ module.exports = function () {
}, a.never).end();
},
"Erroneous": function (a) {
- var x = new Error('Test');
- var fn = function (callback) {
+ var x, fn;
+ x = new Error('Test');
+ fn = function () {
return x;
};
deferred({}).invoke(fn)(a.never, function (e) {
@@ -88,7 +89,7 @@ module.exports = function () {
},
"Function crash": function (a) {
var x = new Error('Test'), fn;
- fn = function (callback) {
+ fn = function () {
throw x;
};
deferred({}).invoke(fn)(a.never, function (e) {
View
14 test/index.js
@@ -1,11 +1,9 @@
'use strict';
-var path = require('path')
- , readdir = require('fs').readdir
- , isFunction = require('es5-ext/lib/Function/is-function')
- , not = require('es5-ext/lib/Function/prototype/not')
- , contains = require('es5-ext/lib/Array/prototype/contains')
+var isFunction = require('es5-ext/lib/Function/is-function')
, convert = require('es5-ext/lib/String/prototype/hyphen-to-camel')
+ , path = require('path')
+ , readdir = require('fs').readdir
, indexTest = require('tad/lib/utils/index-test')
, dir = path.dirname(__dirname) + '/lib';
@@ -35,11 +33,11 @@ module.exports = {
var fn, dx, dy, ready;
fn = t.gate(function (p) {
return p;
- }, 1)
+ }, 1);
dx = t();
fn(dx.promise);
dy = t();
- fn(dy.promise).end(function (r) {
+ fn(dy.promise).end(function () {
a(ready, true);
});
dy.resolve({});
@@ -70,7 +68,6 @@ module.exports = {
}).end(d, d);
},
"Map": function (t, a, d) {
- var x = {};
t.map([t(1), t(2), 3], function (res) {
return t(res * res);
})(function (r) {
@@ -78,7 +75,6 @@ module.exports = {
}, a.never).end(d, d);
},
"Reduce": function (t, a, d) {
- var x = {};
t.reduce([t(1), t(2), 3], function (arg1, arg2) {
return t(arg1 * arg2);
}, 1)(function (r) {
View
2  test/monitor.js
@@ -5,7 +5,7 @@ var deferred = require('../lib/deferred');
module.exports = function (t, a, d) {
var invoked, df, cachet, cachec;
cachet = t.timeout;
- cachec = t.callback
+ cachec = t.callback;
t(100, function (stack) {
a.ok(stack instanceof Error);
invoked = true;
View
2  test/profiler.js
@@ -8,7 +8,7 @@ module.exports = function (t, a) {
deferred(1);
t.profile();
- deferred(2)
+ deferred(2);
deferred({});
deferred('raz');
d1 = deferred();
View
11 test/promise.js
@@ -1,14 +1,13 @@
'use strict';
-var noop = require('es5-ext/lib/Function/noop')
- , deferred = require('../lib/deferred')
+var deferred = require('../lib/deferred')
, x = {}, y = {}, e = new Error("Error");
module.exports = {
"Then callback run in current tick": function (t, a) {
var next = false;
- t(null)(function (result) {
+ t(null)(function () {
a(next, false);
}, a.never).end();
next = true;
@@ -62,12 +61,14 @@ module.exports = {
}).end(d, d);
},
"Chain promise & resolve with function": function (t, a) {
- var d1 = deferred(), fn = function () { return 'bar' };
+ var d1, fn, p1;
+ d1 = deferred();
+ fn = function () { return 'bar'; };
d1.promise(t('foo')).end(function (res) {
a(res, 'foo', "Unresolved");
});
d1.resolve(fn);
- var p1 = t(2);
+ p1 = t(2);
a(t(1)(p1), p1, "Resolved");
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.