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.1 to 0.12.2

4

dist/ico.js
/*!
* icojs v0.12.1
* icojs v0.12.2
* (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).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)}}});
!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(o){var t=URL.createObjectURL(new Blob([e])),a=document.createElement("img");a.src=t,a.onload=function(){var t=a.naturalHeight,e=a.naturalWidth,r=document.createElement("canvas");r.width=e,r.height=t;var n=r.getContext("2d");n.drawImage(a,0,0);var i=n.getImageData(0,0,e,t).data;o({data:i,height:t,width:e})}})},encode:function(c){var u=1<arguments.length&&void 0!==arguments[1]?arguments[1]:e;return new Promise(function(t){var e=c.data,r=c.height,n=c.width,i=document.createElement("canvas");i.width=n,i.height=r;for(var o=i.getContext("2d"),a=o.createImageData(n,r),h=a.data,f=0;f<h.length;f++)h[f]=e[f];o.putImageData(a,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(u)))})}};t.exports=r}),v=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")},e=t(function(t){t.exports=function(t){var e=v(t);return 0===e.getUint16(0,!0)&&1===e.getUint16(2,!0)}});function i(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)}}var y=function(){function c(t,e,r){var n,i,o=r.width,a=r.height,h=r.colorDepth,f=r.format;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),this.format=f,this.offset=e,this.depth=h,this.stride=(n=o*this.depth/8,(i=n%4)?n+4-i:n),this.size=this.stride*a,this.data=t.slice(this.offset,this.offset+this.size),this.size!==this.data.byteLength)throw new Error("Truncated bitmap data")}var t,e,r;return t=c,(e=[{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*(this.depth/8)+n]:(this.data[e*this.stride+(t/2|0)]&15<<4-t%2*4)>>>4-t%2*4}}])&&i(t.prototype,e),r&&i(t,r),c}();var m=function(t){var e,r,n,i,o,a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},h=a.width,f=void 0===h?0:h,c=a.height,u=void 0===c?0:c,d=a.icon,g=void 0!==d&&d,s=v(t);0===(o=g?(e=s.getUint32(0,!0),r=s.getUint32(4,!0)/1|0,n=s.getUint32(8,!0)/2|0,i=s.getUint16(14,!0),s.getUint32(32,!0)):(function(t){if(19778!==t)throw new Error("Invalid magic byte 0x".concat(t.toString(16)))}(s.getUint16(0,!0)),e=14+s.getUint32(14,!0),r=s.getUint32(18,!0),n=s.getUint32(22,!0),i=s.getUint16(28,!0),s.getUint32(46,!0)))&&i<=8&&(o=1<<i);var p=0===r?f:r,l=0===n?u:n,w=new Uint8Array(s.buffer,s.byteOffset+e,s.byteLength-e);return{width:p,height:l,data:o?function(t,e){var r=e.width,n=e.height,i=e.colorDepth,o=e.colorCount,a=e.icon;if(8!==i&&4!==i&&2!==i&&1!==i)throw new Error("A color depth of ".concat(i," is not supported"));for(var h=new y(t,0,{width:o,height:1,colorDepth:32,format:"BGRA"}),f=new y(t,h.offset+h.size,{width:r,height:n,colorDepth:i,format:"C"}),c=a?new y(t,f.offset+f.size,{width:r,height:n,colorDepth:1,format:"A"}):null,u=new Uint8Array(r*n*4),d=0,g=0;g<n;g++)for(var s=0;s<r;s++){var p=f.get(s,n-g-1,"C");u[d++]=h.get(p,0,"R"),u[d++]=h.get(p,0,"G"),u[d++]=h.get(p,0,"B"),u[d++]=c&&c.get(s,n-g-1,"A")?0:255}return u}(w,{width:p,height:l,colorDepth:i,colorCount:o,icon:g}):function(t,e){var r=e.width,n=e.height,i=e.colorDepth,o=e.icon;if(32!==i&&24!==i)throw new Error("A color depth of ".concat(i," is not supported"));for(var a=new y(t,0,{width:r,height:n,colorDepth:i,format:"BGRA"}),h=24===i&&o?new y(t,a.offset+a.size,{width:r,height:n,colorDepth:1,format:"A"}):null,f=new Uint8Array(r*n*4),c=0,u=0;u<n;u++)for(var d=0;d<r;d++)f[c++]=a.get(d,n-u-1,"R"),f[c++]=a.get(d,n-u-1,"G"),f[c++]=a.get(d,n-u-1,"B"),f[c++]=32===i?a.get(d,n-u-1,"A"):h&&h.get(d,n-u-1,"A")?0:255;return f}(w,{width:p,height:l,colorDepth:i,icon:g}),colorDepth:i}};var a=function(t){var l=v(t);if(l.byteLength<6)throw new Error("Truncated header");if(0!==l.getUint16(0,!0))throw new Error("Invalid magic bytes");var w=l.getUint16(2,!0);if(1!==w&&2!==w)throw new Error("Invalid image type");var e=l.getUint16(4,!0);if(l.byteLength<6+16*e)throw new Error("Truncated image list");return Array.from({length:e},function(t,e){var r,n,i,o,a,h,f=l.getUint8(6+16*e+0),c=l.getUint8(6+16*e+1),u=l.getUint32(6+16*e+8,!0),d=l.getUint32(6+16*e+12,!0),g=2!==w?null:{x:l.getUint16(6+16*e+4,!0),y:l.getUint16(6+16*e+6,!0)};if(h=d,2303741511===(a=l).getUint32(h+0)&&218765834===a.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")}(l,d),data:new Uint8Array(l.buffer,l.byteOffset+d,u),height:(i=l,o=d,i.getUint32(o+20,!1)),hotspot:g,type:"png",width:(r=l,n=d,r.getUint32(n+16,!1))};var s=new Uint8Array(l.buffer,l.byteOffset+d,u),p=m(s,{width:f,height:c,icon:!0});return{bpp:p.colorDepth,data:p.data,height:p.height,hotspot:g,type:"bmp",width:p.width}})},o=t(function(t){var o=n;t.exports=function(t,r,n){var e=null;try{e=a(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===o&&"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}))}}),h=n;return{isICO:e,parse:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:h;return o(t,e,r)}}});
//# sourceMappingURL=ico.js.map
{
"name": "icojs",
"description": "parse ico file",
"version": "0.12.1",
"version": "0.12.2",
"author": "egy186",
"browser": "browser.js",
"bugs": {

@@ -11,4 +12,4 @@ "url": "https://github.com/egy186/icojs/issues"

"bmp-js": "0.1.0",
"decode-ico": "^0.2.1",
"file-type": "^8.0.0",
"decode-ico": "^0.3.1",
"file-type": "^10.4.0",
"jpeg-js": "^0.3.3",

@@ -19,6 +20,5 @@ "pngjs": "^3.3.3",

"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@egy186/eslint-config": "~0.34.0",
"babel-core": "^6.26.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-es2015": "^6.24.1",
"chai": "^4.0.1",

@@ -31,3 +31,3 @@ "chai-as-promised": "^7.0.0",

"jsdoc-to-markdown": "^4.0.1",
"jsonfile": "^4.0.0",
"jsonfile": "^5.0.0",
"jstransformer-markdown-it": "^2.0.0",

@@ -41,7 +41,7 @@ "mocha": "^5.0.0",

"rimraf": "^2.5.2",
"rollup": "^0.63.0",
"rollup-plugin-babel": "^3.0.2",
"rollup": "^0.67.1",
"rollup-plugin-babel": "^4.0.2",
"rollup-plugin-commonjs": "^9.0.0",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-plugin-uglify": "^4.0.0"
"rollup-plugin-uglify": "^6.0.0"
},

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

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