generated from s9a/zero
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi.js
107 lines (92 loc) · 2.11 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
!function(esta) {
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
function create(bet) {
bet = bet ? lower.call(bet) : latin
var base = norm ? bass : basic
function bass(txt) {
return norm.call(txt, "NFD").replace(glyph, "")
}
function basic(txt) {
return "" + txt
}
function key(n) {
return modulo(digit.test(n) ? n : place(n))
}
function modulo(n) {
return +n ? n % 9 || 9 : 0
}
function place(letter) {
letter = base(lower.call(letter))
return bet.indexOf(letter) + 1
}
function stack(txt) {
var how = txt instanceof Array ? join : split
return how.call(txt, "")
}
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 raiz(txt) {
var n = suma(txt)
return n < 10 ? n : raiz(n)
}
function numero(txt) {
var n = suma(txt)
return n < 10 || rep(n) ? n : numero(n)
}
function show(txt) {
txt = stack(txt)
var over = txt.length
var next = 0
var show = ""
while (next < over) {
show += key(txt[next++])
}
return show
}
function rep(dig) {
return repeating.test(dig)
}
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.show = show
api.sum = suma
api.suma = suma
return api
}
var api = create()
var nombre = "numerologia"
typeof module != "undefined" && module.exports
? module.exports = api
: esta[nombre] = api
}(this)