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

typescript-utilitys

v1.0.1

Published

Utility and helper functions for Typescript

Downloads

92

Readme

Package Name

typescript-utilitys

Description

Utility and helper functions for TypeScript.

Author

Srikar Phani Kumar Marti

Version

1.0.0

License

MIT

Repository

GitHub Repository

Installation

You can install the package using npm or yarn:

npm install typescript-utilitys

or

yarn add typescript-utilitys

A few of the available utils

Async Utils

| Function | Description | Example | |-----------|----------------------------------------------------------------------------------------------|--------------------------------------------------------| | retry | Retries an asynchronous operation a specified number of times until it succeeds or reaches the maximum number of retries. | const result = await retry(() => fetchData(url), 3); | | timeout | Adds a timeout to an asynchronous operation, ensuring it completes within a specified time limit. | const result = await timeout(() => fetchData(url), 5000); | | race | Races multiple asynchronous operations and returns the result of the first one to complete. | const result = await race([fetchData(url1), fetchData(url2)]); | | sequence | Runs asynchronous operations sequentially, waiting for each to complete before starting the next one. | const result = await sequence([() => fetchData(url1), () => fetchData(url2)]); | | parallel | Runs multiple asynchronous operations in parallel and returns the results in the same order. | const results = await parallel([() => fetchData(url1), () => fetchData(url2)]); |

Function Utils

| Function | Description | Example | |-------------------|-------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------| | debounce | Delays the execution of a function until a specified amount of time has passed since the last call. | const debouncedFunc = debounce(() => console.log('Hello'), 300); | | throttle | Ensures a function is only called once within a specified time period. | const throttledFunc = throttle(() => console.log('Hello'), 300); | | memoize | Caches the results of a function based on its inputs to improve performance. | const memoizedFunc = memoize(slowFunction);

Guard Utils

| Function | Description | Example | |-------------------|-------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------| | isString | Checks if a value is a string. | const result = isString('Hello'); | | isNumber | Checks if a value is a number. | const result = isNumber(123); | | isArray | Checks if a value is an array. | const result = isArray([1, 2, 3]); | | isObject | Checks if a value is an object. | const result = isObject({ key: 'value' }); | | isFunction | Checks if a value is a function. | const result = isFunction(() => {}); |

Misc

| Function | Description | Example | |-------------------|-------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------| | isValidUrl | Checks if the URL is valid. | const isValid = isValidUrl('https://google.com'); | | deepClone | Creates a deep clone of an object. | const clone = deepClone({ key: 'value' }); | | merge | Merges multiple objects into one. | const merged = merge({ a: 1 }, { b: 2 }); | | omit | Omits specified keys from an object. | const result = omit({ a: 1, b: 2 }, ['a']); | | pick | Picks specified keys from an object. | const result = pick({ a: 1, b: 2 }, ['a']); |

Transformations

| Function | Description | Example | |-------------------|-------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------| | toCamelCase | Converts a string to camel case. | const result = toCamelCase('hello_world'); | | toSnakeCase | Converts a string to snake case. | const result = toSnakeCase('helloWorld'); | | toKebabCase | Converts a string to kebab case. | const result = toKebabCase('helloWorld'); | | capitalize | Capitalizes the first letter of a string. | const result = capitalize('hello'); | | reverseString | Reverses a string. | const result = reverseString('hello'); | | convertDate | Converts a date string to a specified format. | const result = convertDate('2023-01-01', 'MM/DD/YYYY'); | | addDays | Adds a specified number of days to a date. | const result = addDays(new Date(), 5); | | subtractDays | Subtracts a specified number of days from a date. | const result = subtractDays(new Date(), 5); | | formatDate | Formats a date according to a specified format. | const result = formatDate(new Date(), 'YYYY-MM-DD'); |

Contributing

Feel free to contribute to this project by opening issues or submitting pull requests. Please follow the existing code style and conventions.

License

This project is licensed under the MIT License - see the LICENSE file for details.