{"name":"srcset","version":"5.0.2","keywords":["html","attribute","image","img","src","parse","stringify","srcset","responsive","picture","element"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"srcset@5.0.2","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/srcset#readme","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"dist":{"shasum":"153f05c66b818f787ac51a30ea63c1062f29081a","tarball":"http://registry-npm.ywwl.com/srcset/download/srcset-5.0.2.tgz","fileCount":5,"integrity":"sha512-pucR5KmXL7uWI59sXE2nuodomLsfnIQDa5Fck0TooiyxsIx+JYGiFm+wFO7aaDvvl/43ipjUjAb5je7dcAwlzQ==","signatures":[{"sig":"MEQCIEGSCUNwS9XHF/aBHml64inuCMoipojZ5RX5itgQbL1WAiBlfId1NlJWst4kU3FW6sS8qE5yBdausRcFQKkMDdR6DQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11564,"size":4233,"noattachment":false,"key":"/srcset/-/srcset-5.0.2.tgz"},"type":"module","types":"./index.d.ts","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"exports":"./index.js","funding":"https://github.com/sponsors/sindresorhus","gitHead":"1423c3d6885b42fa0525555802b93ae1433ff716","scripts":{"test":"ava && tsd","//test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/srcset.git","type":"git"},"_npmVersion":"10.9.2","description":"Parse and stringify the HTML `<img>` srcset attribute","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.46.4","ava":"^3.15.0","tsd":"^0.19.0"},"_npmOperationalInternal":{"tmp":"tmp/srcset_5.0.2_1757989691568_0.6085489324501332","host":"s3://npm-registry-packages-npm-production"},"readme":"# srcset\n\n> Parse and stringify the HTML `<img>` [srcset](https://www.smashingmagazine.com/2013/08/webkit-implements-srcset-and-why-its-a-good-thing/) attribute.\n\nCan be useful if you're creating a build-tool.\n\n## Install\n\n```sh\nnpm install srcset\n```\n\n## Usage\n\nHow an image with `srcset` might look like:\n\n```html\n<img\n\talt=\"The Breakfast Combo\"\n\tsrc=\"banner.jpg\"\n\tsrcset=\"banner-HD.jpg 2x, banner-phone.jpg 100w\"\n>\n```\n\nThen have some fun with it:\n\n```js\nimport {parseSrcset, stringifySrcset} from 'srcset';\n\nconst parsed = parseSrcset('banner-HD.jpg 2x, banner-phone.jpg 100w');\nconsole.log(parsed);\n/*\n[\n\t{\n\t\turl: 'banner-HD.jpg',\n\t\tdensity: 2\n\t},\n\t{\n\t\turl: 'banner-phone.jpg',\n\t\twidth: 100\n\t}\n]\n*/\n\nparsed.push({\n\turl: 'banner-super-HD.jpg',\n\tdensity: 3\n});\n\nconst stringified = stringifySrcset(parsed);\nconsole.log(stringified);\n/*\nbanner-HD.jpg 2x, banner-phone.jpg 100w, banner-super-HD.jpg 3x\n*/\n```\n\n## API\n\n### parseSrcset(string, options?)\n\nParse the HTML `<img>` [srcset](http://mobile.smashingmagazine.com/2013/08/21/webkit-implements-srcset-and-why-its-a-good-thing/) attribute.\n\nAccepts a “srcset” string and returns an array of objects with the possible properties: `url` (always), `width`, `height`, and `density`.\n\n#### string\n\nType: `string`\n\nA “srcset” string.\n\n#### options\n\nType: `object`\n\n##### strict\n\nType: `boolean`\\\nDefault: `false`\n\nWhen enabled, an invalid “srcset” string will cause an error to be thrown. When disabled, a best effort will be made to parse the string, potentially resulting in invalid or nonsensical output.\n\n### stringifySrcset(SrcSetDefinitions, options?)\n\nStringify `SrcSetDefinition`s. Accepts an array of `SrcSetDefinition` objects and returns a “srcset” string.\n\n#### srcsetDescriptors\n\nType: `array`\n\nAn array of `SrcSetDefinition` objects. Each object should have a `url` field and may have `width`, `height` or `density` fields. When the `strict` option is `true`, only `width` or `density` is accepted.\n\n#### options\n\nType: `object`\n\n##### strict\n\nType: `boolean`\\\nDefault: `false`\n\nEnable or disable validation of the `SrcSetDefinition`'s. When true, invalid input will cause an error to be thrown. When false, a best effort will be made to stringify invalid input, likely resulting in invalid srcset value.\n","publish_time":1757989691777,"_cnpm_publish_time":1757989691777,"dist-tags":{"latest":"5.0.3"}}