Socket
Socket
Sign inDemoInstall

canvas-size

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-size - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

6

CHANGELOG.md
# Change Log
## 1.0.4
*2019-04-08*
- Fix memory consumption
## 1.0.3

@@ -4,0 +10,0 @@

8

dist/canvas-size.esm.js
/*!
* canvas-size
* v1.0.3
* v1.0.4
* https://github.com/jhildenbiddle/canvas-size

@@ -8,6 +8,2 @@ * (c) 2015-2019 John Hildenbiddle <http://hildenbiddle.com>

*/
const cvs = document ? document.createElement("canvas") : null;
const ctx = cvs && cvs.getContext ? cvs.getContext("2d") : null;
const defaults = {

@@ -29,2 +25,4 @@ max: null,

function canvasTest(width, height) {
const cvs = document ? document.createElement("canvas") : null;
const ctx = cvs && cvs.getContext ? cvs.getContext("2d") : null;
const w = 1;

@@ -31,0 +29,0 @@ const h = 1;

/*!
* canvas-size
* v1.0.3
* v1.0.4
* https://github.com/jhildenbiddle/canvas-size

@@ -8,3 +8,3 @@ * (c) 2015-2019 John Hildenbiddle <http://hildenbiddle.com>

*/
const t=document?document.createElement("canvas"):null,e=t&&t.getContext?t.getContext("2d"):null,i={max:null,min:1,sizes:[],step:1024,onError:Function.prototype,onSuccess:Function.prototype},s={area:[16384,14188,11402,10836,11180,8192,4096,i.min],height:[8388607,32767,16384,8192,4096,i.min],width:[4194303,32767,16384,8192,4096,i.min]};function n(i,s){const n=i-1,h=s-1;try{return t.width=i,t.height=s,e.fillRect(n,h,1,1),Boolean(e.getImageData(n,h,1,1).data[3])}catch(t){return!1}}function h(t){const e=t.sizes.shift(),i=e[0],s=e[1];n(i,s)?t.onSuccess(i,s):(t.onError(i,s),t.sizes.length&&setTimeout(function(){h(t)},0))}function o(t){const e=t.width===t.height,s=1===t.height,n=1===t.width,h=[];if(t.width&&t.height){const o=t.min||i.min,c=t.step||i.step;let a=Math.max(t.width,t.height);for(;a>o;){const t=e||s?a:1,i=e||n?a:1;h.push([t,i]),a-=c}h.push([o,o])}else t.sizes.forEach(t=>{const i=e||s?t:1,o=e||n?t:1;h.push([i,o])});return h}export default{maxArea(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=o({width:t.max,height:t.max,min:t.min,step:t.step,sizes:[...s.area]});h(Object.assign({},i,t,{sizes:e}))},maxHeight(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=o({width:1,height:t.max,min:t.min,step:t.step,sizes:[...s.height]});h(Object.assign({},i,t,{sizes:e}))},maxWidth(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=o({width:t.max,height:1,min:t.min,step:t.step,sizes:[...s.width]});h(Object.assign({},i,t,{sizes:e}))},test(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=Object.assign({},i,t);if(!e.sizes.length){return n(e.width,e.height)}e.sizes=[...t.sizes],h(e)}};
const t={max:null,min:1,sizes:[],step:1024,onError:Function.prototype,onSuccess:Function.prototype},e={area:[16384,14188,11402,10836,11180,8192,4096,t.min],height:[8388607,32767,16384,8192,4096,t.min],width:[4194303,32767,16384,8192,4096,t.min]};function i(t,e){const i=document?document.createElement("canvas"):null,s=i&&i.getContext?i.getContext("2d"):null,n=t-1,h=e-1;try{return i.width=t,i.height=e,s.fillRect(n,h,1,1),Boolean(s.getImageData(n,h,1,1).data[3])}catch(t){return!1}}function s(t){const e=t.sizes.shift(),n=e[0],h=e[1];i(n,h)?t.onSuccess(n,h):(t.onError(n,h),t.sizes.length&&setTimeout(function(){s(t)},0))}function n(e){const i=e.width===e.height,s=1===e.height,n=1===e.width,h=[];if(e.width&&e.height){const o=e.min||t.min,c=e.step||t.step;let a=Math.max(e.width,e.height);for(;a>o;){const t=i||s?a:1,e=i||n?a:1;h.push([t,e]),a-=c}h.push([o,o])}else e.sizes.forEach(t=>{const e=i||s?t:1,o=i||n?t:1;h.push([e,o])});return h}export default{maxArea(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const h=n({width:i.max,height:i.max,min:i.min,step:i.step,sizes:[...e.area]});s(Object.assign({},t,i,{sizes:h}))},maxHeight(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const h=n({width:1,height:i.max,min:i.min,step:i.step,sizes:[...e.height]});s(Object.assign({},t,i,{sizes:h}))},maxWidth(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const h=n({width:i.max,height:1,min:i.min,step:i.step,sizes:[...e.width]});s(Object.assign({},t,i,{sizes:h}))},test(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=Object.assign({},t,e);if(!n.sizes.length){return i(n.width,n.height)}n.sizes=[...e.sizes],s(n)}};
//# sourceMappingURL=canvas-size.esm.min.js.map
/*!
* canvas-size
* v1.0.3
* v1.0.4
* https://github.com/jhildenbiddle/canvas-size

@@ -42,4 +42,2 @@ * (c) 2015-2019 John Hildenbiddle <http://hildenbiddle.com>

}
var cvs = document ? document.createElement("canvas") : null;
var ctx = cvs && cvs.getContext ? cvs.getContext("2d") : null;
var defaults = {

@@ -59,2 +57,4 @@ max: null,

function canvasTest(width, height) {
var cvs = document ? document.createElement("canvas") : null;
var ctx = cvs && cvs.getContext ? cvs.getContext("2d") : null;
var w = 1;

@@ -61,0 +61,0 @@ var h = 1;

/*!
* canvas-size
* v1.0.3
* v1.0.4
* https://github.com/jhildenbiddle/canvas-size

@@ -8,3 +8,3 @@ * (c) 2015-2019 John Hildenbiddle <http://hildenbiddle.com>

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).canvasSize=e()}(this,function(){"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function e(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var n=document?document.createElement("canvas"):null,i=n&&n.getContext?n.getContext("2d"):null,r={max:null,min:1,sizes:[],step:1024,onError:Function.prototype,onSuccess:Function.prototype},o={area:[16384,14188,11402,10836,11180,8192,4096,r.min],height:[8388607,32767,16384,8192,4096,r.min],width:[4194303,32767,16384,8192,4096,r.min]};function s(t,e){var r=t-1,o=e-1;try{return n.width=t,n.height=e,i.fillRect(r,o,1,1),Boolean(i.getImageData(r,o,1,1).data[3])}catch(t){return!1}}function a(t){var e=t.sizes.shift(),n=e[0],i=e[1];s(n,i)?t.onSuccess(n,i):(t.onError(n,i),t.sizes.length&&setTimeout(function(){a(t)},0))}function h(t){var e=t.width===t.height,n=1===t.height,i=1===t.width,o=[];if(t.width&&t.height){for(var s=t.min||r.min,a=t.step||r.step,h=Math.max(t.width,t.height);h>s;){var u=e||n?h:1,c=e||i?h:1;o.push([u,c]),h-=a}o.push([s,s])}else t.sizes.forEach(function(t){var r=e||n?t:1,s=e||i?t:1;o.push([r,s])});return o}return{maxArea:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=h({width:n.max,height:n.max,min:n.min,step:n.step,sizes:e(o.area)});a(t({},r,n,{sizes:i}))},maxHeight:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=h({width:1,height:n.max,min:n.min,step:n.step,sizes:e(o.height)});a(t({},r,n,{sizes:i}))},maxWidth:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=h({width:n.max,height:1,min:n.min,step:n.step,sizes:e(o.width)});a(t({},r,n,{sizes:i}))},test:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t({},r,n);if(!i.sizes.length)return s(i.width,i.height);i.sizes=e(n.sizes),a(i)}}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).canvasSize=e()}(this,function(){"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function e(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var n={max:null,min:1,sizes:[],step:1024,onError:Function.prototype,onSuccess:Function.prototype},i={area:[16384,14188,11402,10836,11180,8192,4096,n.min],height:[8388607,32767,16384,8192,4096,n.min],width:[4194303,32767,16384,8192,4096,n.min]};function r(t,e){var n=document?document.createElement("canvas"):null,i=n&&n.getContext?n.getContext("2d"):null,r=t-1,o=e-1;try{return n.width=t,n.height=e,i.fillRect(r,o,1,1),Boolean(i.getImageData(r,o,1,1).data[3])}catch(t){return!1}}function o(t){var e=t.sizes.shift(),n=e[0],i=e[1];r(n,i)?t.onSuccess(n,i):(t.onError(n,i),t.sizes.length&&setTimeout(function(){o(t)},0))}function s(t){var e=t.width===t.height,i=1===t.height,r=1===t.width,o=[];if(t.width&&t.height){for(var s=t.min||n.min,a=t.step||n.step,h=Math.max(t.width,t.height);h>s;){var u=e||i?h:1,c=e||r?h:1;o.push([u,c]),h-=a}o.push([s,s])}else t.sizes.forEach(function(t){var n=e||i?t:1,s=e||r?t:1;o.push([n,s])});return o}return{maxArea:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=s({width:r.max,height:r.max,min:r.min,step:r.step,sizes:e(i.area)});o(t({},n,r,{sizes:a}))},maxHeight:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=s({width:1,height:r.max,min:r.min,step:r.step,sizes:e(i.height)});o(t({},n,r,{sizes:a}))},maxWidth:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=s({width:r.max,height:1,min:r.min,step:r.step,sizes:e(i.width)});o(t({},n,r,{sizes:a}))},test:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=t({},n,i);if(!s.sizes.length)return r(s.width,s.height);s.sizes=e(i.sizes),o(s)}}});
//# sourceMappingURL=canvas-size.min.js.map
{
"name": "canvas-size",
"version": "1.0.3",
"version": "1.0.4",
"description": "Determine the maximum size of an HTML canvas element and test support for custom canvas dimensions.",

@@ -46,16 +46,16 @@ "author": "John Hildenbiddle <http://hildenbiddle.com>",

"devDependencies": {
"@babel/core": "^7.2.0",
"@babel/core": "^7.4.3",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.2.0",
"@babel/polyfill": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"babel-loader": "^8.0.5",
"babel-plugin-istanbul": "^5.1.0",
"babel-plugin-istanbul": "^5.1.1",
"chai": "^4.2.0",
"eslint": "^5.12.0",
"eslint": "^5.16.0",
"eslint-plugin-chai-expect": "^2.0.1",
"eslint-plugin-mocha": "^5.2.1",
"karma": "^3.1.4",
"eslint-plugin-mocha": "^5.3.0",
"karma": "^4.0.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-eslint": "^2.2.0",

@@ -66,16 +66,16 @@ "karma-mocha": "^1.3.0",

"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.0-rc.5",
"karma-webpack": "^4.0.0-rc.6",
"lodash.merge": "^4.6.1",
"mocha": "^4.1.0",
"rimraf": "^2.6.3",
"rollup": "^1.1.0",
"rollup-plugin-babel": "^4.2.0",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-eslint": "^5.0.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-terser": "^4.0.2",
"webpack": "^4.28.1"
"rollup": "^1.9.0",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-eslint": "^5.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^4.2.1",
"rollup-plugin-terser": "^4.0.4",
"webpack": "^4.29.6"
},
"dependencies": {}
}

@@ -207,2 +207,4 @@ # canvas-size

Tests conducted using [BrowserStack](https://www.browserstack.com/) virtualized device are denoted with an asterisk (`*`). Results from these tests may vary from actual hardware.
### Desktop

@@ -214,3 +216,3 @@

| Edge 17 * | 16,384 | 16,384 | 268,435,456 (16,384 x 16,384) |
| Firefox 63 (Mac, Win *) | 32,767 | 32,767 | 124,992,400 (11,180 x 11,180) |
| Firefox 63 (Mac, Win*) | 32,767 | 32,767 | 124,992,400 (11,180 x 11,180) |
| IE 11 * | 16,384 | 16,384 | 67,108,864 (8,192 x 8,192) |

@@ -220,4 +222,2 @@ | IE 9 - 10 * | 8,192 | 8,192 | 67,108,864 (8,192 x 8,192) |

\* Tests conducted using [BrowserStack](https://www.browserstack.com/) virtualized device. Results from actual hardware may vary.
### Mobile

@@ -235,4 +235,2 @@

\* Tests conducted using [BrowserStack](https://www.browserstack.com/) virtualized device. Results from actual hardware may vary.
## Known Issues

@@ -239,0 +237,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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