{"name":"srcset","version":"3.0.1","description":"Parse and stringify the HTML `<img>` srcset attribute","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/srcset.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["html","attribute","image","img","src","parse","stringify","srcset","responsive","picture","element"],"devDependencies":{"ava":"^2.4.0","tsd":"^0.13.1","xo":"^0.32.1"},"gitHead":"2c153e4461c15ea0b907d2d83936f0ecd1c8a07a","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"homepage":"https://github.com/sindresorhus/srcset#readme","_id":"srcset@3.0.1","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-MM8wDGg5BQJEj94tDrZDrX9wrC439/Eoeg3sgmVLPMjHgrAFeXAKk3tmFlCbKw5k+yOEhPXRpPlRcisQmqWVSQ==","shasum":"3a09637782e71ded70126320e71b8eb92ce2ad6c","tarball":"http://registry-npm.ywwl.com/srcset/download/srcset-3.0.1.tgz","fileCount":5,"unpackedSize":7254,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgfdDmCRA9TVsSAnZWagAAdiQQAI7UQEzb/K0uuSCINkKe\nT6dF3uFNVreNHf4mbTfl5RSWTPvSC4azogFFpZJpCTVj0Unfo8m9wU8iML9b\n15qHUvPhmsoPWg7K7iQQk2LU23iN8CoN9XtIg0H+5F5SupjA/RH8aW2wN7UI\nYY+dlixxinmZkTQBMMmNOygX5LE36rZkv3YNJCLPWmXVRD4C4TWi5hwA3on/\n7771q70vY02Ig4BpTqyv6lGh30XcDVwNHm/8p0/1ezTpnS7gWtKwkrc6Tt1L\n4VJSuISNmhbcIn1c2mPjQsAXQlxRAk7LoNqH1oB+FVkMRAyYzfGxcxu7Astd\nKHlxAX80WpvhirCE812kz53xQUB8avHZAqThKPIwEXMn0PlsVBnuGReh/EQe\n7AH0ULyKu+LISKtdmlp7POb0GY4J8YzUHlDVsXjTtrnFNQyzW57WKIxd9Q0a\nsaCbLgBf12sakMHQEr9+6Y7zxb1aLNU6ycKzMqxVVNU0w2brtEV/ckSqwfYD\npTRL+7i/chUOXR9uW6TR2G5q+4TehEz2k0eodMzJF3RSqYbYWqPDyY7Ch1qR\nJZMIqrdPtiBLvSaRMlluxorSCGaommbv7LUNl3T8NWSg+E1WCPcbzbFPOKH4\nsXOjmPyPd4xleU42uV6bNZHfnKYY0T67xwypb+oxgpThLUw1Oi82xFqCq+Xv\njwN7\r\n=R2ra\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHs+tBcWLb+R70aP018eKs8whKDXWEE90JZU4mo/sq/MAiAuwQjBUlEogJvC9hQH2d5Plr5a5Jh0oyv0f67Z1+uHiQ=="}],"size":3241,"noattachment":false,"key":"/srcset/-/srcset-3.0.1.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/srcset_3.0.1_1618858214520_0.5349437316178152"},"_hasShrinkwrap":false,"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":1618858214653,"_cnpm_publish_time":1618858214653,"dist-tags":{"latest":"5.0.3"}}