avatar-initials
Advanced tools
Comparing version 1.4.1 to 2.0.0
@@ -1,10 +0,226 @@ | ||
// Generated by CoffeeScript 1.10.0 | ||
(function() { | ||
var Avatar, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
/* eslint no-var: 0, vars-on-top: 0, no-extend-native: 0, no-else-return: 0, prefer-rest-params: 0, no-self-compare: 0 */ | ||
// https://developer.mozilla.org/en-US/docs/MDN/About#Copyrights_and_licenses | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign | ||
/* istanbul ignore else */ | ||
if (typeof Object.assign !== 'function') { | ||
Object.assign = function assign(target) { | ||
/* istanbul ignore if */ | ||
if (target == null) { | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
Avatar = (function() { | ||
var defaults; | ||
target = Object(target); | ||
for (var index = 1; index < arguments.length; index++) { | ||
var source = arguments[index]; | ||
/* istanbul ignore else */ | ||
if (source != null) { | ||
for (var key in source) { | ||
/* istanbul ignore else */ | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
} | ||
defaults = { | ||
/* eslint no-bitwise: 0 */ | ||
// http://www.myersdaily.org/joseph/javascript/md5.js | ||
// http://www.myersdaily.org/joseph/javascript/md5-text.html | ||
// http://www.myersdaily.org/joseph/javascript/md5-speed-test.html | ||
function add32(a, b) { | ||
return a + b & 0xFFFFFFFF; | ||
} | ||
function cmn(q, a, b, x, s, t) { | ||
a = add32(add32(a, q), add32(x, t)); | ||
return add32(a << s | a >>> 32 - s, b); | ||
} | ||
function ff(a, b, c, d, x, s, t) { | ||
return cmn(b & c | ~b & d, a, b, x, s, t); | ||
} | ||
function gg(a, b, c, d, x, s, t) { | ||
return cmn(b & d | c & ~d, a, b, x, s, t); | ||
} | ||
function hh(a, b, c, d, x, s, t) { | ||
return cmn(b ^ c ^ d, a, b, x, s, t); | ||
} | ||
function ii(a, b, c, d, x, s, t) { | ||
return cmn(c ^ (b | ~d), a, b, x, s, t); | ||
} | ||
function md5cycle(x, k) { | ||
var a = x[0]; | ||
var b = x[1]; | ||
var c = x[2]; | ||
var d = x[3]; | ||
a = ff(a, b, c, d, k[0], 7, -680876936); | ||
d = ff(d, a, b, c, k[1], 12, -389564586); | ||
c = ff(c, d, a, b, k[2], 17, 606105819); | ||
b = ff(b, c, d, a, k[3], 22, -1044525330); | ||
a = ff(a, b, c, d, k[4], 7, -176418897); | ||
d = ff(d, a, b, c, k[5], 12, 1200080426); | ||
c = ff(c, d, a, b, k[6], 17, -1473231341); | ||
b = ff(b, c, d, a, k[7], 22, -45705983); | ||
a = ff(a, b, c, d, k[8], 7, 1770035416); | ||
d = ff(d, a, b, c, k[9], 12, -1958414417); | ||
c = ff(c, d, a, b, k[10], 17, -42063); | ||
b = ff(b, c, d, a, k[11], 22, -1990404162); | ||
a = ff(a, b, c, d, k[12], 7, 1804603682); | ||
d = ff(d, a, b, c, k[13], 12, -40341101); | ||
c = ff(c, d, a, b, k[14], 17, -1502002290); | ||
b = ff(b, c, d, a, k[15], 22, 1236535329); | ||
a = gg(a, b, c, d, k[1], 5, -165796510); | ||
d = gg(d, a, b, c, k[6], 9, -1069501632); | ||
c = gg(c, d, a, b, k[11], 14, 643717713); | ||
b = gg(b, c, d, a, k[0], 20, -373897302); | ||
a = gg(a, b, c, d, k[5], 5, -701558691); | ||
d = gg(d, a, b, c, k[10], 9, 38016083); | ||
c = gg(c, d, a, b, k[15], 14, -660478335); | ||
b = gg(b, c, d, a, k[4], 20, -405537848); | ||
a = gg(a, b, c, d, k[9], 5, 568446438); | ||
d = gg(d, a, b, c, k[14], 9, -1019803690); | ||
c = gg(c, d, a, b, k[3], 14, -187363961); | ||
b = gg(b, c, d, a, k[8], 20, 1163531501); | ||
a = gg(a, b, c, d, k[13], 5, -1444681467); | ||
d = gg(d, a, b, c, k[2], 9, -51403784); | ||
c = gg(c, d, a, b, k[7], 14, 1735328473); | ||
b = gg(b, c, d, a, k[12], 20, -1926607734); | ||
a = hh(a, b, c, d, k[5], 4, -378558); | ||
d = hh(d, a, b, c, k[8], 11, -2022574463); | ||
c = hh(c, d, a, b, k[11], 16, 1839030562); | ||
b = hh(b, c, d, a, k[14], 23, -35309556); | ||
a = hh(a, b, c, d, k[1], 4, -1530992060); | ||
d = hh(d, a, b, c, k[4], 11, 1272893353); | ||
c = hh(c, d, a, b, k[7], 16, -155497632); | ||
b = hh(b, c, d, a, k[10], 23, -1094730640); | ||
a = hh(a, b, c, d, k[13], 4, 681279174); | ||
d = hh(d, a, b, c, k[0], 11, -358537222); | ||
c = hh(c, d, a, b, k[3], 16, -722521979); | ||
b = hh(b, c, d, a, k[6], 23, 76029189); | ||
a = hh(a, b, c, d, k[9], 4, -640364487); | ||
d = hh(d, a, b, c, k[12], 11, -421815835); | ||
c = hh(c, d, a, b, k[15], 16, 530742520); | ||
b = hh(b, c, d, a, k[2], 23, -995338651); | ||
a = ii(a, b, c, d, k[0], 6, -198630844); | ||
d = ii(d, a, b, c, k[7], 10, 1126891415); | ||
c = ii(c, d, a, b, k[14], 15, -1416354905); | ||
b = ii(b, c, d, a, k[5], 21, -57434055); | ||
a = ii(a, b, c, d, k[12], 6, 1700485571); | ||
d = ii(d, a, b, c, k[3], 10, -1894986606); | ||
c = ii(c, d, a, b, k[10], 15, -1051523); | ||
b = ii(b, c, d, a, k[1], 21, -2054922799); | ||
a = ii(a, b, c, d, k[8], 6, 1873313359); | ||
d = ii(d, a, b, c, k[15], 10, -30611744); | ||
c = ii(c, d, a, b, k[6], 15, -1560198380); | ||
b = ii(b, c, d, a, k[13], 21, 1309151649); | ||
a = ii(a, b, c, d, k[4], 6, -145523070); | ||
d = ii(d, a, b, c, k[11], 10, -1120210379); | ||
c = ii(c, d, a, b, k[2], 15, 718787259); | ||
b = ii(b, c, d, a, k[9], 21, -343485551); | ||
x[0] = add32(a, x[0]); | ||
x[1] = add32(b, x[1]); | ||
x[2] = add32(c, x[2]); | ||
x[3] = add32(d, x[3]); | ||
} | ||
/* there needs to be support for Unicode here, | ||
* unless we pretend that we can redefine the MD-5 | ||
* algorithm for multi-byte characters (perhaps | ||
* by adding every four 16-bit characters and | ||
* shortening the sum to 32 bits). Otherwise | ||
* I suggest performing MD-5 as if every character | ||
* was two bytes--e.g., 0040 0025 = @%--but then | ||
* how will an ordinary MD-5 sum be matched? | ||
* There is no way to standardize text to something | ||
* like UTF-8 before transformation; speed cost is | ||
* utterly prohibitive. The JavaScript standard | ||
* itself needs to look at this: it should start | ||
* providing access to strings as preformed UTF-8 | ||
* 8-bit unsigned value arrays. | ||
*/ | ||
function md5blk(s) { | ||
/* I figured global was faster. */ | ||
var md5blks = []; /* Andy King said do it this way. */ | ||
for (var i = 0; i < 64; i += 4) { | ||
md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24); | ||
} | ||
return md5blks; | ||
} | ||
function md51(s) { | ||
var n = s.length; | ||
var state = [1732584193, -271733879, -1732584194, 271733878]; | ||
var i = void 0; | ||
for (i = 64; i <= s.length; i += 64) { | ||
md5cycle(state, md5blk(s.substring(i - 64, i))); | ||
} | ||
s = s.substring(i - 64); | ||
var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
for (i = 0; i < s.length; i++) { | ||
tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3); | ||
} | ||
tail[i >> 2] |= 0x80 << (i % 4 << 3); | ||
if (i > 55) { | ||
md5cycle(state, tail); | ||
for (i = 0; i < 16; i++) { | ||
tail[i] = 0; | ||
} | ||
} | ||
tail[14] = n * 8; | ||
md5cycle(state, tail); | ||
return state; | ||
} | ||
var hex_chr = '0123456789abcdef'.split(''); | ||
function rhex(n) { | ||
var s = ''; | ||
var j = 0; | ||
for (; j < 4; j++) { | ||
s += hex_chr[n >> j * 8 + 4 & 0x0F] + hex_chr[n >> j * 8 & 0x0F]; | ||
} | ||
return s; | ||
} | ||
function hex(x) { | ||
for (var i = 0; i < x.length; i++) { | ||
x[i] = rhex(x[i]); | ||
} | ||
return x.join(''); | ||
} | ||
function md5(s) { | ||
return hex(md51(s)); | ||
} | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/* exported Avatar */ | ||
/* global jQuery */ | ||
var Avatar = function () { | ||
function Avatar(element) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
_classCallCheck(this, Avatar); | ||
if (!element) { | ||
throw new Error('No image element provided.'); | ||
} | ||
this.element = element; | ||
this.settings = Object.assign({ | ||
useGravatar: true, | ||
@@ -35,93 +251,94 @@ allowGravatarFallback: false, | ||
} | ||
}; | ||
}, options); | ||
function Avatar(element, options) { | ||
if (options == null) { | ||
options = {}; | ||
} | ||
this.gravatarValidOnError = bind(this.gravatarValidOnError, this); | ||
this.gravatarValidOnLoad = bind(this.gravatarValidOnLoad, this); | ||
if (element == null) { | ||
throw new Error('No image element provided.'); | ||
} | ||
this.element = element; | ||
this.settings = this.merge(defaults, options); | ||
if (this.settings.useGravatar && this.settings.allowGravatarFallback) { | ||
this.setSource(this.gravatarUrl(this.settings)); | ||
} else if (this.settings.useGravatar) { | ||
this.gravatarValid(this.settings); | ||
} else if (this.settings.use_avatars_io && ((this.settings.avatars_io.user_id != null) || (this.settings.avatars_io.twitter != null) || (this.settings.avatars_io.facebook != null) || (this.settings.avatars_io.instagram != null))) { | ||
this.setSource(this.avatarsioAvatar(this.settings)); | ||
} else if (this.settings.github_id) { | ||
this.setSource(this.githubAvatar(this.settings)); | ||
} else if (this.settings.initials.length > 0) { | ||
this.setSource(this.initialAvatar(this.settings)); | ||
} else { | ||
this.setSource(this.settings.fallbackImage); | ||
} | ||
var source = this.settings.fallbackImage; | ||
if (this.settings.useGravatar && this.settings.allowGravatarFallback) { | ||
source = Avatar.gravatarUrl(this.settings); | ||
} else if (this.settings.useGravatar) { | ||
this.gravatarValid(); | ||
} else if (this.settings.use_avatars_io && (this.settings.avatars_io.user_id || this.settings.avatars_io.twitter || this.settings.avatars_io.facebook || this.settings.avatars_io.instagram)) { | ||
source = Avatar.avatarsioAvatar(this.settings); | ||
} else if (this.settings.github_id) { | ||
source = Avatar.githubAvatar(this.settings); | ||
} else if (this.settings.initials.length > 0) { | ||
source = this.initialAvatar(); | ||
} | ||
Avatar.prototype.setSource = function(source) { | ||
this.setSource(source); | ||
return this; | ||
} | ||
_createClass(Avatar, [{ | ||
key: 'setSource', | ||
value: function setSource(source) { | ||
if (!this.element) { | ||
throw new Error('No image element set.'); | ||
} | ||
if (source) { | ||
this.element.src = source; | ||
} | ||
}; | ||
Avatar.prototype.initialAvatar = function(options) { | ||
var canvas, context, font_size, height, width, x, y; | ||
canvas = document.createElement('canvas'); | ||
if (!(canvas.getContext && canvas.getContext('2d'))) { | ||
return; | ||
} | ||
context = canvas.getContext('2d'); | ||
width = this.element.width || options.size; | ||
height = this.element.height || options.size; | ||
x = width / 2; | ||
y = height / 2; | ||
font_size = options.initial_size || height / 2; | ||
} | ||
}, { | ||
key: 'initialAvatar', | ||
value: function initialAvatar() { | ||
var canvas = document.createElement('canvas'); | ||
var context = canvas.getContext('2d'); | ||
var width = this.element.width || this.settings.size; | ||
var height = this.element.height || this.settings.size; | ||
canvas.width = width * window.devicePixelRatio; | ||
canvas.height = height * window.devicePixelRatio; | ||
canvas.style.width = width + "px"; | ||
canvas.style.height = height + "px"; | ||
canvas.style.width = width + 'px'; | ||
canvas.style.height = height + 'px'; | ||
context.scale(window.devicePixelRatio, window.devicePixelRatio); | ||
context.rect(0, 0, canvas.width, canvas.height); | ||
context.fillStyle = options.initial_bg; | ||
context.fillStyle = this.settings.initial_bg; | ||
context.fill(); | ||
context.font = options.initial_weight + " " + font_size + "px " + options.initial_font_family; | ||
context.font = this.settings.initial_weight + ' ' + (this.settings.initial_size || height / 2) + 'px ' + this.settings.initial_font_family; | ||
context.textAlign = 'center'; | ||
context.textBaseline = 'middle'; | ||
context.fillStyle = options.initial_fg; | ||
context.fillText(options.initials, x, y); | ||
context.fillStyle = this.settings.initial_fg; | ||
context.fillText(this.settings.initials, width / 2, height / 2); | ||
return canvas.toDataURL('image/png'); | ||
}; | ||
Avatar.prototype.githubAvatar = function(options) { | ||
var cdn, cdn_max, cdn_min; | ||
cdn_min = 0; | ||
cdn_max = 3; | ||
cdn = Math.floor(Math.random() * (cdn_max - cdn_min + 1)) + cdn_min; | ||
return "https://avatars" + cdn + ".githubusercontent.com/u/" + options.github_id + "?v=3&s=" + options.size; | ||
}; | ||
Avatar.prototype.avatarsioAvatar = function(options) { | ||
var avatars_io_url; | ||
avatars_io_url = 'http://avatars.io/'; | ||
if (options.avatars_io.user_id && options.avatars_io.identifier) { | ||
avatars_io_url += options.avatars_io.user_id + "/" + options.avatars_io.identifier; | ||
} else if (options.avatars_io.twitter) { | ||
avatars_io_url += "twitter/" + options.avatars_io.twitter; | ||
} else if (options.avatars_io.facebook) { | ||
avatars_io_url += "facebook/" + options.avatars_io.facebook; | ||
} else if (options.avatars_io.instagram) { | ||
avatars_io_url += "instagram/" + options.avatars_io.instagram; | ||
} | ||
}, { | ||
key: 'gravatarValid', | ||
value: function gravatarValid() { | ||
if (!(this.settings.email || this.settings.hash)) { | ||
return; | ||
} | ||
avatars_io_url += "?size=" + options.avatars_io.size; | ||
return avatars_io_url; | ||
}; | ||
var image_source = void 0; | ||
if (this.settings.email) { | ||
image_source = 'https://secure.gravatar.com/avatar/' + md5(this.settings.email) + '?d=404'; | ||
} | ||
if (this.settings.hash) { | ||
image_source = 'https://secure.gravatar.com/avatar/' + this.settings.hash + '?d=404'; | ||
} | ||
var image = new Image(); | ||
image.onload = this.gravatarValidOnLoad.bind(this); | ||
image.onerror = this.gravatarValidOnError.bind(this); | ||
image.src = image_source; | ||
} | ||
}, { | ||
key: 'gravatarValidOnLoad', | ||
value: function gravatarValidOnLoad() { | ||
this.setSource(Avatar.gravatarUrl(this.settings)); | ||
} | ||
}, { | ||
key: 'gravatarValidOnError', | ||
value: function gravatarValidOnError() { | ||
if (this.settings.initials.length > 0) { | ||
this.setSource(this.initialAvatar()); | ||
return; | ||
} | ||
this.setSource(this.settings.fallbackImage); | ||
} | ||
}], [{ | ||
key: 'gravatarUrl', | ||
value: function gravatarUrl() { | ||
var settings = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
Avatar.prototype.gravatarUrl = function(options) { | ||
var email_or_hash; | ||
options = this.merge(defaults, options); | ||
options.size = (options.size >= 1 && options.size <= 2048 ? options.size : 80); | ||
email_or_hash = options.hash || options.email; | ||
var size = settings.size >= 1 && settings.size <= 2048 ? settings.size : 80; | ||
var email_or_hash = settings.hash || settings.email; | ||
if (!email_or_hash || typeof email_or_hash !== 'string') { | ||
@@ -131,69 +348,61 @@ email_or_hash = '00000000000000000000000000000000'; | ||
email_or_hash = email_or_hash.toLowerCase().trim(); | ||
return ['https://secure.gravatar.com/avatar/', (email_or_hash.match(/@/g) !== null ? this.md5(email_or_hash) : email_or_hash), "?s=" + options.size, "&d=" + (encodeURIComponent(options.fallback)), "&r=" + options.rating, (options.forcedefault ? '&f=y' : '')].join(''); | ||
}; | ||
Avatar.prototype.gravatarValid = function(options) { | ||
var image, image_source; | ||
if (!(options.email || options.hash)) { | ||
return; | ||
} | ||
if (options.email) { | ||
image_source = "https://secure.gravatar.com/avatar/" + (this.md5(options.email)) + "?d=404"; | ||
} | ||
if (options.hash) { | ||
image_source = "https://secure.gravatar.com/avatar/" + options.hash + "?d=404"; | ||
} | ||
image = new Image(); | ||
image.onload = this.gravatarValidOnLoad; | ||
image.onerror = this.gravatarValidOnError; | ||
image.src = image_source; | ||
}; | ||
var hash = email_or_hash.match(/@/g) !== null ? md5(email_or_hash) : email_or_hash; | ||
var fallback = settings.fallback ? encodeURIComponent(settings.fallback) : 'mm'; | ||
var rating = settings.rating || 'x'; | ||
var forcedefault = settings.forcedefault ? '&f=y' : ''; | ||
Avatar.prototype.gravatarValidOnLoad = function() { | ||
return this.setSource(this.gravatarUrl(this.settings)); | ||
}; | ||
return 'https://secure.gravatar.com/avatar/' + hash + '?s=' + size + '&d=' + fallback + '&r=' + rating + forcedefault; | ||
} | ||
}, { | ||
key: 'githubAvatar', | ||
value: function githubAvatar() { | ||
var settings = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
Avatar.prototype.gravatarValidOnError = function() { | ||
if (this.settings.initials.length > 0) { | ||
return this.setSource(this.initialAvatar(this.settings)); | ||
} else { | ||
return this.setSource(this.settings.fallbackImage); | ||
} | ||
}; | ||
var cdn_min = 0; | ||
var cdn_max = 3; | ||
var cdn = Math.floor(Math.random() * (cdn_max - (cdn_min + 1))) + cdn_min; | ||
return 'https://avatars' + cdn + '.githubusercontent.com/u/' + (settings.github_id || 0) + '?v=3&s=' + (settings.size || 80); | ||
} | ||
}, { | ||
key: 'avatarsioAvatar', | ||
value: function avatarsioAvatar() { | ||
var settings = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
Avatar.prototype.merge = function(input, options) { | ||
var k, output, v; | ||
output = JSON.parse(JSON.stringify(input)); | ||
for (k in options) { | ||
v = options[k]; | ||
output[k] = v; | ||
var avatars_io_url = 'http://avatars.io/'; | ||
if (!settings.avatars_io) { | ||
return avatars_io_url; | ||
} | ||
return output; | ||
}; | ||
Avatar.prototype.md5 = function(string) { | ||
if (typeof md5 === 'function') { | ||
return md5(string); | ||
} else { | ||
return '00000000000000000000000000000000'; | ||
/* istanbul ignore else */ | ||
if (settings.avatars_io.user_id && settings.avatars_io.identifier) { | ||
avatars_io_url += settings.avatars_io.user_id + '/' + settings.avatars_io.identifier; | ||
} else if (settings.avatars_io.twitter) { | ||
avatars_io_url += 'twitter/' + settings.avatars_io.twitter; | ||
} else if (settings.avatars_io.facebook) { | ||
avatars_io_url += 'facebook/' + settings.avatars_io.facebook; | ||
} else if (settings.avatars_io.instagram) { | ||
avatars_io_url += 'instagram/' + settings.avatars_io.instagram; | ||
} | ||
}; | ||
avatars_io_url += '?size=' + settings.avatars_io.size; | ||
return avatars_io_url; | ||
} | ||
}]); | ||
return Avatar; | ||
return Avatar; | ||
}(); | ||
})(); | ||
/* istanbul ignore else */ | ||
(typeof exports !== "undefined" && exports !== null ? exports : this).Avatar = Avatar; | ||
if (typeof jQuery !== 'undefined') { | ||
jQuery.fn['avatar'] = function(options) { | ||
return this.each(function() { | ||
if (!jQuery.data(this, 'plugin_avatar')) { | ||
jQuery.data(this, 'plugin_avatar', new Avatar(this, options)); | ||
} | ||
}); | ||
}; | ||
return; | ||
} | ||
if (typeof jQuery !== 'undefined') { | ||
jQuery.fn.avatar = function avatar(options) { | ||
var _this = this; | ||
}).call(this); | ||
return this.each(function () { | ||
/* istanbul ignore else */ | ||
if (!jQuery.data(_this, 'plugin_avatar')) { | ||
jQuery.data(_this, 'plugin_avatar', new Avatar(_this, options)); | ||
} | ||
}); | ||
}; | ||
} |
@@ -0,1 +1,8 @@ | ||
## 2.0.0 (September 13th, 2016) | ||
* Update to ES6 from CoffeeScript. | ||
* More test coverage. | ||
* Code Coverage 100% | ||
* Static methods if you only need URL generation. | ||
## 1.4.0 (Feb. 16, 2015) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "avatar-initials", | ||
"version": "1.4.1", | ||
"version": "2.0.0", | ||
"description": "JavaScript library for showing Gravatars or generating user avatars from initials.", | ||
@@ -29,9 +29,2 @@ "author": "Matthew Callis <matthew.callis@gmail.com>", | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/MatthewCallis/avatar", | ||
"path": "MatthewCallis/avatar" | ||
} | ||
], | ||
"bugs": { | ||
@@ -48,18 +41,37 @@ "url": "https://github.com/MatthewCallis/avatar/issues" | ||
"devDependencies": { | ||
"MD5": "*", | ||
"chai": "*", | ||
"chai-as-promised": "*", | ||
"codeclimate-test-reporter": "*", | ||
"coffee-script": "*", | ||
"coveralls": "*", | ||
"jquery": "^2", | ||
"jsdom": "*", | ||
"mocha": "*", | ||
"mocha-istanbul": "*", | ||
"mocha-jsdom": "*", | ||
"mocha-lcov-reporter": "*", | ||
"mocha-phantomjs": "^3.5.3", | ||
"npm-bump": "0.0.15", | ||
"sinon": "*", | ||
"sinon-chai": "*" | ||
"autoprefixer": "^6.4.1", | ||
"babel-cli": "^6.14.0", | ||
"babel-plugin-external-helpers": "^6.8.0", | ||
"babel-preset-es2015": "^6.14.0", | ||
"babel-preset-es2016": "^6.11.3", | ||
"babel-register": "^6.14.0", | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^5.3.0", | ||
"codeclimate-test-reporter": "^0.3.3", | ||
"coveralls": "^2.11.12", | ||
"dirty-chai": "^1.2.2", | ||
"eslint": "^3.5.0", | ||
"eslint-config-airbnb": "^11.1.0", | ||
"eslint-loader": "^1.5.0", | ||
"eslint-plugin-import": "^1.15.0", | ||
"eslint-plugin-jsx-a11y": "^2.2.2", | ||
"eslint-plugin-mocha": "4.5.1", | ||
"eslint-plugin-react": "^6.2.1", | ||
"istanbul": "^0.4.5", | ||
"jquery": "^3", | ||
"local-web-server": "^1.2.6", | ||
"mocha": "^3.0.2", | ||
"mocha-phantomjs-core": "^1.3.1", | ||
"node-sass": "^3.10.0", | ||
"npm-bump": "^0.0.20", | ||
"phantomjs": "^2.1.7", | ||
"postcss-cli": "^2.6.0", | ||
"precommit-hook-eslint": "^3.0.0", | ||
"rollup": "^0.35.10", | ||
"rollup-plugin-babel": "^2.6.1", | ||
"rollup-plugin-json": "^2.0.2", | ||
"s3-deploy": "^0.6.1", | ||
"sinon": "^1.17.5", | ||
"sinon-chai": "^2.8.0", | ||
"uglify-js": "^2.7.3" | ||
}, | ||
@@ -80,12 +92,25 @@ "directories": {}, | ||
"scripts": { | ||
"instrument": "istanbul instrument --output build-coverage build/", | ||
"compile-tests": "coffee --compile --output test/ test/", | ||
"coverage": "istanbul instrument --output build-coverage build/ && istanbul cover _mocha -- test/*_spec.js -R spec", | ||
"coverage-report": "istanbul report --root coverage lcov", | ||
"lint": "coffeelint src/*.coffee", | ||
"make": "coffee --compile --output build/ src/*.coffee", | ||
"test": "coffee --compile --output test/ test/*.coffee && ./node_modules/mocha/bin/mocha --globals md5", | ||
"test-phantomjs": "mocha-phantomjs --setting localToRemoteUrlAccessEnabled=true --ssl-protocol=any --setting webSecurityEnabled=false test/index.html --hooks ./phantom_hooks.js --timeout 25000" | ||
"coverage": "istanbul cover _mocha -- spec/**/*_spec.js -R spec", | ||
"instrument": "istanbul instrument --output instrumented/ build/", | ||
"lint": "eslint src", | ||
"local-web-server": "ws --port 8181 --no-cache --verbose", | ||
"make": "node rollup.config.js", | ||
"make-individual": "babel src --out-dir build", | ||
"make-tests": "babel --compact false spec_src --out-dir spec", | ||
"test": "phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js http://localhost:8181/spec/index.html spec \"{ \\\"useColors\\\": true, \\\"settings\\\": { \\\"loadImages\\\": false, \\\"localToRemoteUrlAccessEnabled\\\": true, \\\"webSecurityEnabled\\\": false } }\"", | ||
"test-coverage": "phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js http://localhost:8181/spec/index_coverage.html spec \"{ \\\"useColors\\\": true, \\\"hooks\\\": \\\"../../spec/phantom_hooks.js\\\", \\\"settings\\\": { \\\"loadImages\\\": false, \\\"localToRemoteUrlAccessEnabled\\\": true, \\\"webSecurityEnabled\\\": false } }\"", | ||
"test-phantomjs": "phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js http://localhost:8181/spec/index_coverage.html spec \"{ \\\"useColors\\\": true, \\\"hooks\\\": \\\"../../spec/phantom_hooks.js\\\", \\\"settings\\\": { \\\"loadImages\\\": false, \\\"localToRemoteUrlAccessEnabled\\\": true, \\\"webSecurityEnabled\\\": false } }\"", | ||
"test-precommit": "phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js http://localhost:8181/spec/index.html spec", | ||
"validate": "npm ls", | ||
"build-styles": "node-sass --output-style compressed sass/styles.scss -o build/styles && postcss --use autoprefixer build/styles/*.css -d build/styles/", | ||
"watch-styles": "node-sass --watch sass/styles.scss -o build/styles/", | ||
"uglify": "uglifyjs build/avatar.js > build/avatar.min.js" | ||
}, | ||
"github": "https://github.com/MatthewCallis/avatar" | ||
"github": "https://github.com/MatthewCallis/avatar", | ||
"pre-commit": [ | ||
"lint", | ||
"validate", | ||
"test-precommit" | ||
] | ||
} |
@@ -8,2 +8,3 @@ # [Avatar](http://matthewcallis.github.io/avatar/) | ||
[![Coverage Status](https://coveralls.io/repos/MatthewCallis/avatar/badge.svg)](https://coveralls.io/r/MatthewCallis/avatar) | ||
[![bitHound Overall Score](https://www.bithound.io/github/MatthewCallis/avatar/badges/score.svg)](https://www.bithound.io/github/MatthewCallis/avatar) | ||
@@ -10,0 +11,0 @@ Avatar is a JavaScript library for showing Gravatars or generating user avatars. |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
26192
372
124
35
5
1