{"_id":"srcset","_rev":"3273789","name":"srcset","description":"Parse and stringify the HTML `<img>` srcset attribute","dist-tags":{"latest":"5.0.1"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2024-03-21T10:19:11.000Z","created":"2013-08-22T00:02:57.319Z","5.0.1":"2024-01-29T12:46:18.972Z","5.0.0":"2021-11-21T12:53:36.340Z","4.0.0":"2021-05-14T10:42:19.444Z","3.0.1":"2021-04-19T18:50:14.653Z","3.0.0":"2020-07-12T13:51:51.883Z","2.0.1":"2019-11-21T09:43:51.519Z","2.0.0":"2019-04-28T04:36:02.933Z","1.0.0":"2015-05-20T21:11:47.859Z","0.1.1":"2014-04-30T22:50:37.896Z","0.1.0":"2013-08-22T00:02:57.319Z"},"users":{"passy":true,"princetoad":true,"stretchgz":true,"timdp":true,"ash":true,"soenkekluth":true,"ierceg":true,"alexeiramone":true},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/srcset.git"},"versions":{"5.0.1":{"name":"srcset","version":"5.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"},"type":"module","exports":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"//test":"xo && ava && tsd","test":"ava && tsd"},"keywords":["html","attribute","image","img","src","parse","stringify","srcset","responsive","picture","element"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.19.0","xo":"^0.46.4"},"gitHead":"ee8997211913601aed606b80a22ce21b31c9e324","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"homepage":"https://github.com/sindresorhus/srcset#readme","_id":"srcset@5.0.1","_nodeVersion":"20.11.0","_npmVersion":"9.2.0","dist":{"shasum":"e660a728f195419e4afa95121099bc9efb7a1e36","size":3954,"noattachment":false,"key":"/srcset/-/srcset-5.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/srcset/download/srcset-5.0.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/srcset_5.0.1_1706532378807_0.4137589416649372"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-01-29T12:46:18.972Z","publish_time":1706532378972,"_source_registry_name":"default","_cnpm_publish_time":1706532378972},"5.0.0":{"name":"srcset","version":"5.0.0","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"},"type":"module","exports":"./index.js","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["html","attribute","image","img","src","parse","stringify","srcset","responsive","picture","element"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.19.0","xo":"^0.46.4"},"types":"./index.d.ts","gitHead":"f7c48acd7facf18e94dec47e6b96e84e0f0e69dc","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"homepage":"https://github.com/sindresorhus/srcset#readme","_id":"srcset@5.0.0","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"shasum":"9df6c3961b5b44a02532ce6ae4544832609e2e3f","size":4084,"noattachment":false,"key":"/srcset/-/srcset-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/srcset/download/srcset-5.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/srcset_5.0.0_1637499216182_0.22489143687350266"},"_hasShrinkwrap":false,"publish_time":1637499216340,"_cnpm_publish_time":1637499216340},"4.0.0":{"name":"srcset","version":"4.0.0","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":">=12"},"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.39.0"},"gitHead":"9549e25ca7919a08f2fb519e84784658e4009c9a","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"homepage":"https://github.com/sindresorhus/srcset#readme","_id":"srcset@4.0.0","_nodeVersion":"12.22.1","_npmVersion":"7.10.0","dist":{"shasum":"336816b665b14cd013ba545b6fe62357f86e65f4","size":4123,"noattachment":false,"key":"/srcset/-/srcset-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/srcset/download/srcset-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/srcset_4.0.0_1620988939336_0.5496458766421219"},"_hasShrinkwrap":false,"publish_time":1620988939444,"_cnpm_publish_time":1620988939444},"3.0.1":{"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":{"shasum":"3a09637782e71ded70126320e71b8eb92ce2ad6c","size":3241,"noattachment":false,"key":"/srcset/-/srcset-3.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/srcset/download/srcset-3.0.1.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/srcset_3.0.1_1618858214520_0.5349437316178152"},"_hasShrinkwrap":false,"publish_time":1618858214653,"_cnpm_publish_time":1618858214653},"3.0.0":{"name":"srcset","version":"3.0.0","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":"20305d968c275c89031f145c21f5c0fca76905b0","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"homepage":"https://github.com/sindresorhus/srcset#readme","_id":"srcset@3.0.0","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"8afd8b971362dfc129ae9c1a99b3897301ce6441","size":2927,"noattachment":false,"key":"/srcset/-/srcset-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/srcset/download/srcset-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/srcset_3.0.0_1594561911784_0.8605874722544176"},"_hasShrinkwrap":false,"publish_time":1594561911883,"_cnpm_publish_time":1594561911883},"2.0.1":{"name":"srcset","version":"2.0.1","description":"Parse and stringify the HTML <img> srcset attribute","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/srcset.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["html","attribute","image","img","src","parse","stringify","srcset","responsive","picture","element"],"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"5a0de0cd7fe459df0d769773256e53c5e3b0d489","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"homepage":"https://github.com/sindresorhus/srcset#readme","_id":"srcset@2.0.1","_nodeVersion":"10.17.0","_npmVersion":"6.11.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"8f842d357487eb797f413d9c309de7a5149df5ac","size":2820,"noattachment":false,"key":"/srcset/-/srcset-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/srcset/download/srcset-2.0.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/srcset_2.0.1_1574329431394_0.1424140433052059"},"_hasShrinkwrap":false,"publish_time":1574329431519,"_cnpm_publish_time":1574329431519},"2.0.0":{"name":"srcset","version":"2.0.0","description":"Parse and stringify the HTML <img> srcset attribute","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/srcset.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["html","attribute","image","img","src","parse","stringify","srcset","responsive","picture","element"],"dependencies":{"array-uniq":"^2.1.0"},"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"a8f5a47aafd776b718a2e711989f2b199a7f9a58","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"homepage":"https://github.com/sindresorhus/srcset#readme","_id":"srcset@2.0.0","_nodeVersion":"10.15.3","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"7d66b2cf223980ff1aa9d8389c23a449f00ad753","size":2642,"noattachment":false,"key":"/srcset/-/srcset-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/srcset/download/srcset-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/srcset_2.0.0_1556426162772_0.46719668119738555"},"_hasShrinkwrap":false,"publish_time":1556426162933,"_cnpm_publish_time":1556426162933},"1.0.0":{"name":"srcset","version":"1.0.0","description":"Parse and stringify the HTML <img> srcset attribute","keywords":["html","attribute","image","img","src","parse","stringify","srcset","responsive","picture","element"],"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/srcset.git"},"scripts":{"test":"mocha"},"dependencies":{"array-uniq":"^1.0.2","number-is-nan":"^1.0.0"},"devDependencies":{"mocha":"*"},"engines":{"node":">=0.10.0"},"license":"MIT","files":["index.js"],"gitHead":"3f11b6a47d916a3d6d67ccc3e6e3c2d9709e2922","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"homepage":"https://github.com/sindresorhus/srcset#readme","_id":"srcset@1.0.0","_shasum":"a5669de12b42f3b1d5e83ed03c71046fc48f41ef","_from":".","_npmVersion":"2.10.0","_nodeVersion":"0.12.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"a5669de12b42f3b1d5e83ed03c71046fc48f41ef","size":2310,"noattachment":false,"key":"/srcset/-/srcset-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/srcset/download/srcset-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1432156307859,"_cnpm_publish_time":1432156307859,"_hasShrinkwrap":false},"0.1.1":{"name":"srcset","version":"0.1.1","description":"Parse and stringify the HTML <img> srcset attribute","keywords":["html","attribute","image","img","src","parse","stringify"],"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"main":"srcset","repository":{"type":"git","url":"git://github.com/sindresorhus/srcset"},"scripts":{"test":"mocha"},"devDependencies":{"mocha":"*"},"engines":{"node":">=0.8.0"},"license":"MIT","files":["srcset.js"],"bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"homepage":"https://github.com/sindresorhus/srcset","_id":"srcset@0.1.1","dist":{"shasum":"244d82c270fe540e1d04193a7e5756184108842a","size":1761,"noattachment":false,"key":"/srcset/-/srcset-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/srcset/download/srcset-0.1.1.tgz"},"_from":".","_npmVersion":"1.4.6","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1398898237896,"_cnpm_publish_time":1398898237896,"_hasShrinkwrap":false},"0.1.0":{"name":"srcset","version":"0.1.0","description":"Parse and stringify the HTML <img> srcset attribute","keywords":["html","attribute","image","img","src","parse","stringify"],"homepage":"https://github.com/sindresorhus/srcset","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"main":"srcset","repository":{"type":"git","url":"git://github.com/sindresorhus/srcset.git"},"scripts":{"test":"mocha && phantomjs node_modules/mocha-phantomjs/lib/mocha-phantomjs.coffee test/test.html"},"devDependencies":{"mocha":"~1.12.0","chai":"~1.7.2","phantomjs":"~1.9.0","mocha-phantomjs":"~3.1.1"},"engines":{"node":">=0.8.0"},"licenses":[{"type":"MIT"}],"files":["srcset.js"],"readmeFilename":"readme.md","_id":"srcset@0.1.0","dist":{"shasum":"62c96648c7c79a7d6bc0aa46043d2c31158867d7","size":1892,"noattachment":false,"key":"/srcset/-/srcset-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/srcset/download/srcset-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1377129777319,"_cnpm_publish_time":1377129777319,"_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","_attachments":{},"homepage":"https://github.com/sindresorhus/srcset#readme","bugs":{"url":"https://github.com/sindresorhus/srcset/issues"},"license":"MIT"}