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

@nimey/units

v1.0.5

Published

Das Ziel dieser Bibliothek ist es, dir die Angabe von statischen Einheiten zu vereinfachen. Benötigst du zum Beispiel die Zeit von einer Woche in Millisekunden, wirst du in Code häufig die Varianten “7 * 24 * 60 * 60 * 1000” oder “604800000” finden. Um di

Downloads

36

Readme

Bibliothek zur Umrechnung von Einheiten

Das Ziel dieser Bibliothek ist es, dir die Angabe von statischen Einheiten zu vereinfachen. Benötigst du zum Beispiel die Zeit von einer Woche in Millisekunden, wirst du in Code häufig die Varianten “7 * 24 * 60 * 60 * 1000” oder “604800000” finden. Um diese statische Angabe lesbarer zu machen, kannst du mit dieser Bibliothek die folgende Angabe verwenden:

import { Duration } from '@nimey/units';
Duration.week(1).toMillis()

Duration / Dauer

Basiseiheit Millisekunden

Neues Objekt erstellen

  new Duration(1000);                    // > Duration { value: 1000 }
  new Duration('1y 1w 1d 1h 1m 1s 1ms'); // > Duration { value: 221446861001 }
  Duration.millis(1);                    // > Duration { value: 1 }
  Duration.seconds(1);                   // > Duration { value: 1000 }
  Duration.minutes(1);                   // > Duration { value: 60000 }
  Duration.hours(1);                     // > Duration { value: 3600000 }
  Duration.days(1);                      // > Duration { value: 86400000 }
  Duration.weeks(1);                     // > Duration { value: 604800000 }
  Duration.years(1);                     // > Duration { value: 31536000000 }

Umwandlung

  const dauer = new Duration('1y 1w 1d 1h 1m 1s 1ms');
  dauer.toMillis();       // > 32230861001
  dauer.toSeconds();      // > 32230861
  dauer.toMinutes();      // > 537181
  dauer.toHours();        // > 8953
  dauer.toDays();         // > 373
  dauer.toWeeks();        // > 53
  dauer.toYears();        // > 1

  dauer.toDays(2);        // > 373.04
  JSON.stringify(dauer);  // > {"years":1,"weeks":1,"days":1,"hours":1,"minutes":1,"seconds":1,"millis":1}
  dauer.toString();       // > 1y 1w 1d 1h 1m 1s 1ms
  +dauer;                 // > 32230861001

Rechnen

  Duration.seconds(1).add(Duration.millis(50));  // > Duration { value: 1050 }
  Duration.seconds(1).sub(Duration.millis(50));  // > Duration { value: 950 }

FileSize / Dateigröße

Basiseiheit Byte

Neues Objekt erstellen

  new FileSize(1000);                  // > FileSize { value: 1000 }
  new FileSize('1tb 1gb 1mb 1kb 1b');  // > FileSize { value: 1100586419201 }
  FileSize.bytes(1);                   // > FileSize { value: 1 }
  FileSize.kiloBytes(1);               // > FileSize { value: 1024 }
  FileSize.megaBytes(1);               // > FileSize { value: 1048576 }
  FileSize.gigaBytes(1);               // > FileSize { value: 1073741824 }
  FileSize.teraBytes(1);               // > FileSize { value: 1099511627776 }

Umwandlung

  const groesse = new FileSize('1tb 1gb 1mb 1kb 1b');
  groesse.toBytes();        // > 1100586419201
  groesse.toKiloBytes();    // > 1074791425
  groesse.toMegaBytes();    // > 1049601
  groesse.toGigaBytes();    // > 1025
  groesse.toTeraBytes();    // > 1

  JSON.stringify(groesse);  // > {"terabyte":1,"gigabyte":1,"megabyte":1,"kilobyte":1,"byte":1}
  groesse.toString();       // > 1tb 1gb 1mb 1kb 1b
  +groesse;                 // > 1100586419201

Rechnen

  FileSize.kiloBytes(1).add(FileSize.bytes(1));  // > FileSize { value: 1025 }
  FileSize.kiloBytes(1).sub(FileSize.bytes(1));  // > FileSize { value: 1023 }