Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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.0 to 5.1.1

7

dist/index.d.ts
import { Accessor, Setter, AccessorArray, NoInfer, EffectFunction, onCleanup } from 'solid-js';
export { EffectOptions, MemoOptions, OnOptions, SignalOptions } from 'solid-js/types/reactive/signal';
export { EffectOptions, OnOptions } from 'solid-js/types/reactive/signal';

@@ -81,5 +81,6 @@ /**

};
type Narrow<T> = (T extends [] ? [] : never) | (T extends string | number | bigint | boolean ? T : never) | {
[K in keyof T]: T[K] extends Function ? T[K] : Narrow<T[K]>;
type RawNarrow<T> = (T extends [] ? [] : never) | (T extends string | number | bigint | boolean ? T : never) | {
[K in keyof T]: T[K] extends Function ? T[K] : RawNarrow<T[K]>;
};
type Narrow<T extends any> = T extends [] ? T : RawNarrow<T>;

@@ -86,0 +87,0 @@ /** no operation */

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

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

var isProd = !isDev;
var ofClass = (v, c) => v instanceof c || v && v.constructor === c;
var ofClass = /* @__PURE__ */ __name((v, c) => v instanceof c || v && v.constructor === c, "ofClass");
function isObject(value) {
return value !== null && (typeof value === "object" || typeof value === "function");
}
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]);
__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");
function chain(callbacks) {

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

}
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) => {
__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) => {
const _value = access(value);
typeof _value !== "undefined" && _value !== null && fn(_value);
};
var asAccessor = (v) => typeof v === "function" ? v : () => v;
}, "withAccess");
var asAccessor = /* @__PURE__ */ __name((v) => typeof v === "function" ? v : () => v, "asAccessor");
function accessWith(valueOrFn, ...args) {
return typeof valueOrFn === "function" ? valueOrFn(...args) : valueOrFn;
}
__name(accessWith, "accessWith");
function defer(deps, fn, initialValue) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}
__name(handleDiffArray, "handleDiffArray");
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 };
{
"name": "@solid-primitives/utils",
"version": "5.1.0",
"version": "5.1.1",
"description": "A bunch of reactive utility types and functions, for building primitives with Solid.js",

@@ -5,0 +5,0 @@ "author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",

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