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.12.0 to 0.12.1

4

dist/ico.js
/*!
* icojs v0.12.0
* icojs v0.12.1
* (c) egy186
* https://github.com/egy186/icojs/blob/master/LICENSE
*/
!function(t,e){var r,n;"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r=t.ICO,n=e(),t.ICO=n,n.noConflict=function(){return t.ICO=r,n})}(this,function(){"use strict";function t(t,e){return t(e={exports:{}},e.exports),e.exports}var e="image/png",r=t(function(t){var r=e,n={decode:function(t){return new Promise(function(e){var r=URL.createObjectURL(new Blob([t])),n=document.createElement("img");n.src=r,n.onload=function(){var t=n.naturalHeight,r=n.naturalWidth,i=document.createElement("canvas");i.width=r,i.height=t;var a=i.getContext("2d");a.drawImage(n,0,0);var o=a.getImageData(0,0,r,t).data;e({data:o,height:t,width:r})}})},encode:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r;return new Promise(function(r){var n=t.data,i=t.height,a=t.width,o=document.createElement("canvas");o.width=a,o.height=i;for(var h=o.getContext("2d"),f=h.createImageData(a,i),u=f.data,s=0;s<u.length;s++)u[s]=n[s];h.putImageData(f,0,0),r(function(t){for(var e=atob(t.replace(/.+,/,"")),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r.buffer}(o.toDataURL(e)))})}};t.exports=n}),n=function(t){if(t instanceof Uint8Array)return new DataView(t.buffer,t.byteOffset,t.byteLength);if(t instanceof ArrayBuffer)return new DataView(t);throw new TypeError("Expected `data` to be an ArrayBuffer or Uint8Array")},i=t(function(t){t.exports=function(t){var e=n(t);return 0===e.getUint16(0,!0)&&1===e.getUint16(2,!0)}}),a=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();var h=function(){function t(e,r,n){var i,o;if(a(this,t),this.format=n.format,this.offset=r,this.depth=n.colorDepth,this.stride=(i=n.width*this.depth/8,(o=i%4)?i+4-o:i),this.size=this.stride*n.height,this.data=e.slice(this.offset,this.offset+this.size),this.size!==this.data.byteLength)throw new Error("Truncated bitmap data")}return o(t,[{key:"get",value:function(t,e,r){var n=this.format.indexOf(r);return 1===this.depth?(this.data[e*this.stride+(t/8|0)]&1<<7-t%8*1)>>7-t%8*1:2===this.depth?(this.data[e*this.stride+(t/4|0)]&3<<6-t%4*2)>>>6-t%4*2:4===this.depth?(this.data[e*this.stride+(t/2|0)]&15<<4-t%2*4)>>>4-t%2*4:this.data[e*this.stride+t*(this.depth/8)+n]}}]),t}();function f(t,e,r){var n=t.getUint32(0,!0),i=t.getUint32(4,!0)/1|0,a=t.getUint32(8,!0)/2|0,o=t.getUint16(14,!0),f=t.getUint32(32,!0);0===f&&o<=8&&(f=1<<o);var u=0===i?e:i,s=0===a?r:a,c=new Uint8Array(t.buffer,t.byteOffset+n,t.byteLength-n);return{width:u,height:s,data:f?function(t,e){var r=e.colorCount,n=e.colorDepth,i=e.height,a=e.width;if(8!==n&&4!==n&&2!==n&&1!==n)throw new Error("A color depth of "+n+" is not supported");for(var o=new h(t,0,{width:r,height:1,colorDepth:32,format:"BGRA"}),f=new h(t,o.offset+o.size,{width:a,height:i,colorDepth:n,format:"C"}),u=new h(t,f.offset+f.size,{width:a,height:i,colorDepth:1,format:"A"}),s=new Uint8Array(a*i*4),c=0,d=0;d<i;d++)for(var g=0;g<a;g++){var p=f.get(g,i-d-1,"C");s[c++]=o.get(p,0,"R"),s[c++]=o.get(p,0,"G"),s[c++]=o.get(p,0,"B"),s[c++]=u.get(g,i-d-1,"A")?0:255}return s}(c,{width:u,height:s,colorDepth:o,colorCount:f}):function(t,e){var r=e.colorDepth,n=e.height,i=e.width;if(32!==r&&24!==r)throw new Error("A color depth of "+r+" is not supported");for(var a=new h(t,0,{width:i,height:n,colorDepth:r,format:"BGRA"}),o=24===r?new h(t,a.offset+a.size,{width:i,height:n,colorDepth:1,format:"A"}):null,f=new Uint8Array(i*n*4),u=0,s=0;s<n;s++)for(var c=0;c<i;c++)f[u++]=a.get(c,n-s-1,"R"),f[u++]=a.get(c,n-s-1,"G"),f[u++]=a.get(c,n-s-1,"B"),f[u++]=32===r?a.get(c,n-s-1,"A"):o.get(c,n-s-1,"A")?0:255;return f}(c,{width:u,height:s,colorDepth:o}),colorDepth:o}}var u=function(t){var e=n(t);if(e.byteLength<6)throw new Error("Truncated header");if(0!==e.getUint16(0,!0))throw new Error("Invalid magic bytes");var r=e.getUint16(2,!0);if(1!==r&&2!==r)throw new Error("Invalid image type");var i=e.getUint16(4,!0);if(e.byteLength<6+16*i)throw new Error("Truncated image list");return Array.from({length:i},function(t,n){var i,a,o,h,u,s,c=e.getUint8(6+16*n+0),d=e.getUint8(6+16*n+1),g=e.getUint32(6+16*n+8,!0),p=e.getUint32(6+16*n+12,!0),l=2!==r?null:{x:e.getUint16(6+16*n+4,!0),y:e.getUint16(6+16*n+6,!0)};if(s=p,2303741511===(u=e).getUint32(s+0)&&218765834===u.getUint32(s+4))return{bpp:function(t,e){var r=t.getUint8(e+24),n=t.getUint8(e+25);if(0===n)return 1*r;if(2===n)return 3*r;if(3===n)return 1*r;if(4===n)return 2*r;if(6===n)return 4*r;throw new Error("Invalid PNG colorType")}(e,p),data:new Uint8Array(e.buffer,e.byteOffset+p,g),height:(o=e,h=p,o.getUint32(h+20,!1)),hotspot:l,type:"png",width:(i=e,a=p,i.getUint32(a+16,!1))};var w=f(new DataView(e.buffer,e.byteOffset+p,g),c,d);return{bpp:w.colorDepth,data:w.data,height:w.height,hotspot:l,type:"bmp",width:w.width}})},s=t(function(t){var r=e;t.exports=function(t,e,n){var i=null;try{i=u(t)}catch(t){return Promise.reject(t)}var a=function(t){return n.encode(t,e).then(function(r){return Object.assign(t,{type:e.replace("image/",""),buffer:r})})};return Promise.all(i.map(function(t){return e===r&&"png"===t.type?Promise.resolve(Object.assign({buffer:t.data.buffer.slice(t.data.byteOffset,t.data.byteOffset+t.data.byteLength)},t)):(i=t,"png"!==i.type?Promise.resolve(i):n.decode(i.data).then(function(t){return Object.assign(i,{type:"bmp",data:t.data})})).then(a);var i}))}}),c=e;return{isICO:i,parse:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c;return s(t,e,r)}}});
!function(t,e){var r,n;"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r=t.ICO,n=e(),(t.ICO=n).noConflict=function(){return t.ICO=r,n})}(this,function(){"use strict";function t(t,e){return t(e={exports:{}},e.exports),e.exports}var n="image/png",r=t(function(t){var e=n,r={decode:function(e){return new Promise(function(a){var t=URL.createObjectURL(new Blob([e])),o=document.createElement("img");o.src=t,o.onload=function(){var t=o.naturalHeight,e=o.naturalWidth,r=document.createElement("canvas");r.width=e,r.height=t;var n=r.getContext("2d");n.drawImage(o,0,0);var i=n.getImageData(0,0,e,t).data;a({data:i,height:t,width:e})}})},encode:function(u){var s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:e;return new Promise(function(t){var e=u.data,r=u.height,n=u.width,i=document.createElement("canvas");i.width=n,i.height=r;for(var a=i.getContext("2d"),o=a.createImageData(n,r),h=o.data,f=0;f<h.length;f++)h[f]=e[f];a.putImageData(o,0,0),t(function(t){for(var e=atob(t.replace(/.+,/,"")),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r.buffer}(i.toDataURL(s)))})}};t.exports=r}),e=function(t){if(t instanceof Uint8Array)return new DataView(t.buffer,t.byteOffset,t.byteLength);if(t instanceof ArrayBuffer)return new DataView(t);throw new TypeError("Expected `data` to be an ArrayBuffer or Uint8Array")},i=Object.freeze({default:e,__moduleExports:e}),a=i&&e||i,o=t(function(t){t.exports=function(t){var e=a(t);return 0===e.getUint16(0,!0)&&1===e.getUint16(2,!0)}}),h=function(){function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}}();var p=function(){function a(t,e,r){var n,i;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),this.format=r.format,this.offset=e,this.depth=r.colorDepth,this.stride=(n=r.width*this.depth/8,(i=n%4)?n+4-i:n),this.size=this.stride*r.height,this.data=t.slice(this.offset,this.offset+this.size),this.size!==this.data.byteLength)throw new Error("Truncated bitmap data")}return h(a,[{key:"get",value:function(t,e,r){var n=this.format.indexOf(r);return 1===this.depth?(this.data[e*this.stride+(t/8|0)]&1<<7-t%8*1)>>7-t%8*1:2===this.depth?(this.data[e*this.stride+(t/4|0)]&3<<6-t%4*2)>>>6-t%4*2:4===this.depth?(this.data[e*this.stride+(t/2|0)]&15<<4-t%2*4)>>>4-t%2*4:this.data[e*this.stride+t*(this.depth/8)+n]}}]),a}();function w(t,e,r){var n=t.getUint32(0,!0),i=t.getUint32(4,!0)/1|0,a=t.getUint32(8,!0)/2|0,o=t.getUint16(14,!0),h=t.getUint32(32,!0);0===h&&o<=8&&(h=1<<o);var f=0===i?e:i,u=0===a?r:a,s=new Uint8Array(t.buffer,t.byteOffset+n,t.byteLength-n);return{width:f,height:u,data:h?function(t,e){var r=e.colorCount,n=e.colorDepth,i=e.height,a=e.width;if(8!==n&&4!==n&&2!==n&&1!==n)throw new Error("A color depth of "+n+" is not supported");for(var o=new p(t,0,{width:r,height:1,colorDepth:32,format:"BGRA"}),h=new p(t,o.offset+o.size,{width:a,height:i,colorDepth:n,format:"C"}),f=new p(t,h.offset+h.size,{width:a,height:i,colorDepth:1,format:"A"}),u=new Uint8Array(a*i*4),s=0,c=0;c<i;c++)for(var d=0;d<a;d++){var g=h.get(d,i-c-1,"C");u[s++]=o.get(g,0,"R"),u[s++]=o.get(g,0,"G"),u[s++]=o.get(g,0,"B"),u[s++]=f.get(d,i-c-1,"A")?0:255}return u}(s,{width:f,height:u,colorDepth:o,colorCount:h}):function(t,e){var r=e.colorDepth,n=e.height,i=e.width;if(32!==r&&24!==r)throw new Error("A color depth of "+r+" is not supported");for(var a=new p(t,0,{width:i,height:n,colorDepth:r,format:"BGRA"}),o=24===r?new p(t,a.offset+a.size,{width:i,height:n,colorDepth:1,format:"A"}):null,h=new Uint8Array(i*n*4),f=0,u=0;u<n;u++)for(var s=0;s<i;s++)h[f++]=a.get(s,n-u-1,"R"),h[f++]=a.get(s,n-u-1,"G"),h[f++]=a.get(s,n-u-1,"B"),h[f++]=32===r?a.get(s,n-u-1,"A"):o.get(s,n-u-1,"A")?0:255;return h}(s,{width:f,height:u,colorDepth:o}),colorDepth:o}}var f=function(t){var p=a(t);if(p.byteLength<6)throw new Error("Truncated header");if(0!==p.getUint16(0,!0))throw new Error("Invalid magic bytes");var l=p.getUint16(2,!0);if(1!==l&&2!==l)throw new Error("Invalid image type");var e=p.getUint16(4,!0);if(p.byteLength<6+16*e)throw new Error("Truncated image list");return Array.from({length:e},function(t,e){var r,n,i,a,o,h,f=p.getUint8(6+16*e+0),u=p.getUint8(6+16*e+1),s=p.getUint32(6+16*e+8,!0),c=p.getUint32(6+16*e+12,!0),d=2!==l?null:{x:p.getUint16(6+16*e+4,!0),y:p.getUint16(6+16*e+6,!0)};if(h=c,2303741511===(o=p).getUint32(h+0)&&218765834===o.getUint32(h+4))return{bpp:function(t,e){var r=t.getUint8(e+24),n=t.getUint8(e+25);if(0===n)return 1*r;if(2===n)return 3*r;if(3===n)return 1*r;if(4===n)return 2*r;if(6===n)return 4*r;throw new Error("Invalid PNG colorType")}(p,c),data:new Uint8Array(p.buffer,p.byteOffset+c,s),height:(i=p,a=c,i.getUint32(a+20,!1)),hotspot:d,type:"png",width:(r=p,n=c,r.getUint32(n+16,!1))};var g=w(new DataView(p.buffer,p.byteOffset+c,s),f,u);return{bpp:g.colorDepth,data:g.data,height:g.height,hotspot:d,type:"bmp",width:g.width}})},u=t(function(t){var a=n;t.exports=function(t,r,n){var e=null;try{e=f(t)}catch(t){return Promise.reject(t)}var i=function(e){return n.encode(e,r).then(function(t){return Object.assign(e,{buffer:t,type:r.replace("image/","")})})};return Promise.all(e.map(function(t){return r===a&&"png"===t.type?Promise.resolve(Object.assign({buffer:t.data.buffer.slice(t.data.byteOffset,t.data.byteOffset+t.data.byteLength)},t)):(e=t,"png"!==e.type?Promise.resolve(e):n.decode(e.data).then(function(t){return Object.assign(e,{data:t.data,type:"bmp"})})).then(i);var e}))}}),s=n;return{isICO:o,parse:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:s;return u(t,e,r)}}});
//# sourceMappingURL=ico.js.map
{
"name": "icojs",
"description": "parse ico file",
"version": "0.12.0",
"version": "0.12.1",
"author": "egy186",

@@ -12,3 +12,3 @@ "bugs": {

"decode-ico": "^0.2.1",
"file-type": "^7.2.0",
"file-type": "^8.0.0",
"jpeg-js": "^0.3.3",

@@ -19,4 +19,4 @@ "pngjs": "^3.3.3",

"devDependencies": {
"@egy186/eslint-config": "~0.30.0",
"babel-core": "^6.26.0",
"@egy186/eslint-config": "~0.34.0",
"babel-core": "^6.26.3",
"babel-plugin-external-helpers": "^6.22.0",

@@ -27,3 +27,5 @@ "babel-preset-es2015": "^6.24.1",

"concat": "^1.0.3",
"eslint": "~4.17.0",
"data-uri-to-buffer": "^2.0.0",
"eslint": "~5.0.1",
"inline-source": "^6.1.5",
"jsdoc-to-markdown": "^4.0.1",

@@ -34,11 +36,12 @@ "jsonfile": "^4.0.0",

"npm-run-all": "^4.0.1",
"nyc": "^11.1.0",
"nyc": "^12.0.2",
"pixelmatch": "^4.0.2",
"pug-cli": "^1.0.0-alpha6",
"puppeteer": "^1.6.0",
"rimraf": "^2.5.2",
"rollup": "^0.58.0",
"rollup": "^0.63.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^9.0.0",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-plugin-uglify": "^3.0.0"
"rollup-plugin-uglify": "^4.0.0"
},

@@ -73,5 +76,7 @@ "engines": {

"lint": "eslint .",
"pretest:browser": "npm run build:dist",
"test": "nyc --reporter lcov --reporter text-summary --report-dir coverage mocha \"test/**/*.spec.js\"",
"test:browser": "mocha test/browser/test.js",
"version": "npm run build && git add docs/index.html README.md"
}
}

@@ -37,4 +37,4 @@ 'use strict';

return Image.decode(icon.data).then(decoded => Object.assign(icon, {
type: 'bmp',
data: decoded.data
data: decoded.data,
type: 'bmp'
}));

@@ -44,4 +44,4 @@ };

const encodeImage = icon => Image.encode(icon, mime).then(encoded => Object.assign(icon, {
type: mime.replace('image/', ''),
buffer: encoded
buffer: encoded,
type: mime.replace('image/', '')
}));

@@ -48,0 +48,0 @@

@@ -25,4 +25,4 @@ 'use strict';

Object.assign(icon, {
type: 'bmp',
data: decoded.data
data: decoded.data,
type: 'bmp'
});

@@ -32,4 +32,4 @@ }

return Object.assign(icon, {
type: mime.replace('image/', ''),
buffer: Image.encodeSync(icon, mime)
buffer: Image.encodeSync(icon, mime),
type: mime.replace('image/', '')
});

@@ -36,0 +36,0 @@ };

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