File tree Expand file tree Collapse file tree 6 files changed +142
-0
lines changed Expand file tree Collapse file tree 6 files changed +142
-0
lines changed Original file line number Diff line number Diff line change 1+ # Compiled source #
2+ # ##################
3+ * .com
4+ * .class
5+ * .dll
6+ * .exe
7+ * .o
8+ * .so
9+
10+ # Packages #
11+ # ###########
12+ # it's better to unpack these files and commit the raw source
13+ # git has its own built in compression methods
14+ * .7z
15+ * .dmg
16+ * .gz
17+ * .iso
18+ * .jar
19+ * .rar
20+ * .tar
21+ * .zip
22+
23+ # Logs and databases #
24+ # #####################
25+ * .log
26+ * .sql
27+ * .sqlite
28+
29+ # OS generated files #
30+ # #####################
31+ .DS_Store *
32+ ehthumbs.db
33+ Icon ?
34+ Thumbs.db
35+
36+ # Node.js #
37+ # ##########
38+ lib-cov
39+ * .seed
40+ * .log
41+ * .csv
42+ * .dat
43+ * .out
44+ * .pid
45+ * .gz
46+
47+ pids
48+ logs
49+ results
50+
51+ node_modules
52+ npm-debug.log
53+
54+ # Components #
55+ # #############
56+
57+ /build
58+ /components
59+ /vendors
Original file line number Diff line number Diff line change 1+ test.js
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " mongodb-ok-for-storage" ,
3+ "description" : " Helper for storing objects in MongoDB" ,
4+ "version" : " 0.0.1" ,
5+ "main" : " index.js" ,
6+ "scripts" : [
7+ " index.js"
8+ ]
9+ }
Original file line number Diff line number Diff line change 1+ exports . is = function isOk ( obj ) {
2+ return ! Object . keys ( obj ) . some ( function ( key ) {
3+ var value = obj [ key ]
4+
5+ if ( key [ 0 ] === '$' || key . match ( / \. / ) ) return true ;
6+ if ( Object ( value ) === value ) return ! isOk ( value ) ;
7+
8+ return false
9+ } )
10+ }
11+
12+ exports . remove = function remove ( obj ) {
13+ var buf = { }
14+
15+ Object . keys ( obj ) . forEach ( function ( key ) {
16+ var value = obj [ key ]
17+
18+ if ( key [ 0 ] !== '$' && ! key . match ( / \. / ) )
19+ buf [ key ] = Object ( value ) === value ? remove ( value ) : value ;
20+ } )
21+
22+ return buf
23+ }
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " mongodb-ok-for-storage" ,
3+ "description" : " Helper for storing objects in MongoDB" ,
4+ "version" : " 0.0.1" ,
5+ "author" : {
6+ "name" : " Jonathan Ong" ,
7+ 8+ },
9+ "repository" : {
10+ "type" : " git" ,
11+ "url" : " https://github.com/discore/mongodb-ok-for-storage.git"
12+ },
13+ "bugs" : {
14+ 15+ "url" : " https://github.com/discore/mongodb-ok-for-storage/issues"
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ var assert = require ( 'assert' )
2+
3+ var okForStorage = require ( './' )
4+
5+ assert . ok ( ! okForStorage . is ( {
6+ 'a.b' : 1
7+ } ) )
8+
9+ assert . ok ( okForStorage . is ( {
10+ 'a' : 1
11+ } ) )
12+
13+ assert . ok ( ! okForStorage . is ( {
14+ a : {
15+ 'a.b' : 1
16+ }
17+ } ) )
18+
19+ assert . ok ( ! okForStorage . is ( {
20+ a : {
21+ $b : 1
22+ }
23+ } ) )
24+
25+ var obj1 = okForStorage . remove ( {
26+ a : {
27+ 'a.b' : 1 ,
28+ $set : true
29+ }
30+ } )
31+
32+ assert . ok ( ! obj1 . a [ 'a.b' ] )
33+ assert . ok ( ! obj1 . a . $set )
You can’t perform that action at this time.
0 commit comments