-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for phoentics. update formatting. allow empty string argu…
…ments
- Loading branch information
1 parent
47775d6
commit 21b507c
Showing
6 changed files
with
205 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# CHANGELOG | ||
|
||
Dates are YYYY-MM-DD. | ||
|
||
## 0.2.0 / 2018-03-14 | ||
* Improve README | ||
* Added `usePhonetics` flag to support phonetic replacements for characters/letters | ||
missing from the [Irish Alphabet](https://en.wikipedia.org/wiki/Irish_orthography#Alphabet) | ||
and [Ogham Symbols](https://en.wikipedia.org/wiki/Ogham) | ||
* Fix typings in published module | ||
* Support passing of an empty string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,64 @@ | ||
import * as ogham from "../src/ogham"; | ||
import * as ogham from '../src/ogham'; | ||
|
||
describe("#convert", () => { | ||
it("should reject input containing characters not in [a-z] range", () => { | ||
expect(() => { | ||
ogham.convert("Hey there 123 -"); | ||
}).toThrowError(/input can only contain alphabetic characters/gi); | ||
describe('#convert', () => { | ||
it('should reject input containing characters not in [a-z] range', () => { | ||
expect(() => ogham.convert('Hey there 123 -')).toThrowError( | ||
/input can only contain alphabetic characters/gi | ||
); | ||
}); | ||
|
||
it("should convert text and add head and tail characters", () => { | ||
expect(ogham.convert("eire")).toEqual("᚛ᚓᚔᚏᚓ᚜"); | ||
it('should convert text and add head and tail characters', () => { | ||
expect(ogham.convert('eire')).toEqual('᚛ᚓᚔᚏᚓ᚜'); | ||
}); | ||
|
||
it("should convert text and not add head and tail characters", () => { | ||
expect(ogham.convert("eire", { addBoundary: false })).toEqual("ᚓᚔᚏᚓ"); | ||
it('should convert text and not add head and tail characters', () => { | ||
expect(ogham.convert('eire', { addBoundary: false })).toEqual('ᚓᚔᚏᚓ'); | ||
}); | ||
|
||
it("should convert text without using forfeda characters and include head/tail", () => { | ||
expect(ogham.convert("is maith liom tae")).toEqual("᚛ᚔᚄ ᚋᚐᚔᚈᚆ ᚂᚔᚑᚋ ᚈᚐᚓ᚜"); | ||
it('should convert text without using forfeda characters and include head/tail', () => { | ||
expect(ogham.convert('is maith liom tae')).toEqual('᚛ᚔᚄ ᚋᚐᚔᚈᚆ ᚂᚔᚑᚋ ᚈᚐᚓ᚜'); | ||
}); | ||
|
||
it("should convert text using forfeda characters and include head/tail", () => { | ||
expect(ogham.convert("is maith liom tae", { useForfeda: true })).toEqual( | ||
"᚛ᚔᚄ ᚋᚐᚔᚈᚆ ᚂᚔᚑᚋ ᚈᚙ᚜" | ||
it('should convert text using forfeda characters and include head/tail', () => { | ||
expect(ogham.convert('is maith liom tae', { useForfeda: true })).toEqual( | ||
'᚛ᚔᚄ ᚋᚐᚔᚈᚆ ᚂᚔᚑᚋ ᚈᚙ᚜' | ||
); | ||
}); | ||
|
||
it("should convert text using forfeda characters and not include head/tail", () => { | ||
it('should convert text using forfeda characters and not include head/tail', () => { | ||
expect( | ||
ogham.convert("is maith liom tae", { | ||
ogham.convert('is maith liom tae', { | ||
useForfeda: true, | ||
addBoundary: false | ||
}) | ||
).toEqual("ᚔᚄ ᚋᚐᚔᚈᚆ ᚂᚔᚑᚋ ᚈᚙ"); | ||
).toEqual('ᚔᚄ ᚋᚐᚔᚈᚆ ᚂᚔᚑᚋ ᚈᚙ'); | ||
}); | ||
|
||
it('should flag invalid characters', () => { | ||
expect(() => ogham.convert('keys')).toThrowError( | ||
'input cannot contain j, k, v, w, x, y unless "usePhonetics" option is passed' | ||
); | ||
}); | ||
|
||
it('should convert string containing invalid characters with "usePhonetics"', () => { | ||
expect(ogham.convert('jkvwxy', { usePhonetics: true })).toEqual( | ||
'᚛ᚌᚊᚃᚒᚒᚎᚔ᚜' | ||
); | ||
}); | ||
|
||
it('should convert string containing invalid characters with "usePhonetics"', () => { | ||
const input = 'abcdefghijklmnopqrstuvwxyz'; | ||
const output = ogham.convert(input, { | ||
usePhonetics: true, | ||
addBoundary: false | ||
}); | ||
|
||
// 'W' becomes 'UU' so it adds padding | ||
expect(output.length).toEqual(27); | ||
expect(output).toEqual('ᚐᚁᚉᚇᚓᚃᚌᚆᚔᚌᚊᚂᚋᚅᚑᚚᚊᚏᚄᚈᚒᚃᚒᚒᚎᚔᚎ'); | ||
}); | ||
|
||
it('should support passing an empty string', () => { | ||
expect(ogham.convert('')).toEqual('᚛᚜'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,125 @@ | ||
export default { | ||
// These are the standard 20 characters in ogham | ||
individual: { | ||
" ": { | ||
char: " ", | ||
' ': { | ||
char: ' ', | ||
code: 5760 | ||
}, | ||
b: { | ||
char: "ᚁ", | ||
char: 'ᚁ', | ||
code: 5761 | ||
}, | ||
l: { | ||
char: "ᚂ", | ||
char: 'ᚂ', | ||
code: 5762 | ||
}, | ||
f: { | ||
char: "ᚃ", | ||
char: 'ᚃ', | ||
code: 5763 | ||
}, | ||
s: { | ||
char: "ᚄ", | ||
char: 'ᚄ', | ||
code: 5764 | ||
}, | ||
n: { | ||
char: "ᚅ", | ||
char: 'ᚅ', | ||
code: 5765 | ||
}, | ||
h: { | ||
char: "ᚆ", | ||
char: 'ᚆ', | ||
code: 5766 | ||
}, | ||
d: { | ||
char: "ᚇ", | ||
char: 'ᚇ', | ||
code: 5767 | ||
}, | ||
t: { | ||
char: "ᚈ", | ||
char: 'ᚈ', | ||
code: 5768 | ||
}, | ||
c: { | ||
char: "ᚉ", | ||
char: 'ᚉ', | ||
code: 5769 | ||
}, | ||
q: { | ||
char: "ᚊ", | ||
char: 'ᚊ', | ||
code: 5770 | ||
}, | ||
m: { | ||
char: "ᚋ", | ||
char: 'ᚋ', | ||
code: 5771 | ||
}, | ||
g: { | ||
char: "ᚌ", | ||
char: 'ᚌ', | ||
code: 5772 | ||
}, | ||
z: { | ||
char: "ᚎ", | ||
char: 'ᚎ', | ||
code: 5774 | ||
}, | ||
r: { | ||
char: "ᚏ", | ||
char: 'ᚏ', | ||
code: 5775 | ||
}, | ||
a: { | ||
char: "ᚐ", | ||
char: 'ᚐ', | ||
code: 5776 | ||
}, | ||
o: { | ||
char: "ᚑ", | ||
char: 'ᚑ', | ||
code: 5777 | ||
}, | ||
u: { | ||
char: "ᚒ", | ||
char: 'ᚒ', | ||
code: 5778 | ||
}, | ||
e: { | ||
char: "ᚓ", | ||
char: 'ᚓ', | ||
code: 5779 | ||
}, | ||
i: { | ||
char: "ᚔ", | ||
char: 'ᚔ', | ||
code: 5780 | ||
}, | ||
p: { | ||
char: "ᚚ", | ||
char: 'ᚚ', | ||
code: 5786 | ||
} | ||
}, | ||
// These are part of the aicme forfeda and are treated as opt-in by the module | ||
// https://en.wikipedia.org/wiki/Forfeda#The_aicme_forfeda | ||
combination: { | ||
ea: { | ||
char: "ᚕ", | ||
char: 'ᚕ', | ||
code: 5781 | ||
}, | ||
oi: { | ||
char: "ᚖ", | ||
char: 'ᚖ', | ||
code: 5782 | ||
}, | ||
ui: { | ||
char: "ᚗ", | ||
char: 'ᚗ', | ||
code: 5783 | ||
}, | ||
// ng: { | ||
// char: "ᚍ", | ||
// code: 5773 | ||
// }, | ||
ia: { | ||
char: "ᚘ", | ||
char: 'ᚘ', | ||
code: 5784 | ||
}, | ||
ae: { | ||
char: "ᚙ", | ||
char: 'ᚙ', | ||
code: 5785 | ||
} | ||
}, | ||
head: { | ||
char: "᚛", | ||
char: '᚛', | ||
code: 5787 | ||
}, | ||
tail: { | ||
char: "᚜", | ||
char: '᚜', | ||
code: 5788 | ||
} | ||
}; |
Oops, something went wrong.