Skip to content

ndolidzee/pear-apps-utils-avatar-initials

 
 

Repository files navigation

pear-apps-utils-avatar-initials

A simple utility to generate initials for an avatar.

Table of Contents

Features

  • Generates initials from names for use in avatars
  • Handles single names by returning first two characters
  • For multiple names, returns first letter of each of the first two names
  • Properly handles edge cases like null, undefined, or empty strings
  • Consistently returns uppercase initials

Security Notice

  1. To ensure the security and integrity of your projects, please note that official PearPass packages are distributed exclusively through our GitHub organization.
  2. Any packages with similar names found on the npm registry or other third-party package managers are not affiliated with PearPass and should be strictly avoided. We recommend installing directly from this repository to ensure you are using the verified, open-source version.

Installation

npm install git+https://github.com/tetherto/pear-apps-utils-avatar-initials.git

Usage Examples

import { generateAvatarInitials } from '@tetherto/pear-apps-utils-avatar-initials';

// Single name
generateAvatarInitials('John'); // Returns 'JO'

// Multiple names
generateAvatarInitials('John Doe'); // Returns 'JD'
generateAvatarInitials('John Doe Smith'); // Returns 'JD' (only uses first two names)

// Edge cases
generateAvatarInitials(''); // Returns ''
generateAvatarInitials(null); // Returns ''
generateAvatarInitials(undefined); // Returns ''

Dependencies

This package has no external dependencies, making it lightweight and easy to include in any project.

Related Projects

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%