j-templates 6.1.8 → 6.1.9

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.
@@ -6,13 +6,22 @@ const diffWorker_1 = require("./diffWorker");
6
6
  class DiffAsync {
7
7
  constructor(keyFunc) {
8
8
  this.workerQueue = new workerQueue_1.WorkerQueue(diffWorker_1.DiffWorker.Create());
9
- this.workerQueue.Push({ method: "create", arguments: keyFunc ? [keyFunc.toString()] : [] });
9
+ this.workerQueue.Push({
10
+ method: "create",
11
+ arguments: keyFunc ? [keyFunc.toString()] : [],
12
+ });
10
13
  }
11
14
  async DiffPath(path, value) {
12
- return await this.workerQueue.Push({ method: "diffpath", arguments: [path, value] });
15
+ return await this.workerQueue.Push({
16
+ method: "diffpath",
17
+ arguments: [path, value],
18
+ });
13
19
  }
14
20
  async DiffBatch(data) {
15
- return await this.workerQueue.Push({ method: "diffbatch", arguments: [data] });
21
+ return await this.workerQueue.Push({
22
+ method: "diffbatch",
23
+ arguments: [data],
24
+ });
16
25
  }
17
26
  Destroy() {
18
27
  this.workerQueue.Destroy();
@@ -73,7 +73,7 @@ function DiffTreeFactory(jsonDiffFactory, worker) {
73
73
  curr[path[x]] = value;
74
74
  }
75
75
  function ResolveKeyPath(source, path, keyFunc) {
76
- const parts = path.split('.');
76
+ const parts = path.split(".");
77
77
  const pathValues = new Array(parts.length - 1);
78
78
  let curr = source;
79
79
  for (let x = 0; x < parts.length - 1; x++) {
@@ -81,11 +81,12 @@ function DiffTreeFactory(jsonDiffFactory, worker) {
81
81
  pathValues[x] = curr;
82
82
  }
83
83
  let y = pathValues.length - 1;
84
- for (; y >= 0 && !(JsonType(pathValues[y]) === 'object' && keyFunc(pathValues[y])); y--) { }
84
+ for (; y >= 0 &&
85
+ !(JsonType(pathValues[y]) === "object" && keyFunc(pathValues[y])); y--) { }
85
86
  if (y >= 0) {
86
87
  const key = keyFunc(pathValues[y]);
87
88
  parts.splice(0, y + 1, key);
88
- return parts.join('.');
89
+ return parts.join(".");
89
90
  }
90
91
  return path;
91
92
  }
@@ -11,6 +11,7 @@ class StoreSync extends store_1.Store {
11
11
  this.diff = new diffSync_1.DiffSync(keyFunc);
12
12
  }
13
13
  Write(data, key) {
14
+ data = (0, json_1.JsonDeepClone)(data);
14
15
  key = key || this.keyFunc?.(data);
15
16
  if (!key)
16
17
  throw "No key provided for data";
@@ -12,7 +12,6 @@ exports.PreReq = PreReq;
12
12
  const observableScope_1 = require("../Store/Tree/observableScope");
13
13
  const observableNode_1 = require("../Store/Tree/observableNode");
14
14
  const Store_1 = require("../Store");
15
- const json_1 = require("./json");
16
15
  const nodeInstanceMap = new WeakMap();
17
16
  const scopeInstanceMap = new WeakMap();
18
17
  const destroyPrototypeMap = new WeakMap();
@@ -52,8 +51,8 @@ function ComputedDecorator(target, prop, descriptor, defaultValue) {
52
51
  const getterScope = observableScope_1.ObservableScope.Create(async () => getter.call(this));
53
52
  const syncStore = new Store_1.StoreSync();
54
53
  observableScope_1.ObservableScope.Watch(getterScope, (scope) => {
55
- const copy = (0, json_1.JsonDeepClone)(observableScope_1.ObservableScope.Value(scope));
56
- syncStore.Write(copy, 'root');
54
+ const data = observableScope_1.ObservableScope.Value(scope);
55
+ syncStore.Write(data, 'root');
57
56
  });
58
57
  observableScope_1.ObservableScope.Init(getterScope);
59
58
  const propertyScope = observableScope_1.ObservableScope.Create(() => syncStore.Get('root', defaultValue));
package/Utils/json.js CHANGED
@@ -58,8 +58,13 @@ function JsonDiffFactory() {
58
58
  function JsonDeepClone(value) {
59
59
  const type = JsonType(value);
60
60
  switch (type) {
61
- case "array":
62
- return value.map(JsonDeepClone);
61
+ case "array": {
62
+ const typed = value;
63
+ const result = new Array(typed.length);
64
+ for (let x = 0; x < typed.length; x++)
65
+ result[x] = JsonDeepClone(typed[x]);
66
+ return result;
67
+ }
63
68
  case "object": {
64
69
  const ret = {};
65
70
  const keys = Object.keys(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "6.1.8",
3
+ "version": "6.1.9",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",
File without changes
File without changes
File without changes
File without changes