New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rsvg

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rsvg - npm Package Compare versions

Comparing version 0.1.5 to 0.2.0

.jshintrc

248

index.js

@@ -1,3 +0,1 @@

/*jshint node:true*/
'use strict';

@@ -12,6 +10,15 @@

* directly as an argument (Buffer or string) to the constructor. Otherwise the
* object is a writable stream and you can pipe a file into it.
* object is a writable stream and you can pipe a file into it. Optionally you
* can initialize the writable stream with specific options if you pass an
* object.
*
* @see [LibRSVG Default Constructor]{@link
* https://developer.gnome.org/rsvg/2.40/RsvgHandle.html#rsvg-handle-new}
* @see [LibRSVG Constructor From Data]{@link
* https://developer.gnome.org/rsvg/2.40/RsvgHandle.html#rsvg-handle-new-from-data}
* @see [Writable Stream Constructor]{@link
* http://nodejs.org/api/stream.html#stream_new_stream_writable_options}
*
* @constructor
* @param {(Buffer|string)} [buffer] - SVG file.
* @param {(Buffer|string|Object)} [buffer] - SVG file.
*/

@@ -30,2 +37,5 @@ function Rsvg(buffer) {

options = {};
} else if (typeof(buffer) === 'object') {
options = buffer;
buffer = null;
} else {

@@ -39,4 +49,14 @@ throw new TypeError('Invalid argument: buffer');

// Create new instance of binding.
self.handle = new binding.Rsvg(buffer);
try {
self.handle = new binding.Rsvg(buffer);
} catch (error) {
throw new Error('Rsvg load failure: ' + error.message);
}
if (buffer) {
process.nextTick(function() {
self.emit('load');
});
}
// When finished piping into this object, we need to tell the binding that by

@@ -49,58 +69,7 @@ // invoking the `close()` method.

self.trigger('error', error);
return;
}
});
// Define getter/setter for `baseURI` property.
Object.defineProperty(self, 'baseURI', {
configurable: true,
enumerable: true,
get: function() {
return self.handle.getBaseURI();
},
set: function(uri) {
self.handle.setBaseURI(uri);
}
self.emit('load');
});
// Define getter/setter for `dpiX` property.
Object.defineProperty(self, 'dpiX', {
configurable: true,
enumerable: true,
get: function() {
return self.handle.getDPIX();
},
set: function(dpi) {
self.handle.setDPIX(dpi);
}
});
// Define getter/setter for `dpiY` property.
Object.defineProperty(self, 'dpiY', {
configurable: true,
enumerable: true,
get: function() {
return self.handle.getDPIY();
},
set: function(dpi) {
self.handle.setDPIY(dpi);
}
});
// Define getter for `width` property.
Object.defineProperty(self, 'width', {
configurable: true,
enumerable: true,
get: function() {
return self.handle.getWidth();
}
});
// Define getter for `height` property.
Object.defineProperty(self, 'height', {
configurable: true,
enumerable: true,
get: function() {
return self.handle.getHeight();
}
});
}

@@ -117,4 +86,17 @@

// Define getter/setter for `baseURI` property.
Object.defineProperty(Rsvg.prototype, 'baseURI', {
configurable: true,
enumerable: true,
get: function() {
return this.handle.getBaseURI();
},
set: function(uri) {
this.handle.setBaseURI(uri);
}
});
/**
* Horizontal resolution. Allowed values: >= 0.
* @deprecated since version 2.0
* @member {number}

@@ -124,4 +106,17 @@ */

// Define getter/setter for deprecated `dpiX` property.
Object.defineProperty(Rsvg.prototype, 'dpiX', {
configurable: true,
enumerable: true,
get: util.deprecate(function() {
return this.handle.getDPIX();
}, 'Rsvg#dpiX: DPI does not affect rendering.'),
set: util.deprecate(function(dpi) {
this.handle.setDPIX(dpi);
}, 'Rsvg#dpiX: DPI does not affect rendering.')
});
/**
* Vertical resolution. Allowed values: >= 0.
* @deprecated since version 2.0
* @member {number}

@@ -131,2 +126,14 @@ */

// Define getter/setter for deprecated `dpiY` property.
Object.defineProperty(Rsvg.prototype, 'dpiY', {
configurable: true,
enumerable: true,
get: util.deprecate(function() {
return this.handle.getDPIY();
}, 'Rsvg#dpiY: DPI does not affect rendering.'),
set: util.deprecate(function(dpi) {
this.handle.setDPIY(dpi);
}, 'Rsvg#dpiY: DPI does not affect rendering.')
});
/**

@@ -139,2 +146,11 @@ * Image width. Always integer.

// Define getter for `width` property.
Object.defineProperty(Rsvg.prototype, 'width', {
configurable: true,
enumerable: true,
get: function() {
return this.handle.getWidth();
}
});
/**

@@ -147,4 +163,14 @@ * Image height. Always integer.

// Define getter for `height` property.
Object.defineProperty(Rsvg.prototype, 'height', {
configurable: true,
enumerable: true,
get: function() {
return this.handle.getHeight();
}
});
/**
* @see [Node.JS API]{@link http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback_1}
* @see [Node.JS API]{@link
* http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback_1}
* @private

@@ -156,3 +182,3 @@ */

} catch (error) {
callback(error);
callback(new Error('Rsvg write failure: ' + error.message));
return;

@@ -166,7 +192,9 @@ }

* Get the DPI for the outgoing pixbuf.
*
* @deprecated since version 2.0
* @returns {{x: number, y: number}}
*/
Rsvg.prototype.getDPI = function() {
Rsvg.prototype.getDPI = util.deprecate(function() {
return this.handle.getDPI();
};
}, 'Rsvg#getDPI(): DPI does not affect rendering.');

@@ -179,8 +207,9 @@ /**

*
* @deprecated since version 2.0
* @param {number} x - Horizontal resolution.
* @param {number} [y] - Vertical resolution. Set to the same as X if left out.
*/
Rsvg.prototype.setDPI = function(x, y) {
Rsvg.prototype.setDPI = util.deprecate(function(x, y) {
this.handle.setDPI(x, y);
};
}, 'Rsvg#setDPI(): DPI does not affect rendering.');

@@ -209,9 +238,9 @@ /**

/**
* Base render method. Valid high-level formats are: PNG, PDF, SVG, RAW. You
* can also specify the pixel structure of raw images: ARGB32 (default), RGB24,
* A8, A1, RGB16_565, and RGB30 (only enabled for Cairo >= 1.12). You can read
* Base render method. Valid high-level formats are: png, pdf, svg, raw. You
* can also specify the pixel structure of raw images: argb32 (default), rgb24,
* a8, a1, rgb16_565, and rgb30 (only enabled for Cairo >= 1.12). You can read
* more about the low-level pixel formats in the [Cairo Documentation]{@link
* http://cairographics.org/manual/cairo-Image-Surfaces.html#cairo-format-t}.
*
* If the id is given, only that subelement is rendered.
* If the element property is given, only that subelement is rendered.
*

@@ -221,13 +250,33 @@ * The PNG format is the slowest of them all, since it takes time to encode the

*
* @param {number} width - Output image width, should be an integer.
* @param {number} height - Output image height, should be an integer.
* @param {string} [format] - One of the formats listed above.
* @param {string} [id] - Subelement to render.
* @param {Object} [options] - Rendering options.
* @param {string} [options.format] - One of the formats listed above.
* @param {number} [options.width] - Output image width, should be an integer.
* @param {number} [options.height] - Output image height, should be an integer.
* @param {string} [options.element] - Subelement to render.
* @returns {{data: Buffer, format: string, width: number, height: number}}
*/
Rsvg.prototype.render = function(width, height, format, id) {
return this.handle.render(width, height, format, id);
Rsvg.prototype.render = function(options) {
if (arguments.length > 1 || typeof(options) !== 'object') {
return this._renderArgs.apply(this, arguments);
}
options = options || {};
return this.handle.render(
options.width,
options.height,
options.format,
options.id
);
};
/**
* @deprecated since version 2.0
* @private
*/
Rsvg.prototype._renderArgs = util.deprecate(function(width, height, format, id) {
return this.handle.render(width, height, format ? format.toLowerCase() : null, id);
}, 'Rsvg#render(): Call render({ format, width, height, ... }) instead.');
/**
* Render the SVG as a raw memory buffer image. This can be used to create an

@@ -241,2 +290,3 @@ * image that is imported into other image libraries. This render method is

*
* @deprecated since version 2.0
* @param {number} width - Output image width, should be an integer.

@@ -247,5 +297,10 @@ * @param {number} height - Output image height, should be an integer.

*/
Rsvg.prototype.renderRaw = function(width, height, id) {
return this.render(width, height, 'RAW', id);
};
Rsvg.prototype.renderRaw = util.deprecate(function(width, height, id) {
return this.render({
format: 'raw',
width: width,
height: height,
element: id
});
}, 'Rsvg#renderRaw(): Call render({ format: "raw" }) instead.');

@@ -255,2 +310,3 @@ /**

*
* @deprecated since version 2.0
* @param {number} width - Output image width, should be an integer.

@@ -261,5 +317,10 @@ * @param {number} height - Output image height, should be an integer.

*/
Rsvg.prototype.renderPNG = function(width, height, id) {
return this.render(width, height, 'PNG', id);
};
Rsvg.prototype.renderPNG = util.deprecate(function(width, height, id) {
return this.render({
format: 'png',
width: width,
height: height,
element: id
});
}, 'Rsvg#renderPNG(): Call render({ format: "png" }) instead.');

@@ -269,2 +330,3 @@ /**

*
* @deprecated since version 2.0
* @param {number} width - Output document width, should be an integer.

@@ -275,5 +337,10 @@ * @param {number} height - Output document height, should be an integer.

*/
Rsvg.prototype.renderPDF = function(width, height, id) {
return this.render(width, height, 'PDF', id);
};
Rsvg.prototype.renderPDF = util.deprecate(function(width, height, id) {
return this.render({
format: 'pdf',
width: width,
height: height,
element: id
});
}, 'Rsvg#renderPDF(): Call render({ format: "pdf" }) instead.');

@@ -286,2 +353,3 @@ /**

*
* @deprecated since version 2.0
* @param {number} width - Output document width, should be an integer.

@@ -292,5 +360,10 @@ * @param {number} height - Output document height, should be an integer.

*/
Rsvg.prototype.renderSVG = function(width, height, id) {
return this.render(width, height, 'SVG', id);
};
Rsvg.prototype.renderSVG = util.deprecate(function(width, height, id) {
return this.render({
format: 'svg',
width: width,
height: height,
element: id
});
}, 'Rsvg#renderSVG(): Call render({ format: "svg" }) instead.');

@@ -309,5 +382,2 @@ /**

var dpi = this.getDPI();
obj.dpi = (dpi.x === dpi.y) ? dpi.x : dpi;
obj.width = this.width;

@@ -314,0 +384,0 @@ obj.height = this.height;

{
"name": "rsvg",
"version": "0.1.5",
"version": "0.2.0",
"description": "Parse SVG files and render them as PNG, PDF, SVG, or raw memory buffer images.",

@@ -13,3 +13,14 @@ "keywords": [

},
"scripts": {
"test": "grunt test"
},
"devDependencies": {
"chai": "~1.8.1",
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.7.1",
"grunt-mocha-test": "~0.7.0",
"sinon": "~1.7.3",
"sinon-chai": "~2.4.0"
},
"license": "MIT"
}

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