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

@1500cloud/taitimestamp

v0.2.11

Published

A JavaScript/TypeScript library for manipulating TAI timestamps

Downloads

36

Readme

taitimestamp

A JavaScript/TypeScript library for manipulating TAI timestamps to nanosecond precision (e.g., for representing PTP time).

Licensed under the Apache License and given back to the community by 1500 Cloud.

Installation

npm i --save @1500cloud/taitimestamp

or

yarn add @1500cloud/taitimestamp

Usage

e.g.,

import { now } from "@1500cloud/taitimestamp";

or

const { now } = require("@1500cloud/taitimestamp");

The type TaiTimestamp is used to represent this in TypeScript. This is officially an object, but please use the built-in helpers to convert other domains.

now(): TaiTimestamp

Returns a string representing a TAI Timestamp for the current date. This is limited to the millisecond resolution of the underlying JavaScript platform.

taiTimestampFromJsTime(number): TaiTimestamp

Takes a JavaScript timestamp (e.g., new Date().getTime()) and converts it to a TAI Timestamp object (limited to the millisecond precision of a JavaScript date object).

taiTimestampFromString(string): TaiTimestamp | null

This takes a string like "123455.66" which represents a fractional number of seconds since the Unix epoch and converts it into an object. (Strings are used to maintain precision).

taiTimestampFromMediaTimestamp(string): TaiTimestamp | null

This takes a string like "123455:678000000" as used to represent time in the broadcasting domain (e.g., NMOS APIs) and returns a TaiTimestamp object.

taiTimestampFromNanoseconds(BigInt): TaiTimestamp | null

This takes a BigInt number representing the number of nanoseconds and returns a TaiTimestamp object.

taiTimestampToString(TaiTimestamp): string

This converts a TaiTimestamp object to a string representation.

taiTimestampToMediaTimestamp(TaiTimestamp): string

This converts a TaiTimestamp object to a string representation for TAI time as used in broadcasting (e.g., NMOS APIs).

taiTimestampToNanoseconds(TaiTimestamp): BigInt

This returns a BigInt number representing the number of nanoseconds in the TaiTimestamp.

equals(TaiTimestamp, TaiTimestamp): boolean

This compares two timestamp objects and returns if they are equal or not.

gt(TaiTimestamp, TaiTimestamp): boolean

This compares two timestamp objects and returns whether or not the first is greater (later) than the second.

gte(TaiTimestamp, TaiTimestamp): boolean

This compares two timestamp objects and returns whether or not the first is greater (later) than or equal to the second.

lt(TaiTimestamp, TaiTimestamp): boolean

This compares two timestamp objects and returns whether or not the first is less (earlier) than the second.

lte(TaiTimestamp, TaiTimestamp): boolean

This compares two timestamp objects and returns whether or not the first is less (earlier) than or equal to the second.

add(TaiTimestamp, TaiTimestamp): TaiTimestamp

This adds two TaiTimestamps together and returns the result. This only really makes sense if you think of at least one of the TaiTimestamps as a duration, as adding together two absolute times doesn't really make sense.

subtract(TaiTimestamp, TaiTimestamp): TaiTimestamp

This subtracts the second TaiTimestamp from the first and returns the result. This only really makes sense if you think of at least one of the TaiTimestamps as a duration, as subtracting two absolute times doesn't really make sense.

Changelog

Semantic versioning is in use here. Please see the GitHub releases page for change information.

Contributing

Contributions are welcomed in the form of bug reports, bug fixes or feature improvements! If you're unsure on the change you want to make, please open an issue on GitHub first to discuss with the maintainers. Please note that by contributing back to this project you agree to assign copyright of any code modifications to 1500 Services Ltd. Please also see our code of conduct.

  • Run unit tests: yarn test
  • Run a test watcher: yarn dev