Skip to content

Commit

Permalink
📚 README updated. Package typo. License file
Browse files Browse the repository at this point in the history
  • Loading branch information
wfoxall committed Oct 4, 2021
1 parent 8434ce7 commit 1535963
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
8 changes: 8 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

ISC License (ISC)

Copyright 2021 Will Foxall

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35 changes: 28 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,22 @@ npm install @wfoxall/timeframe

### Timecode Class

Import the `Timecode` class and create an instance.

```typescript
import {Timecode} from '@wfoxall/timeframe';

const tc = new Timecode('00:01:02:03',"29.97DF");

console.log(tc.toString());
// 00;01;02;03
```

A `TimecodeError` is thrown if the supplied string or framerate are invalid or incompatible. And the `toString()` class will take care of formatting the timecode correctly (e.g. semicolons for drop timecode).

Timecodes can be instantiated from a string or framecount, and the framerate can be expressed in any of several ways too (see [Framerate class](#Framerate-Class)):

```typescript
const tc1 = new Timecode('00:01:01:00',"29.97DF");
console.log(tc1.toString());
// 00;01;01;00
Expand All @@ -26,7 +39,11 @@ console.log(tc2.toString());
const tc3 = new Timecode(12345,29.97); // 29.97 and 59.94 numbers are interpretted as drop-frame by default
console.log(tc3.toString());
// 00;06;51;27
```

You can add and subtract timecodes (with matching framerates) using the static method on the Timecode class, or with the method on an existing timecode object:

```typescript
let sum = Timecode.add(tc1,tc2); // Immutable - tc1 and tc2 remain unchanged.
console.log(sum.toString());
// 00;02;03;15
Expand All @@ -38,7 +55,17 @@ console.log(tc1.toString());

### Framerate Class

Framerate objects can be instantiated by passing a FramerateLike value. The resulting object can then be used to initialize a Timecode instance.
Framerate objects can be instantiated by passing a `FramerateLike` value. This can be a string, number or object as follows:

```typescript
let fr1 = "59.94DF"
let fr2 = 59.94
let fr3 = {numer:60000,denom:1001,drop:true}
```

This is particularly useful when marshalling framerates from various formats. For example, some video APIs like to express framerates as a fraction (eg. 29.97 is expressed as 30000/1001).

The resulting Framerate instance can then be used to initialize a Timecode instance.

```typescript
import {Framerate} from '@wfoxall/timeframe';
Expand All @@ -52,12 +79,6 @@ console.log(tc.toString());
// 01;59;59;28
```

As framerates can be expressed in multiple formats, this is useful for marshelling the same framerate into the same uniform type. For example, the following are the same framerate:
```typescript
let fr1 = "59.94DF"
let fr2 = 59.94
let fr3 = {numer:60000,denom:1001,drop:true}
```

## Credit

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wfoxall/timeframe",
"version": "1.0.1",
"description": "A javascript library for parsing and manipulatio of SMPTE/EBU/Generic timecodes, framerates and framecounts.",
"description": "A javascript library for parsing and manipulation of SMPTE/EBU/Generic timecodes, framerates and framecounts.",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
Expand Down

0 comments on commit 1535963

Please sign in to comment.