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 to 0.4.1

src/browser/.eslintrc.json

35

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

@@ -10,18 +10,18 @@ "bugs": {

"dependencies": {
"jimp": "^0.2.21"
"jimp": "^0.2.24"
},
"devDependencies": {
"babel-preset-es2015": "^6.3.13",
"babelify": "^7.2.0",
"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",
"@egy186/eslint-config": "^0.8.0",
"babel-preset-es2015": "^6.9.0",
"babelify": "^7.3.0",
"browserify": "^13.0.1",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"eslint": "^2.13.0",
"istanbul": "^0.4.4",
"jsdoc-to-markdown": "^1.3.6",
"minifyify": "^7.3.3",
"mkdirp": "^0.5.1",
"mocha": "^2.3.4",
"rimraf": "^2.5.0"
"mocha": "^2.5.3",
"rimraf": "^2.5.2"
},

@@ -33,7 +33,4 @@ "engines": {

"src",
"LICENSE",
"README.md",
"browser.js",
"index.js",
"package.json"
"index.js"
],

@@ -54,3 +51,3 @@ "homepage": "https://egy186.github.io/icojs",

"clean": "rimraf coverage dist",
"doc": "jsdoc2md -f src/ico.js -t templates/README.md > README.md",
"doc": "jsdoc2md src/ico.js --template templates/README.md > README.md",
"lint": "eslint src test",

@@ -57,0 +54,0 @@ "test": "istanbul cover --root src --report lcov --dir coverage node_modules/mocha/bin/_mocha -- test/*.js"

'use strict';
const dataURLToArrayBuffer = dataURL => {
const string = global.atob(dataURL.replace(/.+,/, ''));
const string = atob(dataURL.replace(/.+,/, ''));
const view = new Uint8Array(string.length);

@@ -26,3 +26,3 @@ for (let i = 0; i < string.length; i++) {

const data = image.data;
const canvas = global.document.createElement('canvas');
const canvas = document.createElement('canvas');
canvas.width = image.width;

@@ -29,0 +29,0 @@ canvas.height = image.height;

@@ -22,10 +22,10 @@ 'use strict';

const dv = new DataView(buffer);
const icoWidth = dv.getUint8(6 + index * 16) || 256;
const icoHeight = dv.getUint8(7 + index * 16) || 256;
const icoOffset = dv.getUint32(18 + index * 16, true);
const icoWidth = dv.getUint8(6 + (index * 16)) || 256;
const icoHeight = dv.getUint8(7 + (index * 16)) || 256;
const icoOffset = dv.getUint32(18 + (index * 16), true);
const icoBit = dv.getUint16(icoOffset + 14, true);
const icoColorsOffset = dv.getUint32(18 + index * 16, true) + dv.getUint32(icoOffset, true);
const icoColorsOffset = dv.getUint32(18 + (index * 16), true) + dv.getUint32(icoOffset, true);
const icoColorsCount = dv.getUint32(icoOffset + 32, true);
const icoXorOffset = icoColorsOffset + icoColorsCount * 4;
const icoAndOffset = icoXorOffset + toDividableBy4(icoWidth * icoBit / 8) * icoHeight;
const icoXorOffset = icoColorsOffset + (icoColorsCount * 4);
const icoAndOffset = icoXorOffset + (toDividableBy4(icoWidth * icoBit / 8) * icoHeight);

@@ -35,10 +35,10 @@ const ico = {

height: icoHeight,
colorCount: dv.getUint8(8 + index * 16),
colorCount: dv.getUint8(8 + (index * 16)),
bit: icoBit,
colors: [],
xor: buffer.slice(icoXorOffset, icoAndOffset),
and: buffer.slice(icoAndOffset, icoAndOffset + toDividableBy4(icoWidth / 8) * icoHeight)
and: buffer.slice(icoAndOffset, icoAndOffset + (toDividableBy4(icoWidth / 8) * icoHeight))
};
for (let i = 0; i < icoColorsCount; i++) {
ico.colors.push(bitArray.of8(buffer.slice(icoColorsOffset + i * 4, icoColorsOffset + i * 4 + 4)));
ico.colors.push(bitArray.of8(buffer.slice(icoColorsOffset + (i * 4), icoColorsOffset + (i * 4) + 4)));
}

@@ -45,0 +45,0 @@

@@ -35,33 +35,30 @@ 'use strict';

const icos = Promise.all(range(icoDv.getUint16(4, true)).map(i => {
let data;
const ico = extractOne(buffer, i);
const image = {
width: ico.width,
height: ico.height
};
switch (ico.bit) { // eslint-disable-line default-case
case 1:
data = imageData.from1bit(ico);
image.data = imageData.from1bit(ico);
break;
case 4:
data = imageData.from4bit(ico);
image.data = imageData.from4bit(ico);
break;
case 8:
data = imageData.from8bit(ico);
image.data = imageData.from8bit(ico);
break;
case 24:
data = imageData.from24bit(ico);
image.data = imageData.from24bit(ico);
break;
case 32:
data = imageData.from32bit(ico);
image.data = imageData.from32bit(ico);
break;
}
return Image.encode({
return Image.encode(image, mime).then(pngBuffer => ({
bit: ico.bit,
width: ico.width,
height: ico.height,
data
}, mime).then(pngBuffer => {
return {
bit: ico.bit,
width: ico.width,
height: ico.height,
buffer: pngBuffer
};
});
buffer: pngBuffer
}));
}));

@@ -68,0 +65,0 @@ return icos;

@@ -22,7 +22,7 @@ 'use strict';

for (let w = 0; w < ico.width; w++) {
const color = ico.colors[xor[h * xorLine + w]];
const color = ico.colors[xor[(h * xorLine) + w]];
data[index] = color[2];
data[index + 1] = color[1];
data[index + 2] = color[0];
data[index + 3] = and[h * andLine + w] ? 0 : 255;
data[index + 3] = and[(h * andLine) + w] ? 0 : 255;
index += 4;

@@ -48,7 +48,7 @@ }

for (let w = 0; w < ico.width; w++) {
const color = ico.colors[xor[h * xorLine + w]];
const color = ico.colors[xor[(h * xorLine) + w]];
data[index] = color[2];
data[index + 1] = color[1];
data[index + 2] = color[0];
data[index + 3] = and[h * andLine + w] ? 0 : 255;
data[index + 3] = and[(h * andLine) + w] ? 0 : 255;
index += 4;

@@ -74,7 +74,7 @@ }

for (let w = 0; w < ico.width; w++) {
const color = ico.colors[xor[h * xorLine + w]];
const color = ico.colors[xor[(h * xorLine) + w]];
data[index] = color[2];
data[index + 1] = color[1];
data[index + 2] = color[0];
data[index + 3] = and[h * andLine + w] ? 0 : 255;
data[index + 3] = and[(h * andLine) + w] ? 0 : 255;
index += 4;

@@ -100,6 +100,6 @@ }

for (let w = 0; w < ico.width; w++) {
data[index] = xor[(h * xorLine + w) * 3 + 2];
data[index + 1] = xor[(h * xorLine + w) * 3 + 1];
data[index + 2] = xor[(h * xorLine + w) * 3];
data[index + 3] = and[h * andLine + w] ? 0 : 255;
data[index] = xor[(((h * xorLine) + w) * 3) + 2];
data[index + 1] = xor[(((h * xorLine) + w) * 3) + 1];
data[index + 2] = xor[((h * xorLine) + w) * 3];
data[index + 3] = and[(h * andLine) + w] ? 0 : 255;
index += 4;

@@ -125,6 +125,6 @@ }

for (let w = 0; w < ico.width; w++) {
data[index] = xor[(h * xorLine + w) * 4 + 2];
data[index + 1] = xor[(h * xorLine + w) * 4 + 1];
data[index + 2] = xor[(h * xorLine + w) * 4];
data[index + 3] = and[h * andLine + w] === 1 || xor[(h * xorLine + w) * 4 + 3] === 1 ? 0 : xor[(h * xorLine + w) * 4 + 3] > 1 ? xor[(h * xorLine + w) * 4 + 3] : 255; // eslint-disable-line no-nested-ternary
data[index] = xor[(((h * xorLine) + w) * 4) + 2];
data[index + 1] = xor[(((h * xorLine) + w) * 4) + 1];
data[index + 2] = xor[((h * xorLine) + w) * 4];
data[index + 3] = and[(h * andLine) + w] === 1 || xor[(((h * xorLine) + w) * 4) + 3] === 1 ? 0 : xor[(((h * xorLine) + w) * 4) + 3] > 1 ? xor[(((h * xorLine) + w) * 4) + 3] : 255; // eslint-disable-line no-nested-ternary
index += 4;

@@ -131,0 +131,0 @@ }

@@ -21,3 +21,3 @@ 'use strict';

const jimp = new Jimp(image.width, image.height);
jimp.scan(0, 0, jimp.bitmap.width, jimp.bitmap.height, function (x, y, idx) {
jimp.scan(0, 0, jimp.bitmap.width, jimp.bitmap.height, function scan (x, y, idx) {
this.bitmap.data[idx + 0] = data[idx + 0]; // eslint-disable-line no-invalid-this

@@ -24,0 +24,0 @@ this.bitmap.data[idx + 1] = data[idx + 1]; // eslint-disable-line no-invalid-this

@@ -14,7 +14,5 @@ 'use strict';

for (let i = 0; i < buff.byteLength; i++) {
bit += ('000000000' + buff[i].toString(2)).slice(-8);
bit += `000000000${buff[i].toString(2)}`.slice(-8);
}
return bit.split('').map(el => {
return parseInt(el, 2);
});
return bit.split('').map(el => parseInt(el, 2));
},

@@ -31,7 +29,5 @@ /**

for (let i = 0; i < buff.byteLength; i++) {
bit += ('00' + buff[i].toString(16)).slice(-2);
bit += `00${buff[i].toString(16)}`.slice(-2);
}
return bit.split('').map(el => {
return parseInt(el, 16);
});
return bit.split('').map(el => parseInt(el, 16));
},

@@ -38,0 +34,0 @@ /**

@@ -10,8 +10,6 @@ 'use strict';

const toDividableBy4 = num => {
if (num % 4 !== 0) {
num += 4 - num % 4;
}
return num;
const rest = num % 4;
return num % 4 === 0 ? num : num + 4 - rest;
};
module.exports = toDividableBy4;
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