Socket
Socket
Sign inDemoInstall

default-avatar-helper

Package Overview
Dependencies
4
Maintainers
1
Versions
157
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    default-avatar-helper

A helper for creating default avatars.


Version published
Weekly downloads
74
increased by196%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

v2.0.138 (2024-03-27)

Full Changelog

:house: Internal

Readme

Source

default-avatar-helper

npm version build status coverage status npm downloads minzipped size

A helper for creating default avatars.

Usage

import { getDefaultAvatarDetails } from 'default-avatar-helper'

const palette = ['red', 'green', 'blue']
const name = 'random name'

// Providing both arguments at once will return a result object straight away:
const { colour, initials } = getDefaultAvatarDetails(palette, name)

// Alternatively, since `getDefaultAvatarDetails` is curried, you can do
// something like:
const getDefaultAvatarDetailsWithPalette = getDefaultAvatarDetails(palette)
const { colour, initials } = getDefaultAvatarDetailsWithPalette(name)

The following live examples show how colour and initials can be used to create a default avatar.

Live Examples

API

getDefaultAvatarDetails(palette, colour)

Arguments

  • palette - An array of strings representing the colour palette to use.
  • name - A string representing a user name.

Returns

If less than two arguments have been provided, returns a function accepting the remaining argument.

If both arguments have been provided, returns an object containing the properties defined below:

  • colour - A colour string.
  • initials - The user initials string.

Example

const palette = ['red', 'green', 'blue']
const name = 'random name'

// Providing both arguments at once.
const { colour, initials } = getDefaultAvatarDetails(palette, name)

// Making use of currying.
const getDefaultAvatarDetailsWithPalette = getDefaultAvatarDetails(palette)
const { colour, initials } = getDefaultAvatarDetailsWithPalette(name)

Installation

$ npm install default-avatar-helper

There are also UMD builds available via unpkg:

Make sure you have already included:

License

MIT

Keywords

FAQs

Last updated on 27 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc