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

default-avatar-helper

Package Overview
Dependencies
Maintainers
0
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

default-avatar-helper

A helper for creating default avatars.

  • 2.0.140
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
decreased by-29.17%
Maintainers
0
Weekly downloads
 
Created
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

Package last updated on 31 Aug 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc