@mtillmann/chapters 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -66,7 +66,8 @@ declare abstract class Base implements MediaItem {
66
66
  mimeType: string;
67
67
  duration: number;
68
68
  isChapterFormat: boolean;
69
- static create(input?: string | MediaItem): MediaItem;
69
+ constructor(duration?: number);
70
+ static create(input?: string | MediaItem, duration?: number): MediaItem;
70
71
  from(input?: string | MediaItem): MediaItem;
71
72
  detect(inputString: string): boolean;
72
73
  test(data: object): {
package/dist/index.js CHANGED
@@ -189,8 +189,11 @@ var Base = class {
189
189
  mimeType = "application/json";
190
190
  duration = 0;
191
191
  isChapterFormat = true;
192
- static create(input) {
193
- return new this().from(input);
192
+ constructor(duration = 3600) {
193
+ this.duration = duration;
194
+ }
195
+ static create(input, duration) {
196
+ return new this(duration).from(input);
194
197
  }
195
198
  from(input) {
196
199
  if (!input) {
@@ -209,9 +212,6 @@ var Base = class {
209
212
  this.duration = chapter.startTime;
210
213
  }
211
214
  }
212
- if (this.duration === 0) {
213
- this.duration = 3600;
214
- }
215
215
  this.bump();
216
216
  return this;
217
217
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtillmann/chapters",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "library that manages and converts chapters of multiple formats",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -69,6 +69,10 @@ const vtt2 = Autoformat.as(WebVTT, webVttString) // returns an instance of WebVT
69
69
 
70
70
  All formats support the following methods:
71
71
 
72
+ ### `constructor (duration: number = 3600)`
73
+
74
+ Creates a new instance of the class, optionally with a duration in seconds.
75
+
72
76
  ### `static create (input?: string | MediaItem): MediaItem`
73
77
 
74
78
  Creates a new media item. This is the suggested way to create a media item: