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

@dicebear/initials

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dicebear/initials - npm Package Compare versions

Comparing version 6.1.2 to 6.1.3

lib/utils/escape.d.ts

7

./lib/index.js

@@ -9,2 +9,3 @@ /*!

import { convertColor } from './utils/convertColor.js';
import { escapeXml } from './utils/escape.js';
export const meta = {

@@ -28,3 +29,3 @@ title: 'Initials',

const svg = [
`<text x="50%" y="50%" font-family="${fontFamily}" font-size="${fontSize}" font-weight="${fontWeight}" fill="${textColor}" text-anchor="middle" dy="${(fontSize * .356).toFixed(3)}">${initials}</text>`,
`<text x="50%" y="50%" font-family="${fontFamily}" font-size="${fontSize}" font-weight="${fontWeight}" fill="${textColor}" text-anchor="middle" dy="${(fontSize * .356).toFixed(3)}">${escapeXml(initials)}</text>`,
].join('');

@@ -41,6 +42,6 @@ return {

textColor,
initials
})
initials,
}),
};
};
export { schema } from './schema.js';

@@ -9,2 +9,3 @@ /*!

import { convertColor } from './utils/convertColor.js';
import { escapeXml } from './utils/escape.js';
export const meta = {

@@ -28,3 +29,3 @@ title: 'Initials',

const svg = [
`<text x="50%" y="50%" font-family="${fontFamily}" font-size="${fontSize}" font-weight="${fontWeight}" fill="${textColor}" text-anchor="middle" dy="${(fontSize * .356).toFixed(3)}">${initials}</text>`,
`<text x="50%" y="50%" font-family="${fontFamily}" font-size="${fontSize}" font-weight="${fontWeight}" fill="${textColor}" text-anchor="middle" dy="${(fontSize * .356).toFixed(3)}">${escapeXml(initials)}</text>`,
].join('');

@@ -41,6 +42,6 @@ return {

textColor,
initials
})
initials,
}),
};
};
export { schema } from './schema.js';

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

/**
* Do not change this file manually! This file was generated with the "Dicebear Exporter"-Plugin for Figma.
*
* Plugin: https://www.figma.com/community/plugin/1005765655729342787
* File: https://www.figma.com/file/BRj9eonsORJ7GIUdm8gnu5
*/
export declare function convertColor(color: string): string;

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

/**
* Do not change this file manually! This file was generated with the "Dicebear Exporter"-Plugin for Figma.
*
* Plugin: https://www.figma.com/community/plugin/1005765655729342787
* File: https://www.figma.com/file/BRj9eonsORJ7GIUdm8gnu5
*/
export function convertColor(color) {
return 'transparent' === color ? color : `#${color}`;
}

@@ -1,6 +0,1 @@

/*!
* Copyright by chickens / stackoverflow
* Licensed under CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/).
* Source: https://stackoverflow.com/a/63763497
*/
export declare function getInitials(seed: string): string;
export declare function getInitials(seed: string, discardAtSymbol?: boolean): string;

@@ -1,14 +0,15 @@

/*!
* Copyright by chickens / stackoverflow
* Licensed under CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/).
* Source: https://stackoverflow.com/a/63763497
*/
export function getInitials(seed) {
return seed
.match(/(^\S\S?|\s\S)?/g)
.map((v) => v.trim())
.join('')
.match(/(^\S|\S$)?/g)
.join('')
.toLocaleUpperCase();
// @see https://www.regular-expressions.info/unicode.html
export function getInitials(seed, discardAtSymbol = true) {
const input = discardAtSymbol ? seed.replace(/@.*/, '') : seed;
const matches = input.match(/(\p{L}[\p{L}\p{M}]*)/gu);
if (!matches) {
// Re-run without discarding `@`-symbol, if no matches
return discardAtSymbol ? getInitials(seed, false) : '';
}
if (matches.length === 1) {
return matches[0].match(/^(?:\p{L}\p{M}*){1,2}/u)[0].toUpperCase();
}
const firstCharacter = matches[0].match(/^(?:\p{L}\p{M}*)/u)[0];
const secondCharacter = matches[matches.length - 1].match(/^(?:\p{L}\p{M}*)/u)[0];
return (firstCharacter + secondCharacter).toUpperCase();
}
{
"name": "@dicebear/initials",
"version": "6.1.2",
"version": "6.1.3",
"description": "Initials avatar style for DiceBear",

@@ -32,3 +32,3 @@ "keywords": [

"devDependencies": {
"@dicebear/core": "6.1.2",
"@dicebear/core": "6.1.3",
"@tsconfig/recommended": "^1.0.2",

@@ -48,3 +48,3 @@ "del-cli": "^5.0.0",

},
"gitHead": "a71246cd16f0427370d0b569062b4992846a3421"
"gitHead": "6ab623547fc02b2fb21ae4ef53e089ef1aa0d504"
}
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