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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kitaitimakoto/media-fragment

v0.0.1

Published

Media Fragments URI implementation

Downloads

4

Readme

Media Fragment

Media Fragments URI implementation described at https://www.w3.org/2008/WebVideo/Fragments/WD-media-fragments-spec/ .

Synopsis

import MediaFragment, {TemporalDimension, SpatialDimension} from '@kitaitimakoto/media-fragment';

let mf = new MediaFragment('t=npt:10,20&xywh=pixel:160,120,320,240');
console.log(mf.toString()); // t=npt:10,20&xywh=pixel:160,120,320,240

let td = mf.get('t'); // TemporalDimension
td === mf.temporalDimension;
console.log(td.s); // start time: 10 seconds
console.log(td.e); // end time: 20 seconds

let sd = mf.get('xywh'); // SpatialDimension
console.log(sd.x); // 160 px
console.log(sd.y); // 120 px
console.log(sd.w); // 320 px
console.log(sd.h); // 240 px

let sd2 = new SpatialDimension('percent:25.3,25.5,50.456,50');
let width = 1000; // pixels
let height = 1000; // pixels
let result = sd2.clip({width, height});
console.log(result); // { x: 253, y: 255, w: 505, h: 500 }

Environments

Media Fragment provides index.js file as an ES module. You can use it in both browser module scripts and Node.js modules.

Browser

<script type=module>
  import MediaFragment, {SpatialDimension} from './node_modules/@kitaitimakoto/media-fragment/index.js';

  let mf = new MediaFragment('t=npt:10,20&xywh=pixel:160,120,320,240');
  // work with `mf`
</script>

Node.js module

index.mjs:

import MediaFragment, {SpatialDimension} from '@kitaitimakoto/media-fragment';

let mf = new MediaFragment('t=npt:10,20&xywh=pixel:160,120,320,240');
// work with `mf`

Run script:

% node index.mjs

TypeScript

index.ts:

import MediaFragment, {SpatialDimension} from '@kitaitimakoto/media-fragment';

let mf = new MediaFragment('t=npt:10,20&xywh=pixel:160,120,320,240');

let sd = mf.get('xywh');
// Need if clause to tell that mfs is a SpatialDimension to compiler
if (sd instanceof SpatialDimension) {
  console.log(sd.x); // 160 px
  console.log(sd.y); // 120 px
  console.log(sd.w); // 320 px
  console.log(sd.h); // 240 px
}

// Or
let sdAlt = mf.spatialDimension;
console.log(sdAlt.x); // 160 px
console.log(sdAlt.y); // 120 px
console.log(sdAlt.w); // 320 px
console.log(sdAlt.h); // 240 px

// work with `mf` and `sd` or `sdAlt`

tsconfig.json:

{
  "compilerOptions": {
    "module": "ES2020",
    "target": "ES2020",
    "moduleResolution": "node"
  },
  "files": [
    "index.ts"
  ]
}

Run the script:

% tsc && mv index.js index.mjs && node index.mjs
160
120
320
240

API

Visit https://kitaitimakoto.gitlab.io/media-fragment/

Source Code

Visit https://gitlab.com/KitaitiMakoto/media-fragment