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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ts-codecraft

v2.0.3

Published

A TypeScript utility package for web automation and web scraping.

Downloads

5

Readme

ts-codecraft

ts-codecraft is a powerful TypeScript utility library that simplifies your development workflow by providing a comprehensive collection of reusable, high-performance, and well-tested utility functions. These functions cover a broad range of common operations, reducing the need to reinvent the wheel and letting you focus on building amazing applications.

🚀 Features

  • Wide Variety of Utilities: Includes functions for time manipulation, formatting, storage handling, debouncing, and more.
  • Typed with TypeScript: Fully typed with TypeScript for an optimized developer experience.
  • Plug-and-Play: Designed for both Node.js and browser environments.
  • Zero Dependencies: Lightweight and fast with zero external dependencies.
  • Cloud-Ready Utilities: Integrates with common cloud platforms (e.g., IndexedDB, Cookies, Storage Buckets, Cache Storage).

📦 Installation

Install ts-codecraft in your project with npm or yarn:

npm install ts-codecraft
# or
yarn add ts-codecraft

🛠️ Usage

To use ts-codecraft in your project, simply import the utilities you need:

import { debounce, formatDate, uploadFile } from 'ts-codecraft';

// Example usage: Debouncing a function
const logMessage = () => console.log('Hello, World!');
const debouncedLog = debounce(logMessage, 300);
debouncedLog();  // Call as needed, only logs once every 300ms

📚 Available Utilities

1. Time Utilities

  • formatDate: Formats dates into custom string formats.
  • getTimeAgo: Calculate relative time from a given date.
  • getTimeDifference: Get the difference between two times in human-readable format.
  • convertTimeTo24Hour: Converts a normal time format into 24-hour time (e.g., 14:30:00).

Example:

import { formatDate } from 'ts-codecraft';

const formattedDate = formatDate(new Date(), 'yyyy-MM-dd');
console.log(formattedDate); // Output: 2024-09-25

2. Debounce & Throttle

  • debounce: Delays invoking a function until after a wait time has elapsed.
  • throttle: Ensures a function is only called once in a set time interval.

Example:

import { debounce } from 'ts-codecraft';

const handleClick = () => console.log('Button clicked!');
const debouncedClick = debounce(handleClick, 500);
debouncedClick();  // Only triggers if there are no clicks within 500ms

3. Storage Utilities

  • setLocalStorage, getLocalStorage, removeLocalStorage: Manage browser's localStorage with ease.
  • setSessionStorage, getSessionStorage, removeSessionStorage: Manage browser's sessionStorage.
  • setCookie, getCookie, removeCookie: Simplify cookie management.
  • openIndexedDB, addToIndexedDB, getFromIndexedDB: Easy integration with IndexedDB for structured data storage.

Example:

import { setLocalStorage, getLocalStorage } from 'ts-codecraft';

// Set data to localStorage
setLocalStorage('username', 'JohnDoe');

// Retrieve data from localStorage
const user = getLocalStorage('username');
console.log(user);  // Output: JohnDoe

4. Cloud Storage Utilities

  • uploadFile, downloadFile, deleteFile: Interact with cloud storage (S3, GCP, etc.) for file operations.
  • generateSignedUrl: Generate a signed URL for secure file access.
  • fileExists: Check if a file exists in the cloud bucket.

Example:

import { uploadFile } from 'ts-codecraft';

// Example: Upload file to cloud storage (e.g., Google Cloud Storage)
uploadFile(myBucket, myFile, 'uploads/profile.jpg').then((url) => {
  console.log('File uploaded at: ', url);
});

5. IndexedDB Utilities

  • openIndexedDB: Open a database in IndexedDB.
  • addToIndexedDB: Add data to IndexedDB.
  • getFromIndexedDB: Retrieve data from IndexedDB.

Example:

import { openIndexedDB, addToIndexedDB } from 'ts-codecraft';

openIndexedDB('MyDatabase', 1, ['store1']).then((db) => {
  addToIndexedDB(db, 'store1', { id: 1, name: 'Item 1' });
});

6. Cache Storage Utilities

  • cacheData: Store data in the browser's Cache Storage.
  • getCachedData: Retrieve data from Cache Storage.
  • deleteCachedData: Remove data from Cache Storage.

7. Utilities for Storage Buckets

  • uploadFile, downloadFile, listFiles, deleteFile, generateSignedUrl: Interact with cloud-based storage services like S3, Firebase Storage, Google Cloud Storage.

✨ Examples

Here are some common examples of how to use the ts-codecraft library in your project.

Debouncing a Search Input:

import { debounce } from 'ts-codecraft';

const searchInput = document.getElementById('search');
const handleSearch = debounce(() => {
  console.log('Search query:', searchInput.value);
}, 300);

searchInput.addEventListener('input', handleSearch);

Formatting Dates:

import { formatDate } from 'ts-codecraft';

const date = new Date();
console.log(formatDate(date, 'yyyy/MM/dd'));  // Output: 2024/09/25

🔧 Contribution

We welcome contributions! Feel free to open issues or submit pull requests to improve ts-codecraft. Check out our CONTRIBUTING.md for more details.


📝 License

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


👏 Acknowledgements

Special thanks to all the open-source contributors and the community for helping make this project possible!


By providing a clean and comprehensive API for common utility operations, ts-codecraft is here to make your TypeScript development experience faster and smoother!


🤝 Let's Connect

If you enjoy using ts-codecraft, consider giving it a ⭐ on GitHub! For any questions or feedback, reach out to [email protected].


This README covers everything your users will need, from installation, examples, and function explanations to usage guidance and contribution details. It presents ts-codecraft as a polished, professional, and well-thought-out package!