@solid-primitives/utils 2.1.1 → 3.0.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/README.md +1 -28
- package/dist/index.cjs +33 -44
- package/dist/index.d.ts +31 -48
- package/dist/index.js +41 -45
- package/package.json +47 -47
package/README.md
CHANGED
|
@@ -16,31 +16,4 @@ yarn add @solid-primitives/utils
|
|
|
16
16
|
|
|
17
17
|
## Changelog
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
<summary><b>Expand Changelog</b></summary>
|
|
21
|
-
|
|
22
|
-
0.0.100
|
|
23
|
-
|
|
24
|
-
First commit of the timer primitive.
|
|
25
|
-
|
|
26
|
-
0.0.250
|
|
27
|
-
|
|
28
|
-
Republished version with better ESM support and build tooling.
|
|
29
|
-
|
|
30
|
-
0.0.260
|
|
31
|
-
|
|
32
|
-
Added comments for util methods.
|
|
33
|
-
|
|
34
|
-
0.1.0
|
|
35
|
-
|
|
36
|
-
Add `/fp` and `/setter` export entries. Add `destore` and `raceTimeout` util. More jsdoc.
|
|
37
|
-
|
|
38
|
-
0.1.2
|
|
39
|
-
|
|
40
|
-
Updated to Solid 1.3
|
|
41
|
-
|
|
42
|
-
0.1.3
|
|
43
|
-
|
|
44
|
-
Minor upgrades.
|
|
45
|
-
|
|
46
|
-
</details>
|
|
19
|
+
See [CHANGELOG.md](./CHANGELOG.md)
|
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
6
|
var __export = (target, all) => {
|
|
20
7
|
for (var name in all)
|
|
21
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -48,6 +35,7 @@ __export(src_exports, {
|
|
|
48
35
|
createStaticStore: () => createStaticStore,
|
|
49
36
|
createTrigger: () => createTrigger,
|
|
50
37
|
createTriggerCache: () => createTriggerCache,
|
|
38
|
+
createWeakTriggerCache: () => createWeakTriggerCache,
|
|
51
39
|
entries: () => entries,
|
|
52
40
|
forEachEntry: () => forEachEntry,
|
|
53
41
|
handleDiffArray: () => handleDiffArray,
|
|
@@ -60,8 +48,6 @@ __export(src_exports, {
|
|
|
60
48
|
noop: () => noop,
|
|
61
49
|
ofClass: () => ofClass,
|
|
62
50
|
onRootCleanup: () => onRootCleanup,
|
|
63
|
-
promiseTimeout: () => promiseTimeout,
|
|
64
|
-
raceTimeout: () => raceTimeout,
|
|
65
51
|
warn: () => warn,
|
|
66
52
|
withAccess: () => withAccess
|
|
67
53
|
});
|
|
@@ -105,15 +91,6 @@ function forEachEntry(object, iterator) {
|
|
|
105
91
|
}
|
|
106
92
|
var entries = Object.entries;
|
|
107
93
|
var keys = Object.keys;
|
|
108
|
-
var promiseTimeout = (ms, throwOnTimeout = false, reason = "Timeout") => new Promise((resolve, reject) => throwOnTimeout ? setTimeout(() => reject(reason), ms) : setTimeout(resolve, ms));
|
|
109
|
-
function raceTimeout(input, ms, throwOnTimeout = false, reason = "Timeout") {
|
|
110
|
-
const promises = asArray(input);
|
|
111
|
-
const race = Promise.race([...promises, promiseTimeout(ms, throwOnTimeout, reason)]);
|
|
112
|
-
race.finally(() => {
|
|
113
|
-
promises.forEach((p) => p && typeof p === "object" && typeof p.dispose === "function" && p.dispose());
|
|
114
|
-
});
|
|
115
|
-
return race;
|
|
116
|
-
}
|
|
117
94
|
var onRootCleanup = (fn) => (0, import_solid_js.getOwner)() ? (0, import_solid_js.onCleanup)(fn) : fn;
|
|
118
95
|
var createCallbackStack = () => {
|
|
119
96
|
let stack = [];
|
|
@@ -145,29 +122,42 @@ function createProxy(traps) {
|
|
|
145
122
|
}
|
|
146
123
|
});
|
|
147
124
|
}
|
|
148
|
-
|
|
149
|
-
|
|
125
|
+
var createTrigger = isDev ? () => (0, import_solid_js.createSignal)(void 0, { equals: false, name: "trigger" }) : () => (0, import_solid_js.createSignal)(void 0, { equals: false });
|
|
126
|
+
function dirtyTriggerCache(key) {
|
|
127
|
+
const trigger = this.get(key);
|
|
128
|
+
if (trigger)
|
|
129
|
+
trigger[1]();
|
|
130
|
+
}
|
|
131
|
+
function dirtyAllTriggerCache() {
|
|
132
|
+
this.forEach((s) => s[1]());
|
|
133
|
+
}
|
|
134
|
+
function trackTriggerCache(key) {
|
|
135
|
+
if (!(0, import_solid_js.getListener)())
|
|
136
|
+
return;
|
|
137
|
+
let trigger = this.get(key);
|
|
138
|
+
if (!trigger) {
|
|
139
|
+
trigger = createTrigger();
|
|
140
|
+
this.set(key, trigger);
|
|
141
|
+
}
|
|
142
|
+
trigger[0]();
|
|
150
143
|
}
|
|
151
|
-
function createTriggerCache(
|
|
144
|
+
function createTriggerCache() {
|
|
152
145
|
const cache = /* @__PURE__ */ new Map();
|
|
153
146
|
return {
|
|
154
|
-
dirty: (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
trigger[0]();
|
|
166
|
-
}
|
|
147
|
+
dirty: dirtyTriggerCache.bind(cache),
|
|
148
|
+
dirtyAll: dirtyAllTriggerCache.bind(cache),
|
|
149
|
+
track: trackTriggerCache.bind(cache)
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function createWeakTriggerCache() {
|
|
153
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
154
|
+
return {
|
|
155
|
+
dirty: dirtyTriggerCache.bind(cache),
|
|
156
|
+
track: trackTriggerCache.bind(cache)
|
|
167
157
|
};
|
|
168
158
|
}
|
|
169
159
|
function createStaticStore(init) {
|
|
170
|
-
const copy =
|
|
160
|
+
const copy = { ...init };
|
|
171
161
|
const store = {};
|
|
172
162
|
const cache = /* @__PURE__ */ new Map();
|
|
173
163
|
const getValue = (key) => {
|
|
@@ -256,6 +246,7 @@ function handleDiffArray(current, prev, handleAdded, handleRemoved) {
|
|
|
256
246
|
createStaticStore,
|
|
257
247
|
createTrigger,
|
|
258
248
|
createTriggerCache,
|
|
249
|
+
createWeakTriggerCache,
|
|
259
250
|
entries,
|
|
260
251
|
forEachEntry,
|
|
261
252
|
handleDiffArray,
|
|
@@ -268,8 +259,6 @@ function handleDiffArray(current, prev, handleAdded, handleRemoved) {
|
|
|
268
259
|
noop,
|
|
269
260
|
ofClass,
|
|
270
261
|
onRootCleanup,
|
|
271
|
-
promiseTimeout,
|
|
272
|
-
raceTimeout,
|
|
273
262
|
warn,
|
|
274
263
|
withAccess
|
|
275
264
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessor, Setter, onCleanup } from 'solid-js';
|
|
2
|
-
import { BaseOptions } from 'solid-js/types/reactive/signal';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Can be single or in an array
|
|
@@ -82,12 +81,6 @@ declare type PrimitiveValue = PropertyKey | boolean | bigint | null | undefined;
|
|
|
82
81
|
declare type FalsyValue = false | 0 | "" | null | undefined;
|
|
83
82
|
declare type Truthy<T> = Exclude<T, FalsyValue>;
|
|
84
83
|
declare type Falsy<T> = Extract<T, FalsyValue>;
|
|
85
|
-
declare type TriggerCache<T> = {
|
|
86
|
-
track: (v: T) => void;
|
|
87
|
-
dirty: (v: T) => void;
|
|
88
|
-
dirtyAll: VoidFunction;
|
|
89
|
-
};
|
|
90
|
-
declare type Trigger = [track: VoidFunction, dirty: VoidFunction];
|
|
91
84
|
declare type Position = {
|
|
92
85
|
x: number;
|
|
93
86
|
y: number;
|
|
@@ -159,42 +152,6 @@ declare const entries: <T extends object>(obj: T) => [keyof T, T[keyof T]][];
|
|
|
159
152
|
* Get keys of an object
|
|
160
153
|
*/
|
|
161
154
|
declare const keys: <T extends object>(object: T) => (keyof T)[];
|
|
162
|
-
/**
|
|
163
|
-
* Creates a promise that resolves *(or rejects)* after given time.
|
|
164
|
-
*
|
|
165
|
-
* @param ms timeout duration in ms
|
|
166
|
-
* @param throwOnTimeout promise will be rejected on timeout if set to `true`
|
|
167
|
-
* @param reason rejection reason
|
|
168
|
-
* @returns Promise<void>
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
* ```ts
|
|
172
|
-
* await promiseTimeout(1500) // will resolve void after timeout
|
|
173
|
-
* await promiseTimeout(1500, true, 'rejection reason') // will reject 'rejection reason' after timout
|
|
174
|
-
* ```
|
|
175
|
-
*/
|
|
176
|
-
declare const promiseTimeout: (ms: number, throwOnTimeout?: boolean, reason?: string) => Promise<void>;
|
|
177
|
-
/**
|
|
178
|
-
* Combination of `Promise.race()` and `promiseTimeout`.
|
|
179
|
-
*
|
|
180
|
-
* @param promises single promise, or array of promises
|
|
181
|
-
* @param ms timeout duration in ms
|
|
182
|
-
* @param throwOnTimeout promise will be rejected on timeout if set to `true`
|
|
183
|
-
* @param reason rejection reason
|
|
184
|
-
* @returns a promise resulting in value of the first source promises to be resolved
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```ts
|
|
188
|
-
* // single promise
|
|
189
|
-
* await raceTimeout(new Promise(() => {...}), 3000)
|
|
190
|
-
* // list of promises racing
|
|
191
|
-
* await raceTimeout([new Promise(),new Promise()...], 3000)
|
|
192
|
-
* // reject on timeout
|
|
193
|
-
* await raceTimeout(new Promise(), 3000, true, 'rejection reason')
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
declare function raceTimeout<T>(promises: T, ms: number, throwOnTimeout: true, reason?: string): T extends any[] ? Promise<Awaited<T[number]>> : Promise<Awaited<T>>;
|
|
197
|
-
declare function raceTimeout<T>(promises: T, ms: number, throwOnTimeout?: boolean, reason?: string): T extends any[] ? Promise<Awaited<T[number]> | undefined> : Promise<Awaited<T> | undefined>;
|
|
198
155
|
/**
|
|
199
156
|
* Solid's `onCleanup` that is registered only if there is a root.
|
|
200
157
|
*/
|
|
@@ -219,6 +176,7 @@ declare function createProxy<T extends Record<string | symbol, any>>(traps: {
|
|
|
219
176
|
get: <K extends keyof T>(key: K) => T[K];
|
|
220
177
|
set?: undefined;
|
|
221
178
|
}): Readonly<T>;
|
|
179
|
+
declare type Trigger = [track: VoidFunction, dirty: VoidFunction];
|
|
222
180
|
/**
|
|
223
181
|
* Set listeners in reactive computations and then trigger them when you want.
|
|
224
182
|
* @returns `[track function, dirty function]`
|
|
@@ -231,7 +189,12 @@ declare function createProxy<T extends Record<string | symbol, any>>(traps: {
|
|
|
231
189
|
* // later
|
|
232
190
|
* dirty()
|
|
233
191
|
*/
|
|
234
|
-
declare
|
|
192
|
+
declare const createTrigger: () => Trigger;
|
|
193
|
+
declare type TriggerCache<T> = {
|
|
194
|
+
track: (v: T) => void;
|
|
195
|
+
dirty: (v: T) => void;
|
|
196
|
+
dirtyAll: VoidFunction;
|
|
197
|
+
};
|
|
235
198
|
/**
|
|
236
199
|
* Set listeners in reactive computations and then trigger them when you want. Cache trackers by a `key`.
|
|
237
200
|
* @returns `{ track, dirty, dirtyAll }` functions
|
|
@@ -247,14 +210,34 @@ declare function createTrigger(options?: BaseOptions): Trigger;
|
|
|
247
210
|
* // this won't cause an update:
|
|
248
211
|
* dirty(2)
|
|
249
212
|
*/
|
|
250
|
-
declare function createTriggerCache<T>(
|
|
213
|
+
declare function createTriggerCache<T>(): TriggerCache<T>;
|
|
214
|
+
declare type WeakTriggerCache<T extends object> = {
|
|
215
|
+
track: (v: T) => void;
|
|
216
|
+
dirty: (v: T) => void;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Set listeners in reactive computations and then trigger them when you want. Cache trackers by a `key`.
|
|
220
|
+
* @returns `{ track, dirty }` functions
|
|
221
|
+
* `track` and `dirty` are called with a `key` so that each tracker will trigger an update only when his individual `key` would get marked as dirty.
|
|
222
|
+
* @example
|
|
223
|
+
* const { track, dirty } = createWeakTriggerCache()
|
|
224
|
+
* createEffect(() => {
|
|
225
|
+
* track(1)
|
|
226
|
+
* ...
|
|
227
|
+
* })
|
|
228
|
+
* // later
|
|
229
|
+
* dirty(1)
|
|
230
|
+
* // this won't cause an update:
|
|
231
|
+
* dirty(2)
|
|
232
|
+
*/
|
|
233
|
+
declare function createWeakTriggerCache<T extends object>(): WeakTriggerCache<T>;
|
|
251
234
|
declare type StaticStoreSetter<T extends Readonly<AnyStatic>> = {
|
|
252
235
|
(setter: (prev: T) => Partial<T>): T;
|
|
253
236
|
(state: Partial<T>): T;
|
|
254
237
|
<K extends keyof T>(key: K, state: SetterValue<T[K]>): T;
|
|
255
238
|
};
|
|
256
239
|
/**
|
|
257
|
-
* A shallowly wrapped reactive store object. It behaves similarly to the
|
|
240
|
+
* A shallowly wrapped reactive store object. It behaves similarly to the createStore, but with limited features to keep it simple. Designed to be used for reactive objects with static keys, but dynamic values, like reactive Event State, location, etc.
|
|
258
241
|
* @param init initial value of the store
|
|
259
242
|
* @returns
|
|
260
243
|
* ```ts
|
|
@@ -270,6 +253,6 @@ declare function createStaticStore<T extends Readonly<AnyStatic>>(init: T): [acc
|
|
|
270
253
|
* @param handleAdded called once for every added item to array
|
|
271
254
|
* @param handleRemoved called once for every removed from array
|
|
272
255
|
*/
|
|
273
|
-
declare function handleDiffArray<T>(current: T[], prev: T[], handleAdded: (item: T) => void, handleRemoved: (item: T) => void): void;
|
|
256
|
+
declare function handleDiffArray<T>(current: readonly T[], prev: readonly T[], handleAdded: (item: T) => void, handleRemoved: (item: T) => void): void;
|
|
274
257
|
|
|
275
|
-
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Definite, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Mutable, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterValue, Simplify, StaticStoreSetter, Tail, Trigger, TriggerCache, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, createTrigger, createTriggerCache, entries, forEachEntry, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup,
|
|
258
|
+
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Definite, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Mutable, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterValue, Simplify, StaticStoreSetter, Tail, Trigger, TriggerCache, Truthy, UnboxLazy, UnionToIntersection, Values, WeakTriggerCache, access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, createTrigger, createTriggerCache, createWeakTriggerCache, entries, forEachEntry, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup, warn, withAccess };
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
1
|
+
"use strict";
|
|
17
2
|
|
|
18
3
|
// src/index.ts
|
|
19
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getOwner,
|
|
6
|
+
onCleanup,
|
|
7
|
+
createSignal,
|
|
8
|
+
DEV,
|
|
9
|
+
untrack,
|
|
10
|
+
batch,
|
|
11
|
+
getListener
|
|
12
|
+
} from "solid-js";
|
|
20
13
|
import { isServer as _isServer } from "solid-js/web";
|
|
21
14
|
var noop = () => void 0;
|
|
22
15
|
var isServer = _isServer;
|
|
@@ -55,15 +48,6 @@ function forEachEntry(object, iterator) {
|
|
|
55
48
|
}
|
|
56
49
|
var entries = Object.entries;
|
|
57
50
|
var keys = Object.keys;
|
|
58
|
-
var promiseTimeout = (ms, throwOnTimeout = false, reason = "Timeout") => new Promise((resolve, reject) => throwOnTimeout ? setTimeout(() => reject(reason), ms) : setTimeout(resolve, ms));
|
|
59
|
-
function raceTimeout(input, ms, throwOnTimeout = false, reason = "Timeout") {
|
|
60
|
-
const promises = asArray(input);
|
|
61
|
-
const race = Promise.race([...promises, promiseTimeout(ms, throwOnTimeout, reason)]);
|
|
62
|
-
race.finally(() => {
|
|
63
|
-
promises.forEach((p) => p && typeof p === "object" && typeof p.dispose === "function" && p.dispose());
|
|
64
|
-
});
|
|
65
|
-
return race;
|
|
66
|
-
}
|
|
67
51
|
var onRootCleanup = (fn) => getOwner() ? onCleanup(fn) : fn;
|
|
68
52
|
var createCallbackStack = () => {
|
|
69
53
|
let stack = [];
|
|
@@ -95,29 +79,42 @@ function createProxy(traps) {
|
|
|
95
79
|
}
|
|
96
80
|
});
|
|
97
81
|
}
|
|
98
|
-
|
|
99
|
-
|
|
82
|
+
var createTrigger = isDev ? () => createSignal(void 0, { equals: false, name: "trigger" }) : () => createSignal(void 0, { equals: false });
|
|
83
|
+
function dirtyTriggerCache(key) {
|
|
84
|
+
const trigger = this.get(key);
|
|
85
|
+
if (trigger)
|
|
86
|
+
trigger[1]();
|
|
87
|
+
}
|
|
88
|
+
function dirtyAllTriggerCache() {
|
|
89
|
+
this.forEach((s) => s[1]());
|
|
90
|
+
}
|
|
91
|
+
function trackTriggerCache(key) {
|
|
92
|
+
if (!getListener())
|
|
93
|
+
return;
|
|
94
|
+
let trigger = this.get(key);
|
|
95
|
+
if (!trigger) {
|
|
96
|
+
trigger = createTrigger();
|
|
97
|
+
this.set(key, trigger);
|
|
98
|
+
}
|
|
99
|
+
trigger[0]();
|
|
100
100
|
}
|
|
101
|
-
function createTriggerCache(
|
|
101
|
+
function createTriggerCache() {
|
|
102
102
|
const cache = /* @__PURE__ */ new Map();
|
|
103
103
|
return {
|
|
104
|
-
dirty: (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
trigger[0]();
|
|
116
|
-
}
|
|
104
|
+
dirty: dirtyTriggerCache.bind(cache),
|
|
105
|
+
dirtyAll: dirtyAllTriggerCache.bind(cache),
|
|
106
|
+
track: trackTriggerCache.bind(cache)
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function createWeakTriggerCache() {
|
|
110
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
111
|
+
return {
|
|
112
|
+
dirty: dirtyTriggerCache.bind(cache),
|
|
113
|
+
track: trackTriggerCache.bind(cache)
|
|
117
114
|
};
|
|
118
115
|
}
|
|
119
116
|
function createStaticStore(init) {
|
|
120
|
-
const copy =
|
|
117
|
+
const copy = { ...init };
|
|
121
118
|
const store = {};
|
|
122
119
|
const cache = /* @__PURE__ */ new Map();
|
|
123
120
|
const getValue = (key) => {
|
|
@@ -205,6 +202,7 @@ export {
|
|
|
205
202
|
createStaticStore,
|
|
206
203
|
createTrigger,
|
|
207
204
|
createTriggerCache,
|
|
205
|
+
createWeakTriggerCache,
|
|
208
206
|
entries,
|
|
209
207
|
forEachEntry,
|
|
210
208
|
handleDiffArray,
|
|
@@ -217,8 +215,6 @@ export {
|
|
|
217
215
|
noop,
|
|
218
216
|
ofClass,
|
|
219
217
|
onRootCleanup,
|
|
220
|
-
promiseTimeout,
|
|
221
|
-
raceTimeout,
|
|
222
218
|
warn,
|
|
223
219
|
withAccess
|
|
224
220
|
};
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@solid-primitives/utils",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A bunch of reactive utility types and functions, for building primitives with Solid.js",
|
|
5
|
-
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/solidjs-community/solid-primitives/tree/main/packages/utils#readme",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/solidjs-community/solid-primitives.git"
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/solidjs-community/solid-primitives/issues"
|
|
14
|
-
},
|
|
15
|
-
"private": false,
|
|
16
|
-
"sideEffects": false,
|
|
17
|
-
"type": "module",
|
|
18
|
-
"main": "dist/index.cjs",
|
|
19
|
-
"module": "dist/index.js",
|
|
20
|
-
"types": "dist/index.d.ts",
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsup",
|
|
26
|
-
"test": "uvu -r solid-register",
|
|
27
|
-
"test:watch": "watchlist src test -- npm test"
|
|
28
|
-
},
|
|
29
|
-
"keywords": [
|
|
30
|
-
"utilities",
|
|
31
|
-
"reactivity",
|
|
32
|
-
"solid",
|
|
33
|
-
"primitives"
|
|
34
|
-
],
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"jsdom": "^
|
|
37
|
-
"prettier": "^2.
|
|
38
|
-
"solid-register": "^0.2.5",
|
|
39
|
-
"tslib": "^2.
|
|
40
|
-
"tsup": "^
|
|
41
|
-
"uvu": "^0.5.
|
|
42
|
-
"watchlist": "^0.3.1"
|
|
43
|
-
},
|
|
44
|
-
"peerDependencies": {
|
|
45
|
-
"solid-js": "^1.4.1"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@solid-primitives/utils",
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"description": "A bunch of reactive utility types and functions, for building primitives with Solid.js",
|
|
5
|
+
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/solidjs-community/solid-primitives/tree/main/packages/utils#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/solidjs-community/solid-primitives.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/solidjs-community/solid-primitives/issues"
|
|
14
|
+
},
|
|
15
|
+
"private": false,
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "dist/index.cjs",
|
|
19
|
+
"module": "dist/index.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"test": "uvu -r solid-register",
|
|
27
|
+
"test:watch": "watchlist src test -- npm test"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"utilities",
|
|
31
|
+
"reactivity",
|
|
32
|
+
"solid",
|
|
33
|
+
"primitives"
|
|
34
|
+
],
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"jsdom": "^20.0.0",
|
|
37
|
+
"prettier": "^2.7.1",
|
|
38
|
+
"solid-register": "^0.2.5",
|
|
39
|
+
"tslib": "^2.4.0",
|
|
40
|
+
"tsup": "^6.2.1",
|
|
41
|
+
"uvu": "^0.5.6",
|
|
42
|
+
"watchlist": "^0.3.1"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"solid-js": "^1.4.1"
|
|
46
|
+
}
|
|
47
|
+
}
|