@@ -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 ( / I d $ / . test ( key ) ) {
48+ _ ( db ) . each ( function ( coll , collName ) {
49+ _ ( coll ) . each ( function ( doc ) {
50+ _ ( doc ) . each ( function ( value , key ) {
51+ if ( / I d $ / . 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