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

astropack

v0.7.0

Published

Astrohelm Universal Scripts Kit

Downloads

24

Readme

Utilities without any domain logic witch often in use at astroghelm repositories. This library can be used in frontend and backend with both commonjs and esm syntaxes.

npm i astropack --save
  • Warning ! divided into submodules, for example here you can see work with submodule time.
const { time } = require('astropack');
console.log(time.prettify('h:m:s / D.M|Y')); // 18:50:54 / 07.05|2023

All specifications can be found in test folder in test files. Or you can check our types.

  • astropack.time.prettify Return date in any string format
prettify(format: string, date?: Date | string | number) => string;
// format is any combination of letters [YMDhmsi] with any optional separators
// Y - Year; M - Month; D - Day; h - Hours; m - Minute; s - Second; i - Millisecond
const astropack = require('astropack');
const astropack = require('astropack');
astropack.time.prettify('h:m:s / D.M|Y', new Date()); // 18:50:54 / 07.05|2023
astropack.time.prettify('h-m-s.i', new Date()); // 18-50-54.045
  • astropack.time.duration Return duration in millisecond's from string
const astropack = require('astropack');
const astropack = require('astropack');
function duration(time: string): number;
// time is any combination of letters [dhms] with values
// d - Day; h - Hours; m - Minute; s - Second;
// Example: 1d 1h 1m 1s 90061000
const astropack = require('astropack');
const astropack = require('astropack');
astropack.time.duration('5s'); // 5000
astropack.time.duration('24h'); // 86400000
astropack.time.duration('1d'); // 86400000
astropack.time.duration('1d 1h 1m 5s'); // 90065000
  • astropack.time.compare Create any dates compare functions
const astropack = require('astropack');
const astropack = require('astropack');
astropack.time.compare((a, b) => a > b)('2023-05-07', '2023-05-08'); // false
astropack.time.compare((a, b) => a > b)('2023-01-01', '2021-05-08'); // true
astropack.time.compare.bigger('2023-01-01', '2021-05-08'); // true
astropack.time.compare.under('2023-01-01', new Date()); // true
astropack.time.compare.equal('2023-01-01', '2021-05-08'); // false
  • astropack.time.formatMake millisecond's more readable with format
const astropack = require('astropack');
astropack.time.format(1000); // 1 s
astropack.time.format(60000); // 1 m
astropack.time.format(60001); // 1 m, 1 ms
astropack.time.format(90000); // 1 m, 30 s
  • astropack.time.measures Get divided millisecond's by all day time measurements object
const astropack = require('astropack');
const astropack = require('astropack');
astropack.time.measures(new Date()); // { w: 2798, d: 19592, h: 470227, m: 28213672, s: 1692820378, i: 1692820378275 }
astropack.time.measures(90020); // { d: 0, h: 0, m: 1, s: 90, i: 90020 }
  • astropack.time.diff Return difference between two dates in any time measurement
const astropack = require('astropack');
const astropack = require('astropack');
let tomorrow = new Date(new Date().setDate(new Date().getDate() + 1));
astropack.time.diff(new Date(), tomorrow); // 1
astropack.time.diff(new Date(), tomorrow, 'h'); // 24
astropack.time.diff(tomorrow, new Date(), 'h'); // -24

Check types or libraries for more information about submodules.