Socket
Socket
Sign inDemoInstall

@isaacs/string-locale-compare

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@isaacs/string-locale-compare

Compare strings with Intl.Collator if available, falling back to String.localeCompare otherwise


Version published
Maintainers
1
Weekly downloads
1,875,907
increased by0.02%
Bundle size
430 bytes
Minified + gzipped

Weekly downloads

Readme

Source

@isaacs/string-locale-compare

Compare strings with Intl.Collator if available, falling back to String.localeCompare otherwise.

This also forces the use of a specific locale, to avoid using the system locale, which is non-deterministic.

USAGE

const stringLocaleCompare = require('@isaacs/string-locale-compare')

myArrayOfStrings.sort(stringLocaleCompare('en'))

// can also pass extra options
myArrayOfNumericStrings.sort(stringLocaleCompare('en', { numeric: true }))

API

stringLocaleCompare(locale, [options])

Locale is required, must be a valid locale string.

Options is optional. The following options are supported:

  • sensitivity
  • numeric
  • ignorePunctuation
  • caseFirst

FAQs

Last updated on 28 Sep 2021

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