-
-
Notifications
You must be signed in to change notification settings - Fork 30
Other functions
Arthur Guiot edited this page May 19, 2018
·
2 revisions
You can easily apply a function to a number or an array:
t.apply(2, x => 2*x) // 4
t.apply([2, 4], x => x / 2) // [1, 2]
t.min(2, 1, 3, 4) // 1
t.max(2, 1, 3, 4) // 4
t.sort(2, 1, 3, 4) // [1, 2, 3, 4]
t.product(5, 6, 12, 8) // 2880 => BigNumber
t.sum(5, 6, 12, 8) // 31 => BigNumber
You can convert any number n
in base 10 to any other base.
Example:
t.convertToBase(10, 2) // '1010'
t.convertToBase(1200, 64) // 'iM'
This function is like the opposite of the function above.
t.toBase10('iM', 64) // 1200 => BigNumber
Any questions? Don't hesitate to create an issue and tell me about your problem 😊.
Copyright © 2017-2018 Arthur Guiot