Socket
Socket
Sign inDemoInstall

abbrev

Package Overview
Dependencies
0
Maintainers
5
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

abbrev

Like ruby's abbrev module, but in js

    2.0.0latest
    GitHub
    npm

Version published
Maintainers
5
Weekly downloads
19,451,141
decreased by-15.16%

Weekly downloads

Package description

What is abbrev?

The abbrev npm package is used to create a list of unique abbreviations for a given set of strings. It is particularly useful when you need to generate a minimal set of distinct abbreviations for a list of words, ensuring that each word's abbreviation is unambiguous.

What are abbrev's main functionalities?

Generating abbreviations

This feature allows you to generate an object where the keys are all possible unique abbreviations and the values are the full strings that they map to. In the code sample, abbreviations for 'apple', 'ape', and 'april' are generated, resulting in an object with keys like 'a', 'ap', 'app', etc., each pointing to their respective full words.

const abbrev = require('abbrev');
const abbreviations = abbrev('apple', 'ape', 'april');
console.log(abbreviations);

Other packages similar to abbrev

Changelog

Source

2.0.0 (2022-10-31)

⚠️ BREAKING CHANGES

  • Refactored with the following breaking changes:
    • abbrev is now compatible with the following semver range for node: ^14.17.0 || ^16.13.0 || >=18.0.0
    • monkeyPatch API has been removed

Features

  • 602c0fe add @npmcli/template-oss (#36) (@lukekarrys)

Bug Fixes

  • b658525 replace deprecated String.prototype.substr() (#38) (@CommanderRoot)

Readme

Source

abbrev-js

Just like ruby's Abbrev.

Usage:

var abbrev = require("abbrev");
abbrev("foo", "fool", "folding", "flop");

// returns:
{ fl: 'flop'
, flo: 'flop'
, flop: 'flop'
, fol: 'folding'
, fold: 'folding'
, foldi: 'folding'
, foldin: 'folding'
, folding: 'folding'
, foo: 'foo'
, fool: 'fool'
}

This is handy for command-line scripts, or other cases where you want to be able to accept shorthands.

FAQs

Last updated on 01 Nov 2022

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the 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