{"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"],"_id":"srcset@0.1.0","dist":{"shasum":"62c96648c7c79a7d6bc0aa46043d2c31158867d7","tarball":"http://registry-npm.ywwl.com/srcset/download/srcset-0.1.0.tgz","integrity":"sha512-xF+JogXNnKRxVqw38jFKaiPGOG1JANzOvf8QbihKVuLNU63kT0PLHjjJNXvS2qoQ4MdZWYGS/qFzWsvK4MqE1A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDW9XZ0G1k7P7mQ3kzS20fmValbeEFkrzTR5NBLpNKPdAiBWTArVDKBfg1sHRMQRF79Qmr3KThgB3AdV/TUot13IWA=="}],"size":1892,"noattachment":false,"key":"/srcset/-/srcset-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"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":1377129777319,"_cnpm_publish_time":1377129777319,"dist-tags":{"latest":"5.0.3"}}