srcset-parse
An extra small srcset
attribute parser compliant with the latest spec.
Unlike srcset package, supports:
- URLs that contain commas;
- Zero or one descriptors per image definitions (like
2x
or100w
, but not both!).
Example usage:
; /** * [ * { url: "hifi-cat.jpeg", density: 3 }, * { url: "lowfi-cat.jpeg", width: 128 }, * ] */;
Using with TypeScript
The library is written in TypeScript, so you can import types if needed:
; const result: ImageCandidate = ;
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.