Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jimp/core

Package Overview
Dependencies
Maintainers
2
Versions
240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jimp/core - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

50

dist/index.js

@@ -161,2 +161,17 @@ "use strict";

function loadFromURL(options, cb) {
(0, _request.default)(options, function (err, response, data) {
if (err) {
return cb(err);
}
if (_typeof(data) === 'object' && Buffer.isBuffer(data)) {
return cb(null, data);
}
var msg = 'Could not load Buffer from <' + options.url + '> ' + '(HTTP: ' + response.statusCode + ')';
return new Error(msg);
});
}
function loadBufferFromPath(src, cb) {

@@ -166,14 +181,5 @@ if (_fs.default && typeof _fs.default.readFile === 'function' && !src.match(/^(http|ftp)s?:\/\/./)) {

} else {
(0, _request.default)(src, function (err, response, data) {
if (err) {
return cb(err);
}
if (_typeof(data) === 'object' && Buffer.isBuffer(data)) {
return cb(null, data);
}
var msg = 'Could not load Buffer from <' + src + '> ' + '(HTTP: ' + response.statusCode + ')';
return new Error(msg);
});
loadFromURL({
url: src
}, cb);
}

@@ -219,2 +225,8 @@ }

/**
* Jimp constructor (from a url with options)
* @param options { url, otherOptions}
* @param {function(Error, Jimp)} cb (optional) a function to call when the image is parsed to a bitmap
*/
/**
* Jimp constructor (from another Jimp image or raw image data)

@@ -362,2 +374,16 @@ * @param image a Jimp image to clone

finish(null, _assertThisInitialized(_assertThisInitialized(_this)));
} else if (_typeof(args[0]) === 'object' && args[0].url) {
cb = args[1] || noop;
if (typeof cb !== 'function') {
return _possibleConstructorReturn(_this, _utils.throwError.call(_assertThisInitialized(_assertThisInitialized(_this)), 'cb must be a function', finish));
}
loadFromURL(args[0], function (err, data) {
if (err) {
return _utils.throwError.call(_assertThisInitialized(_assertThisInitialized(_this)), err, finish);
}
_this.parseBitmap(data, args[0].url, finish);
});
} else if (args[0] instanceof Jimp) {

@@ -364,0 +390,0 @@ // clone an existing Jimp

"use strict";
require("core-js/modules/es6.array.for-each");
require("core-js/modules/es6.array.filter");
require("core-js/modules/web.dom.iterable");
require("core-js/modules/es6.array.iterator");
require("core-js/modules/es6.object.keys");
require("core-js/modules/es6.object.define-property");
require("core-js/modules/es6.object.assign");
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/* global XMLHttpRequest */

@@ -7,5 +25,5 @@ if (process.browser || process.env.ENVIRONMENT === 'BROWSER' || typeof process.versions.electron !== 'undefined' && process.type === 'renderer' && typeof XMLHttpRequest === 'function') {

// use XHR method instead of Request node module.
module.exports = function (url, cb) {
module.exports = function (options, cb) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.open('GET', options.url, true);
xhr.responseType = 'arraybuffer';

@@ -18,6 +36,6 @@ xhr.addEventListener('load', function () {

} catch (err) {
return cb(new Error('Response is not a buffer for url ' + url + '. Error: ' + err.message));
return cb(new Error('Response is not a buffer for url ' + options.url + '. Error: ' + err.message));
}
} else {
cb(new Error('HTTP Status ' + xhr.status + ' for url ' + url));
cb(new Error('HTTP Status ' + xhr.status + ' for url ' + options.url));
}

@@ -31,9 +49,10 @@ });

} else {
module.exports = function (url, cb) {
module.exports = function (_ref, cb) {
var options = Object.assign({}, _ref);
var p = require('phin');
p({
url: url,
p(_objectSpread({
compression: true
}, function (err, res) {
}, options), function (err, res) {
if (err === null) {

@@ -40,0 +59,0 @@ cb(null, res, res.body);

@@ -79,2 +79,17 @@ function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }

function loadFromURL(options, cb) {
request(options, function (err, response, data) {
if (err) {
return cb(err);
}
if (_typeof(data) === 'object' && Buffer.isBuffer(data)) {
return cb(null, data);
}
var msg = 'Could not load Buffer from <' + options.url + '> ' + '(HTTP: ' + response.statusCode + ')';
return new Error(msg);
});
}
function loadBufferFromPath(src, cb) {

@@ -84,14 +99,5 @@ if (fs && typeof fs.readFile === 'function' && !src.match(/^(http|ftp)s?:\/\/./)) {

} else {
request(src, function (err, response, data) {
if (err) {
return cb(err);
}
if (_typeof(data) === 'object' && Buffer.isBuffer(data)) {
return cb(null, data);
}
var msg = 'Could not load Buffer from <' + src + '> ' + '(HTTP: ' + response.statusCode + ')';
return new Error(msg);
});
loadFromURL({
url: src
}, cb);
}

@@ -137,2 +143,8 @@ }

/**
* Jimp constructor (from a url with options)
* @param options { url, otherOptions}
* @param {function(Error, Jimp)} cb (optional) a function to call when the image is parsed to a bitmap
*/
/**
* Jimp constructor (from another Jimp image or raw image data)

@@ -280,2 +292,16 @@ * @param image a Jimp image to clone

finish(null, _assertThisInitialized(_assertThisInitialized(_this)));
} else if (_typeof(args[0]) === 'object' && args[0].url) {
cb = args[1] || noop;
if (typeof cb !== 'function') {
return _possibleConstructorReturn(_this, throwError.call(_assertThisInitialized(_assertThisInitialized(_this)), 'cb must be a function', finish));
}
loadFromURL(args[0], function (err, data) {
if (err) {
return throwError.call(_assertThisInitialized(_assertThisInitialized(_this)), err, finish);
}
_this.parseBitmap(data, args[0].url, finish);
});
} else if (args[0] instanceof Jimp) {

@@ -282,0 +308,0 @@ // clone an existing Jimp

@@ -0,1 +1,7 @@

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
/* global XMLHttpRequest */

@@ -5,5 +11,5 @@ if (process.browser || process.env.ENVIRONMENT === 'BROWSER' || typeof process.versions.electron !== 'undefined' && process.type === 'renderer' && typeof XMLHttpRequest === 'function') {

// use XHR method instead of Request node module.
module.exports = function (url, cb) {
module.exports = function (options, cb) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.open('GET', options.url, true);
xhr.responseType = 'arraybuffer';

@@ -16,6 +22,6 @@ xhr.addEventListener('load', function () {

} catch (err) {
return cb(new Error('Response is not a buffer for url ' + url + '. Error: ' + err.message));
return cb(new Error('Response is not a buffer for url ' + options.url + '. Error: ' + err.message));
}
} else {
cb(new Error('HTTP Status ' + xhr.status + ' for url ' + url));
cb(new Error('HTTP Status ' + xhr.status + ' for url ' + options.url));
}

@@ -29,9 +35,10 @@ });

} else {
module.exports = function (url, cb) {
module.exports = function (_ref, cb) {
var options = _extends({}, _ref);
var p = require('phin');
p({
url: url,
p(_objectSpread({
compression: true
}, function (err, res) {
}, options), function (err, res) {
if (err === null) {

@@ -38,0 +45,0 @@ cb(null, res, res.body);

{
"name": "@jimp/core",
"version": "0.5.1",
"version": "0.5.2",
"description": "Jimp core",

@@ -54,3 +54,3 @@ "main": "dist/index.js",

},
"gitHead": "b23ab92550336eed5d4ac422564c7c63ea280c73"
"gitHead": "206fa4a372f89b6b3ea87d73656066a0baf055d6"
}

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