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

@jumpn/utils-composite

v0.7.0

Published

Composite utilities (immutability, fp helpers)

Downloads

89,894

Readme

@jumpn/utils-composite

Composite utilities (immutability, fp helpers)

NOTE: All the functions described in API are curried

Installation

Using npm

$ npm install --save @jumpn/utils-composite

Using yarn

$ yarn add @jumpn/utils-composite

Types

type Composite = Array<*> | Object;

type Key = number | string;

type Path = Array<Key>;

API

get

Get property value of given key.

Parameters

  • key Key
  • composite Composite

Returns any

getIn

Returns value located at the given path or undefined otherwise.

Parameters

  • path Path
  • composite Composite

Returns any

getKeys

Get own enumerable keys.

Parameters

  • composite Composite

Returns Array<Key>

hasIn

Returns true if value located at given path is deeply equal to the one specified.

Parameters

  • path Path
  • value any
  • composite Composite

Returns boolean

hasKey

Returns true if key is included in composite's own enumerable ones, or false otherwise.

Parameters

  • key Key
  • composite Composite

Returns boolean

haveSameProps

Returns true if both composites have the same props or false otherwise.

Parameters

  • c1 Composite
  • c2 Composite

Returns boolean

is

Returns true if parameter is a Composite or false otherwise

Parameters

  • thing any

isEmpty

Returns true if composite has no own enumerable keys (is empty) or false otherwise

Parameters

  • composite Composite

Returns boolean

map

Maps values of the given composite using mapper

Parameters

  • mapper function (value: any, key: Key, composite: $Supertype<C>): any
  • composite C

Returns $Supertype<C>

remove

Returns a new composite with the result of having removed the property with the given key.

Parameters

  • key Key
  • composite Composite

Returns Composite

removeIn

Returns a new composite with the result of having removed the property located at the given path.

(This does the same as calling updateIn with updater: () => updateIn.remove)

Parameters

  • path Path
  • composite Composite

Returns Composite

set

Returns a new composite with the result of having updated the property with the given key with the specified value.

Parameters

  • key Key
  • value any
  • composite Composite

Returns Composite

setIn

Returns a new composite with the result of having updated the property located at the given path with the specified value.

(This does the same as calling updateIn with updater: () => value)

Parameters

  • path Path
  • value any
  • composite Composite

Returns Composite

shallowCopy

Returns a new composite with the same own enumerable props of the one given.

Parameters

  • composite C

Returns C

shallowEqual

Returns true if both composites are of the same type (Array or Object) and their properties are strictly equal.

Parameters

  • c1 Composite
  • c2 Composite

Returns boolean

toUndefinedIfEmpty

Returns given composite if it has any own enumerable keys (is not empty) or undefined otherwise

Parameters

  • composite Composite

Returns Composite

updateIn

Returns a new composite with the result of having updated the property value at the given path with the result of the call to updater function.

Entry removal is supported by returning updateIn.remove symbol on updater function.

Parameters

  • path Path
  • updater function (prev: any): any
  • composite Composite

Returns Composite

License

MIT :copyright: Jumpn Limited / Mauro Titimoli ([email protected])