diff --git a/lib/firstLetters.js b/lib/firstLetters.js index 4bb76c0..742d9ec 100644 --- a/lib/firstLetters.js +++ b/lib/firstLetters.js @@ -32,6 +32,8 @@ const vowelFirstLetters = { const firstLetters = line => line // Split into words .split( ' ' ) + // Remove any wrods that are excess spaces + .filter( word => word.trim().length ) // Grab correct letter of each word .map( word => { const [ letter ] = word diff --git a/test/firstLetters.spec.js b/test/firstLetters.spec.js index e6d432a..ea45f86 100644 --- a/test/firstLetters.spec.js +++ b/test/firstLetters.spec.js @@ -1,14 +1,16 @@ const { expect } = require( 'chai' ) -const { firstLetters, toHindi, toEnglish } = require( '../index' ) +const { firstLetters, toUnicode, toHindi, toEnglish } = require( '../index' ) describe( 'firstLetters(gurmukhi)', () => { const lines = [ + [ 'ਗੁਰਮੁਖਿ ਲਾਧਾ ਮਨਮੁਖਿ ਗਵਾਇਆ ॥', 'ਗਲਮਗ॥' ], [ 'ਗੁਰਮੁਖਿ ਲਾਧਾ ਮਨਮੁਖਿ ਗਵਾਇਆ ॥', 'ਗਲਮਗ॥' ], [ 'ਜਿਨਿ ਹਰਿ ਸੇਵਿਆ ਤਿਨਿ ਸੁਖੁ ਪਾਇਆ ॥', 'ਜਹਸਤਸਪ॥' ], [ 'ਗ਼ੈਰਿ ਹਮਦਿ ਹੱਕ ਨਿਆਇਦ ਬਰ ਜ਼ਬਾਨਮ ਹੀਚ ਗਾਹ', 'ਗ਼ਹਹਨਬਜ਼ਹਗ' ], [ 'ਸਬਦਿ ਮਰੈ. ਸੋ ਮਰਿ ਰਹੈ; ਫਿਰਿ. ਮਰੈ ਨ, ਦੂਜੀ ਵਾਰ ॥', 'ਸਮ.ਸਮਰ;ਫ.ਮਨ,ਦਵ॥' ], [ 'ਇਕਨਾ. ਹੁਕਮੀ ਬਖਸੀਸ; ਇਕਿ, ਹੁਕਮੀ ਸਦਾ ਭਵਾਈਅਹਿ ॥', 'ੲ.ਹਬ;ੲ,ਹਸਭ॥' ], + [ toUnicode( 'ik hr hSqo Ssq Awmdw cwkrS [148[' ), 'ਕਹਹਸ਼ਅਚ।' ], ] lines.map( ( [ line, expectedFirstLetters ] ) => it( `should generate first letters for '${line}' as '${expectedFirstLetters}'`, () => {