Skip to content

Commit

Permalink
Switch to canvas-prebuilt. Refs assetgraph/assetgraph-builder#627
Browse files Browse the repository at this point in the history
  • Loading branch information
Munter committed Oct 18, 2018
1 parent 36bed61 commit b4b1bf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 6 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(function () {
var Canvas,
Image,
getCanvasImageData = function (imageBuffer, callback) {
var canvasImage = new Canvas.Image();
var canvasImage = new Image();

canvasImage.onerror = function () {
callback(new Error('error while reading from input stream'));
Expand Down Expand Up @@ -108,7 +109,9 @@

if (typeof exports === 'object') {
// Assume nodejs
Canvas = require('canvas');
var canvasPrebuilt = require('canvas-prebuilt');
Canvas = canvasPrebuilt.Canvas;
Image = canvasPrebuilt.Image;
module.exports = histogram;
} else {
// Polyfill canvas constructor
Expand All @@ -119,7 +122,7 @@

return canvas;
};
Canvas.Image = Image;
Image = window.Image;

if (typeof define === 'function') {
// AMD module
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
],
"main": "lib/index.js",
"dependencies": {
"canvas": "^1.6.7"
"canvas-prebuilt": "2.0.0-alpha.14"
},
"devDependencies": {
"coveralls": "^2.11.9",
Expand All @@ -53,9 +53,8 @@
},
"scripts": {
"lint": "jshint .",
"phantom": "phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/global.html spec \"`node -pe 'JSON.stringify({useColors:true,grep:process.env.grep})'`\"",
"test": "npm run lint && mocha && npm run phantom",
"preversion": "uglifyjs lib/index.js -m -c > histogram.min.js && git add histogram.min.js",
"test": "npm run lint && mocha && mocha-phantomjs test/global.html",
"preversion": "npm t && uglifyjs lib/index.js -m -c > histogram.min.js && git add histogram.min.js",
"travis": "npm run lint && npm run coverage",
"coverage": "istanbul cover _mocha"
}
Expand Down

0 comments on commit b4b1bf0

Please sign in to comment.