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

@shopify/name

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/name

Name-related utilities

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
53K
increased by17.55%
Maintainers
0
Weekly downloads
 
Created
Source

@shopify/name

Build Status Build Status License: MIT npm version npm bundle size (minified + gzip)

Utilities for formatting localized names.

Installation

yarn add @shopify/name

formatName

Formats a name (given name and/or family name) according to the locale. For example:

  • formatName({name: {givenName: 'John', familyName: 'Smith'}, locale: 'en'}) will return John in English and Smith様 in Japanese
  • formatName({name: {givenName: 'John', familyName: 'Smith'}, locale: 'en', options: {full: true}}) will return John Smith in English and SmithJohn in Japanese

hasFamilyNameGivenNameOrdering

Returns true when the provided locale formats family name before given name. For example:

  • hasFamilyNameGivenNameOrdering('ja') will return true
  • hasFamilyNameGivenNameOrdering('en') will return false

abbreviateName

Takes a name (given and family name) and returns a language appropriate abbreviated name, or will return formatName if it is unable to find a suitable abbreviation.

For example:

  • abbreviateName({name: {givenName: 'John', familyName: 'Smith'}, locale: 'en'}) will return JS
  • abbreviateName({name: {givenName: '健', familyName: '田中'}, locale: 'en'}) will return 田中

You may also pass an optional idealMaxLength parameter, which gives the maximum allowable abbreviation length when trying to abbreviate a name in the Korean language (default 3 characters). In Korean, if the given name is longer than this length, the method will instead return the first character of the given name.

abbreviateBusinessName

Takes a business name and returns a language appropriate abbreviated name, or will return the input name if it is unable to find a suitable abbreviation.

For example:

  • abbreviateBusinessName({name: 'Shopify'}) will return Sho
  • abbreviateBusinessName({name: 'My Store'}) will return MS
  • abbreviateBusinessName({name: '任天堂'}) will return 任天堂

You may also pass an optional idealMaxLength parameter, which gives the maximum allowable abbreviation length when trying to abbreviate a name.

FAQs

Package last updated on 16 Jul 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