Skip to content

Commit

Permalink
create pattern (#29)
Browse files Browse the repository at this point in the history
* create pattern

* esta aqui
  • Loading branch information
ryanve authored Jul 23, 2021
1 parent 2a06199 commit ae99968
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 75 deletions.
157 changes: 84 additions & 73 deletions api.js
Original file line number Diff line number Diff line change
@@ -1,88 +1,99 @@
!function(scope) {
var latin = "abcdefghijklmnopqrstuvwxyz"
var bet = latin
var join = "".join
var split = "".split
var lower = "".toLowerCase
var digit = /^\d+$/
var round = Math.round
var repeating = /^(.)\1+$/
var glyph = /[\u0300-\u036f]/g
var norm = "".normalize
var base = norm ? bass : basic
!function(esta) {
var api = create()
var nombre = "numerologia"
typeof module != "undefined" && module.exports
? module.exports = api
: esta[nombre] = api

function bass(txt) {
return norm.call(txt, "NFD").replace(glyph, "")
}
function create(bet) {
var latin = "abcdefghijklmnopqrstuvwxyz"
var join = "".join
var split = "".split
var lower = "".toLowerCase
var digit = /^\d+$/
var round = Math.round
var repeating = /^(.)\1+$/
var glyph = /[\u0300-\u036f]/g
var norm = "".normalize
var base = norm ? bass : basic
bet = bet ? lower.call(bet) : latin

function basic(txt) {
return "" + txt
}
function bass(txt) {
return norm.call(txt, "NFD").replace(glyph, "")
}

function key(n) {
return modulo(digit.test(n) ? n : place(n))
}
function basic(txt) {
return "" + txt
}

function modulo(n) {
return +n ? n % 9 || 9 : 0
}
function key(n) {
return modulo(digit.test(n) ? n : place(n))
}

function place(letter) {
letter = base(lower.call(letter))
return bet.indexOf(letter) + 1
}
function modulo(n) {
return +n ? n % 9 || 9 : 0
}

function stack(txt) {
var how = txt instanceof Array ? join : split
return how.call(txt, "")
}
function place(letter) {
letter = base(lower.call(letter))
return bet.indexOf(letter) + 1
}

function suma(txt) {
txt = stack(txt)
var i = txt.length
var suma = 0
var next
while (i--) {
next = txt[i]
next = key(next)
suma += next > 0 ? +next : 0
function stack(txt) {
var how = txt instanceof Array ? join : split
return how.call(txt, "")
}
return round(suma)
}

function raiz(txt) {
var n = suma(txt)
return n < 10 ? n : raiz(n)
}
function suma(txt) {
txt = stack(txt)
var i = txt.length
var suma = 0
var next
while (i--) {
next = txt[i]
next = key(next)
suma += next > 0 ? +next : 0
}
return round(suma)
}

function numero(txt) {
var n = suma(txt)
return n < 10 || rep(n) ? n : numero(n)
}
function raiz(txt) {
var n = suma(txt)
return n < 10 ? n : raiz(n)
}

function rep(dig) {
return repeating.test(dig)
}
function numero(txt) {
var n = suma(txt)
return n < 10 || rep(n) ? n : numero(n)
}

function api(method, txt) {
return api[method](txt)
}
function rep(dig) {
return repeating.test(dig)
}

api.base = base
api.bass = bass
api.basic = basic
api.key = key
api.modulo = modulo
api.num = numero
api.numero = numero
api.place = place
api.raiz = raiz
api.rep = rep
api.root = raiz
api.sum = suma
api.suma = suma
function rep(dig) {
return repeating.test(dig)
}

typeof module != "undefined" && module.exports
? module.exports = api
: scope.numerologia = api
function api(method, txt) {
return api[method](txt)
}

api.base = base
api.bass = bass
api.basic = basic
api.create = create
api.key = key
api.modulo = modulo
api.num = numero
api.numero = numero
api.place = place
api.raiz = raiz
api.rep = rep
api.root = raiz
api.sum = suma
api.suma = suma

return api
}
}(this)
1 change: 1 addition & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ assert.ok(api.suma === api.sum)
console.log("ok alias")

assert.ok(api("raiz", 11) === api.raiz("11"))
assert.ok(api.create("!@#").raiz("!!") === 2)
console.log("ok api")

console.log("=)\n")
4 changes: 2 additions & 2 deletions www.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!function(scope) {
var api = scope.numerologia
!function(esta) {
var api = esta.numerologia
var form = document.getElementById("formulario")
var key = "_"
var text = form[key]
Expand Down

0 comments on commit ae99968

Please sign in to comment.