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

unit-simple

v1.0.13

Published

Typescript Simple Unit implementation.

Downloads

10

Readme

Simple Unit (implémentation Typescript)

npm version

Utilisation

Utilisation des unités transformées :

const m: Unit = new FundamentalUnit()
const km: Unit = m.scaleMultiply(1000)
const cm: Unit = m.scaleDivide(100)
const cmToKm: UnitConverter = cm.getConverterTo​(km)

cmToKm.convert(3) // 0.00003
cmToKm.inverse().convert(0.00003) // 3

Utilisation des unités dérivées :

const m: Unit = new FundamentalUnit()
const km: Unit = m.scaleMultiply(1000)
const km2: Unit = new DerivedUnit(km.factor(2))
const cm: Unit = m.scaleDivide(100)
const cm2: Unit = new DerivedUnit(cm.factor(2))
const km2Tocm2: UnitConverter = km2.getConverterTo​(cm2)

km2Tocm2.convert(3) // 30000000000
km2Tocm2.inverse().convert(30000000000) // 3

Utilisation des unités dérivées en combinant les dimensions :

const m: Unit = new FundamentalUnit()
const kg: Unit = new FundamentalUnit()
const g: Unit = kg.scaleDivide(1000)
const ton: Unit = kg.scaleMultiply(1000)
const gPerM2: Unit = new DerivedUnit(g, m.factor(-2))
const km: Unit = m.scaleMultiply(1000)
const tonPerKm2: Unit = new DerivedUnit(ton, km.factor(-2))
const cm: Unit = m.scaleDivide(100)
const tonPerCm2: Unit = new DerivedUnit(ton, cm.factor(-2))
const gPerM2ToTonPerKm2: UnitConverter = gPerM2.getConverterTo​(tonPerKm2)
const gPerM2ToTonPerCm2: UnitConverter = gPerM2.getConverterTo​(tonPerCm2)


gPerM2ToTonPerKm2.convert(1) // 1
gPerM2ToTonPerKm2.inverse().convert(3) // 3
gPerM2ToTonPerCm2.convert(1) // 1e-4
gPerM2ToTonPerCm2.convert(3) // 3e-10
gPerM2ToTonPerCm2.offset() // 0.0
gPerM2ToTonPerCm2.scale() // 1e-10
gPerM2ToTonPerCm2.inverse().offset() // -0.0
gPerM2ToTonPerCm2.inverse().convert(3e-10) // 3

Utilisation des températures (conversions affines et linéaires) :

const k: Unit = new FundamentalUnit()
const c: Unit = k.shift(273.15)
const kToC: UnitConverter = k.getConverterTo​(c)

kToC.convert(0) // -273.15
kToC.inverse().convert(0) // 273.15

// en combinaison avec d'autres unités, les conversions d'unités de températures doivent devenir linéaires
const m: Unit = new FundamentalUnit()
const cPerM: Unit = new DerivedUnit(c, m.factor(-1))
const kPerM: Unit = new DerivedUnit(k, m.factor(-1))
const kPerMToCPerM: UnitConverter = kPerM.getConverterTo​(cPerM)

kPerMToCPerM.convert(3) // 3
kPerMToCPerM.inverse().convert(3) // 3

Utilisation des conversions non-décimales :

const m: Unit = new FundamentalUnit()
const km: Unit = m.scaleMultiply(1000.0)

const s: Unit = new FundamentalUnit()
const h: Unit = s.scaleMultiply(3600.0)

const ms: Unit = new DerivedUnit(m, s.factor(-1))
const kmh: Unit = new DerivedUnit(km, h.factor(-1))

const msToKmh: UnitConverter = ms.getConverterTo(kmh)

msToKmh.convert(100.0) // 360
msToKmh.inverse().convert(18) // 5

Développement

Résolution des dépendances :

npm install

Compilation et tests :

npm run build

Test seuls :

npm run test