Skip to content
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

Gh 194 #204

Merged
merged 3 commits into from
Nov 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 1 addition & 113 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -1,115 +1,3 @@
{

"disallowMultipleVarDecl": true,

"disallowEmptyBlocks": true,

"disallowSpacesInsideObjectBrackets": true,

"disallowSpacesInsideArrayBrackets": true,

"disallowQuotedKeysInObjects": "allButReserved",

"disallowSpaceAfterObjectKeys": true,

"disallowSpaceBeforeBinaryOperators": [","],

"disallowSpaceAfterPrefixUnaryOperators": true,

"disallowSpaceBeforePostfixUnaryOperators": true,

"disallowKeywords": ["with"],

"disallowMultipleLineStrings": true,

"disallowMultipleLineBreaks": true,

"disallowMixedSpacesAndTabs": true,

"disallowTrailingWhitespace": true,

"disallowKeywordsOnNewLine": ["else", "catch"],

"requireYodaConditions": true,

"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch",
"case",
"default"
],

"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],

"requireParenthesesAroundIIFE": true,

"requireSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},

"requireCommaBeforeLineBreak": true,

"requireOperatorBeforeLineBreak": [
"?",
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],

"requireSpaceBeforeBinaryOperators": [
"=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
"&=", "|=", "^=", "+=",

"+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
"|", "^", "&&", "||", "===", "==", ">=",
"<=", "<", ">", "!=", "!=="
],

"requireSpaceAfterBinaryOperators": true,

"validateQuoteMarks": "'",

"requireLineFeedAtFileEnd": true,

"maximumLineLength": 80,

"requireDotNotation": true,

"validateJSDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
},

"excludeFiles": [
"test/fixtures/**",
"coverage/**",
"node_modules/**"
]
"preset": "yandex"
}
44 changes: 22 additions & 22 deletions core/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {
* */
alias: function (base, path) {

if ( _.isObject(base) ) {
if (_.isObject(base)) {
_.forOwn(base, function (path, base) {
this.unit({
base: base,
Expand Down Expand Up @@ -124,7 +124,7 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {
unit: function (members, statics) {
members = Object(members);

if ( !_.has(members, 'path') ) {
if (!_.has(members, 'path')) {
members.path = 'unit-' + uniqueId();
}

Expand All @@ -151,7 +151,7 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {
ready: function () {
var sys = this.channel('sys');

if ( this.__ready ) {
if (this.__ready) {

return this.__ready;
}
Expand Down Expand Up @@ -197,7 +197,7 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {
then(function (units) {
var paths = Agent.__findDepsConflicts(units);

if ( _.size(paths) ) {
if (_.size(paths)) {

throw new DepsConflictError(paths);
}
Expand All @@ -219,7 +219,7 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {
return _.reduce(units, function (units, Unit) {
var path = Unit.prototype.path;

if ( R_PUBLIC_UNIT.test(path) ) {
if (R_PUBLIC_UNIT.test(path)) {
units[path] = this._instUnit(Unit);
}

Expand Down Expand Up @@ -262,16 +262,16 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {
var l;
var remaining = _.size(decls);

function findBase (decl) {
function findBase(decl) {
var base = decl.members.base;

if ( Agent.__isFalsy(base) ) {
if (Agent.__isFalsy(base)) {
base = Unit.prototype.path;
}

return _.find(classes, function (Class) {

if ( _.isFunction(Class) ) {
if (_.isFunction(Class)) {

return Class.prototype.path === base;
}
Expand All @@ -280,15 +280,15 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {
});
}

function getUnitMixes (decl) {
function getUnitMixes(decl) {
var mixes = decl.members.mix;

if ( Agent.__isFalsy(mixes) ) {
if (Agent.__isFalsy(mixes)) {

return [];
}

if ( _.isArray(mixes) ) {
if (_.isArray(mixes)) {

return mixes;
}
Expand All @@ -298,19 +298,19 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {

decls = _.clone(decls);

while ( remaining ) {
while (remaining) {

for ( i = 0, l = decls.length; i < l; i += 1 ) {
for (i = 0, l = decls.length; i < l; i += 1) {
decl = decls[i];

if ( !decl ) {
if (!decl) {

continue;
}

Base = findBase(decl);

if ( !_.isFunction(Base) ) {
if (!_.isFunction(Base)) {

continue;
}
Expand All @@ -323,7 +323,7 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {

count = Agent.__count(decls);

if ( count < remaining ) {
if (count < remaining) {
remaining = count;

continue;
Expand Down Expand Up @@ -373,21 +373,21 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {
var unit;
var paths = [];

if ( _.has(found, path) ) {
if (_.has(found, path)) {

return paths;
}

unit = units[path];

if ( _.isUndefined(unit) ) {
if (_.isUndefined(unit)) {

return paths;
}

deps = unit.deps;

if ( !_.size(deps) ) {
if (!_.size(deps)) {

return paths;
}
Expand All @@ -398,7 +398,7 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {

branch.push(path);

if ( _.contains(trunk, path) ) {
if (_.contains(trunk, path)) {
paths.push(branch);

return paths;
Expand Down Expand Up @@ -427,7 +427,7 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {

return _.reduce(items, function (count, v) {

if ( v ) {
if (v) {

return count + 1;
}
Expand All @@ -447,7 +447,7 @@ var Agent = inherit(Channel, /** @lends Agent.prototype */ {
* */
__isFalsy: function (v) {

return _.isUndefined(v) || _.isNull(v) || '' === v;
return _.isUndefined(v) || _.isNull(v) || v === '';
}

});
Expand Down
8 changes: 4 additions & 4 deletions core/cache/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ var Cache = inherit(LRUCache, /** @lends Cache.prototype */ {
* @param {Function} done
* */
set: function (k, v, cacheMaxAge, done) {
var lastUpdated = +new Date();
var lastUpdated = Date.now();
var base = this.__base;
var self = this;

cacheMaxAge = +cacheMaxAge;
cacheMaxAge *= 1;

if ( _.isNaN(cacheMaxAge) ) {
if (_.isNaN(cacheMaxAge)) {
cacheMaxAge = 0;

} else if (cacheMaxAge) {
Expand Down Expand Up @@ -92,7 +92,7 @@ var Cache = inherit(LRUCache, /** @lends Cache.prototype */ {
var base = this.__base;
var self = this;

if ( this.has(k) && this.__checker[k]() ) {
if (this.has(k) && this.__checker[k]()) {

delete this.__checker[k];
this.del(k);
Expand Down
2 changes: 1 addition & 1 deletion core/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var Channel = inherit(EventEmitter, /** @lends Channel.prototype */ {
* */
channel: function (name) {

if ( !_.has(this.__channels, name) ) {
if (!_.has(this.__channels, name)) {
this.__channels[name] = new Channel();
}

Expand Down
18 changes: 10 additions & 8 deletions core/deps/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var Deps = inherit(/** @lends Deps.prototype */ {
arg: function (path, defaultValue) {
var result = ns.use(this.args(), path);

if ( this._isFalsy(result) ) {
if (this._isFalsy(result)) {
result = defaultValue;
}

Expand All @@ -118,7 +118,7 @@ var Deps = inherit(/** @lends Deps.prototype */ {
* */
args: function () {

if ( !this.__args ) {
if (!this.__args) {
this.__args = this._dumpArgs();
}

Expand Down Expand Up @@ -196,19 +196,21 @@ var Deps = inherit(/** @lends Deps.prototype */ {

this.trigger('pending');

/** @this {Deps} */
defer.promise().then(function (data) {
this.trigger('accept', data);
}, function (data) {
this.trigger('reject', data);
}, this);

if ( _.isUndefined(unit) ) {
if (_.isUndefined(unit)) {
// TODO 500!
defer.reject();

return defer.promise();
}

if ( 0 === _.size(unit.deps) ) {
if (!_.size(unit.deps)) {
defer.resolve(unit.getValue(this));

return defer.promise();
Expand All @@ -220,7 +222,7 @@ var Deps = inherit(/** @lends Deps.prototype */ {
return promise.valueOf() instanceof Control;
});

if ( _.isUndefined(promise) ) {
if (_.isUndefined(promise)) {

return unit.getValue(this);
}
Expand Down Expand Up @@ -313,7 +315,7 @@ var Deps = inherit(/** @lends Deps.prototype */ {
* */
_isFalsy: function (v) {

return _.isUndefined(v) || _.isNull(v) || '' === v;
return _.isUndefined(v) || _.isNull(v) || v === '';
},

/**
Expand All @@ -329,14 +331,14 @@ var Deps = inherit(/** @lends Deps.prototype */ {
__get: function (root, args) {
var result;

if ( 0 === args.length ) {
if (!args.length) {

return root;
}

result = ns.use(root, args[0]);

if ( this._isFalsy(result) ) {
if (this._isFalsy(result)) {
result = args[1];
}

Expand Down
Loading