Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base bass basic #11

Merged
merged 1 commit into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
var repeating = /^(.)\1+$/
var glyph = /[\u0300-\u036f]/g
var norm = "".normalize
var base = norm ? bass : basic

function grapheme(txt) {
return digit.test(txt) ? "" + txt :
norm.call(txt, "NFD").replace(glyph, "")
function bass(txt) {
return norm.call(txt, "NFD").replace(glyph, "")
}

function basic(txt) {
return "" + txt
}

function modulo(n) {
Expand All @@ -21,7 +25,7 @@
}

function place(letter) {
letter = grapheme(lower.call(letter))
letter = base(lower.call(letter))
return bet.indexOf(letter) + 1
}

Expand Down Expand Up @@ -61,7 +65,9 @@
return api[method](txt)
}

api.grapheme = grapheme
api.base = base
api.bass = bass
api.basic = basic
api.life = vida
api.modulo = modulo
api.raiz = raiz
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ assert.ok(api.raiz("FF") === 3)
assert.ok(api.raiz("firefox") === 2)
console.log("ok raiz")

assert.ok(api.grapheme("Áá"), "Aa")
console.log("ok grapheme")
assert.ok(api.base("Áá"), "Aa")
console.log("ok base")

assert.ok(api.raiz === api.root)
assert.ok(api.vida === api.life)
Expand Down