image-raub
Advanced tools
Comparing version 0.0.5 to 0.1.0
@@ -10,3 +10,3 @@ 'use strict'; | ||
class JsImage extends EventEmitter { | ||
class JsImage extends Image { | ||
@@ -17,6 +17,2 @@ constructor(src) { | ||
this.emit = this.emit.bind(this); | ||
this._image = new Image(this); | ||
this._complete = false; | ||
@@ -41,2 +37,6 @@ this._src = ''; | ||
addEventListener(type, cb) { | ||
this.on(type, cb.bind(this)); | ||
} | ||
on(name, cb) { | ||
@@ -49,10 +49,15 @@ super.on(name, cb); | ||
once(name, cb) { | ||
super.once(name, cb); | ||
if (name === 'load' && this._complete) { | ||
cb.call(this); | ||
} | ||
} | ||
get complete() { return this._complete; } | ||
get data() { return this._complete ? this._image.data : null; } | ||
get data() { return this._complete ? this.data : null; } | ||
get width() { return this._complete ? this._image.width : 0; } | ||
get height() { return this._complete ? this._image.height : 0; } | ||
get naturalWidth() { return this.width; } | ||
@@ -81,3 +86,3 @@ get naturalHeight() { return this.height; } | ||
} | ||
this._image.load(data); | ||
this.load(data); | ||
}); | ||
@@ -88,7 +93,2 @@ | ||
addEventListener(type, cb) { | ||
this.on(type, cb.bind(this)); | ||
} | ||
get onerror() { return this.listeners('error'); } | ||
@@ -104,5 +104,2 @@ set onerror(cb) { this.on('error', cb); } | ||
save(dest, w, h) { return this._image.save(dest, w, h); } | ||
} | ||
@@ -109,0 +106,0 @@ |
{ | ||
"author": "Luis Blanco <luisblanco1337@gmail.com>", | ||
"name": "image-raub", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"description": "Native Image loader for Node.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71
14498