Skip to content

Commit

Permalink
add toJSON method
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Oct 6, 2017
1 parent c85e08e commit b1eabfc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/y-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ export default function extendYMap (Y) {
this.os = null
this.map = null
}
toJSON () {
var obj = {}
for (let key in this.contents) {
obj[key] = this.contents[key]
}
for (let key in this.opContents) {
let type = this.os.getType(this.opContents[key])
if (type.toJSON != null) {
obj[key] = type.toJSON()
} else if (type.toString != null) {
obj[key] = type.toString()
}
}
return obj
}
get (key) {
// return property.
// if property does not exist, return null
Expand Down

0 comments on commit b1eabfc

Please sign in to comment.