@solid-primitives/utils 2.0.0 → 2.0.3

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/index.cjs CHANGED
@@ -53,7 +53,7 @@ __export(src_exports, {
53
53
  isDev: () => isDev,
54
54
  isObject: () => isObject,
55
55
  isProd: () => isProd,
56
- isServer: () => import_web.isServer,
56
+ isServer: () => isServer,
57
57
  keys: () => keys,
58
58
  noop: () => noop,
59
59
  ofClass: () => ofClass,
@@ -67,7 +67,8 @@ module.exports = __toCommonJS(src_exports);
67
67
  var import_solid_js = require("solid-js");
68
68
  var import_web = require("solid-js/web");
69
69
  var noop = () => void 0;
70
- var isClient = !import_web.isServer;
70
+ var isServer = import_web.isServer;
71
+ var isClient = !isServer;
71
72
  var isDev = import_solid_js.DEV && isClient;
72
73
  var isProd = !isDev;
73
74
  var warn = (...a) => isDev && console.warn(...a);
@@ -78,8 +79,10 @@ function isObject(value) {
78
79
  var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
79
80
  function chain(callbacks) {
80
81
  return (...args) => {
81
- for (const callback of callbacks)
82
- callback(...args);
82
+ for (const callback of callbacks) {
83
+ if (typeof callback === "function")
84
+ callback(...args);
85
+ }
83
86
  };
84
87
  }
85
88
  var clamp = (n, min, max) => Math.min(Math.max(n, min), max);
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Accessor, Setter, onCleanup } from 'solid-js';
2
2
  import { BaseOptions } from 'solid-js/types/reactive/signal';
3
- export { isServer } from 'solid-js/web';
4
3
 
5
4
  /**
6
5
  * Can be single or in an array
@@ -54,6 +53,10 @@ declare type NonIterable<T> = T & {
54
53
  declare type Definite<T> = {
55
54
  [K in keyof T]-?: T[K];
56
55
  };
56
+ /** An opposite of `Readonly`. Makes all the params mutable. */
57
+ declare type Mutable<T> = {
58
+ -readonly [K in keyof T]: T[K];
59
+ };
57
60
  /** Unwraps the type definition of an object, making it more readable */
58
61
  declare type Simplify<T> = T extends object ? {
59
62
  [K in keyof T]: T[K];
@@ -92,8 +95,8 @@ declare type Position = {
92
95
 
93
96
  /** no operation */
94
97
  declare const noop: Noop;
98
+ declare const isServer: boolean;
95
99
  declare const isClient = true;
96
-
97
100
  /** development environment */
98
101
  declare const isDev = true;
99
102
  /** production environment */
@@ -111,7 +114,7 @@ declare const compare: (a: any, b: any) => number;
111
114
  * Returns a function that will call all functions in the order they were chained with the same arguments.
112
115
  */
113
116
  declare function chain<Args extends [] | any[]>(callbacks: {
114
- [Symbol.iterator](): IterableIterator<(...args: Args) => any>;
117
+ [Symbol.iterator](): IterableIterator<((...args: Args) => any) | undefined>;
115
118
  }): (...args: Args) => void;
116
119
  declare const clamp: (n: number, min: number, max: number) => number;
117
120
  /**
@@ -256,4 +259,4 @@ declare type StaticStoreSetter<T extends Readonly<AnyStatic>> = {
256
259
  */
257
260
  declare function createStaticStore<T extends Readonly<AnyStatic>>(init: T): [access: T, write: StaticStoreSetter<T>];
258
261
 
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 };
262
+ export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Definite, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Mutable, 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, isServer, keys, noop, ofClass, onRootCleanup, promiseTimeout, raceTimeout, warn, withAccess };
package/dist/index.js CHANGED
@@ -17,8 +17,9 @@ var __spreadValues = (a, b) => {
17
17
 
18
18
  // src/index.ts
19
19
  import { getOwner, onCleanup, createSignal, DEV, untrack, batch } from "solid-js";
20
- import { isServer } from "solid-js/web";
20
+ import { isServer as _isServer } from "solid-js/web";
21
21
  var noop = () => void 0;
22
+ var isServer = _isServer;
22
23
  var isClient = !isServer;
23
24
  var isDev = DEV && isClient;
24
25
  var isProd = !isDev;
@@ -30,8 +31,10 @@ function isObject(value) {
30
31
  var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
31
32
  function chain(callbacks) {
32
33
  return (...args) => {
33
- for (const callback of callbacks)
34
- callback(...args);
34
+ for (const callback of callbacks) {
35
+ if (typeof callback === "function")
36
+ callback(...args);
37
+ }
35
38
  };
36
39
  }
37
40
  var clamp = (n, min, max) => Math.min(Math.max(n, min), max);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solid-primitives/utils",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
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",