give-me-an-avatar
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -5,4 +5,4 @@ export declare const avatarCollection: [string, string][]; | ||
export declare enum avatarSizeRange { | ||
Min = 16, | ||
Max = 512 | ||
Min = 96, | ||
Max = 513 | ||
} |
import { AvatarSettings } from "./models"; | ||
export { AvatarSettings } from "./models"; | ||
/** | ||
* Returns the URL of an avatar that is picked at random. | ||
* @param {AvatarSettings} settings - You can supply settings to customize the avatar a bit. | ||
*/ | ||
export declare function giveMeAnAvatar(settings: AvatarSettings): string; |
@@ -1,2 +0,2 @@ | ||
var t;!function(t){t[t.KEY=0]="KEY",t[t.FILTERS=1]="FILTERS"}(t||(t={}));var e,a=[["via.placeholder.com","https://via.placeholder.com/${this.Size}?text=${this.Name}"],["placeimg.com","https://placeimg.com/${this.Size}/${this.Size}/people"],["placekitten.com","https://placekitten.com/g/${this.Size}/${this.Size}"],["dummyimage.com","https://dummyimage.com/${this.Size}x${this.Size}&text=${this.Name}"],["loremflickr.com","https://loremflickr.com/${this.Size}/${this.Size}/human"],["baconmockup.com","https://baconmockup.com/${this.Size}/${this.Size}/"],["placebeard.it","https://placebeard.it/128"],["fakeimg.pl","https://fakeimg.pl/${this.Size}x${this.Size}/?text=${this.Name}&font=bebas"],["thispersondoesnotexist.com","https://thispersondoesnotexist.com/image"],["picsum.photos","https://picsum.photos/${this.Size}"],["fillmurray.com","https://www.fillmurray.com/${this.Size}/${this.Size}"],["placecage.com","https://www.placecage.com/${this.Size}/${this.Size}"],["stevensegallery.com","https://www.stevensegallery.com/${this.Size}/${this.Size}"],["gravatar.com","https://www.gravatar.com/avatar/default?s=${this.Size}"],["ui-avatars.com","https://ui-avatars.com/api/?background=random&size=${this.Size}&name=${this.Name}"],["generative-placeholders.glitch.me","https://generative-placeholders.glitch.me/image?width=${this.Size}&height=${this.Size}"],["robohash.org","https://robohash.org/${this.Name}?size=${this.Size}x${this.Size}${this.ExtraFilter}"],["avatars.dicebear.com","https://avatars.dicebear.com/api${this.ExtraFilter}/${this.Name}.svg?w=${this.Size}&h=${this.Size}"],["avatar.uimaterial.com","https://avatar.uimaterial.com/?name=${this.Name}&size=${this.Size}${this.ExtraFilter}"]],i=[["robohash.org","&set=set1"],["robohash.org","&set=set2"],["robohash.org","&set=set3"],["robohash.org","&set=set4"],["avatars.dicebear.com","/gridy"],["avatars.dicebear.com","/human"],["avatars.dicebear.com","/identicon"],["avatars.dicebear.com","/jdenticon"],["avatars.dicebear.com","/avataaars"],["avatars.dicebear.com","/bottts"],["avatar.uimaterial.com","&setId=8Pfmys5bgfL2NbXFG2sU"],["avatar.uimaterial.com","&setId=0496UVJDTqyd2eCIAa46"],["avatar.uimaterial.com","&setId=SM2u3518GjohwtHQXNK0"],["avatar.uimaterial.com","&setId=Pb7ErSM37KjjIZyJk8w6"]],r=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];!function(t){t[t.Min=16]="Min",t[t.Max=512]="Max"}(e||(e={}));var s=function(){function a(){}var s=a.prototype;return s.getDefaultName=function(){return r[Math.floor(Math.random()*r.length)]+"%20"+r[Math.floor(Math.random()*r.length)]},s.getDefaultSize=function(){return Math.floor(Math.random()*(e.Max-e.Min+1))+e.Min},s.getDefaultSettings=function(){return{Name:this.getDefaultName(),Size:this.getDefaultSize(),ExtraFilter:""}},s.getRandomAvatarService=function(t){var e=t[Math.floor(Math.random()*t.length)];return{Key:e[0],URL:e[1]}},s.processAvatarTemplate=function(t,e){return new Function("return `"+t+"`;").call(e)},s.validateAndCleanSettings=function(t,e){return t.Name&&(t.Name=t.Name.replace(/ /gi,"%20")),t.Name||(t.Name=this.getDefaultName()),t.Size||(t.Size=this.getDefaultSize()),t.ExtraFilter||(t.ExtraFilter=this.applyExtraFiltersToAvatarURL(e)),t},s.applyExtraFiltersToAvatarURL=function(e){var a=i.filter(function(a){return a[t.KEY]===e});return void 0===a||0==a.length?"":a[Math.floor(Math.random()*a.length)][t.FILTERS]},a}();exports.giveMeAnAvatar=function(t){var e=new s;t||(t=e.getDefaultSettings());var i=e.getRandomAvatarService(a);return t=e.validateAndCleanSettings(t,i.Key),e.processAvatarTemplate(i.URL,t)}; | ||
var t;!function(t){t[t.KEY=0]="KEY",t[t.FILTERS=1]="FILTERS"}(t||(t={}));var e,a=[["via.placeholder.com","https://via.placeholder.com/${this.Size}?text=${this.Name}"],["placeimg.com","https://placeimg.com/${this.Size}/${this.Size}/people"],["placekitten.com","https://placekitten.com/g/${this.Size}/${this.Size}"],["dummyimage.com","https://dummyimage.com/${this.Size}x${this.Size}&text=${this.Name}"],["loremflickr.com","https://loremflickr.com/${this.Size}/${this.Size}/human"],["baconmockup.com","https://baconmockup.com/${this.Size}/${this.Size}/"],["placebeard.it","https://placebeard.it/128"],["fakeimg.pl","https://fakeimg.pl/${this.Size}x${this.Size}/?text=${this.Name}&font=bebas"],["thispersondoesnotexist.com","https://thispersondoesnotexist.com/image"],["picsum.photos","https://picsum.photos/${this.Size}"],["fillmurray.com","https://www.fillmurray.com/${this.Size}/${this.Size}"],["placecage.com","https://www.placecage.com/${this.Size}/${this.Size}"],["stevensegallery.com","https://www.stevensegallery.com/${this.Size}/${this.Size}"],["gravatar.com","https://www.gravatar.com/avatar/default?s=${this.Size}"],["ui-avatars.com","https://ui-avatars.com/api/?background=random&size=${this.Size}&name=${this.Name}"],["generative-placeholders.glitch.me","https://generative-placeholders.glitch.me/image?width=${this.Size}&height=${this.Size}"],["robohash.org","https://robohash.org/${this.Name}?size=${this.Size}x${this.Size}${this.ExtraFilter}"],["avatars.dicebear.com","https://avatars.dicebear.com/api${this.ExtraFilter}/${this.Name}.svg?w=${this.Size}&h=${this.Size}"],["avatar.uimaterial.com","https://avatar.uimaterial.com/?name=${this.Name}&size=${this.Size}${this.ExtraFilter}"]],i=[["robohash.org","&set=set1"],["robohash.org","&set=set2"],["robohash.org","&set=set3"],["robohash.org","&set=set4"],["avatars.dicebear.com","/gridy"],["avatars.dicebear.com","/human"],["avatars.dicebear.com","/identicon"],["avatars.dicebear.com","/jdenticon"],["avatars.dicebear.com","/avataaars"],["avatars.dicebear.com","/bottts"],["avatar.uimaterial.com","&setId=8Pfmys5bgfL2NbXFG2sU"],["avatar.uimaterial.com","&setId=0496UVJDTqyd2eCIAa46"],["avatar.uimaterial.com","&setId=SM2u3518GjohwtHQXNK0"],["avatar.uimaterial.com","&setId=Pb7ErSM37KjjIZyJk8w6"]],r=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];!function(t){t[t.Min=96]="Min",t[t.Max=513]="Max"}(e||(e={}));var s=function(){function a(){}var s=a.prototype;return s.getDefaultName=function(){return r[Math.floor(Math.random()*r.length)]+"%20"+r[Math.floor(Math.random()*r.length)]},s.getDefaultSize=function(){return Math.floor(Math.random()*(e.Max-e.Min+1))+e.Min},s.getDefaultSettings=function(){return{Name:this.getDefaultName(),Size:this.getDefaultSize(),ExtraFilter:""}},s.getRandomAvatarService=function(t){var e=t[Math.floor(Math.random()*t.length)];return{Key:e[0],URL:e[1]}},s.processAvatarTemplate=function(t,e){return new Function("return `"+t+"`;").call(e)},s.validateAndCleanSettings=function(t,e){return t.Name&&(t.Name=t.Name.replace(/ /gi,"%20")),t.Name||(t.Name=this.getDefaultName()),t.Size||(t.Size=this.getDefaultSize()),t.ExtraFilter||(t.ExtraFilter=this.applyExtraFiltersToAvatarURL(e)),t},s.applyExtraFiltersToAvatarURL=function(e){var a=i.filter(function(a){return a[t.KEY]===e});return void 0===a||0==a.length?"":a[Math.floor(Math.random()*a.length)][t.FILTERS]},a}();exports.giveMeAnAvatar=function(t){var e=new s;t||(t=e.getDefaultSettings());var i=e.getRandomAvatarService(a);return t=e.validateAndCleanSettings(t,i.Key),e.processAvatarTemplate(i.URL,t)}; | ||
//# sourceMappingURL=give-me-an-avatar.js.map |
@@ -1,2 +0,2 @@ | ||
var t;!function(t){t[t.KEY=0]="KEY",t[t.FILTERS=1]="FILTERS"}(t||(t={}));var e,a=[["via.placeholder.com","https://via.placeholder.com/${this.Size}?text=${this.Name}"],["placeimg.com","https://placeimg.com/${this.Size}/${this.Size}/people"],["placekitten.com","https://placekitten.com/g/${this.Size}/${this.Size}"],["dummyimage.com","https://dummyimage.com/${this.Size}x${this.Size}&text=${this.Name}"],["loremflickr.com","https://loremflickr.com/${this.Size}/${this.Size}/human"],["baconmockup.com","https://baconmockup.com/${this.Size}/${this.Size}/"],["placebeard.it","https://placebeard.it/128"],["fakeimg.pl","https://fakeimg.pl/${this.Size}x${this.Size}/?text=${this.Name}&font=bebas"],["thispersondoesnotexist.com","https://thispersondoesnotexist.com/image"],["picsum.photos","https://picsum.photos/${this.Size}"],["fillmurray.com","https://www.fillmurray.com/${this.Size}/${this.Size}"],["placecage.com","https://www.placecage.com/${this.Size}/${this.Size}"],["stevensegallery.com","https://www.stevensegallery.com/${this.Size}/${this.Size}"],["gravatar.com","https://www.gravatar.com/avatar/default?s=${this.Size}"],["ui-avatars.com","https://ui-avatars.com/api/?background=random&size=${this.Size}&name=${this.Name}"],["generative-placeholders.glitch.me","https://generative-placeholders.glitch.me/image?width=${this.Size}&height=${this.Size}"],["robohash.org","https://robohash.org/${this.Name}?size=${this.Size}x${this.Size}${this.ExtraFilter}"],["avatars.dicebear.com","https://avatars.dicebear.com/api${this.ExtraFilter}/${this.Name}.svg?w=${this.Size}&h=${this.Size}"],["avatar.uimaterial.com","https://avatar.uimaterial.com/?name=${this.Name}&size=${this.Size}${this.ExtraFilter}"]],i=[["robohash.org","&set=set1"],["robohash.org","&set=set2"],["robohash.org","&set=set3"],["robohash.org","&set=set4"],["avatars.dicebear.com","/gridy"],["avatars.dicebear.com","/human"],["avatars.dicebear.com","/identicon"],["avatars.dicebear.com","/jdenticon"],["avatars.dicebear.com","/avataaars"],["avatars.dicebear.com","/bottts"],["avatar.uimaterial.com","&setId=8Pfmys5bgfL2NbXFG2sU"],["avatar.uimaterial.com","&setId=0496UVJDTqyd2eCIAa46"],["avatar.uimaterial.com","&setId=SM2u3518GjohwtHQXNK0"],["avatar.uimaterial.com","&setId=Pb7ErSM37KjjIZyJk8w6"]],r=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];!function(t){t[t.Min=16]="Min",t[t.Max=512]="Max"}(e||(e={}));var s=function(){function a(){}var s=a.prototype;return s.getDefaultName=function(){return r[Math.floor(Math.random()*r.length)]+"%20"+r[Math.floor(Math.random()*r.length)]},s.getDefaultSize=function(){return Math.floor(Math.random()*(e.Max-e.Min+1))+e.Min},s.getDefaultSettings=function(){return{Name:this.getDefaultName(),Size:this.getDefaultSize(),ExtraFilter:""}},s.getRandomAvatarService=function(t){var e=t[Math.floor(Math.random()*t.length)];return{Key:e[0],URL:e[1]}},s.processAvatarTemplate=function(t,e){return new Function("return `"+t+"`;").call(e)},s.validateAndCleanSettings=function(t,e){return t.Name&&(t.Name=t.Name.replace(/ /gi,"%20")),t.Name||(t.Name=this.getDefaultName()),t.Size||(t.Size=this.getDefaultSize()),t.ExtraFilter||(t.ExtraFilter=this.applyExtraFiltersToAvatarURL(e)),t},s.applyExtraFiltersToAvatarURL=function(e){var a=i.filter(function(a){return a[t.KEY]===e});return void 0===a||0==a.length?"":a[Math.floor(Math.random()*a.length)][t.FILTERS]},a}();function o(t){var e=new s;t||(t=e.getDefaultSettings());var i=e.getRandomAvatarService(a);return t=e.validateAndCleanSettings(t,i.Key),e.processAvatarTemplate(i.URL,t)}export{o as giveMeAnAvatar}; | ||
var t;!function(t){t[t.KEY=0]="KEY",t[t.FILTERS=1]="FILTERS"}(t||(t={}));var e,a=[["via.placeholder.com","https://via.placeholder.com/${this.Size}?text=${this.Name}"],["placeimg.com","https://placeimg.com/${this.Size}/${this.Size}/people"],["placekitten.com","https://placekitten.com/g/${this.Size}/${this.Size}"],["dummyimage.com","https://dummyimage.com/${this.Size}x${this.Size}&text=${this.Name}"],["loremflickr.com","https://loremflickr.com/${this.Size}/${this.Size}/human"],["baconmockup.com","https://baconmockup.com/${this.Size}/${this.Size}/"],["placebeard.it","https://placebeard.it/128"],["fakeimg.pl","https://fakeimg.pl/${this.Size}x${this.Size}/?text=${this.Name}&font=bebas"],["thispersondoesnotexist.com","https://thispersondoesnotexist.com/image"],["picsum.photos","https://picsum.photos/${this.Size}"],["fillmurray.com","https://www.fillmurray.com/${this.Size}/${this.Size}"],["placecage.com","https://www.placecage.com/${this.Size}/${this.Size}"],["stevensegallery.com","https://www.stevensegallery.com/${this.Size}/${this.Size}"],["gravatar.com","https://www.gravatar.com/avatar/default?s=${this.Size}"],["ui-avatars.com","https://ui-avatars.com/api/?background=random&size=${this.Size}&name=${this.Name}"],["generative-placeholders.glitch.me","https://generative-placeholders.glitch.me/image?width=${this.Size}&height=${this.Size}"],["robohash.org","https://robohash.org/${this.Name}?size=${this.Size}x${this.Size}${this.ExtraFilter}"],["avatars.dicebear.com","https://avatars.dicebear.com/api${this.ExtraFilter}/${this.Name}.svg?w=${this.Size}&h=${this.Size}"],["avatar.uimaterial.com","https://avatar.uimaterial.com/?name=${this.Name}&size=${this.Size}${this.ExtraFilter}"]],i=[["robohash.org","&set=set1"],["robohash.org","&set=set2"],["robohash.org","&set=set3"],["robohash.org","&set=set4"],["avatars.dicebear.com","/gridy"],["avatars.dicebear.com","/human"],["avatars.dicebear.com","/identicon"],["avatars.dicebear.com","/jdenticon"],["avatars.dicebear.com","/avataaars"],["avatars.dicebear.com","/bottts"],["avatar.uimaterial.com","&setId=8Pfmys5bgfL2NbXFG2sU"],["avatar.uimaterial.com","&setId=0496UVJDTqyd2eCIAa46"],["avatar.uimaterial.com","&setId=SM2u3518GjohwtHQXNK0"],["avatar.uimaterial.com","&setId=Pb7ErSM37KjjIZyJk8w6"]],r=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];!function(t){t[t.Min=96]="Min",t[t.Max=513]="Max"}(e||(e={}));var s=function(){function a(){}var s=a.prototype;return s.getDefaultName=function(){return r[Math.floor(Math.random()*r.length)]+"%20"+r[Math.floor(Math.random()*r.length)]},s.getDefaultSize=function(){return Math.floor(Math.random()*(e.Max-e.Min+1))+e.Min},s.getDefaultSettings=function(){return{Name:this.getDefaultName(),Size:this.getDefaultSize(),ExtraFilter:""}},s.getRandomAvatarService=function(t){var e=t[Math.floor(Math.random()*t.length)];return{Key:e[0],URL:e[1]}},s.processAvatarTemplate=function(t,e){return new Function("return `"+t+"`;").call(e)},s.validateAndCleanSettings=function(t,e){return t.Name&&(t.Name=t.Name.replace(/ /gi,"%20")),t.Name||(t.Name=this.getDefaultName()),t.Size||(t.Size=this.getDefaultSize()),t.ExtraFilter||(t.ExtraFilter=this.applyExtraFiltersToAvatarURL(e)),t},s.applyExtraFiltersToAvatarURL=function(e){var a=i.filter(function(a){return a[t.KEY]===e});return void 0===a||0==a.length?"":a[Math.floor(Math.random()*a.length)][t.FILTERS]},a}();function o(t){var e=new s;t||(t=e.getDefaultSettings());var i=e.getRandomAvatarService(a);return t=e.validateAndCleanSettings(t,i.Key),e.processAvatarTemplate(i.URL,t)}export{o as giveMeAnAvatar}; | ||
//# sourceMappingURL=give-me-an-avatar.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).giveMeAnAvatar={})}(this,function(t){var e;!function(t){t[t.KEY=0]="KEY",t[t.FILTERS=1]="FILTERS"}(e||(e={}));var a,i=[["via.placeholder.com","https://via.placeholder.com/${this.Size}?text=${this.Name}"],["placeimg.com","https://placeimg.com/${this.Size}/${this.Size}/people"],["placekitten.com","https://placekitten.com/g/${this.Size}/${this.Size}"],["dummyimage.com","https://dummyimage.com/${this.Size}x${this.Size}&text=${this.Name}"],["loremflickr.com","https://loremflickr.com/${this.Size}/${this.Size}/human"],["baconmockup.com","https://baconmockup.com/${this.Size}/${this.Size}/"],["placebeard.it","https://placebeard.it/128"],["fakeimg.pl","https://fakeimg.pl/${this.Size}x${this.Size}/?text=${this.Name}&font=bebas"],["thispersondoesnotexist.com","https://thispersondoesnotexist.com/image"],["picsum.photos","https://picsum.photos/${this.Size}"],["fillmurray.com","https://www.fillmurray.com/${this.Size}/${this.Size}"],["placecage.com","https://www.placecage.com/${this.Size}/${this.Size}"],["stevensegallery.com","https://www.stevensegallery.com/${this.Size}/${this.Size}"],["gravatar.com","https://www.gravatar.com/avatar/default?s=${this.Size}"],["ui-avatars.com","https://ui-avatars.com/api/?background=random&size=${this.Size}&name=${this.Name}"],["generative-placeholders.glitch.me","https://generative-placeholders.glitch.me/image?width=${this.Size}&height=${this.Size}"],["robohash.org","https://robohash.org/${this.Name}?size=${this.Size}x${this.Size}${this.ExtraFilter}"],["avatars.dicebear.com","https://avatars.dicebear.com/api${this.ExtraFilter}/${this.Name}.svg?w=${this.Size}&h=${this.Size}"],["avatar.uimaterial.com","https://avatar.uimaterial.com/?name=${this.Name}&size=${this.Size}${this.ExtraFilter}"]],r=[["robohash.org","&set=set1"],["robohash.org","&set=set2"],["robohash.org","&set=set3"],["robohash.org","&set=set4"],["avatars.dicebear.com","/gridy"],["avatars.dicebear.com","/human"],["avatars.dicebear.com","/identicon"],["avatars.dicebear.com","/jdenticon"],["avatars.dicebear.com","/avataaars"],["avatars.dicebear.com","/bottts"],["avatar.uimaterial.com","&setId=8Pfmys5bgfL2NbXFG2sU"],["avatar.uimaterial.com","&setId=0496UVJDTqyd2eCIAa46"],["avatar.uimaterial.com","&setId=SM2u3518GjohwtHQXNK0"],["avatar.uimaterial.com","&setId=Pb7ErSM37KjjIZyJk8w6"]],s=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];!function(t){t[t.Min=16]="Min",t[t.Max=512]="Max"}(a||(a={}));var o=function(){function t(){}var i=t.prototype;return i.getDefaultName=function(){return s[Math.floor(Math.random()*s.length)]+"%20"+s[Math.floor(Math.random()*s.length)]},i.getDefaultSize=function(){return Math.floor(Math.random()*(a.Max-a.Min+1))+a.Min},i.getDefaultSettings=function(){return{Name:this.getDefaultName(),Size:this.getDefaultSize(),ExtraFilter:""}},i.getRandomAvatarService=function(t){var e=t[Math.floor(Math.random()*t.length)];return{Key:e[0],URL:e[1]}},i.processAvatarTemplate=function(t,e){return new Function("return `"+t+"`;").call(e)},i.validateAndCleanSettings=function(t,e){return t.Name&&(t.Name=t.Name.replace(/ /gi,"%20")),t.Name||(t.Name=this.getDefaultName()),t.Size||(t.Size=this.getDefaultSize()),t.ExtraFilter||(t.ExtraFilter=this.applyExtraFiltersToAvatarURL(e)),t},i.applyExtraFiltersToAvatarURL=function(t){var a=r.filter(function(a){return a[e.KEY]===t});return void 0===a||0==a.length?"":a[Math.floor(Math.random()*a.length)][e.FILTERS]},t}();t.giveMeAnAvatar=function(t){var e=new o;t||(t=e.getDefaultSettings());var a=e.getRandomAvatarService(i);return t=e.validateAndCleanSettings(t,a.Key),e.processAvatarTemplate(a.URL,t)}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).giveMeAnAvatar={})}(this,function(t){var e;!function(t){t[t.KEY=0]="KEY",t[t.FILTERS=1]="FILTERS"}(e||(e={}));var a,i=[["via.placeholder.com","https://via.placeholder.com/${this.Size}?text=${this.Name}"],["placeimg.com","https://placeimg.com/${this.Size}/${this.Size}/people"],["placekitten.com","https://placekitten.com/g/${this.Size}/${this.Size}"],["dummyimage.com","https://dummyimage.com/${this.Size}x${this.Size}&text=${this.Name}"],["loremflickr.com","https://loremflickr.com/${this.Size}/${this.Size}/human"],["baconmockup.com","https://baconmockup.com/${this.Size}/${this.Size}/"],["placebeard.it","https://placebeard.it/128"],["fakeimg.pl","https://fakeimg.pl/${this.Size}x${this.Size}/?text=${this.Name}&font=bebas"],["thispersondoesnotexist.com","https://thispersondoesnotexist.com/image"],["picsum.photos","https://picsum.photos/${this.Size}"],["fillmurray.com","https://www.fillmurray.com/${this.Size}/${this.Size}"],["placecage.com","https://www.placecage.com/${this.Size}/${this.Size}"],["stevensegallery.com","https://www.stevensegallery.com/${this.Size}/${this.Size}"],["gravatar.com","https://www.gravatar.com/avatar/default?s=${this.Size}"],["ui-avatars.com","https://ui-avatars.com/api/?background=random&size=${this.Size}&name=${this.Name}"],["generative-placeholders.glitch.me","https://generative-placeholders.glitch.me/image?width=${this.Size}&height=${this.Size}"],["robohash.org","https://robohash.org/${this.Name}?size=${this.Size}x${this.Size}${this.ExtraFilter}"],["avatars.dicebear.com","https://avatars.dicebear.com/api${this.ExtraFilter}/${this.Name}.svg?w=${this.Size}&h=${this.Size}"],["avatar.uimaterial.com","https://avatar.uimaterial.com/?name=${this.Name}&size=${this.Size}${this.ExtraFilter}"]],r=[["robohash.org","&set=set1"],["robohash.org","&set=set2"],["robohash.org","&set=set3"],["robohash.org","&set=set4"],["avatars.dicebear.com","/gridy"],["avatars.dicebear.com","/human"],["avatars.dicebear.com","/identicon"],["avatars.dicebear.com","/jdenticon"],["avatars.dicebear.com","/avataaars"],["avatars.dicebear.com","/bottts"],["avatar.uimaterial.com","&setId=8Pfmys5bgfL2NbXFG2sU"],["avatar.uimaterial.com","&setId=0496UVJDTqyd2eCIAa46"],["avatar.uimaterial.com","&setId=SM2u3518GjohwtHQXNK0"],["avatar.uimaterial.com","&setId=Pb7ErSM37KjjIZyJk8w6"]],s=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];!function(t){t[t.Min=96]="Min",t[t.Max=513]="Max"}(a||(a={}));var o=function(){function t(){}var i=t.prototype;return i.getDefaultName=function(){return s[Math.floor(Math.random()*s.length)]+"%20"+s[Math.floor(Math.random()*s.length)]},i.getDefaultSize=function(){return Math.floor(Math.random()*(a.Max-a.Min+1))+a.Min},i.getDefaultSettings=function(){return{Name:this.getDefaultName(),Size:this.getDefaultSize(),ExtraFilter:""}},i.getRandomAvatarService=function(t){var e=t[Math.floor(Math.random()*t.length)];return{Key:e[0],URL:e[1]}},i.processAvatarTemplate=function(t,e){return new Function("return `"+t+"`;").call(e)},i.validateAndCleanSettings=function(t,e){return t.Name&&(t.Name=t.Name.replace(/ /gi,"%20")),t.Name||(t.Name=this.getDefaultName()),t.Size||(t.Size=this.getDefaultSize()),t.ExtraFilter||(t.ExtraFilter=this.applyExtraFiltersToAvatarURL(e)),t},i.applyExtraFiltersToAvatarURL=function(t){var a=r.filter(function(a){return a[e.KEY]===t});return void 0===a||0==a.length?"":a[Math.floor(Math.random()*a.length)][e.FILTERS]},t}();t.giveMeAnAvatar=function(t){var e=new o;t||(t=e.getDefaultSettings());var a=e.getRandomAvatarService(i);return t=e.validateAndCleanSettings(t,a.Key),e.processAvatarTemplate(a.URL,t)}}); | ||
//# sourceMappingURL=give-me-an-avatar.umd.js.map |
export interface AvatarSettings { | ||
/** | ||
* Some avatars display user initials or even the full name and if this setting isn't supplied, | ||
* the program randomly decides a user initial. Feel free to supply a value if you need to | ||
* override this value. | ||
*/ | ||
Name?: string; | ||
/** | ||
* If this setting isn't supplied, the program will randomly decide an avatar size of the aspect | ||
* ratio 1:1, i.e., a square avatar. If you'd like your avatar size to be of a particular size, | ||
* supply a number to this setting. | ||
*/ | ||
Size?: number; | ||
@@ -4,0 +14,0 @@ } |
{ | ||
"name": "give-me-an-avatar", | ||
"displayName": "Give Me an Avatar", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "Gets a random avatar URL from a collection of different avatar generation services.", | ||
@@ -6,0 +6,0 @@ "source": "./src/give-me-an-avatar.ts", |
<div align="center"> | ||
<br> | ||
<img width="172" src="icon.jpg" alt="Give me an avatar npm package icon"> | ||
<img width="172" src="https://raw.githubusercontent.com/ClydeDz/give-me-an-avatar-npm/main/icon.jpg" alt="Give me an avatar npm package icon"> | ||
<br> | ||
@@ -32,2 +32,4 @@ <br> | ||
If you'd like to consume this package via a CDN, please see [this demo](https://github.com/ClydeDz/give-me-an-avatar-npm/blob/main/demo/index.html). | ||
@@ -40,3 +42,3 @@ ## Supported avatar services | ||
| [placeimg.com](https://placeimg.com) | ![image](https://placeimg.com/128/128/people) | | ||
| [placekitten.com](https://placekitten.com) | ![image](https://placekitten.com/g/128/128) | | ||
| [placekitten.com](https://placekitten.com) | ![image](https://placekitten.com/g/128/128?cache=invalidate) | | ||
| [dummyimage.com](https://dummyimage.com/) | ![image](https://dummyimage.com/128x128&text=J%20S) | | ||
@@ -59,3 +61,5 @@ | [loremflickr.com](https://loremflickr.com) | ![image](https://loremflickr.com/128/128/human) | | ||
I'm not using [avataaars](https://avataaars.io/) separately since [avatars.dicebear.com](https://avatars.dicebear.com) includes avataaars. | ||
## Notes | ||
* I'm not using [avataaars](https://avataaars.io/) separately since [avatars.dicebear.com](https://avatars.dicebear.com) includes avataaars. | ||
* Placekitten image might appear broken at times in the table above, however, the image service itself runs fine. | ||
@@ -62,0 +66,0 @@ ## Credits |
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
85019
96
66