Skip to content

jake-billings/truncated

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✂️ truncated Build Status

Truncates all strings in an array to the minimum length required to keep them unique.

Uses UMD module declaration.

The module will load as a single global function "truncated" in a browser. Will return as a node module function in node. Works with AMD.

Usage

Example with all first elements unique

const truncated = require('truncated');

const longArray = ['monday', 'tuesday', 'wednesday'];
const short = truncated(longArray);
// ['m', 't', 'w'] 🙌

Example with second elements unique

const truncated = require('truncated');

const longArray = ['monday', 'tuesday', 'wednesday', 'thursday'];
const short = truncated(longArray);
// ['mo', 'tu', 'we', 'th'] 🙌

What's going on here?

truncated is taking in all arguments passed as an array, and returning the first minimum instance in which each index is unique.

Install

$ yarn add truncated

Test

$ yarn test

Contributors

License

MIT © Henry Kaufman

About

✂️ Truncate string arrays to their unique elements.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%