npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@solid-primitives/utils

v6.2.3

Published

A bunch of reactive utility types and functions, for building primitives with Solid.js

Downloads

184,156

Readme

@solid-primitives/utils

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.

Installation

npm install @solid-primitives/utils
# or
pnpm add @solid-primitives/utils
# or
yarn add @solid-primitives/utils

Immutable helpers

Functional programming helpers for making non-mutating changes to data. Keeping it immutable. Useful for updating signals.

import { pick } from "@solid-primitives/utils/immutable";

const original = { foo: 123, bar: "baz" };
const newObj = pick(original, "foo");
original; // { foo: 123, bar: "baz" }
newObj; // { foo: 123 }

Use it for changing signals:

import { push, update } from "@solid-primitives/utils/immutable";

const [list, setList] = createSignal([1, 2, 3]);
setList(p => push(p, 4));

const [user, setUser] = createSignal({
  name: "John",
  street: { name: "Kingston Cei", number: 24 },
});
setUser(p => update(p, "street", "number", 64));

List of functions:

Copying

  • shallowArrayCopy - make shallow copy of an array
  • shallowObjectCopy - make shallow copy of an object
  • shallowCopy - make shallow copy of an array/object
  • withArrayCopy - apply mutations to the an array without changing the original
  • withObjectCopy - apply mutations to the an object without changing the original
  • withCopy - apply mutations to the an object/array without changing the original

Array

  • push - non-mutating Array.prototype.push()
  • drop - non-mutating function that drops n items from the array start
  • dropRight - non-mutating function that drops n items from the array end
  • filterOut - standalone Array.prototype.filter() that filters out passed item
  • filter - standalone Array.prototype.filter()
  • sort - non-mutating Array.prototype.sort() as a standalone function
  • sortBy - Sort an array by object key, or multiple keys
  • map - standalone Array.prototype.map() function
  • slice - standalone Array.prototype.slice() function
  • splice - non-mutating Array.prototype.splice() as a standalone function
  • fill - non-mutating Array.prototype.fill() as a standalone function
  • concat - Creates a new array concatenating array with any additional arrays and/or values.
  • remove - Remove item from array
  • removeItems - Remove multiple items from an array
  • flatten - Flattens a nested array into a one-level array
  • filterInstance - Flattens a nested array into a one-level array
  • filterOutInstance - Flattens a nested array into a one-level array

Object

  • omit - Create a new subset object without the provided keys
  • pick - Create a new subset object with only the provided keys
  • split - Split object into multiple subset objects.
  • merge - Merges multiple objects into a single one.

Object/Array

  • get - Get a single property value of an object by specifying a path to it.
  • update - Change single value in an object by key, or series of recursing keys.

Number

  • add - a + b + c + ... (works for numbers or strings)
  • substract - a - b - c - ...
  • multiply - a * b * c * ...
  • divide - a / b / c / ...
  • power - a ** b ** c ** ...
  • clamp - clamp a number value between two other values

Changelog

See CHANGELOG.md