@solid-primitives/utils 7.0.0-next.7 → 7.0.0-next.8
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/dist/colors/helpers.d.ts +1 -3
- package/dist/colors/helpers.js +1 -2
- package/dist/colors/index.js +1 -1
- package/dist/colors/intl.d.ts +1 -3
- package/dist/colors/intl.js +1 -2
- package/dist/colors/manipulation.d.ts +1 -3
- package/dist/colors/manipulation.js +1 -2
- package/dist/colors/types.d.ts +1 -3
- package/dist/immutable/array.d.ts +1 -3
- package/dist/immutable/array.js +1 -2
- package/dist/immutable/copy.d.ts +1 -3
- package/dist/immutable/copy.js +1 -2
- package/dist/immutable/index.d.ts +2 -2
- package/dist/immutable/index.js +2 -2
- package/dist/immutable/number.d.ts +1 -3
- package/dist/immutable/number.js +1 -2
- package/dist/immutable/object.d.ts +1 -3
- package/dist/immutable/object.js +1 -2
- package/dist/immutable/types.d.ts +1 -3
- package/dist/immutable/update.d.ts +1 -3
- package/dist/immutable/update.js +1 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +3 -3
- package/dist/types.d.ts +1 -2
- package/package.json +6 -6
package/dist/colors/helpers.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./helpers.d.ts" */
|
|
2
2
|
import { Color, ColorChannel, ColorSpace } from "./types.js";
|
|
3
|
-
//#region src/colors/helpers.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Parses a color string into a {@link Color} object.
|
|
6
5
|
*
|
|
@@ -45,5 +44,4 @@ export declare function normalizeHue(hue: number): number;
|
|
|
45
44
|
*
|
|
46
45
|
* @see https://www.w3.org/TR/css-color-4/#color-conversion-code
|
|
47
46
|
*/
|
|
48
|
-
export declare function colorToOKLCH(color: Color): [l: number, c: number, h: number];
|
|
49
|
-
//#endregion
|
|
47
|
+
export declare function colorToOKLCH(color: Color): [l: number, c: number, h: number];
|
package/dist/colors/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @ts-self-types="./helpers.d.ts" */
|
|
2
2
|
import { clamp } from "../index.js";
|
|
3
|
-
|
|
3
|
+
// src/colors/helpers.ts
|
|
4
4
|
/**
|
|
5
5
|
* Parses a color string into a {@link Color} object.
|
|
6
6
|
*
|
|
@@ -814,5 +814,4 @@ function toFixedNumber(value, digits, base = 10) {
|
|
|
814
814
|
const pow = base ** digits;
|
|
815
815
|
return Math.round(value * pow) / pow;
|
|
816
816
|
}
|
|
817
|
-
//#endregion
|
|
818
817
|
export { colorToOKLCH, getColorChannels, normalizeColor, normalizeHue, parseColor };
|
package/dist/colors/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./index.d.ts" */
|
|
2
|
-
import { colorToOKLCH, getColorChannels, normalizeColor, normalizeHue, parseColor } from "./helpers.js";
|
|
3
2
|
import { COLOR_INTL_TRANSLATIONS } from "./intl.js";
|
|
3
|
+
import { colorToOKLCH, getColorChannels, normalizeColor, normalizeHue, parseColor } from "./helpers.js";
|
|
4
4
|
import { colorScale, complement, contrastRatio, darken, desaturate, detectColorFormat, isReadable, isValidColor, lighten, mix, perceptualColorScale, saturate, tryParseColor } from "./manipulation.js";
|
|
5
5
|
export { COLOR_INTL_TRANSLATIONS, colorScale, colorToOKLCH, complement, contrastRatio, darken, desaturate, detectColorFormat, getColorChannels, isReadable, isValidColor, lighten, mix, normalizeColor, normalizeHue, parseColor, perceptualColorScale, saturate, tryParseColor };
|
package/dist/colors/intl.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* @ts-self-types="./intl.d.ts" */
|
|
2
|
-
//#region src/colors/intl.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Default English translations for color channel names, descriptors, and hue families.
|
|
5
4
|
* Pass this object (or a translated equivalent) to {@link Color.getColorName} and
|
|
@@ -53,5 +52,4 @@ export declare const COLOR_INTL_TRANSLATIONS: {
|
|
|
53
52
|
magenta: string;
|
|
54
53
|
"magenta pink": string;
|
|
55
54
|
};
|
|
56
|
-
export type ColorIntlTranslations = typeof COLOR_INTL_TRANSLATIONS;
|
|
57
|
-
//#endregion
|
|
55
|
+
export type ColorIntlTranslations = typeof COLOR_INTL_TRANSLATIONS;
|
package/dist/colors/intl.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./intl.d.ts" */
|
|
2
|
-
|
|
2
|
+
// src/colors/intl.ts
|
|
3
3
|
/**
|
|
4
4
|
* Default English translations for color channel names, descriptors, and hue families.
|
|
5
5
|
* Pass this object (or a translated equivalent) to {@link Color.getColorName} and
|
|
@@ -53,5 +53,4 @@ const COLOR_INTL_TRANSLATIONS = {
|
|
|
53
53
|
magenta: "magenta",
|
|
54
54
|
"magenta pink": "magenta pink"
|
|
55
55
|
};
|
|
56
|
-
//#endregion
|
|
57
56
|
export { COLOR_INTL_TRANSLATIONS };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./manipulation.d.ts" */
|
|
2
2
|
import { Color, ColorFormat } from "./types.js";
|
|
3
|
-
//#region src/colors/manipulation.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Like {@link parseColor} but returns `undefined` instead of throwing for invalid input.
|
|
6
5
|
*
|
|
@@ -143,5 +142,4 @@ export declare function colorScale(from: Color, to: Color, steps: number): Color
|
|
|
143
142
|
* perceptualColorScale(parseColor("hsl(0, 80%, 50%)"), parseColor("hsl(240, 80%, 50%)"), 5)
|
|
144
143
|
* ```
|
|
145
144
|
*/
|
|
146
|
-
export declare function perceptualColorScale(from: Color, to: Color, steps: number): Color[];
|
|
147
|
-
//#endregion
|
|
145
|
+
export declare function perceptualColorScale(from: Color, to: Color, steps: number): Color[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @ts-self-types="./manipulation.d.ts" */
|
|
2
2
|
import { clamp } from "../index.js";
|
|
3
3
|
import { colorToOKLCH, normalizeHue, parseColor } from "./helpers.js";
|
|
4
|
-
|
|
4
|
+
// src/colors/manipulation.ts
|
|
5
5
|
/**
|
|
6
6
|
* Like {@link parseColor} but returns `undefined` instead of throwing for invalid input.
|
|
7
7
|
*
|
|
@@ -247,5 +247,4 @@ function perceptualColorScale(from, to, steps) {
|
|
|
247
247
|
return oklchToColor(l, c, h, alphaFrom + (alphaTo - alphaFrom) * t);
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
|
-
//#endregion
|
|
251
250
|
export { colorScale, complement, contrastRatio, darken, desaturate, detectColorFormat, isReadable, isValidColor, lighten, mix, perceptualColorScale, saturate, tryParseColor };
|
package/dist/colors/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./types.d.ts" */
|
|
2
2
|
import { ColorIntlTranslations } from "./intl.js";
|
|
3
|
-
//#region src/colors/types.d.ts
|
|
4
3
|
/** Supported color string formats. Formats without an `a` suffix treat alpha as fully opaque. */
|
|
5
4
|
export type ColorFormat = "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "hsb" | "hsba";
|
|
6
5
|
/** The three supported color spaces. */
|
|
@@ -76,5 +75,4 @@ export interface Color {
|
|
|
76
75
|
getColorName(translations: ColorIntlTranslations): string;
|
|
77
76
|
/** Returns just the hue family name (e.g. `"blue"`, `"orange yellow"`). */
|
|
78
77
|
getHueName(translations: ColorIntlTranslations): string;
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
78
|
+
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { AnyClass, ItemsOf, Many } from "../types.js";
|
|
3
3
|
import "../index.js";
|
|
4
4
|
import { FlattenArray, MappingFn, Predicate } from "./types.js";
|
|
5
|
-
//#region src/immutable/array.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* non-mutating `Array.prototype.push()`
|
|
8
7
|
* @returns changed array copy
|
|
@@ -112,5 +111,4 @@ export declare const filterInstance: <T, I extends AnyClass[]>(list: readonly T[
|
|
|
112
111
|
* @param ...classes list or classes
|
|
113
112
|
* @returns changed array copy
|
|
114
113
|
*/
|
|
115
|
-
export declare const filterOutInstance: <T, I extends AnyClass[]>(list: readonly T[], ...classes: I) => Exclude<T, InstanceType<ItemsOf<I>>>[];
|
|
116
|
-
//#endregion
|
|
114
|
+
export declare const filterOutInstance: <T, I extends AnyClass[]>(list: readonly T[], ...classes: I) => Exclude<T, InstanceType<ItemsOf<I>>>[];
|
package/dist/immutable/array.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { compare, ofClass } from "../index.js";
|
|
3
3
|
import { withArrayCopy } from "./copy.js";
|
|
4
4
|
import { get } from "./object.js";
|
|
5
|
-
|
|
5
|
+
// src/immutable/array.ts
|
|
6
6
|
/**
|
|
7
7
|
* non-mutating `Array.prototype.push()`
|
|
8
8
|
* @returns changed array copy
|
|
@@ -129,5 +129,4 @@ const filterInstance = (list, ...classes) => classes.length === 1 ? list.filter(
|
|
|
129
129
|
* @returns changed array copy
|
|
130
130
|
*/
|
|
131
131
|
const filterOutInstance = (list, ...classes) => classes.length === 1 ? list.filter((item) => item && !ofClass(item, classes[0])) : list.filter((item) => item && !classes.some((c) => ofClass(item, c)));
|
|
132
|
-
//#endregion
|
|
133
132
|
export { concat, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, map, push, remove, removeItems, slice, sort, sortBy, splice };
|
package/dist/immutable/copy.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* @ts-self-types="./copy.d.ts" */
|
|
2
|
-
//#region src/immutable/copy.d.ts
|
|
3
2
|
/** make shallow copy of an array */
|
|
4
3
|
export declare const shallowArrayCopy: <T>(array: readonly T[]) => T[];
|
|
5
4
|
/** make shallow copy of an object */
|
|
@@ -26,5 +25,4 @@ export declare const withObjectCopy: <T extends object>(object: T, mutator: (cop
|
|
|
26
25
|
* @param mutator function applying mutations to the copy of source
|
|
27
26
|
* @returns changed object copy
|
|
28
27
|
*/
|
|
29
|
-
export declare const withCopy: <T extends object>(source: T, mutator: (copy: T) => void) => T;
|
|
30
|
-
//#endregion
|
|
28
|
+
export declare const withCopy: <T extends object>(source: T, mutator: (copy: T) => void) => T;
|
package/dist/immutable/copy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./copy.d.ts" */
|
|
2
|
-
|
|
2
|
+
// src/immutable/copy.ts
|
|
3
3
|
/** make shallow copy of an array */
|
|
4
4
|
const shallowArrayCopy = (array) => array.slice();
|
|
5
5
|
/** make shallow copy of an object */
|
|
@@ -35,5 +35,4 @@ const withObjectCopy = (object, mutator) => {
|
|
|
35
35
|
* @returns changed object copy
|
|
36
36
|
*/
|
|
37
37
|
const withCopy = (source, mutator) => Array.isArray(source) ? withArrayCopy(source, mutator) : withObjectCopy(source, mutator);
|
|
38
|
-
//#endregion
|
|
39
38
|
export { shallowArrayCopy, shallowCopy, shallowObjectCopy, withArrayCopy, withCopy, withObjectCopy };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* @ts-self-types="./index.d.ts" */
|
|
2
|
-
import { FlattenArray, MappingFn, ModifyValue, Predicate } from "./types.js";
|
|
3
|
-
import { concat, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, map, push, remove, removeItems, slice, sort, sortBy, splice } from "./array.js";
|
|
4
2
|
import { shallowArrayCopy, shallowCopy, shallowObjectCopy, withArrayCopy, withCopy, withObjectCopy } from "./copy.js";
|
|
5
3
|
import { add, clamp, divide, multiply, power, substract } from "./number.js";
|
|
6
4
|
import { Update, UpdateSetter, update } from "./update.js";
|
|
7
5
|
import { get, merge, omit, pick, split } from "./object.js";
|
|
6
|
+
import { concat, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, map, push, remove, removeItems, slice, sort, sortBy, splice } from "./array.js";
|
|
7
|
+
import { FlattenArray, MappingFn, ModifyValue, Predicate } from "./types.js";
|
|
8
8
|
export { FlattenArray, MappingFn, ModifyValue, Predicate, Update, UpdateSetter, add, clamp, concat, divide, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, get, map, merge, multiply, omit, pick, power, push, remove, removeItems, shallowArrayCopy, shallowCopy, shallowObjectCopy, slice, sort, sortBy, splice, split, substract, update, withArrayCopy, withCopy, withObjectCopy };
|
package/dist/immutable/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @ts-self-types="./index.d.ts" */
|
|
2
2
|
import { shallowArrayCopy, shallowCopy, shallowObjectCopy, withArrayCopy, withCopy, withObjectCopy } from "./copy.js";
|
|
3
|
-
import { get, merge, omit, pick, split } from "./object.js";
|
|
4
|
-
import { concat, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, map, push, remove, removeItems, slice, sort, sortBy, splice } from "./array.js";
|
|
5
3
|
import { add, clamp, divide, multiply, power, substract } from "./number.js";
|
|
6
4
|
import { update } from "./update.js";
|
|
5
|
+
import { get, merge, omit, pick, split } from "./object.js";
|
|
6
|
+
import { concat, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, map, push, remove, removeItems, slice, sort, sortBy, splice } from "./array.js";
|
|
7
7
|
export { add, clamp, concat, divide, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, get, map, merge, multiply, omit, pick, power, push, remove, removeItems, shallowArrayCopy, shallowCopy, shallowObjectCopy, slice, sort, sortBy, splice, split, substract, update, withArrayCopy, withCopy, withObjectCopy };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* @ts-self-types="./number.d.ts" */
|
|
2
|
-
//#region src/immutable/number.d.ts
|
|
3
2
|
/** `a + b + c + ...` */
|
|
4
3
|
export declare function add(...a: number[]): number;
|
|
5
4
|
export declare function add(...a: string[]): string;
|
|
@@ -12,5 +11,4 @@ export declare const divide: (a: number, ...b: number[]) => number;
|
|
|
12
11
|
/** `a ** b ** c ** ...` */
|
|
13
12
|
export declare const power: (a: number, ...b: number[]) => number;
|
|
14
13
|
/** clamp a number value between two other values */
|
|
15
|
-
export declare const clamp: (n: number, min: number, max: number) => number;
|
|
16
|
-
//#endregion
|
|
14
|
+
export declare const clamp: (n: number, min: number, max: number) => number;
|
package/dist/immutable/number.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./number.d.ts" */
|
|
2
|
-
|
|
2
|
+
// src/immutable/number.ts
|
|
3
3
|
function add(...a) {
|
|
4
4
|
let r = 0;
|
|
5
5
|
for (const n of a) r += n;
|
|
@@ -27,5 +27,4 @@ const power = (a, ...b) => {
|
|
|
27
27
|
};
|
|
28
28
|
/** clamp a number value between two other values */
|
|
29
29
|
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
30
|
-
//#endregion
|
|
31
30
|
export { add, clamp, divide, multiply, power, substract };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* @ts-self-types="./object.d.ts" */
|
|
2
2
|
import { Modify } from "../types.js";
|
|
3
3
|
import "../index.js";
|
|
4
|
-
//#region src/immutable/object.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Create a new subset object without the provided keys
|
|
7
6
|
*
|
|
@@ -56,5 +55,4 @@ export declare function merge<A extends object, B extends object>(a: A, b: B): M
|
|
|
56
55
|
export declare function merge<A extends object, B extends object, C extends object>(a: A, b: B, c: C): Modify<Modify<A, B>, C>;
|
|
57
56
|
export declare function merge<A extends object, B extends object, C extends object, D extends object>(a: A, b: B, c: C, d: D): Modify<Modify<Modify<A, B>, C>, D>;
|
|
58
57
|
export declare function merge<A extends object, B extends object, C extends object, D extends object, E extends object>(a: A, b: B, c: C, d: D, e: E): Modify<Modify<Modify<Modify<A, B>, C>, D>, E>;
|
|
59
|
-
export declare function merge<A extends object, B extends object, C extends object, D extends object, E extends object, F extends object>(a: A, b: B, c: C, d: D, e: E, f: F): Modify<Modify<Modify<Modify<Modify<A, B>, C>, D>, E>, F>;
|
|
60
|
-
//#endregion
|
|
58
|
+
export declare function merge<A extends object, B extends object, C extends object, D extends object, E extends object, F extends object>(a: A, b: B, c: C, d: D, e: E, f: F): Modify<Modify<Modify<Modify<Modify<A, B>, C>, D>, E>, F>;
|
package/dist/immutable/object.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @ts-self-types="./object.d.ts" */
|
|
2
2
|
import { shallowObjectCopy, withObjectCopy } from "./copy.js";
|
|
3
|
-
|
|
3
|
+
// src/immutable/object.ts
|
|
4
4
|
/**
|
|
5
5
|
* Create a new subset object without the provided keys
|
|
6
6
|
*
|
|
@@ -48,5 +48,4 @@ function merge(...objects) {
|
|
|
48
48
|
for (const obj of objects) Object.assign(result, obj);
|
|
49
49
|
return result;
|
|
50
50
|
}
|
|
51
|
-
//#endregion
|
|
52
51
|
export { get, merge, omit, pick, split };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/* @ts-self-types="./types.d.ts" */
|
|
2
2
|
import { ItemsOf } from "../types.js";
|
|
3
3
|
import "../index.js";
|
|
4
|
-
//#region src/immutable/types.d.ts
|
|
5
4
|
export type Predicate<T> = (item: T, index: number, array: readonly T[]) => boolean;
|
|
6
5
|
export type MappingFn<T, V> = (item: T, index: number, array: readonly T[]) => V;
|
|
7
6
|
export type FlattenArray<T> = T extends any[] ? FlattenArray<ItemsOf<T>> : T;
|
|
8
|
-
export type ModifyValue<O, K extends keyof O, V> = Omit<O, K> & { [key in K]: V; };
|
|
9
|
-
//#endregion
|
|
7
|
+
export type ModifyValue<O, K extends keyof O, V> = Omit<O, K> & { [key in K]: V; };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./update.d.ts" */
|
|
2
2
|
import { ModifyValue } from "./types.js";
|
|
3
|
-
//#region src/immutable/update.d.ts
|
|
4
3
|
export type UpdateSetter<O, K extends keyof O, V> = V | ((prev: O[K]) => V);
|
|
5
4
|
export type Update = {
|
|
6
5
|
<O extends object, K0 extends keyof O, K1 extends keyof O[K0], K2 extends keyof O[K0][K1], K3 extends keyof O[K0][K1][K2], K4 extends keyof O[K0][K1][K2][K3], V>(object: O, k0: K0, k1: K1, k2: K2, k3: K3, k4: K4, setter: UpdateSetter<O[K0][K1][K2][K3], K4, V>): ModifyValue<O, K0, ModifyValue<O[K0], K1, ModifyValue<O[K0][K1], K2, ModifyValue<O[K0][K1][K2], K3, ModifyValue<O[K0][K1][K2][K3], K4, V>>>>>;
|
|
@@ -29,5 +28,4 @@ export type Update = {
|
|
|
29
28
|
* original // { foo: { bar: { baz: 123 }}}
|
|
30
29
|
* newObj // { foo: { bar: { baz: 124 }}}
|
|
31
30
|
*/
|
|
32
|
-
export declare const update: Update;
|
|
33
|
-
//#endregion
|
|
31
|
+
export declare const update: Update;
|
package/dist/immutable/update.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @ts-self-types="./update.d.ts" */
|
|
2
2
|
import { withCopy } from "./copy.js";
|
|
3
|
-
|
|
3
|
+
// src/immutable/update.ts
|
|
4
4
|
/**
|
|
5
5
|
* Change single value in an object by key. Allows accessign nested objects by passing multiple keys.
|
|
6
6
|
*
|
|
@@ -26,5 +26,4 @@ const update = (...args) => withCopy(args[0], (obj) => {
|
|
|
26
26
|
else if (typeof args[2] === "function") obj[args[1]] = args[2](obj[args[1]]);
|
|
27
27
|
else obj[args[1]] = args[2];
|
|
28
28
|
});
|
|
29
|
-
//#endregion
|
|
30
29
|
export { update };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* @ts-self-types="./index.d.ts" */
|
|
2
2
|
import { AccessReturnTypes, AccessorArray, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NoInfer, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, Size, Tail, Truthy, UnboxLazy, UnionToIntersection, Values } from "./types.js";
|
|
3
3
|
import { Accessor, ComputeFunction, NoInfer as NoInfer$1, Setter, Signal, SignalOptions, Store, StoreSetter, createSignal, onCleanup } from "solid-js";
|
|
4
|
-
//#region src/index.d.ts
|
|
5
4
|
declare const isServer: boolean;
|
|
6
5
|
/** `true` in the browser, `false` on the server. */
|
|
7
6
|
export declare const isClient: boolean;
|
|
@@ -304,5 +303,4 @@ export declare function wrapSetter<T>(signal: Signal<T>, wrapper: (setter: Sette
|
|
|
304
303
|
export declare function wrapSetter<T>(store: [Store<T>, StoreSetter<T>], wrapper: (setter: StoreSetter<T>) => StoreSetter<T>): [Store<T>, StoreSetter<T>];
|
|
305
304
|
export declare function wrapSetter<T, S extends Signal<T> | [Store<T>, StoreSetter<T>] | [...Signal<T>, ...any[]] | [Store<T>, StoreSetter<T>, ...any[]]>(signalOrStore: S, wrapper: (setter: S[1]) => S[1]): S;
|
|
306
305
|
export declare function wrapSetter<T, S extends Signal<T> | [Store<T>, StoreSetter<T>] | readonly [...Signal<T>, ...any[]] | readonly [Store<T>, StoreSetter<T>, ...any[]]>(signalOrStore: S, wrapper: (setter: S[1]) => S[1]): S;
|
|
307
|
-
//#endregion
|
|
308
306
|
export { AccessReturnTypes, AccessorArray, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NoInfer, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, Size, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, isServer };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @ts-self-types="./index.d.ts" */
|
|
2
2
|
import { DEV, createSignal, getOwner, onCleanup, onSettled, sharedConfig, untrack } from "solid-js";
|
|
3
|
-
|
|
3
|
+
// src/index.ts
|
|
4
4
|
const isServer = typeof window === "undefined";
|
|
5
5
|
/** `true` in the browser, `false` on the server. */
|
|
6
6
|
const isClient = !isServer;
|
|
@@ -104,7 +104,8 @@ const accessArray = (list) => list.map((v) => access(v));
|
|
|
104
104
|
* @param fn
|
|
105
105
|
*/
|
|
106
106
|
const withAccess = (value, fn) => {
|
|
107
|
-
|
|
107
|
+
const _value = access(value);
|
|
108
|
+
_value != null && fn(_value);
|
|
108
109
|
};
|
|
109
110
|
/**
|
|
110
111
|
* Wraps a plain value in a zero-argument accessor `() => value`.
|
|
@@ -380,5 +381,4 @@ function wrapSetter(signalOrStore, wrapper) {
|
|
|
380
381
|
...signalOrStore.slice(2)
|
|
381
382
|
];
|
|
382
383
|
}
|
|
383
|
-
//#endregion
|
|
384
384
|
export { EQUALS_FALSE_OPTIONS, INTERNAL_OPTIONS, access, accessArray, accessWith, afterPaint, arrayEquals, asAccessor, asArray, chain, clamp, compare, contains, createCallbackStack, createHydratableSignal, createHydrateSignal, createIdGenerator, createMicrotask, createServerSafeSignal, defaultEquals, defer, entries, falseFn, filterNonNullable, globalRegistry, handleDiffArray, isClient, isDev, isNonNullable, isObject, isProd, isServer, json, keys, lines, ndjson, noop, number, ofClass, pipe, reverseChain, safe, trueFn, tryOnCleanup, withAccess, wrapSetter };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./types.d.ts" */
|
|
2
2
|
import { Accessor, Setter } from "solid-js";
|
|
3
|
-
//#region src/types.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Can be single or in an array
|
|
6
5
|
*/
|
|
@@ -74,4 +73,4 @@ export type UnboxLazy<T> = T extends (() => infer U) ? U : T;
|
|
|
74
73
|
type RawNarrow<T> = (T extends [] ? [] : never) | (T extends string | number | bigint | boolean ? T : never) | { [K in keyof T]: T[K] extends Function ? T[K] : RawNarrow<T[K]>; };
|
|
75
74
|
export type Narrow<T> = T extends [] ? T : RawNarrow<T>;
|
|
76
75
|
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
77
|
-
|
|
76
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solid-primitives/utils",
|
|
3
|
-
"version": "7.0.0-next.
|
|
3
|
+
"version": "7.0.0-next.8",
|
|
4
4
|
"description": "A bunch of reactive utility types and functions, for building primitives",
|
|
5
5
|
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -137,15 +137,15 @@
|
|
|
137
137
|
"gzip": 1591
|
|
138
138
|
},
|
|
139
139
|
"peerDependencies": {
|
|
140
|
-
"@solidjs/web": "^2.0.0-rc.
|
|
141
|
-
"solid-js": "^2.0.0-rc.
|
|
140
|
+
"@solidjs/web": "^2.0.0-rc.21",
|
|
141
|
+
"solid-js": "^2.0.0-rc.21"
|
|
142
142
|
},
|
|
143
143
|
"devDependencies": {
|
|
144
|
-
"@solidjs/web": "2.0.0-rc.
|
|
145
|
-
"solid-js": "2.0.0-rc.
|
|
144
|
+
"@solidjs/web": "2.0.0-rc.21",
|
|
145
|
+
"solid-js": "^2.0.0-rc.21"
|
|
146
146
|
},
|
|
147
147
|
"scripts": {
|
|
148
|
-
"dev": "node --import=@nothing-but/node-resolve-ts
|
|
148
|
+
"dev": "node --import=@nothing-but/node-resolve-ts ../../scripts/dev.ts",
|
|
149
149
|
"build": "pnpm -w build",
|
|
150
150
|
"vitest": "vitest -c ../../configs/vitest.config.ts",
|
|
151
151
|
"test": "pnpm run vitest",
|