@solid-primitives/utils 0.0.200 → 0.1.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.
- package/README.md +48 -1
- package/package.json +40 -18
- package/dist/cjs/index.js +0 -43
- package/dist/index.d.ts +0 -20
- package/dist/index.js +0 -30
package/README.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
1
|
# @solid-primitives/utils
|
|
2
2
|
|
|
3
|
-
Solid Primitives Utilities is a support and helper package for a number of primitives in our library. Please free to augment or
|
|
3
|
+
Solid Primitives Utilities is a support and helper package for a number of primitives in our library. Please free to augment or centralize useful utilities and methods in this package for sharing.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @solid-primitives/utils
|
|
9
|
+
# or
|
|
10
|
+
yarn add @solid-primitives/utils
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Package Entries
|
|
14
|
+
|
|
15
|
+
- [`*` - `@solid-primitives/utils`](https://github.com/davedbase/solid-primitives/blob/main/packages/utils/src/index.ts) - General utilities.
|
|
16
|
+
- [`/fp` - `@solid-primitives/utils/fp`](https://github.com/davedbase/solid-primitives/blob/main/packages/utils/src/fp.ts) - Helpers for making changes to immutable data.
|
|
17
|
+
- [`/setter` - `@solid-primitives/utils/setter`](https://github.com/davedbase/solid-primitives/blob/main/packages/utils/src/setter.ts) - Modified helpers from the `/fp`, but optimized for usage with signal setters.
|
|
18
|
+
|
|
19
|
+
Import accordingly.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { access, promiseTimeout } from "@solid-primitives/utils";
|
|
23
|
+
|
|
24
|
+
// between these two some function names will overlap.
|
|
25
|
+
import { pick, omit, filter } from "@solid-primitives/utils/fp";
|
|
26
|
+
import { push, filter, drop } from "@solid-primitives/utils/setter";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Changelog
|
|
30
|
+
|
|
31
|
+
<details>
|
|
32
|
+
<summary><b>Expand Changelog</b></summary>
|
|
33
|
+
|
|
34
|
+
0.0.100
|
|
35
|
+
|
|
36
|
+
First commit of the timer primitive.
|
|
37
|
+
|
|
38
|
+
0.0.250
|
|
39
|
+
|
|
40
|
+
Republished version with better ESM support and build tooling.
|
|
41
|
+
|
|
42
|
+
0.0.260
|
|
43
|
+
|
|
44
|
+
Added comments for util methods.
|
|
45
|
+
|
|
46
|
+
0.1.0
|
|
47
|
+
|
|
48
|
+
Add `/fp` and `/setter` export entries. Add `destore` and `raceTimeout` util. More jsdoc.
|
|
49
|
+
|
|
50
|
+
</details>
|
package/package.json
CHANGED
|
@@ -1,32 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solid-primitives/utils",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "A bunch of reactive utility types and functions, for building primitives with Solid.js",
|
|
5
5
|
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/davedbase/solid-primitives/utils#readme",
|
|
7
|
+
"homepage": "https://github.com/davedbase/solid-primitives/tree/main/packages/utils#readme",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/davedbase/solid-primitives.git"
|
|
11
11
|
},
|
|
12
12
|
"private": false,
|
|
13
|
-
"
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/index.cjs",
|
|
14
16
|
"module": "dist/index.js",
|
|
15
17
|
"types": "dist/index.d.ts",
|
|
16
18
|
"files": [
|
|
17
19
|
"dist"
|
|
18
20
|
],
|
|
19
21
|
"exports": {
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"require": "./dist/index.cjs",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./fp": {
|
|
28
|
+
"types": "./dist/fp.d.ts",
|
|
29
|
+
"require": "./dist/fp.cjs",
|
|
30
|
+
"import": "./dist/fp.js"
|
|
31
|
+
},
|
|
32
|
+
"./setter": {
|
|
33
|
+
"types": "./dist/setter.d.ts",
|
|
34
|
+
"require": "./dist/setter.cjs",
|
|
35
|
+
"import": "./dist/setter.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"typesVersions": {
|
|
39
|
+
"*": {
|
|
40
|
+
"fp": [
|
|
41
|
+
"./dist/fp.d.ts"
|
|
42
|
+
],
|
|
43
|
+
"setter": [
|
|
44
|
+
"./dist/setter.d.ts"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
23
47
|
},
|
|
24
|
-
"sideEffects": false,
|
|
25
48
|
"scripts": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"test": "uvu -r solid-register"
|
|
49
|
+
"build": "tsup",
|
|
50
|
+
"test": "uvu -r solid-register",
|
|
51
|
+
"watch-test": "watchlist src test -- npm test"
|
|
30
52
|
},
|
|
31
53
|
"keywords": [
|
|
32
54
|
"utilities",
|
|
@@ -35,15 +57,15 @@
|
|
|
35
57
|
"primitives"
|
|
36
58
|
],
|
|
37
59
|
"devDependencies": {
|
|
38
|
-
"jsdom": "^
|
|
39
|
-
"prettier": "^2.
|
|
40
|
-
"rimraf": "^3.0.2",
|
|
60
|
+
"jsdom": "^19.0.0",
|
|
61
|
+
"prettier": "^2.5.1",
|
|
41
62
|
"solid-register": "^0.0.18",
|
|
42
63
|
"tslib": "^2.3.1",
|
|
43
|
-
"
|
|
44
|
-
"uvu": "^0.5.2"
|
|
64
|
+
"tsup": "^5.11.0",
|
|
65
|
+
"uvu": "^0.5.2",
|
|
66
|
+
"watchlist": "^0.3.1"
|
|
45
67
|
},
|
|
46
68
|
"peerDependencies": {
|
|
47
|
-
"solid-js": "^1.2.
|
|
69
|
+
"solid-js": "^1.2.6"
|
|
48
70
|
}
|
|
49
|
-
}
|
|
71
|
+
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toArray = exports.toInt = exports.toFloat = exports.concat = exports.stringConcat = exports.objectOmit = exports.promiseTimeout = exports.withAccess = exports.accessAsArray = exports.access = exports.isClient = void 0;
|
|
4
|
-
exports.isClient = typeof window !== "undefined";
|
|
5
|
-
const access = (v) => typeof v === "function" ? v() : v;
|
|
6
|
-
exports.access = access;
|
|
7
|
-
const accessAsArray = (value) => {
|
|
8
|
-
const _value = (0, exports.access)(value);
|
|
9
|
-
return Array.isArray(_value) ? _value : [_value];
|
|
10
|
-
};
|
|
11
|
-
exports.accessAsArray = accessAsArray;
|
|
12
|
-
const withAccess = (value, fn) => {
|
|
13
|
-
const _value = (0, exports.access)(value);
|
|
14
|
-
if (typeof _value !== "undefined" && _value !== null)
|
|
15
|
-
fn(_value);
|
|
16
|
-
};
|
|
17
|
-
exports.withAccess = withAccess;
|
|
18
|
-
const promiseTimeout = (ms, throwOnTimeout = false, reason = "Timeout") => new Promise((resolve, reject) => throwOnTimeout ? setTimeout(() => reject(reason), ms) : setTimeout(resolve, ms));
|
|
19
|
-
exports.promiseTimeout = promiseTimeout;
|
|
20
|
-
const objectOmit = (object, ...keys) => {
|
|
21
|
-
const copy = Object.assign({}, object);
|
|
22
|
-
for (const key of keys) {
|
|
23
|
-
delete copy[key];
|
|
24
|
-
}
|
|
25
|
-
return copy;
|
|
26
|
-
};
|
|
27
|
-
exports.objectOmit = objectOmit;
|
|
28
|
-
//
|
|
29
|
-
// SIGNAL BUILDERS:
|
|
30
|
-
//
|
|
31
|
-
const stringConcat = (...a) => a.reduce((t, c) => t + (0, exports.access)(c), "");
|
|
32
|
-
exports.stringConcat = stringConcat;
|
|
33
|
-
const concat = (...a) => a.reduce((t, c) => {
|
|
34
|
-
const v = (0, exports.access)(c);
|
|
35
|
-
return Array.isArray(v) ? [...t, ...v] : [...t, v];
|
|
36
|
-
}, []);
|
|
37
|
-
exports.concat = concat;
|
|
38
|
-
const toFloat = (string) => Number.parseFloat((0, exports.access)(string));
|
|
39
|
-
exports.toFloat = toFloat;
|
|
40
|
-
const toInt = (string, radix) => Number.parseInt((0, exports.access)(string), radix);
|
|
41
|
-
exports.toInt = toInt;
|
|
42
|
-
const toArray = (...a) => a.map(v => (0, exports.access)(v));
|
|
43
|
-
exports.toArray = toArray;
|
package/dist/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Accessor } from "solid-js";
|
|
2
|
-
export declare type Fn<R = void> = () => R;
|
|
3
|
-
export declare type Many<T> = T | T[];
|
|
4
|
-
/**
|
|
5
|
-
* Infers the element type of an array
|
|
6
|
-
*/
|
|
7
|
-
export declare type ItemsOf<T> = T extends (infer E)[] ? E : never;
|
|
8
|
-
export declare type MaybeAccessor<T> = T | Accessor<T>;
|
|
9
|
-
export declare type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends Fn ? ReturnType<T> : T;
|
|
10
|
-
export declare const isClient: boolean;
|
|
11
|
-
export declare const access: <T extends unknown>(v: T) => MaybeAccessorValue<T>;
|
|
12
|
-
export declare const accessAsArray: <T extends unknown, V = MaybeAccessorValue<T>>(value: T) => V extends any[] ? V : V[];
|
|
13
|
-
export declare const withAccess: <T, A extends MaybeAccessor<T>, V = MaybeAccessorValue<A>>(value: A, fn: (value: NonNullable<V>) => void) => void;
|
|
14
|
-
export declare const promiseTimeout: (ms: number, throwOnTimeout?: boolean, reason?: string) => Promise<void>;
|
|
15
|
-
export declare const objectOmit: <T extends Object, K extends (keyof T)[]>(object: T, ...keys: K) => Omit<T, ItemsOf<K>>;
|
|
16
|
-
export declare const stringConcat: (...a: MaybeAccessor<any>[]) => string;
|
|
17
|
-
export declare const concat: <A extends any[], V = MaybeAccessorValue<ItemsOf<A>>>(...a: A) => (V extends any[] ? ItemsOf<V> : V)[];
|
|
18
|
-
export declare const toFloat: (string: MaybeAccessor<string>) => number;
|
|
19
|
-
export declare const toInt: (string: MaybeAccessor<string>, radix?: number | undefined) => number;
|
|
20
|
-
export declare const toArray: <A extends any[]>(...a: A) => MaybeAccessorValue<ItemsOf<A>>[];
|
package/dist/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const isClient = typeof window !== "undefined";
|
|
2
|
-
export const access = (v) => typeof v === "function" ? v() : v;
|
|
3
|
-
export const accessAsArray = (value) => {
|
|
4
|
-
const _value = access(value);
|
|
5
|
-
return Array.isArray(_value) ? _value : [_value];
|
|
6
|
-
};
|
|
7
|
-
export const withAccess = (value, fn) => {
|
|
8
|
-
const _value = access(value);
|
|
9
|
-
if (typeof _value !== "undefined" && _value !== null)
|
|
10
|
-
fn(_value);
|
|
11
|
-
};
|
|
12
|
-
export const promiseTimeout = (ms, throwOnTimeout = false, reason = "Timeout") => new Promise((resolve, reject) => throwOnTimeout ? setTimeout(() => reject(reason), ms) : setTimeout(resolve, ms));
|
|
13
|
-
export const objectOmit = (object, ...keys) => {
|
|
14
|
-
const copy = Object.assign({}, object);
|
|
15
|
-
for (const key of keys) {
|
|
16
|
-
delete copy[key];
|
|
17
|
-
}
|
|
18
|
-
return copy;
|
|
19
|
-
};
|
|
20
|
-
//
|
|
21
|
-
// SIGNAL BUILDERS:
|
|
22
|
-
//
|
|
23
|
-
export const stringConcat = (...a) => a.reduce((t, c) => t + access(c), "");
|
|
24
|
-
export const concat = (...a) => a.reduce((t, c) => {
|
|
25
|
-
const v = access(c);
|
|
26
|
-
return Array.isArray(v) ? [...t, ...v] : [...t, v];
|
|
27
|
-
}, []);
|
|
28
|
-
export const toFloat = (string) => Number.parseFloat(access(string));
|
|
29
|
-
export const toInt = (string, radix) => Number.parseInt(access(string), radix);
|
|
30
|
-
export const toArray = (...a) => a.map(v => access(v));
|