@knowlearning/agents 0.2.3 → 0.2.5
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/agents/generic.js +5 -1
- package/package.json +1 -1
package/agents/generic.js
CHANGED
|
@@ -12,6 +12,10 @@ function sanitizeJSONPatchPathSegment(s) {
|
|
|
12
12
|
else return s
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
function copy(value) {
|
|
16
|
+
return JSON.parse(JSON.stringify(value))
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
export default function Agent({ host, token, WebSocket, protocol='ws', uuid, fetch, applyPatch, login, logout, reboot }) {
|
|
16
20
|
let ws
|
|
17
21
|
let user
|
|
@@ -283,7 +287,7 @@ export default function Agent({ host, token, WebSocket, protocol='ws', uuid, fet
|
|
|
283
287
|
}
|
|
284
288
|
|
|
285
289
|
async function mutate(scope, initialize=true) {
|
|
286
|
-
const initial = initialize ? await
|
|
290
|
+
const initial = initialize ? copy(await state(scope) || {}) : {}
|
|
287
291
|
return new MutableProxy(initial, patch => interact(scope, patch))
|
|
288
292
|
}
|
|
289
293
|
|