Skip to content

Commit

Permalink
Add check for nullable value
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyiz4262 committed Oct 22, 2018
1 parent 9c89b50 commit ee9454a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/api/tojs.ts
Expand Up @@ -27,16 +27,17 @@ function toJSHelper(source, options: ToJSOptions, __alreadySeen: Map<any, any>)
if (!options.recurseEverything && !isObservable(source)) return source

if (typeof source !== "object") return source

// Directly return null if source is null
if (source === null) return null

// Directly return the Date object itself if contained in the observable
if (source instanceof Date) return source

if (isObservableValue(source)) return toJSHelper(source.get(), options!, __alreadySeen)

// make sure we track the keys of the object
if (isObservable(source)) {
keys(source)
}
if (isObservable(source)) keys(source)

const detectCycles = options.detectCycles === true

Expand Down

0 comments on commit ee9454a

Please sign in to comment.