@arrai-innovations/reactive-helpers 3.2.1 → 4.0.0

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.
@@ -1,49 +0,0 @@
1
- import { isProxy, isRef, toRaw, unref } from "vue";
2
- import { isArray, isUndefined } from "lodash";
3
- import { isObjectLike } from "lodash/lang";
4
-
5
- export const circular = Symbol("circular");
6
-
7
- export function unrefAndToRawDeep(obj) {
8
- if (isUndefined(obj)) {
9
- return obj;
10
- }
11
- const seen = new Set();
12
- const returnValue = isArray(obj) ? [] : {};
13
- const queue = [];
14
- for (const [key, value] of Object.entries(obj)) {
15
- queue.push([returnValue, key, value]);
16
- }
17
- while (queue.length) {
18
- const [writePosition, key, value] = queue.shift();
19
- if (seen.has(value)) {
20
- // if (seen.some((item) => item === value)) {
21
- writePosition[key] = circular;
22
- continue;
23
- }
24
- let raw = value;
25
- if (isRef(raw)) {
26
- const refValue = unref(raw);
27
- // primitive values are not added to the seen set
28
- if (isObjectLike(refValue)) {
29
- seen.add(raw);
30
- }
31
- raw = unref(raw);
32
- }
33
- if (isProxy(raw)) {
34
- // this doesn't seem to do anything for the current test case.
35
- // seen.add(raw);
36
- raw = toRaw(raw);
37
- }
38
- if (!isObjectLike(raw)) {
39
- // primitive values don't need to add to the queue
40
- writePosition[key] = raw;
41
- continue;
42
- }
43
- writePosition[key] = isArray(raw) ? [] : {};
44
- for (const [nextKey, nextValue] of Object.entries(raw)) {
45
- queue.push([writePosition[key], nextKey, nextValue]);
46
- }
47
- }
48
- return returnValue;
49
- }