forked from cryptobuks1/JsWallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.ls
More file actions
19 lines (19 loc) · 786 Bytes
/
math.ls
File metadata and controls
19 lines (19 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require! {
\bignumber.js
\prelude-ls : { map, pairs-to-obj }
}
math = ($)-> (x, y)->
return '..' if x is '..' or y is '..'
try
#if window.location.origin is not \https://wallet.velas.com
#if typeof x is \number
# console.warn "Bignumber operation with number argument. It is dangerous as number->bignumber convertion causes exception sometimes"
#if typeof y is \number
# console.warn "Bignumber operation with number argument. It is dangerous as number->bignumber convertion causes exception sometimes"
new bignumber(x+'')[$](y+'').to-fixed!
catch err
throw "#{x} #{$} #{y} = #{err}"
module.exports =
<[ plus minus times div ]>
|> map -> [it, math(it)]
|> pairs-to-obj