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

@spiretechnology/js-timecode

v1.3.0

Published

A TypeScript / JavaScript library for parsing and manipulating SMPTE timecodes and frame rates.

Downloads

3,268

Readme

js-timecode

A TypeScript / JavaScript library for parsing and manipulating SMPTE timecodes and frame rates.

Development of this library is very test-driven to ensure accuracy of the frame and timecode calculations. If you'd like to contribute to this library, adding additional useful test cases is a great place to start!

Installation

npm install --save @spiretechnology/js-timecode

Usage Examples

Parse a timecode (drop frame)

import { Parse, Rate_29_97 } from '@spiretechnology/js-timecode';

const tc = Parse('00:01:02;23', Rate_29_97);
tc.toString(); // => 00:01:02;23
tc.frame; // => 1881

Parse a timecode (non-drop frame)

const tc = Parse('00:01:02:23', Rate_24);
tc.toString(); // => 00:01:02:23
tc.frame; // => 1511

Create a timecode from a frame count

const tc = new Timecode(1511, Rate_24, false /* non-drop frame */);
tc.toString(); // => 00:01:02:23
tc.frame; // => 1511

Algebra with timecodes and frames

let tc = Parse('00:01:02:23', Rate_24);
tc = tc.add(3);
tc.toString(); // => 00:01:03:02
tc.frame; // => 1514

Note: parsing timecodes that don't exist in drop frame

Drop frame timecodes skip the first 2 frames of each minute, unless the minute is a multiple of 10. This changes to the first 4 frames of each minute if the frame rate is 59.94.

For instance, in 29.97, the timecode 00:00:59:29 is immediately followed by 00:01:00:02. Two timecodes were dropped: 00:01:00:00 and 00:01:00:01

Those dropped timecodes don't correspond to any actual frame number, and so we need to choose how to resolve those frames. The choice we have made with this library is to round up the next valid frame. If you try to parse 00:01:00:00, the result will be rounded up to 00:01:00:02, which is the next valid frame in the sequence.

Contributing

We welcome contributions that make this library more reliable. To add test cases, fix bugs, or anything else, please submit a pull request.

Other resources