Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

icojs

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icojs - npm Package Compare versions

Comparing version 0.4.0-alpha.1 to 0.4.0

src/browser/image.js

18

package.json
{
"name": "icojs",
"description": "parse ico file",
"version": "0.4.0-alpha.1",
"version": "0.4.0",
"author": "egy186",

@@ -15,13 +15,13 @@ "bugs": {

"babelify": "^7.2.0",
"browserify": "^12.0.1",
"chai": "^3.0.0",
"chai-as-promised": "^5.1.0",
"eslint": "^1.10.3",
"eslint-config-eslint": "^1.0.1",
"istanbul": "^0.4.1",
"jsdoc-to-markdown": "^1.3.1",
"browserify": "^13.0.0",
"chai": "^3.4.1",
"chai-as-promised": "^5.2.0",
"eslint": "^2.0.0-beta.1",
"eslint-config-eslint": "^2.0.0",
"istanbul": "^0.4.2",
"jsdoc-to-markdown": "^1.3.3",
"minifyify": "^7.1.0",
"mkdirp": "^0.5.1",
"mocha": "^2.3.4",
"rimraf": "^2.4.4"
"rimraf": "^2.5.0"
},

@@ -28,0 +28,0 @@ "engines": {

@@ -12,10 +12,9 @@ # icojs

A JavaScript library to use ICO.
Work on both Node.js and Browser.
```js
var fs = require('fs');
var ICO = require('icojs');
const fs = require('fs');
const ICO = require('icojs');
var arrayBuffer = new Uint8Array(fs.readFileSync('favicon.ico')).buffer;
const arrayBuffer = new Uint8Array(fs.readFileSync('favicon.ico')).buffer;
ICO.parse(arrayBuffer).then(images => {

@@ -47,3 +46,2 @@ // do something

To fully use this library, browsers must support **JavaScript typed arrays**, **Canvas API** and **Promise**.
Chrome, Edge 12, Firefox and Safari 9 support these functions.

@@ -53,3 +51,3 @@

[http://egy186.github.io/icojs/#demo](http://egy186.github.io/icojs/#demo)
[https://egy186.github.io/icojs/#demo](https://egy186.github.io/icojs/#demo)

@@ -60,3 +58,3 @@ <a name="ICO"></a>

* [ICO](#ICO)
* [.parse(buffer)](#ICO.parse) ⇒ <code>Promise.&lt;Array.&lt;Object&gt;&gt;</code>
* [.parse(buffer, mime)](#ICO.parse) ⇒ <code>Promise.&lt;Array.&lt;Object&gt;&gt;</code>
* [.isICO(buffer)](#ICO.isICO) ⇒ <code>Boolean</code>

@@ -66,3 +64,3 @@ * [.noConflict()](#ICO.noConflict) ⇒ <code>[ICO](#ICO)</code>

<a name="ICO.parse"></a>
### ICO.parse(buffer) ⇒ <code>Promise.&lt;Array.&lt;Object&gt;&gt;</code>
### ICO.parse(buffer, mime) ⇒ <code>Promise.&lt;Array.&lt;Object&gt;&gt;</code>
Parse ICO and return some PNGs.

@@ -80,2 +78,3 @@

| buffer | <code>ArrayBuffer</code> | The ArrayBuffer object contain the TypedArray of a ICO file. |
| mime | <code>String</code> | Mime type for output. |

@@ -82,0 +81,0 @@ <a name="ICO.isICO"></a>

'use strict';
const PNG = require('./png');
const Image = require('./image');
const ico = require('../ico');
const ICO = ico({ PNG });
const ICO = ico({ Image });
module.exports = ICO;

@@ -14,2 +14,3 @@ 'use strict';

const previousICO = global.ICO;
const Image = config.Image;
const ICO = {

@@ -20,2 +21,3 @@ /**

* @param {ArrayBuffer} buffer The ArrayBuffer object contain the TypedArray of a ICO file.
* @param {String} mime Mime type for output.
* @returns {Promise<Object[]>} Resolves to array of parsed ICO.

@@ -27,3 +29,3 @@ * * `width` **Number** - Image width.

*/
parse (buffer) {
parse (buffer, mime) {
const icoDv = new DataView(buffer);

@@ -55,7 +57,7 @@ if (icoDv.getUint16(0, true) !== 0 || icoDv.getUint16(2, true) !== 1) {

}
return config.PNG.encode({
return Image.encode({
width: ico.width,
height: ico.height,
data
}).then(pngBuffer => {
}, mime).then(pngBuffer => {
return {

@@ -62,0 +64,0 @@ bit: ico.bit,

@@ -14,3 +14,2 @@ 'use strict';

from1bit (ico) {
let color;
const xor = bitArray.of1(ico.xor);

@@ -24,3 +23,3 @@ const and = bitArray.of1(ico.and);

for (let w = 0; w < ico.width; w++) {
color = ico.colors[xor[h * xorLine + w]];
const color = ico.colors[xor[h * xorLine + w]];
data[index] = color[2];

@@ -42,3 +41,2 @@ data[index + 1] = color[1];

from4bit (ico) {
let color;
const xor = bitArray.of4(ico.xor);

@@ -52,3 +50,3 @@ const and = bitArray.of1(ico.and);

for (let w = 0; w < ico.width; w++) {
color = ico.colors[xor[h * xorLine + w]];
const color = ico.colors[xor[h * xorLine + w]];
data[index] = color[2];

@@ -70,3 +68,2 @@ data[index + 1] = color[1];

from8bit (ico) {
let color;
const xor = new Uint8Array(ico.xor);

@@ -80,3 +77,3 @@ const and = bitArray.of1(ico.and);

for (let w = 0; w < ico.width; w++) {
color = ico.colors[xor[h * xorLine + w]];
const color = ico.colors[xor[h * xorLine + w]];
data[index] = color[2];

@@ -83,0 +80,0 @@ data[index + 1] = color[1];

'use strict';
const PNG = require('./png');
const Image = require('./image');
const ico = require('./ico');
const ICO = ico({ PNG });
const ICO = ico({ Image });
module.exports = ICO;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc