Content-Length: 258338 | pFad | http://github.com/molefrog/srcset-parse

6E GitHub - molefrog/srcset-parse: ๐Ÿ™ Extra tiny `srcset` attribute parser ~150B
Skip to content

molefrog/srcset-parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

srcset-parse

An extra small srcset attribute parser compliant with the latest spec. It's is inspired by the srcset package and has following features:

  • Extra tiny, only ~150B;
  • Supports URLs that contain commas;
  • Zero or one descriptors per image definitions are supported (like 2x or 100w, but not both!);

Example usage:

import parse from "srcset-parse";

/**
 * [
 *   { url: "hifi-cat.jpeg",  density: 3 },
 *   { url: "lowfi-cat.jpeg", width: 128 },
 * ]
 */
parse("hifi-cat.jpeg 3x, lowfi-cat.jpeg 128w");

Using with TypeScript

The library is written in TypeScript, so you can import types if needed:

import parse, { ImageCandidate } from "srcset-parse";

const result: ImageCandidate[] = parse("icon@2x.png 2x, icon.png 1x");

Platform support

This library is written according to the ES2015 standard. Make sure your platform supports it, or your project is configured to transpile external modules.

About

๐Ÿ™ Extra tiny `srcset` attribute parser ~150B

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/molefrog/srcset-parse

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy