-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use eslint-config-metarhia and fix linting issues #379
Conversation
@@ -152,7 +151,7 @@ Composition.prototype.sequential = function() { | |||
Composition.prototype.then = function(fulfill, reject) { | |||
if (this.canceled) { | |||
reject(new Error(COMPOSE_CANCELED)); | |||
return; | |||
return this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tshemsedinov could you clarify if this should return this
(to allow further chaining) or null
that will result in 'null is not a function' if anyone tries to chain them further?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this
is of for now, but we will use composition as thenable and with async/await so in future we will implement returning new composition from Composition.prototype.then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need tests/examples and more research
lib/collector.functor.js
Outdated
@@ -26,12 +25,12 @@ const collect = ( | |||
const collector = (key, err, value) => { | |||
if (isDone) return collector; | |||
if (!isDistinct || !(key in data)) { | |||
if (!isCount && !keys.has(key)) return; | |||
if (!isCount && !keys.has(key)) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return collector;
lib/collector.functor.js
Outdated
count++; | ||
} | ||
if (err) { | ||
collector.finalize(err, data); | ||
return; | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return collector;
lib/chain.js
Outdated
@@ -11,6 +11,7 @@ const async = op => { | |||
case 'series': return series; | |||
case 'find': return find; | |||
} | |||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (items, fn, callback) => {
callback(null, items.map(id));
};
where
const id = x => x;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simple
items.map(id)
-> items.slice()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, .slice(0)
will be better
@@ -23,7 +24,7 @@ ArrayChain.prototype.execute = function(err) { | |||
|
|||
if (!item.op) { | |||
if (err) throw err; | |||
else return; | |||
else return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -37,7 +38,7 @@ ArrayChain.prototype.execute = function(err) { | |||
|
|||
if (err) { | |||
this.execute(err); | |||
return; | |||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
lib/poolify.opt.js
Outdated
if (Array.isArray(par)) { | ||
while (par.length) { | ||
const item = par.shift(); | ||
const request = delayed.shift(); | ||
if (request) request(item); | ||
else items.push(item); | ||
} | ||
return; | ||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return pool;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tshemsedinov there is no pool
available in this scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to put par => {
to identifier pool
and return it
lib/poolify.opt.js
Outdated
@@ -33,6 +33,7 @@ const poolify = (factory, min, norm, max) => { | |||
const callback = provide(par); | |||
if (res) callback(res); | |||
else delayed.push(callback); | |||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return pool;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tshemsedinov there is no pool
available in this scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
lib/poolify.symbol.js
Outdated
if (par && par[poolified]) { | ||
const delayed = pool.delayed.shift(); | ||
if (delayed) delayed(par); | ||
else pool.items.push(par); | ||
return; | ||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return pool;
lib/poolify.symbol.js
Outdated
@@ -34,10 +34,11 @@ const poolify = (factory, min, norm, max) => { | |||
const callback = provide(par); | |||
if (res) callback(res); | |||
else pool.delayed.push(callback); | |||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return pool;
@@ -136,6 +136,7 @@ Queue.prototype.takeNext = function( | |||
} | |||
const task = tasks.shift(); | |||
if (task) this.next(task); | |||
return this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
978b946
to
b98bfa1
Compare
b98bfa1
to
a5941eb
Compare
Refs: metarhia/Metarhia#22