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

@danielszuk/utilities

v1.2.2

Published

Commonly used utilities for Typescript/Javascript projects.

Downloads

16

Readme

Utilities

npm package License: ISC Node.js CI David npm bundle size Coverage Status

Commonly used utilities for Typescript/Javascript projects.

Installation

npm install @danielszuk/utilities

Usage

Always import only the used functions from the package.

Typescript

import { degreeToRadian, randomBoolean, forEach } from '@danielszuk/utilities'

degreeToRadian(45);
// 0.785398

randomBoolean();
// true OR false

forEach([1,2,3], (number) => console.log(number));
// 1
// 2
// 3

Javascript

const { degreeToRadian, randomBoolean, forEach } = require('@danielszuk/random-boolean');

degreeToRadian(45);
// 0.785398

randomBoolean();
// true OR false

forEach([1,2,3], (number) => console.log(number));
// 1
// 2
// 3

List of available functions

For detailed description, check the definition of the imported function (either by your IDE, or from the source code).

For detailed examples, check the corresponding name.spec.ts file in the __tests__/ folder

| Name | Short Description | Example | |:---------|:---------------------------|:---------| | forEach | Executes a provided function once for each array element (breakable) | forEach([1,2,3], (element) => {if (element === 2) return false; } | | forEachSync | Executes a provided async function synchronously once for each array element (breakable) | await forEachSync([1,2,3], async (element) => { await asyncFn(element); if (element === 2) return false; } | | forEachAsync | Executes a provided async function asynchronously once for each array element (awaitable) | await forEachAsync([1,2,3], async (element) => { await asyncFn(element); } | | clone | Creates a new object from the given one with the exact same values, but without the reference. | const obj2 = clone(obj1) | | deepAssign | Assign an object's values into a target object, value by value deeply. | deepAssign({ a: 1, b: { ba: 21, bb: 22 } }, { b: { ba: 42 } }) // { a: 1, b: { ba: 42, bb: 22 } } | | getSafe | Executes a getter and returns with the value. If the execution runs on error, returns with undefined. | getSafe(() => result.attribute.value) | | isEmpty | Determines whether an object is empty or not. | isEmpty({}) // true | | isEquivalent | Determines whether two objects are equivalent (means all their properties values are the same). | isEquivalent({ a: 1 }, { a: 1 }) // true | | removeElements | Removes elements from an array. Modify the original array. | removeElements([ 1, 2, 3 ], 2, 3) // [ 1 ] | | circulateArray | Circulates over the elements of an array. | const next = circulateArray([12, 21, 39]); next(); next(); next(); next(); // 12 21 39 12 | | degreeToRadian | Converts an angle in degree to radian. | degreeToRadian(30) // 0.5235987755982988 | | htmlToText | Removes all html markup from a string. | htmlToText(`<b>Name</b>`) // 'Name' | | randomBoolean | Generates a random boolean value. | randomBoolean() // true OR false | | round | Rounds a number to a given decimal place. | round(1.237, 2) // 1.24 | | timeout | Delay the execution for a specified number of milliseconds. | await timeout(1000) | | as | Strict type checking a single value. | as<IExample>({ a: 1, b: 2 }) | | DeepPartial | Makes all attributes optional and all its nested object's attributes optional as well. | const toModify: DeepPartial<IExample> |