# @prettier/parse-srcset

> A spec-conformant JavaScript parser for the HTML5 srcset attribute

Latest version **3.1.0** (published 2023-07-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @prettier/parse-srcset
pnpm add @prettier/parse-srcset
yarn add @prettier/parse-srcset
bun add @prettier/parse-srcset
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2023-07-07 |
| First published | 2022-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 15.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Alex Bell |
| Maintainers | fisker, suchipi, mgrip, czosel, patrick91, zimme, azz, vjeux, evilebottnawi, kddeisz, shinigami92, j-f, lydell |

## Links

- npm: https://www.npmjs.com/package/@prettier/parse-srcset
- Repository: https://github.com/prettier/parse-srcset
- Homepage: https://github.com/prettier/parse-srcset#readme
- Issues: https://github.com/prettier/parse-srcset/issues
- npm.io page: https://npm.io/package/@prettier/parse-srcset

## Recent versions

- 3.1.0 (latest) — 2023-07-07
- 3.0.0 — 2023-04-04
- 2.0.2 — 2022-10-14
- 2.0.1 — 2022-09-26
- 2.0.0 — 2022-09-26

## README

# @prettier/parse-srcset

This repository is a fork of https://github.com/albell/parse-srcset for [Prettier](https://github.com/prettier/prettier).

---

A javascript parser for the [HTML5 srcset](http://www.w3.org/TR/html-srcset/) attribute, based on the [WHATWG reference algorithm](https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute). It has an extensive test suite based on the [W3C srcset conformance checker](http://w3c-test.org/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html).

## Installation

```bash
yarn add @prettier/parse-srcset
```

## Usage

```js
import parseSrcset from "@prettier/parse-srcset";

parseSrcset('elva-fairy-320w.jpg, elva-fairy-480w.jpg 1.5x, elva-fairy-640w.jpg 2x');
/*
[
  { source: { value: 'elva-fairy-320w.jpg', startOffset: 0 } },
  {
    source: { value: 'elva-fairy-480w.jpg', startOffset: 21 },
    density: { value: 1.5 }
  },
  {
    source: { value: 'elva-fairy-640w.jpg', startOffset: 47 },
    density: { value: 2 }
  }
]
*/
```

---
_Source: https://npm.io/package/@prettier/parse-srcset · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
