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

@bombaysoftwares/tskit

v1.0.14

Published

The @bombaysoftwares/tskit package provides a set of utility functions for working with dates and timestamps in JavaScript. These functions simplify common tasks such as date formatting, timestamp conversion, and JSON validation.

Downloads

542

Readme

tskit

The @bombaysoftwares/tskit package provides a comprehensive set of utility functions for various operations in JavaScript. These functions simplify common tasks such as date formatting, timestamp conversion, JSON validation, manipulating strings, and working with HTML content. This package is designed to enhance the functionality of various operations in your JavaScript projects.

Installation

To use the Date Utils package, you can install it via npm:

npm i @bombaysoftwares/tskit

Usage

Import the desired functions from the package:

import { getCurrentDateTime, getCurrentTimestamp, getDateTimeFromTimestamp } from '@bombaysoftwares/tskit';

getCurrentDateTime

This function returns the current date and time in the format "YYYY-MM-DD HH:MM:SS".

const currentDateTime = getCurrentDateTime();
console.log(currentDateTime);
// Output: 2023-06-20 12:22:20

isSet

This function checks if the value provided is none of this - null, undefined, empty string, "undefined", empty array as string.

console.log(isSet("null"));
// Output: false

getRandomColor

This function generates a random color in hexadecimal format.

console.log(getRandomColor());
// Output: #62C5B9

getTextFromHtml

Extracts text from an HTML string by removing HTML tags.

console.log(getTextFromHtml("<h1>Title</h1><p>This is a paragraph.</p>"); returns TitleThis is a paragraph.);
// Output: The extracted text without HTML tags.

getDateTimeFromTimestamp

This function formats a timestamp into a string representation of date and time. You can choose whether to include seconds in the formatted string.

const timestamp = 1695193213;
const formattedDateTime = getDateTimeFromTimestamp(timestamp);
console.log(formattedDateTime);
// Output: 20-Sep-2023 12:30:13

Other Functions

The package also includes other useful functions:

  • evalBooleanValue(value: string | boolean | undefined): boolean : This function checks if the value provided is "true" or true.
  • dateAndTimeFormat(dateObject: Date, showSeconds = true): string | null : Formats a Date object into a string representation of date and time.
  • dateFormat(dateObject: Date): string | null : Formats a Date object into a string representation of date in DD-Mmm-YYYY format.
  • dateFormatHHMM(dateObject: Date): string | null : Formats a Date object into a string representation of date and time in DD-Mmm-YYYY, HH:mm format.
  • getTwodigitFormat(data: number): string | number | null : Converts a number to a two-digit format by adding a leading zero if necessary.
  • isValidJsonData(data: string): object | boolean : Checks if a string is valid JSON data by attempting to parse it.
  • getLocalDate(dateAndTime: string): string | null : Retrieves the local date in a specific format from the provided date and time string.
  • strToDate = (dateString: string, format: string): Date | null : Parses the input date string based on the specified format and returns a Date object.
  • camelCaseKeys= (obj: {[x: string]: string | number}):{[x: string]: string | number} : Converts the keys of an object from snake_case to camelCase.

For detailed usage and examples, refer to the inline documentation and code samples within each function.

Author

Bombay Softwares

License

This project is licensed under the MIT license. See the LICENSE file for more info.