@solid-primitives/utils 0.0.150 → 0.0.200
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 +2 -0
- package/dist/cjs/index.js +14 -5
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12 -4
- package/package.json +4 -4
package/README.md
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toArray = exports.toInt = exports.toFloat = exports.concat = exports.stringConcat = exports.promiseTimeout = exports.withAccess = exports.accessAsArray = exports.access = void 0;
|
|
4
|
-
|
|
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;
|
|
5
6
|
exports.access = access;
|
|
6
7
|
const accessAsArray = (value) => {
|
|
7
8
|
const _value = (0, exports.access)(value);
|
|
@@ -10,16 +11,24 @@ const accessAsArray = (value) => {
|
|
|
10
11
|
exports.accessAsArray = accessAsArray;
|
|
11
12
|
const withAccess = (value, fn) => {
|
|
12
13
|
const _value = (0, exports.access)(value);
|
|
13
|
-
if (typeof _value !==
|
|
14
|
+
if (typeof _value !== "undefined" && _value !== null)
|
|
14
15
|
fn(_value);
|
|
15
16
|
};
|
|
16
17
|
exports.withAccess = withAccess;
|
|
17
|
-
const promiseTimeout = (ms, throwOnTimeout = false, reason =
|
|
18
|
+
const promiseTimeout = (ms, throwOnTimeout = false, reason = "Timeout") => new Promise((resolve, reject) => throwOnTimeout ? setTimeout(() => reject(reason), ms) : setTimeout(resolve, ms));
|
|
18
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;
|
|
19
28
|
//
|
|
20
29
|
// SIGNAL BUILDERS:
|
|
21
30
|
//
|
|
22
|
-
const stringConcat = (...a) => a.reduce((t, c) => t + (0, exports.access)(c),
|
|
31
|
+
const stringConcat = (...a) => a.reduce((t, c) => t + (0, exports.access)(c), "");
|
|
23
32
|
exports.stringConcat = stringConcat;
|
|
24
33
|
const concat = (...a) => a.reduce((t, c) => {
|
|
25
34
|
const v = (0, exports.access)(c);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Accessor } from
|
|
1
|
+
import type { Accessor } from "solid-js";
|
|
2
2
|
export declare type Fn<R = void> = () => R;
|
|
3
3
|
export declare type Many<T> = T | T[];
|
|
4
4
|
/**
|
|
@@ -7,10 +7,12 @@ export declare type Many<T> = T | T[];
|
|
|
7
7
|
export declare type ItemsOf<T> = T extends (infer E)[] ? E : never;
|
|
8
8
|
export declare type MaybeAccessor<T> = T | Accessor<T>;
|
|
9
9
|
export declare type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends Fn ? ReturnType<T> : T;
|
|
10
|
+
export declare const isClient: boolean;
|
|
10
11
|
export declare const access: <T extends unknown>(v: T) => MaybeAccessorValue<T>;
|
|
11
12
|
export declare const accessAsArray: <T extends unknown, V = MaybeAccessorValue<T>>(value: T) => V extends any[] ? V : V[];
|
|
12
13
|
export declare const withAccess: <T, A extends MaybeAccessor<T>, V = MaybeAccessorValue<A>>(value: A, fn: (value: NonNullable<V>) => void) => void;
|
|
13
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>>;
|
|
14
16
|
export declare const stringConcat: (...a: MaybeAccessor<any>[]) => string;
|
|
15
17
|
export declare const concat: <A extends any[], V = MaybeAccessorValue<ItemsOf<A>>>(...a: A) => (V extends any[] ? ItemsOf<V> : V)[];
|
|
16
18
|
export declare const toFloat: (string: MaybeAccessor<string>) => number;
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const isClient = typeof window !== "undefined";
|
|
2
|
+
export const access = (v) => typeof v === "function" ? v() : v;
|
|
2
3
|
export const accessAsArray = (value) => {
|
|
3
4
|
const _value = access(value);
|
|
4
5
|
return Array.isArray(_value) ? _value : [_value];
|
|
5
6
|
};
|
|
6
7
|
export const withAccess = (value, fn) => {
|
|
7
8
|
const _value = access(value);
|
|
8
|
-
if (typeof _value !==
|
|
9
|
+
if (typeof _value !== "undefined" && _value !== null)
|
|
9
10
|
fn(_value);
|
|
10
11
|
};
|
|
11
|
-
export const promiseTimeout = (ms, throwOnTimeout = false, reason =
|
|
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
|
+
};
|
|
12
20
|
//
|
|
13
21
|
// SIGNAL BUILDERS:
|
|
14
22
|
//
|
|
15
|
-
export const stringConcat = (...a) => a.reduce((t, c) => t + access(c),
|
|
23
|
+
export const stringConcat = (...a) => a.reduce((t, c) => t + access(c), "");
|
|
16
24
|
export const concat = (...a) => a.reduce((t, c) => {
|
|
17
25
|
const v = access(c);
|
|
18
26
|
return Array.isArray(v) ? [...t, ...v] : [...t, v];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solid-primitives/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.200",
|
|
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",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"url": "git+https://github.com/davedbase/solid-primitives.git"
|
|
11
11
|
},
|
|
12
12
|
"private": false,
|
|
13
|
-
"main": "dist/index.
|
|
13
|
+
"main": "dist/cjs/index.cjs",
|
|
14
14
|
"module": "dist/index.js",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"exports": {
|
|
20
|
-
"require": "./dist/cjs/index.
|
|
20
|
+
"require": "./dist/cjs/index.cjs",
|
|
21
21
|
"import": "./dist/index.js",
|
|
22
22
|
"default": "./dist/index.js"
|
|
23
23
|
},
|
|
@@ -46,4 +46,4 @@
|
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"solid-js": "^1.2.5"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|