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

@check-engineering/ts-utils

v1.0.9

Published

A versatile TypeScript utility package that provides a collection of essential functions to enhance your TypeScript projects.

Downloads

210

Readme

Check-Engineering/Ts-utils npm version

Overview

The Check-Engineering/TS-Utils is a versatile TypeScript utility package that provides a collection of useful functions for various tasks, including array manipulation, date formatting, string & number operations, and object handling. This package offers essential tools to enhance your TypeScript projects with ease.
Below is a brief overview of the main functions included in this package:

Table of Contents

Documentation

For a comprehensive documentation, we highly recommend that you take a look at the 📘TS-Utils Documentation, where each function and its usage are highlighted.

Functions

Array Methods

isArr: Check if the given variable is an array

isArrEmpty: Check if the given array is empty

pushUniqueValue: Pushes a unique value into an array if it doesn't already exist.

pushOrUpdate: Pushes a unique value into an array if it doesn't already exist.

Date Methods

toNow: Calculate the relative time difference between a given date and the current date

formatDate: Convert a date into a formatted string based on the specified format

fromNow: Calculate the relative time difference between a given date and the current date for future events

Number Methods

toFixed: Format a number to a specified precision

parseNumber: Parse a number string or number and return its float, integer, and sign

parseFormat: Parse a formatted string and extract its sign, base, decimals, and unit

addUnit: Add a unit to a number based on the provided configuration

addSeparators: Add thousands and decimal separators to a number string based on the provided configuration

formatNumber: Format a number or string into a specified format with separators and units

ensureNumber: Ensures the input value is a valid number, returning the minimum value if the input is invalid

numberEmptyState: Handles the display of numeric values, providing a fallback format for "empty" or invalid values.

Object Methods

parseJSON: Parse a JSON string into a specified type, with a default value if parsing fails or input is null

deepClone: Create a deep clone of a given object, including nested objects and arrays

parseNumValues: Recursively parse the values of an object, converting any numeric string values to numbers

removeEmptyKeys: Recursively remove keys with null, undefined, or empty string values from an object

sanitizeQuery: Sanitize a query object by removing empty keys and parsing numeric string values to numbers

removeKeys: Remove specified keys from an object, returning a new object with the keys removed

renameKey: Rename a key in an object from an old name to a new name

renameKeys: Rename multiple keys in an object from old names to new names

sortByKeyLength: Sort an object's key-value pairs by the length of the values, with ties broken by the lexicographic order of the keys

querylize: Convert an object into a query string for URL parameters

parseNumericObj: Convert numeric string values in an object to numbers, preserving non-numeric values

reserveKeys: Create a new object containing only the specified keys from the original object

hasKeysAndValues: Check if an object has all the specified keys and if the values associated with those keys are not undefined or null

defaultOptions: Create a new object with selected keys from the original object

String Methods

randomStr: Generate a random string based on specified options

toUpperCase: Convert a string to uppercase

toLowerCase: Convert a string to lowercase

toFullUrl: Convert a partial URL to a full URL by adding missing components like protocol and domain

initials: Generate the initials from a person's name

generateUuid: Generate a Universally Unique Identifier (UUID)

Installation

To install the Check-ENGINEERING/TS-Utils package, you can use the following command:

npm install @check-engineering/ts-utils

or

yarn add @check-engineering/ts-utils

This command will fetch and install the check-engineering/ts-utils package from the package registry, making it available for use in your project.

Usage

Once you have the file in your project, simply import the utility you need using the ES6 import statement.

// Import the specific method category you need
import { randomStr, toUpperCase } from "check-engineering/ts-utils/string.ts";
import { parseNumber, addUnit } from "check-engineering/ts-utils/number.ts";

// OR Import all utilities
import { randomStr, parseNumber, addUnit } from "check-engineering/ts-utils";

Contributing

Contributions to these utilities are welcome. If you find issues or have suggestions for improvements, feel free to contribute by following these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them with descriptive commit messages.
  4. Push your changes to your fork.
  5. Submit a pull request to the main repository.

Please make sure to follow the existing code style and include tests for your changes.

License

This project is licensed under the MIT License. You are free to use, modify, and distribute this software. Refer to the LICENSE file for more details.