6.2.3 • Published 2 months ago

@solid-primitives/utils v6.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@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

@infinitebrahmanuniverse/nolb-_sol@everything-registry/sub-chunk-851@zalastax/nolb-_solrallax@solid-primitives/mutation-observer@solid-primitives/page-visibility@solid-primitives/pagination@solid-primitives/pointer@solid-primitives/presence@solid-primitives/promise@solid-primitives/props@solid-primitives/raf@solid-primitives/range@solid-primitives/refs@solid-primitives/resize-observer@solid-primitives/rootless@solid-primitives/static-store@solid-primitives/storage@solid-primitives/stream@solid-primitives/styles@solid-primitives/trigger@solid-primitives/until@solid-primitives/upload@solid-primitives/signal-builders@solid-primitives/media@solid-primitives/memo@solid-primitives/mouse@solid-aria/accordion@solid-aria/breadcrumbs@solid-aria/button@solid-aria/checkbox@solid-aria/collection@solid-aria/dialog@solid-aria/focus@solid-aria/i18n@solid-aria/interactions@solid-aria/radio@solid-aria/select@solid-aria/selection@solid-aria/separator@solid-aria/switch@solid-aria/textfield@solid-aria/toggle@solid-aria/tree@solid-aria/types@solid-aria/utils@solid-aria/visually-hidden@solid-aria/menu@solid-aria/meter@solid-aria/overlays@solid-aria/progress@solid-aria/label@solid-aria/link@solid-aria/list@solid-aria/listbox@solid-primitives/audio@solid-primitives/autofocus@solid-primitives/bounds@solid-primitives/clipboard@solid-primitives/connectivity@solid-primitives/controlled-props@solid-primitives/cursor@solid-primitives/date@solid-primitives/geolocation@solid-primitives/graphql@solid-primitives/history@solid-primitives/immutable@solid-primitives/intersection-observer@solid-primitives/jsx-parser@solid-primitives/jsx-tokenizer@solid-primitives/keyboard@solid-primitives/masonry@solid-devtools/debugger@solid-devtools/ext-adapter@solid-devtools/extension-adapter@solid-devtools/frontend@solid-devtools/locator@solid-devtools/logger@solid-devtools/overlay@solid-devtools/shared@solid-devtools/ui@solid-primitives/destructure@solid-primitives/event-bus@solid-primitives/event-listener@solid-primitives/active-element@solid-hooks/drag@solid-integrations/html2canvas@solid-hooks/core@uniqed/buttonsolid-dollarsolid-slidersolid-slider-oldsolid-picturesolid-keen-slidersolid-apg@hope-ui/utils@kobalte/utils
6.2.3

2 months ago

6.2.2

4 months ago

6.2.1

9 months ago

6.1.1

1 year ago

6.2.0

12 months ago

5.5.1

1 year ago

5.5.0

1 year ago

5.3.0

1 year ago

5.1.1

1 year ago

6.1.0

1 year ago

5.4.0

1 year ago

5.2.1

1 year ago

5.2.0

1 year ago

6.0.0

1 year ago

5.4.0-beta.0

1 year ago

5.5.2

1 year ago

5.1.0

1 year ago

5.0.0

1 year ago

4.0.1

1 year ago

3.1.0

2 years ago

4.0.0

2 years ago

3.0.2

2 years ago

2.2.1

2 years ago

2.1.1

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

0.5.3

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.260

2 years ago

0.0.255

2 years ago

0.0.250

2 years ago

0.0.200

2 years ago

0.0.150

2 years ago