@esportsplus/reactivity 0.0.1 → 0.0.2

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/build/index.d.ts CHANGED
@@ -1,20 +1,4 @@
1
- declare class Reactive<T> {
2
- private effect;
3
- private fn?;
4
- private observers;
5
- private sources;
6
- private state;
7
- private value;
8
- cleanup: ((old: T) => void)[] | null;
9
- constructor(_: ((fn: VoidFunction) => T) | T, effect?: boolean);
10
- get(): T;
11
- set(value: T): void;
12
- private mark;
13
- private removeParentObservers;
14
- private sync;
15
- private update;
16
- }
17
- declare const effect: <T>(value: () => T) => Reactive<T>;
18
- declare const reactive: <T>(value: T) => {};
1
+ declare const effect: <T>(value: () => T) => void;
2
+ declare const reactive: <T>(value: T) => T;
19
3
  declare const tick: () => void;
20
4
  export { effect, reactive, tick };
package/build/index.js CHANGED
@@ -154,7 +154,7 @@ class Reactive {
154
154
  }
155
155
  }
156
156
  const effect = (value) => {
157
- return new Reactive(value, true);
157
+ new Reactive(value, true);
158
158
  };
159
159
  const reactive = (value) => {
160
160
  if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
package/build/obj.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const factory: (values: Record<string, unknown>) => {};
1
+ declare const factory: <T>(values: T) => T;
2
2
  export default factory;
package/package.json CHANGED
@@ -15,5 +15,5 @@
15
15
  "prepublishOnly": "npm run build"
16
16
  },
17
17
  "types": "./build/index.d.ts",
18
- "version": "0.0.1"
18
+ "version": "0.0.2"
19
19
  }
package/src/index.ts CHANGED
@@ -219,15 +219,15 @@ class Reactive<T> {
219
219
 
220
220
 
221
221
  const effect = <T>(value: () => T) => {
222
- return new Reactive(value, true);
222
+ new Reactive(value, true);
223
223
  };
224
224
 
225
- const reactive = <T>(value: T) => {
225
+ const reactive = <T>(value: T): T => {
226
226
  if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
227
- return obj(value as Record<string, unknown>);
227
+ return obj(value);
228
228
  }
229
229
 
230
- return new Reactive(value);
230
+ return new Reactive(value) as T;
231
231
  };
232
232
 
233
233
  const tick = () => {
package/src/obj.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { reactive } from './index';
2
2
 
3
3
 
4
- const factory = (values: Record<string, unknown>) => {
4
+ const factory = <T>(values: T) => {
5
5
  let lazy: Record<string, any> = {},
6
6
  properties: PropertyDescriptorMap = {};
7
7
 
@@ -31,7 +31,7 @@ const factory = (values: Record<string, unknown>) => {
31
31
  };
32
32
  }
33
33
 
34
- return Object.defineProperties({}, properties);
34
+ return Object.defineProperties({}, properties) as T;
35
35
  };
36
36
 
37
37