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

@qudtlib/core

v6.7.0

Published

Data model for QUDTLib

Downloads

2,419

Readme

QUDTLib: JS Unit Conversion Library based on QUDT

Package of qudtlib-js

Changelog

Provides unit conversion and related functionality for Javascript (Typescript).

Based on the excellent QUDT ontology, available in a js package without any RDF manipulation needed.

This package is a port of qudtlib-java. The major version of this package is the same as that of qudtlib-java.

This package offers the core functionality, but defines no units/quantitykinds/prefixes. It is meant to be imported and re-exported by packages providing such data. At the time of this writing, there is only one package that provides units, @qudtlib/allunits.

Most users will want to use @qudtlib/allunits (which re-exports everything in this package).

Usage

Qudt is your friend. All functionality is accessed through static methods of that class. You can explore the API from that starting point. The main Model classes are:

Unit: encapsulates IRI, label, dimension vector, multiplier/offset, factor units (if any). Descriptions are omitted (create an issue if you want them.)
QuantityKind: IRI, label, applicable units, broader quantity kinds
QuantityValue: value and unit.

Values are always Decimal (from Decimal.js) and there are no convenience methods allowing you to provide other numeric types. This is intentiaonal so as not to mask any conversion problems. You'll be fine. When you need a value, use new Decimal(number|string).

All units, quantityKinds and prefixes are avalable as constants (exported by the package providing the units, such as @qudtlib/allunits):

Units: all units, such as Units.KiloM__PER__SEC
QuantityKinds:: all quantityKinds, such as QuantityKinds.BloodGlucoseLevel
Prefixes: all prefixes, such as Prefixes.Atto

The functionality comprises:

Qudt.convert(...): Convert a value
Qudt.scaleUnit(...): Scale a unit (e.g., make KiloM from M and kilo)
Qudt.unscaleUnit(..): Unscale a unit:
Qudt.unit(...): Get Unit by IRI
Qudt.quantityKind(...): Get QuantityKind by IRI
Qudt.unitFromLocalName(...): Get Unit by local name (i.e., last part of IRI)
Qudt.quantityKindFromLocalName(...): Get QuantityKind by local name (i.e., last part of IRI)
Qudt.derivedUnitsFrom...(...): Get Units by 'factor units', e.g. find N for factors m, kg, and s^-2. Different matching modes available for broader or narrower matching.
Qudt.unitFromLabel(...): Get Unit by label

Acknowledgments

This project has been developed at the Research Studio Smart Application Technologies in the project ‘BIM-Interoperables Merkmalservice’, funded by the Austrian Research Promotion Agency and Österreichische Bautechnik Veranstaltungs GmbH.