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

@hfrada/futils

v1.0.7

Published

simple javascript utility

Downloads

3

Readme

Futils

simple javascript utility

List Of Utility

| Utility | Func Name | | :-------| :-------- | | date parser | dateParser | | date from now | dateFromNow | | date array | dateArray | | debounce | debounce | | delay | sleep |

Date Parser

// dateParser.js
import { dateParser } from "@hfrada/futils";

const date = new Date(2000, 2, 1, 10, 20, 30, 40);
const parse = dateParser(date, format, defResult); // 01/03/2000

Type of date is a string, number or Date. Format default is "DD/MM/YY" with result in dateParser.js. Param defResult refers to the result of invalid date parsing with default empty string.

| Param | Type | Required | Default | | :-----| :--- | :------- | :------ | | date | string | number | Date | true | undefined | | format | string | false | "DD/MM/YY" | | defResult | string | false | "" |

The available formats are as follows: | Format | Result | | :----- | :----- | | YY | 2000 | | MN | Maret | | MNs | Mar | | DD | 01 | | HH | 10 | | mm | 20 | | ss | 30 | | ms | 40 |

Date From Now

// dateParser.js
import { dateFromNow } from "@hfrada/futils";

const date = new Date().getTime() - 10_000;
const parse = dateFromNow(date); // 10 detik lalu

Type of date is a string, number or Date. Result will be a subtract string from the current date with the date from the parameter.

| Param | Type | Required | Default | | :-----| :--- | :------- | :------ | | date | string | number | Date | true | undefined |

The available results are as follows: | Interval | Result | | :----- | :----- | | year | 1 tahun lalu | | month | 3 bulan lalu | | day | 10 hari lalu | | hour | 5 jam lalu | | minute | 10 menit lalu | | second | 20 detik lalu |

Date Array

// dateArray.js
import { dateArray } from "@hfrada/futils";

const ranges = dateArray(startDate, endDate); // [Date, ..., Date]

Date Array is used to create date ranges. The length is based on the startDate and endDate parameters. The parameter startDate has type Date and cannot be greater than endDate. The endDate parameter has type Date and its value must be greater than or equal to startDate.

| Param | Type | Required | Default | | :-----| :--- | :------- | :------ | | startDate | Date | true | undefined | | endDate | Date | true | undefined |

File

documentation here

Debounce

// debounce.js
import { debounce } from "@hfrada/futils";

function callback(...args) {
    // do something
}
const bouncer = debounce(callback, time);
bouncer(); // run callback after `time` delay
bouncer(); // remove previous process and rerun callback after `time` delay

Debounce make code is only triggered once per user input. Debouce waits for a delay to run the some process. During this time, if the process is overwritten, the previous process will not be executed. Debounce delay can be custom by parameter time with type number in milliseconds.

| Param | Type | Required | Default | | :-----| :--- | :------- | :------ | | callback | function | true | undefined | | time | number | false | 300 |

Delay

// delay.js
import { sleep } from "@hfrada/futils";

async function callWithDelay() {
    // do something before delay
    sleep(time);
    // do something after delay
}

Delay is used to pending the asynchronous process before executing the next process. Delay can be custom by parameter time with type number in milliseconds. | Param | Type | Required | Default | | :-----| :--- | :------- | :------ | | time | number | false | 1000 |