@shinyoshiaki/ebml-builder
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

simple-ebml-builder

Simple DSL for building EBML byte array (mkv/webm).

install

npm install simple-ebml-builder

Sample code

import * as EBML from "simple-ebml-builder";

// EBML element object. The name is EBMLVersion and body is 1. The Size is generated automatically.
EBML.element(EBML.ID.EBMLVersion, EBML.number(1));

// 0x01FFFFFFFFFFFFFF is assigned as the element size for unknownSizeElement.
EBML.unknownSizeElement(EBML.ID.EBMLVersion, EBML.number(1));

// Element can have multiple elements.
EBML.element(EBML.ID.Info, [
    EBML.element(EBML.ID.TimecodeScale, EBML.number(1000000)),
    EBML.element(EBML.ID.MuxingApp, EBML.string("MuxingApp")),
    EBML.element(EBML.ID.WritingApp, EBML.string("WritingApp")),
]);

// Build single Uint8Array from element.
EBML.build(EBML.element(EBML.ID.EBMLVersion, EBML.number(1))); // => Uint8Array.of(0x42, 0x86, 0x81, 0x01)

// dumpBytes is useful for debugging.
console.log(EBML.dumpBytes(EBML.build(EBML.element(EBML.ID.EBMLVersion, EBML.number(1))))); // "0x42, 0x86, 0x81, 0x1"

npm scripts

  • build Compile TypeScript to JavaScript file
  • test Run test
  • test:watch Watch files and run test.
  • benchmark:test Run benchmark
  • benchmark:update Run benchmark and update baseline.

Licence

MIT

Readme

Keywords

Package Sidebar

Install

npm i @shinyoshiaki/ebml-builder

Weekly Downloads

726

Version

0.0.1

License

MIT

Unpacked Size

29.2 kB

Total Files

14

Last publish

Collaborators

  • shinyoshiaki