Skip to content

Commit

Permalink
A number of code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Jun 11, 2015
1 parent aed3171 commit c9bc082
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 34 deletions.
1 change: 0 additions & 1 deletion build/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var gulp = require('gulp'),
mocha = require('gulp-mocha'),
plumber = require('gulp-plumber'),
path = require('path');

var paths = require('./paths');
Expand Down
4 changes: 1 addition & 3 deletions build/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ var gulp = require('gulp'),
semver = require('semver'),
runSequence = require('run-sequence'),
fs = require('fs');

var paths = require('./paths');

function getPackageJsonVersion() {
//We parse the json file instead of using require because require caches multiple calls so the version number won't be updated
return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
};
}

gulp.task('version-bump', function () {
var args = minimist(process.argv);
Expand Down
4 changes: 2 additions & 2 deletions dist/lib/Core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/lib/Core.js.map

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions dist/lib/Instance.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/lib/Instance.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/lib/ModelCache.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/lib/ModelCache.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/Core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {Cache} from './Cache';
import NoOpCache from './caches/NoOpCache';
import MemoryCache from './caches/MemoryCache';

var MongoConnectAsyc = Bluebird.promisify(MongoDB.MongoClient.connect);
var mongoConnectAsyc = Bluebird.promisify(MongoDB.MongoClient.connect);

export default class Core {
/**
Expand Down Expand Up @@ -159,7 +159,7 @@ export default class Core {
var self = this;
return Bluebird.bind(this).then(function() {
if (self._connection) return self._connection;
return MongoConnectAsyc(self.url);
return mongoConnectAsyc(self.url);
}).then(function(db: MongoDB.Db) {
self._connection = db;
return self;
Expand Down
28 changes: 15 additions & 13 deletions lib/Instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,22 @@ export default class Instance<TDocument extends { _id?: any }, TInstance> {
}).then((changes) => {
if (!changes && !this._isNew) return false;

if (this._isNew) return new Bluebird<boolean>((resolve, reject) => {
this._model.collection.insertOne(this._modified, { w: 'majority' },(err, doc) => {
if (err) return reject(err);
return resolve(<any>!!doc);
if (this._isNew) {
return new Bluebird<boolean>((resolve, reject) => {
this._model.collection.insertOne(this._modified, { w: 'majority' }, (err, doc) => {
if (err) return reject(err);
return resolve(<any>!!doc);
});
});
});

return new Bluebird<boolean>((resolve: (changed: boolean) => void, reject) => {
this._model.collection.updateOne(conditions, changes, { w: 'majority' },(err: Error, changed: boolean) => {
if (err) return reject(err);
return resolve(changed);
} else {
return new Bluebird<boolean>((resolve: (changed: boolean) => void, reject) => {
this._model.collection.updateOne(conditions, changes, { w: 'majority' }, (err: Error, changed: boolean) => {
if (err) return reject(err);
return resolve(changed);
});
});
});
}).then((changed: boolean) => {
}
}).then((changed: boolean) => {
conditions = { _id: this._modified._id };
if (!changed) {
return _.cloneDeep(this._modified);
Expand Down Expand Up @@ -227,7 +229,7 @@ export default class Instance<TDocument extends { _id?: any }, TInstance> {
}).then((removed) => {
if (removed) return this._model.cache.clear(conditions);
return false;
}).then((removed) => {
}).then(() => {
this._isNew = true;
return <TInstance><any>this;
}).nodeify(callback);
Expand Down
2 changes: 1 addition & 1 deletion lib/ModelCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class ModelCache {
}

set<T>(value: T): void {
if (!this.model.cacheDirector || !this.model.cacheDirector.valid(value)) return;;
if (!this.model.cacheDirector || !this.model.cacheDirector.valid(value)) return;
this.model.core.cache.set(this.model.cacheDirector.buildKey(value), value);
}

Expand Down

0 comments on commit c9bc082

Please sign in to comment.