Skip to content

Commit 30b14d2

Browse files
committed
fix when casting null
1 parent 49e60ad commit 30b14d2

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

Diff for: History.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
3.0.6 / 2016-07-11
2+
==================
3+
- Fix when casting `null`
4+
15
3.0.5 / 2016-07-11
26
==================
37
- Fix when updating with `0`

Diff for: lib/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ exports.cast = function cast (obj) {
1313
return obj.map(cast)
1414
}
1515

16-
if (typeof obj === 'object') {
16+
if (obj && typeof obj === 'object') {
1717
Object.keys(obj).forEach(function (k) {
1818
if (k === '_id') {
1919
if (obj._id.$in) {

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monk",
3-
"version": "3.0.5",
3+
"version": "3.0.6",
44
"main": "lib/monk.js",
55
"tags": [
66
"mongodb",

Diff for: test/casting.js

+12
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,15 @@ test('should cast nested ids', (t) => {
8787
const oid = monk.id(cast.$pull.items[0]._id)
8888
t.is(oid.toHexString(), '4ee0fd75d6bd52107c000118')
8989
})
90+
91+
test('should not fail when casting 0', (t) => {
92+
const cast = monk.util.cast(0)
93+
94+
t.is(cast, 0)
95+
})
96+
97+
test('should not fail when casting null', (t) => {
98+
const cast = monk.util.cast(null)
99+
100+
t.is(cast, null)
101+
})

0 commit comments

Comments
 (0)