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

@shvmerc/development

v0.1.0-alpha

Published

This package provides some tools to improve `javascript` and `typescript` development.

Downloads

3

Readme

Development Tools

This package provides a set of tools to improve the development in javascript and typescript.

Dictionary

This feature provides a set of tools for working with objects in a way similar to working with arrays.

In typescript, this feature uses generic types to remember the type of object values, but not to remember the keys, assuming the keys are just of type string, so the objects will be handled internally as Record<string, T>.

There are two different ways to use this feature. The first is through the dictionary() function, and the other is by using an instance of the Dictionary class.

dictionary()

Provides a set of functions that perform various operations and transformations on the object without directly modifying it, eliminating the need to create a copy of the object or destructure it when passing it as an argument.

Functions that performs modifications will return a new object instead.

const { dictionary } = require('@shvmerc/development')

const object = { a: 1, b: 2, c: 3 }

const result1 = dictionary(object).map((value) => (value * 100))
console.log(result1) // { a: 100, b: 200, c: 300 }

const result2 = dictionary(result1).rename((value, key) => (key.toUpperCase()))
console.log(result2) // { A: 100, B: 200, C: 300 }

console.log(object) // { a: 1, b: 2, c: 3 }
console.log(object === result1) // false
console.log(object === result2) // false

new Dictionary()

Creates an instance of the Dictionary class linked to the provided object. The methods of this class allow various operations and transformations on the original object.

Methods that perform modifications will return this instead of returning the object directly, requiring the use of the .value() method to get the actual object.

const { Dictionary } = require('@shvmerc/development')

const object = { a: 1, b: 2, c: 3 }

const dictionary = new Dictionary(object)

dictionary.map((value) => (value * 100))
console.log(dictionary.value()) // { a: 100, b: 200, c: 300 }

dictionary.rename((value, key) => (key.toUpperCase()))
console.log(dictionary.value()) // { A: 100, B: 200, C: 300 }

console.log(object) // { A: 100, B: 200, C: 300 }
console.log(object === dictionary.value()) // true

Methods

| method / function | description | |--------------------|----------------------------------------------------------------------------------------------| | .keys() | Returns an array of keys from the object. | | .values() | Returns an array of values from the object. | | .entries() | Returns an array of key-value pairs from the object. | | .size() | Returns the number of properties in the object. | | .at() | Returns the value associated with the specified key. | | .set() | Modifies the value of the provided property. | | .has() | Checks if all specified keys are present in the object. | | .hasOneOf() | Checks if at least one of the specified keys is present in the object. | | .includes() | Checks if all specified values are present in the object. | | .includesOneOf() | Checks if at least one of the specified values is present in the object. | | .random() | Returns a random value from the object. | | .times() | Creates a map by counting the number of times that the values provided appear in the object. | | .clear() | Removes all the properties. | | .copy() | Creates a copy of the object. | | .merge() | Merges the object with all the provided objects, rewriting repeated properties. | | .pick() | Removes all, except the provided properties. | | .delete() | Removes the provided properties. | | .forEach() | Executes the provided callback function once for each property in the object. | | .some() | Checks if at least one property in the object satisfies the provided condition. | | .every() | Checks if all properties in the object satisfies the provided condition. | | .find() | Finds the first property in the object that satisfies the provided condition. | | .filter() | Removes the properties that not satisfies the provided condition. | | .rename() | Rename the properties based on the provided callback function. | | .map() | Transform the property values based on the provided callback function. | | .remake() | Rename and transform the properties based on the provided callback function. | | .array() | Creates an array of values based on a provided callback function. | | .count() | Counts the number of properties in the object that satisfies a provided condition. | | .reduce() | Reduces the object to a single value based on a provided callback function. |