Socket
Socket
Sign inDemoInstall

react-avatar

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-avatar - npm Package Compare versions

Comparing version 3.9.1 to 3.9.2

8

es/avatar.js

@@ -13,4 +13,2 @@ 'use strict';

import "core-js/modules/es.object.assign";
import "core-js/modules/es.object.define-properties";
import "core-js/modules/es.object.define-property";
import "core-js/modules/es.object.get-own-property-descriptor";

@@ -28,3 +26,3 @@ import "core-js/modules/es.object.get-own-property-descriptors";

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

@@ -86,5 +84,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

var Avatar =
/*#__PURE__*/
function (_PureComponent) {
var Avatar = /*#__PURE__*/function (_PureComponent) {
_inherits(Avatar, _PureComponent);

@@ -91,0 +87,0 @@

import "core-js/modules/es.array.filter";
import "core-js/modules/es.array.slice";
import "core-js/modules/es.array.some";
import "core-js/modules/es.date.to-string";
import "core-js/modules/es.object.define-property";

@@ -24,5 +22,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

export var Cache =
/*#__PURE__*/
function () {
export var Cache = /*#__PURE__*/function () {
function Cache() {

@@ -29,0 +25,0 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

@@ -7,3 +7,2 @@ import "core-js/modules/es.symbol";

import "core-js/modules/es.object.assign";
import "core-js/modules/es.object.define-property";
import "core-js/modules/es.object.get-prototype-of";

@@ -17,3 +16,3 @@ import "core-js/modules/es.object.keys";

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

@@ -79,5 +78,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

};
export var ConfigProvider =
/*#__PURE__*/
function (_React$Component) {
export var ConfigProvider = /*#__PURE__*/function (_React$Component) {
_inherits(ConfigProvider, _React$Component);

@@ -84,0 +81,0 @@

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

import "core-js/modules/es.object.define-property";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -9,5 +7,3 @@

var InternalState =
/*#__PURE__*/
function () {
var InternalState = /*#__PURE__*/function () {
function InternalState() {

@@ -14,0 +10,0 @@ _classCallCheck(this, InternalState);

'use strict';
import "core-js/modules/es.array.concat";
import "core-js/modules/es.object.define-property";
import "core-js/modules/es.regexp.exec";

@@ -13,2 +12,3 @@ import "core-js/modules/es.string.replace";

import PropTypes from 'prop-types';
import { getImageSize } from '../utils';
export default function createRedirectSource(network, property) {

@@ -29,8 +29,7 @@ var _class, _temp;

_defineProperty(this, "get", function (setState) {
var _this$props = _this.props,
size = _this$props.size,
avatarRedirectUrl = _this$props.avatarRedirectUrl;
var avatarRedirectUrl = _this.props.avatarRedirectUrl;
var size = getImageSize(_this.props.size);
var baseUrl = avatarRedirectUrl.replace(/\/*$/, '/');
var id = _this.props[property];
var query = size ? '' : "size=".concat(size);
var query = size ? "size=".concat(size) : '';
var src = "".concat(baseUrl).concat(network, "/").concat(id, "?").concat(query);

@@ -37,0 +36,0 @@ setState({

'use strict';
import "core-js/modules/es.array.concat";
import "core-js/modules/es.object.define-property";

@@ -11,2 +10,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

import PropTypes from 'prop-types';
import { getImageSize } from '../utils';

@@ -25,6 +25,6 @@ var FacebookSource = function FacebookSource(props) {

_defineProperty(this, "get", function (setState) {
var _this$props = _this.props,
size = _this$props.size,
facebookId = _this$props.facebookId;
var url = 'https://graph.facebook.com/' + "".concat(facebookId, "/picture?width=").concat(size, "&height=").concat(size);
var facebookId = _this.props.facebookId;
var size = getImageSize(_this.props.size);
var url = "https://graph.facebook.com/".concat(facebookId, "/picture");
if (size) url += "?width=".concat(size, "&height=").concat(size);
setState({

@@ -31,0 +31,0 @@ sourceName: 'facebook',

'use strict';
import "core-js/modules/es.array.concat";
import "core-js/modules/es.object.define-property";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -11,2 +8,3 @@

import PropTypes from 'prop-types';
import { getImageSize } from '../utils';

@@ -25,6 +23,6 @@ var GithubSource = function GithubSource(props) {

_defineProperty(this, "get", function (setState) {
var _this$props = _this.props,
size = _this$props.size,
githubHandle = _this$props.githubHandle;
var url = "https://avatars.githubusercontent.com/".concat(githubHandle, "?v=4&s=").concat(size);
var githubHandle = _this.props.githubHandle;
var size = getImageSize(_this.props.size);
var url = "https://avatars.githubusercontent.com/".concat(githubHandle, "?v=4");
if (size) url += "&s=".concat(size);
setState({

@@ -31,0 +29,0 @@ sourceName: 'github',

'use strict';
import "core-js/modules/es.array.concat";
import "core-js/modules/es.object.define-property";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -11,5 +8,4 @@

import PropTypes from 'prop-types';
import retina from 'is-retina';
import md5 from 'md5';
var IS_RETINA = retina();
import { getImageSize } from '../utils';

@@ -30,4 +26,5 @@ var GravatarSource = function GravatarSource(_props) {

var email = props.md5Email || md5(props.email);
var size = IS_RETINA ? props.size * 2 : props.size;
var url = "https://secure.gravatar.com/avatar/".concat(email, "?s=").concat(size, "&d=404");
var size = getImageSize(props.size);
var url = "https://secure.gravatar.com/avatar/".concat(email, "?d=404");
if (size) url += "&s=".concat(size);
setState({

@@ -34,0 +31,0 @@ sourceName: 'gravatar',

'use strict';
import "core-js/modules/es.object.define-property";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -6,0 +4,0 @@

'use strict';
import "core-js/modules/es.object.define-property";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -6,0 +4,0 @@

'use strict';
import "core-js/modules/es.object.define-property";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -6,0 +4,0 @@

'use strict';
import "core-js/modules/es.function.name";
import "core-js/modules/es.object.define-property";

@@ -17,5 +16,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var ValueSource =
/*#__PURE__*/
function () {
var ValueSource = /*#__PURE__*/function () {
function ValueSource(props) {

@@ -22,0 +19,0 @@ var _this = this;

@@ -15,3 +15,2 @@ 'use strict';

import "core-js/modules/es.array.slice";
import "core-js/modules/es.date.to-string";
import "core-js/modules/es.object.to-string";

@@ -42,2 +41,4 @@ import "core-js/modules/es.parse-float";

import retina from 'is-retina';
var IS_RETINA = retina();
export function fetch(url, successCb, errorCb) {

@@ -135,2 +136,19 @@ var request = new XMLHttpRequest();

}
/**
* Calculate absolute size in pixels we want for the images
* that get requested from the various sources. They don't
* understand relative sizes like `em` or `vww`. We select
* a fixed size of 512px when we can't detect the true pixel size.
*/
export function getImageSize(size) {
size = parseSize(size);
if (isNaN(size.value)) // invalid size, use fallback
size = 512;else if (size.unit === 'px') // px are good, use them
size = size.value;else if (size.value === 0) // relative 0 === absolute 0
size = 0;else // anything else is unknown, use fallback
size = 512;
if (IS_RETINA) size = size * 2;
return size;
}
export function defaultInitials(name, _ref3) {

@@ -137,0 +155,0 @@ var maxInitials = _ref3.maxInitials;

@@ -23,6 +23,2 @@ 'use strict';

require("core-js/modules/es.object.define-properties");
require("core-js/modules/es.object.define-property");
require("core-js/modules/es.object.get-own-property-descriptor");

@@ -91,3 +87,3 @@

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

@@ -139,5 +135,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

var Avatar =
/*#__PURE__*/
function (_PureComponent) {
var Avatar = /*#__PURE__*/function (_PureComponent) {
_inherits(Avatar, _PureComponent);

@@ -144,0 +138,0 @@

@@ -9,6 +9,2 @@ "use strict";

require("core-js/modules/es.date.to-string");
require("core-js/modules/es.object.define-property");
Object.defineProperty(exports, "__esModule", {

@@ -38,5 +34,3 @@ value: true

var Cache =
/*#__PURE__*/
function () {
var Cache = /*#__PURE__*/function () {
function Cache() {

@@ -43,0 +37,0 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

@@ -15,4 +15,2 @@ "use strict";

require("core-js/modules/es.object.define-property");
require("core-js/modules/es.object.get-prototype-of");

@@ -47,3 +45,3 @@

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

@@ -110,5 +108,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var ConfigProvider =
/*#__PURE__*/
function (_React$Component) {
var ConfigProvider = /*#__PURE__*/function (_React$Component) {
_inherits(ConfigProvider, _React$Component);

@@ -115,0 +111,0 @@

'use strict';
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

@@ -5,0 +5,0 @@ Object.defineProperty(exports, "__esModule", {

"use strict";
require("core-js/modules/es.object.define-property");
Object.defineProperty(exports, "__esModule", {

@@ -16,5 +14,3 @@ value: true

var InternalState =
/*#__PURE__*/
function () {
var InternalState = /*#__PURE__*/function () {
function InternalState() {

@@ -21,0 +17,0 @@ _classCallCheck(this, InternalState);

@@ -5,4 +5,2 @@ 'use strict';

require("core-js/modules/es.object.define-property");
require("core-js/modules/es.regexp.exec");

@@ -19,2 +17,4 @@

var _utils = require("../utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -41,8 +41,7 @@

_defineProperty(this, "get", function (setState) {
var _this$props = _this.props,
size = _this$props.size,
avatarRedirectUrl = _this$props.avatarRedirectUrl;
var avatarRedirectUrl = _this.props.avatarRedirectUrl;
var size = (0, _utils.getImageSize)(_this.props.size);
var baseUrl = avatarRedirectUrl.replace(/\/*$/, '/');
var id = _this.props[property];
var query = size ? '' : "size=".concat(size);
var query = size ? "size=".concat(size) : '';
var src = "".concat(baseUrl).concat(network, "/").concat(id, "?").concat(query);

@@ -49,0 +48,0 @@ setState({

@@ -5,4 +5,2 @@ 'use strict';

require("core-js/modules/es.object.define-property");
Object.defineProperty(exports, "__esModule", {

@@ -15,2 +13,4 @@ value: true

var _utils = require("../utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -34,6 +34,6 @@

_defineProperty(this, "get", function (setState) {
var _this$props = _this.props,
size = _this$props.size,
facebookId = _this$props.facebookId;
var url = 'https://graph.facebook.com/' + "".concat(facebookId, "/picture?width=").concat(size, "&height=").concat(size);
var facebookId = _this.props.facebookId;
var size = (0, _utils.getImageSize)(_this.props.size);
var url = "https://graph.facebook.com/".concat(facebookId, "/picture");
if (size) url += "?width=".concat(size, "&height=").concat(size);
setState({

@@ -40,0 +40,0 @@ sourceName: 'facebook',

'use strict';
require("core-js/modules/es.array.concat");
require("core-js/modules/es.object.define-property");
Object.defineProperty(exports, "__esModule", {

@@ -14,2 +10,4 @@ value: true

var _utils = require("../utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -33,6 +31,6 @@

_defineProperty(this, "get", function (setState) {
var _this$props = _this.props,
size = _this$props.size,
githubHandle = _this$props.githubHandle;
var url = "https://avatars.githubusercontent.com/".concat(githubHandle, "?v=4&s=").concat(size);
var githubHandle = _this.props.githubHandle;
var size = (0, _utils.getImageSize)(_this.props.size);
var url = "https://avatars.githubusercontent.com/".concat(githubHandle, "?v=4");
if (size) url += "&s=".concat(size);
setState({

@@ -39,0 +37,0 @@ sourceName: 'github',

'use strict';
require("core-js/modules/es.array.concat");
require("core-js/modules/es.object.define-property");
Object.defineProperty(exports, "__esModule", {

@@ -14,6 +10,6 @@ value: true

var _isRetina = _interopRequireDefault(require("is-retina"));
var _md = _interopRequireDefault(require("md5"));
var _utils = require("../utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -25,4 +21,2 @@

var IS_RETINA = (0, _isRetina.default)();
var GravatarSource = function GravatarSource(_props) {

@@ -42,4 +36,5 @@ var _this = this;

var email = props.md5Email || (0, _md.default)(props.email);
var size = IS_RETINA ? props.size * 2 : props.size;
var url = "https://secure.gravatar.com/avatar/".concat(email, "?s=").concat(size, "&d=404");
var size = (0, _utils.getImageSize)(props.size);
var url = "https://secure.gravatar.com/avatar/".concat(email, "?d=404");
if (size) url += "&s=".concat(size);
setState({

@@ -46,0 +41,0 @@ sourceName: 'gravatar',

'use strict';
require("core-js/modules/es.object.define-property");
Object.defineProperty(exports, "__esModule", {

@@ -6,0 +4,0 @@ value: true

'use strict';
require("core-js/modules/es.object.define-property");
Object.defineProperty(exports, "__esModule", {

@@ -6,0 +4,0 @@ value: true

'use strict';
require("core-js/modules/es.object.define-property");
Object.defineProperty(exports, "__esModule", {

@@ -6,0 +4,0 @@ value: true

@@ -5,4 +5,2 @@ 'use strict';

require("core-js/modules/es.object.define-property");
Object.defineProperty(exports, "__esModule", {

@@ -27,5 +25,3 @@ value: true

var ValueSource =
/*#__PURE__*/
function () {
var ValueSource = /*#__PURE__*/function () {
function ValueSource(props) {

@@ -32,0 +28,0 @@ var _this = this;

@@ -27,4 +27,2 @@ 'use strict';

require("core-js/modules/es.date.to-string");
require("core-js/modules/es.object.to-string");

@@ -53,2 +51,3 @@

exports.parseSize = parseSize;
exports.getImageSize = getImageSize;
exports.defaultInitials = defaultInitials;

@@ -58,2 +57,6 @@ exports.setGroupedTimeout = setGroupedTimeout;

var _isRetina = _interopRequireDefault(require("is-retina"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

@@ -75,2 +78,4 @@

var IS_RETINA = (0, _isRetina.default)();
function fetch(url, successCb, errorCb) {

@@ -172,3 +177,21 @@ var request = new XMLHttpRequest();

}
/**
* Calculate absolute size in pixels we want for the images
* that get requested from the various sources. They don't
* understand relative sizes like `em` or `vww`. We select
* a fixed size of 512px when we can't detect the true pixel size.
*/
function getImageSize(size) {
size = parseSize(size);
if (isNaN(size.value)) // invalid size, use fallback
size = 512;else if (size.unit === 'px') // px are good, use them
size = size.value;else if (size.value === 0) // relative 0 === absolute 0
size = 0;else // anything else is unknown, use fallback
size = 512;
if (IS_RETINA) size = size * 2;
return size;
}
function defaultInitials(name, _ref3) {

@@ -175,0 +198,0 @@ var maxInitials = _ref3.maxInitials;

{
"name": "react-avatar",
"version": "3.9.1",
"version": "3.9.2",
"description": "Universal React avatar component makes it possible to generate avatars based on user information.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -66,3 +66,3 @@ # <Avatar> [![Build Status](https://travis-ci.org/Sitebase/react-avatar.svg?branch=master)](https://travis-ci.org/Sitebase/react-avatar) [![npm downloads](https://img.shields.io/npm/dm/react-avatar.svg)](https://www.npmjs.com/package/react-avatar) [![version](https://img.shields.io/npm/v/react-avatar.svg)](https://www.npmjs.com/package/react-avatar) ![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/react-avatar.svg) ![npm type definitions](https://img.shields.io/npm/types/react-avatar.svg)

<Avatar name="Wim Mostmans" size="150" />
<Avatar name="Wim Mostmans" size="150" textSizeRatio="1.75" />
<Avatar name="Wim Mostmans" size="150" textSizeRatio={1.75} />
<Avatar value="86%" size="40" />

@@ -69,0 +69,0 @@ <Avatar size="100" facebook-id="invalidfacebookusername" src="http://www.gravatar.com/avatar/a16a38cdfe8b2cbd38e8a56ab93238d3" />

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