@jollie/soundex
v1.0.8
Published
Calculate the soundex key of a string
Downloads
44
Readme
soundex
Calculate soundex key of a string by implementing the rules described on the wikipedia page Compliant, optimized and small package to get soundex key
For mapping and formula, see https://en.wikipedia.org/wiki/Soundex#American_Soundex
Install
yarn add @jellyfish-commuting/soundex
or
npm install @jellyfish-commuting/soundex
Usage
import soundex from '@jellyfish-commuting/soundex';
// Test 'Ashcraft' (it's a common error in soundex implementation)
console.log(soundex('Ashcraft')); // Output A261 (... not A226)
// Test equal phonetics
if (soundex('Robert') === soundex('Rupert')) {
console.log('Equal soundex');
} else {
console.log('Different soundex');
}
// Output : Equal soundex
Params
soundex(str, length = 4);
| Prop | Type | Default | Note |
|----------|----------|------------------|-----------------------|
| str
| string
| Required field | Input value |
| length
| int
| 4
| Length of soundex key |
Return value
Soundex key of length
chars