{"name":"icojs","version":"0.3.0-alpha","keywords":["ico","parse"],"author":{"name":"egy186"},"license":"MIT","_id":"icojs@0.3.0-alpha","homepage":"https://egy186.github.io/icojs","bugs":{"url":"https://github.com/egy186/icojs/issues"},"dist":{"shasum":"1d7cf659ed72d782a7022aaeb82d3535c5ba0ef1","tarball":"http://registry-npm.ywwl.com/icojs/download/icojs-0.3.0-alpha.tgz","integrity":"sha512-5gTP7Kxwl2T1qgnrklglBxpxJNdGc+QLrSHiXuawK1HJMElaeWXyGfMuv77PeoLsowuCl3HX0VI0M1p8LC7x6w==","signatures":[{"sig":"MEUCIHYU40AU8msn5VI3jQkLBtcMX/swxL1CpNM1xyas3nxoAiEAnsLyAQiaHflqhvHVHDT1GTGyzObS0crrJB9PVwdOglQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":28416,"noattachment":false,"key":"/icojs/-/icojs-0.3.0-alpha.tgz"},"main":"src/ico.js","_from":".","files":["src","test","LICENSE","package.json","README.md"],"_shasum":"1d7cf659ed72d782a7022aaeb82d3535c5ba0ef1","gitHead":"2fa953d4052080023ab30705510ccae042b5c014","scripts":{"test":"gulp test","build":"gulp build"},"_npmUser":{"name":"egy186","email":"egy186@yahoo.co.jp"},"repository":{"url":"git+https://github.com/egy186/icojs.git","type":"git"},"_npmVersion":"2.11.3","description":"parse ico file","directories":{},"_nodeVersion":"0.12.5","dependencies":{"canvas":"^1.2.3"},"devDependencies":{"del":"^1.2.0","chai":"^3.0.0","gulp":"^3.9.0","browserify":"^10.2.4","gulp-mocha":"^2.1.2","gulp-eslint":"^0.14.0","gulp-rename":"^1.2.2","gulp-uglify":"^1.2.0","vinyl-buffer":"^1.0.0","gulp-istanbul":"^0.10.0","gulp-coveralls":"^0.1.4","gulp-sourcemaps":"^1.5.2","vinyl-source-stream":"^1.1.0"},"readme":"# icojs\n\n[![npm](https://img.shields.io/npm/v/icojs.svg)](https://www.npmjs.com/package/icojs)\n[![CI](https://github.com/egy186/icojs/actions/workflows/ci.yml/badge.svg)](https://github.com/egy186/icojs/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/egy186/icojs/badge.svg?branch=main)](https://coveralls.io/github/egy186/icojs?branch=main)\n[![codebeat badge](https://codebeat.co/badges/85bd457f-39b6-43d8-bf8e-c80ace07a8d7)](https://codebeat.co/projects/github-com-egy186-icojs)\n\nA JavaScript library to use ICO.\nWorks on both Node.js and the browser.\n\n## Install\n\n```sh\nnpm install icojs\n```\n\n### Node.js:\n\n```js\nimport { isICO, parseICO } from 'icojs';\n```\n\n### Browser:\n\n```js\nimport { isICO, parseICO } from 'icojs/browser';\n```\n\nor\n\n```html\n<script type=\"text/javascript\" src=\"node_modules/icojs/dist/ico.js\"></script>\n```\n\nTo fully use this library, browsers must support **JavaScript typed arrays**, **Canvas API** and **Promise**.\nChrome, Edge 12, Firefox and Safari 9 support these functions.\n\n## Example\n\n### Node.js:\n\n```js\nimport { readFile, writeFile } from 'node:fs/promises';\nimport { parseICO } from 'icojs';\n\nconst buffer = await readFile('favicon.ico');\nconst images = await parseICO(buffer, 'image/png');\n// save as png files\nimages.forEach(image => {\n  const file = `${image.width}x${image.height}-${image.bpp}bit.png`;\n  const data = Buffer.from(image.buffer);\n  writeFile(file, data);\n});\n```\n\n### Browser:\n\n```html\n<input type=\"file\" id=\"input-file\" />\n<script>\n  document.getElementById('input-file').addEventListener('change', evt => {\n    // use FileReader for converting File object to ArrayBuffer object\n    var reader = new FileReader();\n    reader.onload = async e => {\n      const images = await ICO.parseICO(e.target.result);\n      // logs images\n      console.dir(images);\n    };\n    reader.readAsArrayBuffer(evt.target.files[0]);\n  }, false);\n</script>\n```\n\n## Demo\n\n[https://egy186.github.io/icojs/#demo](https://egy186.github.io/icojs/#demo)\n\n## API\n\n<a name=\"module_ICO\"></a>\n\n### ICO\n\n* [ICO](#module_ICO)\n    * [isICO(source)](#exp_module_ICO--isICO) ⇒ <code>boolean</code> ⏏\n    * [parseICO(buffer, [mime])](#exp_module_ICO--parseICO) ⇒ <code>Promise.&lt;Array.&lt;ParsedImage&gt;&gt;</code> ⏏\n\n<a name=\"exp_module_ICO--isICO\"></a>\n\n#### isICO(source) ⇒ <code>boolean</code> ⏏\nCheck the ArrayBuffer is valid ICO.\n\n**Kind**: global method of [<code>ICO</code>](#module_ICO)  \n**Returns**: <code>boolean</code> - True if arg is ICO.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| source | <code>ArrayBuffer</code> \\| <code>Buffer</code> | ICO file data. |\n\n<a name=\"exp_module_ICO--parseICO\"></a>\n\n#### parseICO(buffer, [mime]) ⇒ <code>Promise.&lt;Array.&lt;ParsedImage&gt;&gt;</code> ⏏\nParse ICO and return some images.\n\n**Kind**: global method of [<code>ICO</code>](#module_ICO)  \n**Returns**: <code>Promise.&lt;Array.&lt;ParsedImage&gt;&gt;</code> - Resolves to an array of [ParsedImage](#ParsedImage).  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| buffer | <code>ArrayBuffer</code> \\| <code>Buffer</code> |  | ICO file data. |\n| [mime] | <code>string</code> | <code>&quot;image/png&quot;</code> | MIME type for output. |\n\n\n## Typedefs\n\n<a name=\"ParsedImage\"></a>\n\n### ParsedImage : <code>object</code>\n**Kind**: global typedef  \n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| width | <code>number</code> | Image width. |\n| height | <code>number</code> | Image height. |\n| bpp | <code>number</code> | Image color depth as bits per pixel. |\n| buffer | <code>ArrayBuffer</code> | Image buffer. |\n\n\n## License\n\nMIT license\n","publish_time":1435372722158,"maintainers":[{"name":"egy186","email":"egy186@yahoo.co.jp"}],"_cnpm_publish_time":1435372722158,"dist-tags":{"latest":"1.0.1"}}