2.0.1 • Published 7 years ago
truncated v2.0.1
✂️ truncated
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
- Henry Kaufman - Designer and Developer
- Jake Billings - Full-stack Web Developer
License
MIT © Henry Kaufman