Skip to content

Commit

Permalink
base bass basic (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanve authored Jul 22, 2021
1 parent 3f2e876 commit 461eec0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
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

0 comments on commit 461eec0

Please sign in to comment.