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

functions-tools

v0.1.5

Published

Your fonctions friends

Downloads

21

Readme

Table of contents

Installation

npm i functions-tools

Examples

const ft = require('functions-tools'); //Define the functions-tools module

Fonctions Times

ft.stringifyTime(4800000); // 1h, 20m
ft.stringifyTime(4800000, {lang: "en", long: true, separator: " | "}); // 1 hour | 20 minutes
ft.stringifyTime(4800000, {lang: "en", valueNull: true, format: "Y-MO-W-D-H-M-S-MS"}); // 0y, 0mo, 0w, 0d, 1h, 20m, 0s, 0ms
ft.stringifyTime(4800000, {lang: "en", format: "M-H-MS"}); // 20m, 1h
ft.stringifyTime(4800000, {lang: "en", suppressTag: true}); // 1, 20

ft.parseTime("2d"); // 172800000
ft.parseTime("2d",{ms: false}); // 172800
ft.parseTime("2day 5m 3hour"); // 183900000
ft.parseTime("2day -1d"); // 86400000
ft.parseTime("-2d"); // -172800000

await ft.wait(5000); 
// {startTime: 1623327459766, endTime: 1623327464766, durationTime: 5000}
await ft.wait("5s 10s -1s");
// {startTime: 1623327464827, endTime: 1623327478827, durationTime: 14000}
 
ft.formatTime(Date.now()); // june 10th 2021, 22:46:10
ft.formatTime("10/06/2021"); // june 10th 2021, 00:00:00
ft.formatTime("10/06/2021", {lang: "en", format: "Do MM, YYYY | hh:mm"}); // 06th Oct, 2021 | 00:00

Fonctions Number

ft.numberToRoman(24); // XXIV

ft.romanToNumber("XXIV"); // 24

Fonctions Text

ft.replaceText("Hello {user}", {user: "NewGlace"}) //Hello NewGlace
ft.replaceText("Hello {user} {suffix}", {user: "NewGlace", suffix: "vanilla"}) //Hello NewGlace vanilla
ft.replaceText("Hello {user}", {user: "NewGlace {suffix}", suffix: "vanilla"}) //Hello NewGlace vanilla

Fonctions Array

ft.findArray(["H",["E",["L"],"L"],"O,"," ","W",["O",["R",["L"]]],"D"], "L");
// Map(1) { 0 => [ 1, 1, 0 ] }
ft.findArray(["H",["E",["L"],"L"],"O,"," ","W",["O",["R",["L"]]],"D"], "L", {all: true});
// Map(3) { 0 => [ 1, 1, 0 ], 1 => [ 1, 1, 2 ], 2 => [ 1, 5, 1, 1, 0 ] }
ft.findArray(["H",["E",["L"],"L"],"O,"," ","W",["O",["R",["L"]]],"D"], "P");
// Map(0) {}

ft.randomArray(["A","B","C"]); // B
ft.randomArray(["A","B","C"], {number: 4}); // ["C", "A", "B", "A"]
ft.randomArray(["A","B","C"], {number: 4, double: false}); // ["A", "C", "B"]

//To shuffle an array
const array = [1,2,3,4,5,6,7,8,9,0];
ft.randomArray(array, {number: array.length, double: false});
// [4, 3, 7, 0, 5, 6, 2, 1, 9, 8]

Fonctions multiFunctions

ft.multiFunctions(ft.numberToRoman, [10, 34, 54]);
await ft.multiFunctions(ft.numberToRoman, [10, 34, 54], async: true);
// Promise { [ 'X', 'XXXIV', 'LIV' ] }

ft.multiFunctions(ft.replaceText, [["Hello {x}", {x: "World"}],["Hi {u}", {u: "World"}],["Bye {p}", {p: "World"}]]);
await ft.multiFunctions(ft.replaceText, [["Hello {x}", {x: "World"}],["Hi {u}", {u: "World"}],["Bye {p}", {p: "World"}]], async: true); 
//Promise { [ 'Hello World', 'Hi World', 'Bye World' ] }

Discord

Join the Discord