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

thingtalk-units

v0.2.1

Published

Unit conversions and definitions for ThingTalk

Downloads

1,384

Readme

thingtalk-units

Build Status Coverage Status Dependency Status Language grade: JavaScript

A small library to convert and normalize between measurement units. This library is used by the ThingTalk language to support measurements.

The library converts to and from base units of various supported types, and various additional units for each base unit.

Usage

const TTUnits = require('thingtalk-units');

API

function normalizeUnit(unit : String) : String

Convert a unit name to the base unit, which is a standard unit for the same property. This method throws if the unit is invalid. Example:

TTUnits.normalizeUnit('F') === 'C'
TTUnits.normalizeUnit('km') === 'm'

function transformToBaseUnit(value : Number, unit : String) : Number

Convert the value value, expressed in the unit unit, in the same amount in the corresponding base unit. Example:

TTUnits.transformToBaseUnit(1, 'km') === 1000

function transformFromBaseUnit(value : Number, unit : String) : Number

Convert the value value, expressed in the base unit, to the unit unit. This is the inverse operation to transformToBaseUnit(). Example:

TTUnits.transformToBaseUnit(1000, 'km') === 1

const BaseUnit : Array

The list of the supported base units.

Supported Units

Base Units

  • ms: time (milliseconds)
  • m: distance (meters)
  • mps: speed (meters per second)
  • kg: mass (kilograms)
  • Pa: pressure (Pascal)
  • C: temperature (Celsius)
  • kcal: energy (kilocalories)
  • byte: data size (Byte)
  • W: power (Watt)
  • lm: luminous flux (lumen)
  • lx: illuminance (lux)

The choice of base units is mostly historical. Some units follow SI convention (mps, kg, Pa), some follow common usage (kcal, C).

Additional Units

| Unit | Base Unit | Physical quantity | | --------------------------------- | --------- | ----------------- | | s (seconds) | ms | time | | min (minutes) | ms | time | | h (hours) | ms | time | | day (days) | ms | time | | week (weeks) | ms | time | | mon (business month = 30 days) | ms | time | | year (business year = 365 days) | ms | time | | km (kilometers) | m | distance | | mm (millimeters) | m | distance | | cm (centimeters) | m | distance | | mi (miles) | m | distance | | in (inches) | m | distance | | kmph (kilometers per hour) | mps | speed | | mph (miles per hour) | mps | speed | | g (grams) | kg | mass | | lb (US pound) | kg | mass | | oz (US ounce) | kg | mass | | bar (bar) | Pa | pressure | | psi (pounds per square inch) | Pa | pressure | | mmHg (millimeters of mercury) | Pa | pressure | | inHg (inches of mercury) | Pa | pressure | | F (Fahrenheit) | C | temperature | | K (Kelvin) | C | temperature | | kJ (kilojoule) | kcal | energy | | KB (kilobyte) | byte | data size | | KiB (kibibyte) | byte | data size | | MB (megabyte) | byte | data size | | MiB (mebibyte) | byte | data size | | GB (gigabyte) | byte | data size | | GiB (gibibyte) | byte | data size | | TB (terabyte) | byte | data size | | TiB (tebibyte) | byte | data size | | kW (kilowatt) | W | power |