@solid-primitives/utils 1.5.1 → 2.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Solid Primitives Working Group
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Solid Primitives Working Group
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,46 +1,46 @@
1
- <p>
2
- <img width="100%" src="https://assets.solidjs.com/banner?type=Primitives&background=tiles&project=Utils" alt="Solid Primitives Utils">
3
- </p>
4
-
5
- # @solid-primitives/utils
6
-
7
- 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.
8
-
9
- ## Installation
10
-
11
- ```bash
12
- npm install @solid-primitives/utils
13
- # or
14
- yarn add @solid-primitives/utils
15
- ```
16
-
17
- ## Changelog
18
-
19
- <details>
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>
1
+ <p>
2
+ <img width="100%" src="https://assets.solidjs.com/banner?type=Primitives&background=tiles&project=Utils" alt="Solid Primitives Utils">
3
+ </p>
4
+
5
+ # @solid-primitives/utils
6
+
7
+ 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.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @solid-primitives/utils
13
+ # or
14
+ yarn add @solid-primitives/utils
15
+ ```
16
+
17
+ ## Changelog
18
+
19
+ <details>
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>
package/dist/index.cjs CHANGED
@@ -76,10 +76,12 @@ function isObject(value) {
76
76
  return value !== null && (typeof value === "object" || typeof value === "function");
77
77
  }
78
78
  var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
79
- function chain(...callbacks) {
79
+ function chain(callbacks) {
80
80
  return (...args) => {
81
- for (const callback of callbacks)
82
- callback(...args);
81
+ for (const callback of callbacks) {
82
+ if (typeof callback === "function")
83
+ callback(...args);
84
+ }
83
85
  };
84
86
  }
85
87
  var clamp = (n, min, max) => Math.min(Math.max(n, min), max);
package/dist/index.d.ts CHANGED
@@ -66,6 +66,8 @@ declare type RequiredKeys<T> = keyof {
66
66
  [_ in K]: unknown;
67
67
  } ? K : never]: 0;
68
68
  };
69
+ /** Remove the first item of a tuple [1, 2, 3, 4] => [2, 3, 4] */
70
+ declare type Tail<T extends any[]> = ((...t: T) => void) extends (x: any, ...u: infer U) => void ? U : never;
69
71
  /** `A | B => A & B` */
70
72
  declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
71
73
  declare type ExtractIfPossible<T, U> = Extract<T, U> extends never ? U : Extract<T, U>;
@@ -108,7 +110,9 @@ declare const compare: (a: any, b: any) => number;
108
110
  /**
109
111
  * Returns a function that will call all functions in the order they were chained with the same arguments.
110
112
  */
111
- declare function chain<Args extends [] | any[]>(...callbacks: ((...args: Args) => any)[]): (...args: Args) => void;
113
+ declare function chain<Args extends [] | any[]>(callbacks: {
114
+ [Symbol.iterator](): IterableIterator<((...args: Args) => any) | undefined>;
115
+ }): (...args: Args) => void;
112
116
  declare const clamp: (n: number, min: number, max: number) => number;
113
117
  /**
114
118
  * Accesses the value of a MaybeAccessor
@@ -252,4 +256,4 @@ declare type StaticStoreSetter<T extends Readonly<AnyStatic>> = {
252
256
  */
253
257
  declare function createStaticStore<T extends Readonly<AnyStatic>>(init: T): [access: T, write: StaticStoreSetter<T>];
254
258
 
255
- export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Definite, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterValue, Simplify, StaticStoreSetter, Trigger, TriggerCache, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, createTrigger, createTriggerCache, entries, forEachEntry, isClient, isDev, isObject, isProd, keys, noop, ofClass, onRootCleanup, promiseTimeout, raceTimeout, warn, withAccess };
259
+ export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Definite, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterValue, Simplify, StaticStoreSetter, Tail, Trigger, TriggerCache, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, createTrigger, createTriggerCache, entries, forEachEntry, isClient, isDev, isObject, isProd, keys, noop, ofClass, onRootCleanup, promiseTimeout, raceTimeout, warn, withAccess };
package/dist/index.js CHANGED
@@ -28,10 +28,12 @@ function isObject(value) {
28
28
  return value !== null && (typeof value === "object" || typeof value === "function");
29
29
  }
30
30
  var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
31
- function chain(...callbacks) {
31
+ function chain(callbacks) {
32
32
  return (...args) => {
33
- for (const callback of callbacks)
34
- callback(...args);
33
+ for (const callback of callbacks) {
34
+ if (typeof callback === "function")
35
+ callback(...args);
36
+ }
35
37
  };
36
38
  }
37
39
  var clamp = (n, min, max) => Math.min(Math.max(n, min), max);
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
- {
2
- "name": "@solid-primitives/utils",
3
- "version": "1.5.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": "^19.0.0",
37
- "prettier": "^2.5.1",
38
- "solid-register": "^0.1.5",
39
- "tslib": "^2.3.1",
40
- "tsup": "^5.11.0",
41
- "uvu": "^0.5.2",
42
- "watchlist": "^0.3.1"
43
- },
44
- "peerDependencies": {
45
- "solid-js": "^1.3.1"
46
- }
47
- }
1
+ {
2
+ "name": "@solid-primitives/utils",
3
+ "version": "2.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": "^19.0.0",
37
+ "prettier": "^2.5.1",
38
+ "solid-register": "^0.2.5",
39
+ "tslib": "^2.3.1",
40
+ "tsup": "^5.11.0",
41
+ "uvu": "^0.5.2",
42
+ "watchlist": "^0.3.1"
43
+ },
44
+ "peerDependencies": {
45
+ "solid-js": "^1.4.1"
46
+ }
47
+ }