braid-text 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/package.json +1 -1
- package/test.html +23 -0
package/index.js
CHANGED
|
@@ -311,7 +311,7 @@ braid_text.put = async (key, options) => {
|
|
|
311
311
|
|
|
312
312
|
let x = JSON.parse(resource.doc.get())
|
|
313
313
|
for (let p of patches)
|
|
314
|
-
apply_patch(x, p.range, JSON.parse(p.content))
|
|
314
|
+
apply_patch(x, p.range, p.content === '' ? undefined : JSON.parse(p.content))
|
|
315
315
|
|
|
316
316
|
return await braid_text.put(key, {
|
|
317
317
|
body: JSON.stringify(x, null, 4)
|
package/package.json
CHANGED
package/test.html
CHANGED
|
@@ -136,4 +136,27 @@ runTest(
|
|
|
136
136
|
JSON.stringify({a: 55, b: 66, c: 7}, null, 4)
|
|
137
137
|
)
|
|
138
138
|
|
|
139
|
+
runTest(
|
|
140
|
+
"test deleting something using a json patch",
|
|
141
|
+
async () => {
|
|
142
|
+
let key = 'test-' + Math.random().toString(36).slice(2)
|
|
143
|
+
|
|
144
|
+
await fetch(`/${key}`, {
|
|
145
|
+
method: 'PUT',
|
|
146
|
+
body: JSON.stringify({a: 5, b: 6}, null, 4)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
await fetch(`/${key}`, {
|
|
150
|
+
method: 'PUT',
|
|
151
|
+
headers: { 'Content-Range': 'json a' },
|
|
152
|
+
body: ''
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
let r = await fetch(`/${key}`)
|
|
156
|
+
|
|
157
|
+
return await r.text()
|
|
158
|
+
},
|
|
159
|
+
JSON.stringify({b: 6}, null, 4)
|
|
160
|
+
)
|
|
161
|
+
|
|
139
162
|
</script>
|