Skip to content

Commit 55f3ed2

Browse files
Ryan CrosserRyan Crosser
authored andcommitted
fixed spacing
1 parent db7712a commit 55f3ed2

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = function (source) {
7878
array = db(req.params.resource).filter(function (obj) {
7979
for (var key in obj) {
8080
var value = obj[key]
81-
if(utils.deepQuery(value, q)){
81+
if (utils.deepQuery(value, q)) {
8282
return true
8383
}
8484
}

src/utils.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ var pluralize = require('pluralize')
66
// Example:
77
// 'true' -> true
88
// '1' -> 1
9-
function toNative(value) {
10-
if(typeof value === 'string') {
11-
if(value === ''
9+
function toNative (value) {
10+
if (typeof value === 'string') {
11+
if (value === ''
1212
|| value.trim() !== value
1313
|| (value.length > 1 && value[0] === '0')) {
1414
return value
15-
} else if(value === 'true' || value === 'false') {
15+
} else if (value === 'true' || value === 'false') {
1616
return value === 'true'
17-
} else if(!isNaN(+value)) {
17+
} else if (!isNaN(+value)) {
1818
return +value
1919
}
2020
}
2121
return value
2222
}
2323

2424
// Return incremented id or uuid
25-
function createId(coll) {
26-
if(_.isEmpty(coll)) {
25+
function createId (coll) {
26+
if (_.isEmpty(coll)) {
2727
return 1
2828
} else {
29-
var id = _.max(coll, function(doc) {
29+
var id = _.max(coll, function (doc) {
3030
return doc.id
3131
}).id
3232

33-
if(_.isFinite(id)) {
33+
if (_.isFinite(id)) {
3434
// Increment integer id
3535
return ++id
3636
} else {
@@ -42,19 +42,19 @@ function createId(coll) {
4242

4343
// Returns document ids that have unsatisfied relations
4444
// Example: a comment that references a post that doesn't exist
45-
function getRemovable(db) {
45+
function getRemovable (db) {
4646
var removable = []
4747

48-
_(db).each(function(coll, collName) {
49-
_(coll).each(function(doc) {
50-
_(doc).each(function(value, key) {
51-
if(/Id$/.test(key)) {
48+
_(db).each(function (coll, collName) {
49+
_(coll).each(function (doc) {
50+
_(doc).each(function (value, key) {
51+
if (/Id$/.test(key)) {
5252
var refName = pluralize.plural(key.slice(0, -2))
5353
// Test if table exists
54-
if(db[refName]) {
54+
if (db[refName]) {
5555
// Test if references is defined in table
5656
var ref = _.findWhere(db[refName], {id: value})
57-
if(_.isUndefined(ref)) {
57+
if (_.isUndefined(ref)) {
5858
removable.push({name: collName, id: doc.id})
5959
}
6060
}
@@ -66,22 +66,22 @@ function getRemovable(db) {
6666
return removable
6767
}
6868

69-
function deepQuery(value, q) {
70-
if(value) {
71-
if(_.isArray(value)) {
72-
for(var i = 0; i < value.length; i++) {
73-
if(deepQuery(value[i], q)) {
69+
function deepQuery (value, q) {
70+
if (value) {
71+
if (_.isArray(value)) {
72+
for (var i = 0; i < value.length; i++) {
73+
if (deepQuery(value[i], q)) {
7474
return true
7575
}
7676
}
77-
} else if(_.isPlainObject(value)) {
78-
for(var k in value) {
79-
if(deepQuery(value[k], q)) {
77+
} else if (_.isPlainObject(value)) {
78+
for (var k in value) {
79+
if (deepQuery(value[k], q)) {
8080
return true
8181
}
8282
}
83-
} else if(value.toString().toLowerCase().indexOf(q) !== -1) {
84-
return true;
83+
} else if (value.toString().toLowerCase().indexOf(q) !== -1) {
84+
return true
8585
}
8686
}
8787
}

0 commit comments

Comments
 (0)