Skip to content

Commit

Permalink
-- lint
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Sep 14, 2012
1 parent cdbef26 commit bfaef4b
Show file tree
Hide file tree
Showing 33 changed files with 238 additions and 152 deletions.
104 changes: 99 additions & 5 deletions .lint
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,102 @@
@root @root

indent 2 indent 2
maxlen 80 maxlen 80
bitwise es5
nomen
plusplus jslint_medikoo.tabs
tabs jslint_medikoo.module
predef clearTimeout, setTimeout 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
11 changes: 5 additions & 6 deletions lib/deferred.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


var every = Array.prototype.every var every = Array.prototype.every
, push = Array.prototype.push , push = Array.prototype.push
, getOwnPropertyNames = Object.getOwnPropertyNames
, isError = require('es5-ext/lib/Error/is-error') , isError = require('es5-ext/lib/Error/is-error')
, isPromise = require('./is-promise') , isPromise = require('./is-promise')


Expand All @@ -27,7 +26,7 @@ Deferred = function () {
Deferred.prototype = { Deferred.prototype = {
resolved: false, resolved: false,
resolve: function (value) { resolve: function (value) {
var i, name, args, data; var i, name, data;
if (this.resolved) { if (this.resolved) {
return this.promise; return this.promise;
} }
Expand Down Expand Up @@ -92,8 +91,8 @@ Deferred.prototype = {
delete this.promise.dependencies; delete this.promise.dependencies;
} }
if ((data = this.promise.pending)) { if ((data = this.promise.pending)) {
for (i = 0; name = data[i], args = data[++i]; ++i) { for (i = 0; (name = data[i]); ++i) {
promise.onresolve[name].apply(this.promise, args); promise.onresolve[name].apply(this.promise, data[++i]);
} }
delete this.promise.pending; delete this.promise.pending;
} }
Expand All @@ -102,12 +101,12 @@ Deferred.prototype = {
}; };


module.exports = createDeferred = function (value) { 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 = arguments.length)) {
if (l > 1) { if (l > 1) {
d = new Deferred(); d = new Deferred();
waiting = 0; waiting = 0;
result = new Array(arguments.length); result = new Array(l);
every.call(arguments, function (value, index) { every.call(arguments, function (value, index) {
if (isPromise(value)) { if (isPromise(value)) {
++waiting; ++waiting;
Expand Down
14 changes: 6 additions & 8 deletions lib/ext/_process-arguments.js
Original file line number Original file line Diff line number Diff line change
@@ -1,19 +1,17 @@
'use strict'; 'use strict';


var isArray = Array.isArray var arrayOf = require('es5-ext/lib/Array/of')
, push = Array.prototype.push
, slice = Array.prototype.slice
, some = Array.prototype.some
, arrayOf = require('es5-ext/lib/Array/of')
, deferred = require('../deferred') , deferred = require('../deferred')
, isPromise = require('../is-promise'); , isPromise = require('../is-promise')

, push = Array.prototype.push, slice = Array.prototype.slice;


module.exports = function (args, length) { module.exports = function (args, length) {
var i, l, promised; var i, l;
if ((length != null) && (args.length !== length)) { if ((length != null) && (args.length !== length)) {
args = slice.call(args, 0, length); args = slice.call(args, 0, length);
if (args.length < 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) { for (i = 0, l = args.length; i < l; ++i) {
Expand Down
8 changes: 4 additions & 4 deletions lib/ext/array/map.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ var isError = require('es5-ext/lib/Error/is-error')
, every = Array.prototype.every , every = Array.prototype.every
, call = Function.prototype.call; , call = Function.prototype.call;


var Map = function (list, cb, context) { var DMap = function (list, cb, context) {
this.list = list; this.list = list;
this.cb = cb; this.cb = cb;
this.context = context; this.context = context;
this.result = new Array(list.length >>> 0) this.result = new Array(list.length >>> 0);


extend(this, deferred()); extend(this, deferred());
every.call(list, this.process, this); every.call(list, this.process, this);
Expand All @@ -28,7 +28,7 @@ var Map = function (list, cb, context) {
return this.promise; return this.promise;
}; };


Map.prototype = { DMap.prototype = {
waiting: 0, waiting: 0,
initialized: false, initialized: false,
process: function (value, index) { process: function (value, index) {
Expand Down Expand Up @@ -90,5 +90,5 @@ module.exports = function (cb/*, thisArg*/) {
value(this); value(this);
(cb == null) || callable(cb); (cb == null) || callable(cb);


return new Map(this, cb, arguments[1]); return new DMap(this, cb, arguments[1]);
}; };
14 changes: 8 additions & 6 deletions lib/ext/function/gate.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// controlled with qLimit value, any calls that would reach over that limit // controlled with qLimit value, any calls that would reach over that limit
// would be discarded (its promise would resolve with "Too many calls" error) // would be discarded (its promise would resolve with "Too many calls" error)


'use strict';

var apply = Function.prototype.apply var apply = Function.prototype.apply
, max = Math.max , max = Math.max
, toUint = require('es5-ext/lib/Number/to-uint') , toUint = require('es5-ext/lib/Number/to-uint')
Expand All @@ -29,10 +31,10 @@ module.exports = function (cLimit, qLimit) {
count = 0; count = 0;
queue = []; queue = [];


run = function (thisArg, arguments, resolve) { run = function (thisArg, args, resolve) {
var r; var r;
try { try {
r = apply.call(fn, thisArg, arguments); r = apply.call(fn, thisArg, args);
} catch (e) { } catch (e) {
r = e; r = e;
} }
Expand Down Expand Up @@ -68,12 +70,12 @@ module.exports = function (cLimit, qLimit) {
}; };


result = function () { result = function () {
var r, d; var def;
if (count >= cLimit) { if (count >= cLimit) {
if (queue.length < qLimit) { if (queue.length < qLimit) {
d = deferred(); def = deferred();
queue.push([this, arguments, d.resolve]); queue.push([this, arguments, def.resolve]);
return d.promise; return def.promise;
} else { } else {
return reject(); return reject();
} }
Expand Down
10 changes: 5 additions & 5 deletions lib/ext/function/promisify-sync.js
Original file line number Original file line Diff line number Diff line change
@@ -1,14 +1,14 @@
// Promisify synchronous function // Promisify synchronous function


var isArray = Array.isArray 'use strict';
, slice = Array.prototype.slice
, apply = Function.prototype.apply var callable = require('es5-ext/lib/Object/valid-callable')
, toArray = require('es5-ext/lib/Array/from')
, callable = require('es5-ext/lib/Object/valid-callable')
, deferred = require('../../deferred') , deferred = require('../../deferred')
, isPromise = require('../../is-promise') , isPromise = require('../../is-promise')
, processArguments = require('../_process-arguments') , processArguments = require('../_process-arguments')


, apply = Function.prototype.apply

, applyFn; , applyFn;


applyFn = function (fn, args, resolve) { applyFn = function (fn, args, resolve) {
Expand Down
3 changes: 1 addition & 2 deletions lib/ext/promise/_array.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


var callable = require('es5-ext/lib/Object/valid-callable') var callable = require('es5-ext/lib/Object/valid-callable')
, deferred = require('../../deferred') , deferred = require('../../deferred')
, promise = require('../../promise') , promise = require('../../promise');


module.exports = function (name, ext) { module.exports = function (name, ext) {
deferred.extend(name, function (cb) { deferred.extend(name, function (cb) {
Expand All @@ -29,7 +29,6 @@ module.exports = function (name, ext) {
resolve(result); resolve(result);
} }
}, function (cb) { }, function (cb) {
var result;
(cb == null) || callable(cb); (cb == null) || callable(cb);
if (this.failed) { if (this.failed) {
return this; return this;
Expand Down
2 changes: 1 addition & 1 deletion lib/ext/promise/aside.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'use strict'; 'use strict';


var callable = require('es5-ext/lib/Object/valid-callable') var callable = require('es5-ext/lib/Object/valid-callable')
, deferred = require('../../deferred') , deferred = require('../../deferred');


deferred.extend('aside', function (win, fail) { deferred.extend('aside', function (win, fail) {
(win == null) || callable(win); (win == null) || callable(win);
Expand Down
3 changes: 1 addition & 2 deletions lib/ext/promise/cb.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
'use strict'; 'use strict';


var callable = require('es5-ext/lib/Object/valid-callable') var callable = require('es5-ext/lib/Object/valid-callable')
, isCallable = require('es5-ext/lib/Object/is-callable')
, nextTick = require('next-tick') , nextTick = require('next-tick')
, deferred = require('../../deferred') , deferred = require('../../deferred');


deferred.extend('cb', function (cb) { deferred.extend('cb', function (cb) {
if (cb == null) { if (cb == null) {
Expand Down
6 changes: 3 additions & 3 deletions lib/ext/promise/get.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
var reduce = Array.prototype.reduce var reduce = Array.prototype.reduce
, value = require('es5-ext/lib/Object/valid-value') , value = require('es5-ext/lib/Object/valid-value')
, deferred = require('../../deferred') , deferred = require('../../deferred')
, promise = require('../../promise') , promise = require('../../promise');


deferred.extend('get', function (name) { deferred.extend('get', function (/*…name*/) {
var def; var def;
if (!this.pending) { if (!this.pending) {
this.pending = []; this.pending = [];
Expand All @@ -33,7 +33,7 @@ deferred.extend('get', function (name) {
result = e; result = e;
} }
return resolve(result); return resolve(result);
}, function (name) { }, function (/*…name*/) {
var result; var result;
if (this.failed) { if (this.failed) {
return this; return this;
Expand Down
Loading

0 comments on commit bfaef4b

Please sign in to comment.