Socket
Socket
Sign inDemoInstall

abbreviate

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    abbreviate

abbreviate strings in style of R: Abbreviate


Version published
Maintainers
1
Install size
12.8 kB
Created

Readme

Source

abbreviate

abbreviate strings in style of R: Abbreviate

Install

npm install --save abbreviate

Usage

abbreviate = require('abbreviate')

// abbreviate(string, opts)
// opts:
// length (default 3)
// keepSeparators (default false) - keeps all separators between words
// strict (default true) - if false, overwrites length to include all words
abbr = abbreviate('Some Important String', {length: 8})
// abbr: 'SmImpStr'
// which chars will be included for varying length?
// [S,o ,m,e ,  ,I,m,p,o ,r,t ,a ,n ,t ,  ,S,t,r,i ,n ,g ]
// [1,16,6,17,20,2,7,8,18,9,10,19,11,12,21,3,4,5,13,14,15]

What it does

In this order:

  • trims the string
  • removes word separators (/\s\-_,/) (unless keepSeparators is true)
  • removes lowercase vocals
  • removes lowercase consonants
  • removes uppercase vocals
  • removes uppercase consonants and numbers
  • removes word beginnings (looks for digraphs, trigraphs and blends)

License

Copyright (c) 2015 Paul Pflugradt Licensed under the MIT license.

Keywords

FAQs

Last updated on 28 Jul 2015

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