Socket
Socket
Sign inDemoInstall

@solid-primitives/utils

Package Overview
Dependencies
Maintainers
3
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/utils - npm Package Compare versions

Comparing version 5.1.1 to 5.2.0

16

dist/index.d.ts

@@ -1,2 +0,2 @@

import { Accessor, Setter, AccessorArray, NoInfer, EffectFunction, onCleanup } from 'solid-js';
import { Accessor, Setter, AccessorArray, NoInfer, EffectFunction, onCleanup, SignalOptions, Signal } from 'solid-js';
export { EffectOptions, OnOptions } from 'solid-js/types/reactive/signal';

@@ -193,3 +193,15 @@

declare function handleDiffArray<T>(current: readonly T[], prev: readonly T[], handleAdded: (item: T) => void, handleRemoved: (item: T) => void): void;
/**
* A signal object that handle hydration.
* @param serverValue initial value of the state on the server
* @param update called once on the client or on hydration to initialise the value
* @param options {@link SignalOptions}
* @returns
* ```ts
* [state: Accessor<T>, setState: Setter<T>]
* ```
* @see {@link createSignal}
*/
declare function createHydrateSignal<T>(serverValue: T, update: () => T, options?: SignalOptions<T>): Signal<T>;
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, StaticStoreSetter, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createStaticStore, defer, entries, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, tryOnCleanup, withAccess };
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, StaticStoreSetter, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createHydrateSignal, createMicrotask, createStaticStore, defer, entries, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, tryOnCleanup, withAccess };

65

dist/index.js

@@ -1,7 +0,6 @@

import { DEV, untrack, getOwner, onCleanup, createSignal, batch } from 'solid-js';
import { DEV, untrack, getOwner, onCleanup, createSignal, sharedConfig, onMount, batch } from 'solid-js';
import { isServer as isServer$1 } from 'solid-js/web';
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var noop = /* @__PURE__ */ __name(() => void 0, "noop");
// src/index.ts
var noop = () => void 0;
var isServer = isServer$1;

@@ -11,9 +10,8 @@ var isClient = !isServer;

var isProd = !isDev;
var ofClass = /* @__PURE__ */ __name((v, c) => v instanceof c || v && v.constructor === c, "ofClass");
var ofClass = (v, c) => v instanceof c || v && v.constructor === c;
function isObject(value) {
return value !== null && (typeof value === "object" || typeof value === "function");
}
__name(isObject, "isObject");
var compare = /* @__PURE__ */ __name((a, b) => a < b ? -1 : a > b ? 1 : 0, "compare");
var arrayEquals = /* @__PURE__ */ __name((a, b) => a === b || a.length === b.length && a.every((e, i) => e === b[i]), "arrayEquals");
var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
var arrayEquals = (a, b) => a === b || a.length === b.length && a.every((e, i) => e === b[i]);
function chain(callbacks) {

@@ -27,16 +25,14 @@ return (...args) => {

}
__name(chain, "chain");
var clamp = /* @__PURE__ */ __name((n, min, max) => Math.min(Math.max(n, min), max), "clamp");
var access = /* @__PURE__ */ __name((v) => typeof v === "function" && !v.length ? v() : v, "access");
var asArray = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value : [value], "asArray");
var accessArray = /* @__PURE__ */ __name((list) => list.map((v) => access(v)), "accessArray");
var withAccess = /* @__PURE__ */ __name((value, fn) => {
var clamp = (n, min, max) => Math.min(Math.max(n, min), max);
var access = (v) => typeof v === "function" && !v.length ? v() : v;
var asArray = (value) => Array.isArray(value) ? value : [value];
var accessArray = (list) => list.map((v) => access(v));
var withAccess = (value, fn) => {
const _value = access(value);
typeof _value !== "undefined" && _value !== null && fn(_value);
}, "withAccess");
var asAccessor = /* @__PURE__ */ __name((v) => typeof v === "function" ? v : () => v, "asAccessor");
};
var asAccessor = (v) => typeof v === "function" ? v : () => v;
function accessWith(valueOrFn, ...args) {
return typeof valueOrFn === "function" ? valueOrFn(...args) : valueOrFn;
}
__name(accessWith, "accessWith");
function defer(deps, fn, initialValue) {

@@ -64,9 +60,8 @@ const isArray = Array.isArray(deps);

}
__name(defer, "defer");
var entries = Object.entries;
var keys = Object.keys;
var tryOnCleanup = /* @__PURE__ */ __name((fn) => getOwner() ? onCleanup(fn) : fn, "tryOnCleanup");
var createCallbackStack = /* @__PURE__ */ __name(() => {
var tryOnCleanup = (fn) => getOwner() ? onCleanup(fn) : fn;
var createCallbackStack = () => {
let stack = [];
const clear = /* @__PURE__ */ __name(() => stack = [], "clear");
const clear = () => stack = [];
return {

@@ -80,3 +75,3 @@ push: (...callbacks) => stack.push(...callbacks),

};
}, "createCallbackStack");
};
function createMicrotask(fn) {

@@ -90,3 +85,2 @@ let calls = 0;

}
__name(createMicrotask, "createMicrotask");
function createStaticStore(init) {

@@ -96,3 +90,3 @@ const copy = { ...init };

const cache = /* @__PURE__ */ new Map();
const getValue = /* @__PURE__ */ __name((key) => {
const getValue = (key) => {
const saved = cache.get(key);

@@ -107,4 +101,4 @@ if (saved)

return signal[0]();
}, "getValue");
const setValue = /* @__PURE__ */ __name((key, value) => {
};
const setValue = (key, value) => {
const saved = cache.get(key);

@@ -115,3 +109,3 @@ if (saved)

copy[key] = accessWith(value, [copy[key]]);
}, "setValue");
};
for (const key of keys(init)) {

@@ -123,3 +117,3 @@ store[key] = void 0;

}
const setter = /* @__PURE__ */ __name((a, b) => {
const setter = (a, b) => {
if (isObject(a))

@@ -135,6 +129,5 @@ untrack(() => {

return store;
}, "setter");
};
return [store, setter];
}
__name(createStaticStore, "createStaticStore");
function handleDiffArray(current, prev, handleAdded, handleRemoved) {

@@ -171,4 +164,12 @@ const currLength = current.length;

}
__name(handleDiffArray, "handleDiffArray");
function createHydrateSignal(serverValue, update, options) {
if (isServer) {
return createSignal(serverValue);
}
let init = !!sharedConfig.context;
const [state, setState] = createSignal(init ? serverValue : update(), options);
init && onMount(() => setState(() => update()));
return [state, setState];
}
export { access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createStaticStore, defer, entries, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, tryOnCleanup, withAccess };
export { access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createHydrateSignal, createMicrotask, createStaticStore, defer, entries, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, tryOnCleanup, withAccess };
{
"name": "@solid-primitives/utils",
"version": "5.1.1",
"version": "5.2.0",
"description": "A bunch of reactive utility types and functions, for building primitives with Solid.js",
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
"contributors": [
"Tom Pichaud <dev.tompichaud@icloud.com>"
],
"license": "MIT",

@@ -7,0 +10,0 @@ "homepage": "https://github.com/solidjs-community/solid-primitives/tree/main/packages/utils#readme",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc