@solid-primitives/utils 0.0.200 → 0.0.250
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 +15 -0
- package/dist/index.cjs +63 -0
- package/dist/index.d.ts +20 -17
- package/dist/index.js +37 -26
- package/package.json +7 -15
- package/dist/cjs/index.js +0 -43
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
# @solid-primitives/utils
|
|
2
2
|
|
|
3
3
|
Solid Primitives Utilities is a support and helper package for a number of primitives in our library. Please free to augment or centralise useful utilities and methods in this package for sharing.
|
|
4
|
+
|
|
5
|
+
## Changelog
|
|
6
|
+
|
|
7
|
+
<details>
|
|
8
|
+
<summary><b>Expand Changelog</b></summary>
|
|
9
|
+
|
|
10
|
+
0.0.100
|
|
11
|
+
|
|
12
|
+
First commit of the timer primitive.
|
|
13
|
+
|
|
14
|
+
0.0.250
|
|
15
|
+
|
|
16
|
+
Republished version with better ESM support and build tooling.
|
|
17
|
+
|
|
18
|
+
</details>
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
__markAsModule(target);
|
|
5
|
+
for (var name in all)
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// src/index.ts
|
|
10
|
+
__export(exports, {
|
|
11
|
+
access: () => access,
|
|
12
|
+
accessAsArray: () => accessAsArray,
|
|
13
|
+
concat: () => concat,
|
|
14
|
+
isClient: () => isClient,
|
|
15
|
+
objectOmit: () => objectOmit,
|
|
16
|
+
promiseTimeout: () => promiseTimeout,
|
|
17
|
+
stringConcat: () => stringConcat,
|
|
18
|
+
toArray: () => toArray,
|
|
19
|
+
toFloat: () => toFloat,
|
|
20
|
+
toInt: () => toInt,
|
|
21
|
+
withAccess: () => withAccess
|
|
22
|
+
});
|
|
23
|
+
var isClient = typeof window !== "undefined";
|
|
24
|
+
var access = (v) => typeof v === "function" ? v() : v;
|
|
25
|
+
var accessAsArray = (value) => {
|
|
26
|
+
const _value = access(value);
|
|
27
|
+
return Array.isArray(_value) ? _value : [_value];
|
|
28
|
+
};
|
|
29
|
+
var withAccess = (value, fn) => {
|
|
30
|
+
const _value = access(value);
|
|
31
|
+
if (typeof _value !== "undefined" && _value !== null)
|
|
32
|
+
fn(_value);
|
|
33
|
+
};
|
|
34
|
+
var promiseTimeout = (ms, throwOnTimeout = false, reason = "Timeout") => new Promise((resolve, reject) => throwOnTimeout ? setTimeout(() => reject(reason), ms) : setTimeout(resolve, ms));
|
|
35
|
+
var objectOmit = (object, ...keys) => {
|
|
36
|
+
const copy = Object.assign({}, object);
|
|
37
|
+
for (const key of keys) {
|
|
38
|
+
delete copy[key];
|
|
39
|
+
}
|
|
40
|
+
return copy;
|
|
41
|
+
};
|
|
42
|
+
var stringConcat = (...a) => a.reduce((t, c) => t + access(c), "");
|
|
43
|
+
var concat = (...a) => a.reduce((t, c) => {
|
|
44
|
+
const v = access(c);
|
|
45
|
+
return Array.isArray(v) ? [...t, ...v] : [...t, v];
|
|
46
|
+
}, []);
|
|
47
|
+
var toFloat = (string) => Number.parseFloat(access(string));
|
|
48
|
+
var toInt = (string, radix) => Number.parseInt(access(string), radix);
|
|
49
|
+
var toArray = (...a) => a.map((v) => access(v));
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
access,
|
|
53
|
+
accessAsArray,
|
|
54
|
+
concat,
|
|
55
|
+
isClient,
|
|
56
|
+
objectOmit,
|
|
57
|
+
promiseTimeout,
|
|
58
|
+
stringConcat,
|
|
59
|
+
toArray,
|
|
60
|
+
toFloat,
|
|
61
|
+
toInt,
|
|
62
|
+
withAccess
|
|
63
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
|
|
3
|
+
declare type Fn<R = void> = () => R;
|
|
4
|
+
declare type Many<T> = T | T[];
|
|
4
5
|
/**
|
|
5
6
|
* Infers the element type of an array
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
declare type ItemsOf<T> = T extends (infer E)[] ? E : never;
|
|
9
|
+
declare type MaybeAccessor<T> = T | Accessor<T>;
|
|
10
|
+
declare type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends Fn ? ReturnType<T> : T;
|
|
11
|
+
declare const isClient: boolean;
|
|
12
|
+
declare const access: <T extends unknown>(v: T) => MaybeAccessorValue<T>;
|
|
13
|
+
declare const accessAsArray: <T extends unknown, V = MaybeAccessorValue<T>>(value: T) => V extends any[] ? V : V[];
|
|
14
|
+
declare const withAccess: <T, A extends MaybeAccessor<T>, V = MaybeAccessorValue<A>>(value: A, fn: (value: NonNullable<V>) => void) => void;
|
|
15
|
+
declare const promiseTimeout: (ms: number, throwOnTimeout?: boolean, reason?: string) => Promise<void>;
|
|
16
|
+
declare const objectOmit: <T extends Object, K extends (keyof T)[]>(object: T, ...keys: K) => Omit<T, ItemsOf<K>>;
|
|
17
|
+
declare const stringConcat: (...a: MaybeAccessor<any>[]) => string;
|
|
18
|
+
declare const concat: <A extends any[], V = MaybeAccessorValue<ItemsOf<A>>>(...a: A) => (V extends any[] ? ItemsOf<V> : V)[];
|
|
19
|
+
declare const toFloat: (string: MaybeAccessor<string>) => number;
|
|
20
|
+
declare const toInt: (string: MaybeAccessor<string>, radix?: number | undefined) => number;
|
|
21
|
+
declare const toArray: <A extends any[]>(...a: A) => MaybeAccessorValue<ItemsOf<A>>[];
|
|
22
|
+
|
|
23
|
+
export { Fn, ItemsOf, Many, MaybeAccessor, MaybeAccessorValue, access, accessAsArray, concat, isClient, objectOmit, promiseTimeout, stringConcat, toArray, toFloat, toInt, withAccess };
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var isClient = typeof window !== "undefined";
|
|
3
|
+
var access = (v) => typeof v === "function" ? v() : v;
|
|
4
|
+
var accessAsArray = (value) => {
|
|
5
|
+
const _value = access(value);
|
|
6
|
+
return Array.isArray(_value) ? _value : [_value];
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
var withAccess = (value, fn) => {
|
|
9
|
+
const _value = access(value);
|
|
10
|
+
if (typeof _value !== "undefined" && _value !== null)
|
|
11
|
+
fn(_value);
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
var promiseTimeout = (ms, throwOnTimeout = false, reason = "Timeout") => new Promise((resolve, reject) => throwOnTimeout ? setTimeout(() => reject(reason), ms) : setTimeout(resolve, ms));
|
|
14
|
+
var objectOmit = (object, ...keys) => {
|
|
15
|
+
const copy = Object.assign({}, object);
|
|
16
|
+
for (const key of keys) {
|
|
17
|
+
delete copy[key];
|
|
18
|
+
}
|
|
19
|
+
return copy;
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const concat = (...a) => a.reduce((t, c) => {
|
|
25
|
-
const v = access(c);
|
|
26
|
-
return Array.isArray(v) ? [...t, ...v] : [...t, v];
|
|
21
|
+
var stringConcat = (...a) => a.reduce((t, c) => t + access(c), "");
|
|
22
|
+
var concat = (...a) => a.reduce((t, c) => {
|
|
23
|
+
const v = access(c);
|
|
24
|
+
return Array.isArray(v) ? [...t, ...v] : [...t, v];
|
|
27
25
|
}, []);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
var toFloat = (string) => Number.parseFloat(access(string));
|
|
27
|
+
var toInt = (string, radix) => Number.parseInt(access(string), radix);
|
|
28
|
+
var toArray = (...a) => a.map((v) => access(v));
|
|
29
|
+
export {
|
|
30
|
+
access,
|
|
31
|
+
accessAsArray,
|
|
32
|
+
concat,
|
|
33
|
+
isClient,
|
|
34
|
+
objectOmit,
|
|
35
|
+
promiseTimeout,
|
|
36
|
+
stringConcat,
|
|
37
|
+
toArray,
|
|
38
|
+
toFloat,
|
|
39
|
+
toInt,
|
|
40
|
+
withAccess
|
|
41
|
+
};
|
package/package.json
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solid-primitives/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.250",
|
|
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
|
-
"exports": {
|
|
20
|
-
"require": "./dist/cjs/index.cjs",
|
|
21
|
-
"import": "./dist/index.js",
|
|
22
|
-
"default": "./dist/index.js"
|
|
23
|
-
},
|
|
24
|
-
"sideEffects": false,
|
|
25
21
|
"scripts": {
|
|
26
|
-
"
|
|
27
|
-
"clean": "rimraf dist/",
|
|
28
|
-
"build": "tsc && tsc -p ./tsconfig-cjs.json",
|
|
29
|
-
"test": "uvu -r solid-register"
|
|
22
|
+
"build": "tsup"
|
|
30
23
|
},
|
|
31
24
|
"keywords": [
|
|
32
25
|
"utilities",
|
|
@@ -37,10 +30,9 @@
|
|
|
37
30
|
"devDependencies": {
|
|
38
31
|
"jsdom": "^18.1.1",
|
|
39
32
|
"prettier": "^2.4.1",
|
|
40
|
-
"rimraf": "^3.0.2",
|
|
41
33
|
"solid-register": "^0.0.18",
|
|
42
34
|
"tslib": "^2.3.1",
|
|
43
|
-
"
|
|
35
|
+
"tsup": "^5.10.1",
|
|
44
36
|
"uvu": "^0.5.2"
|
|
45
37
|
},
|
|
46
38
|
"peerDependencies": {
|
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;
|