1 | var utils = require('../utils')
|
2 | , nodes = require('../nodes');
|
3 |
|
4 | /**
|
5 | * Apply Math `fn` to `n`.
|
6 | *
|
7 | * @param {Unit} n
|
8 | * @param {String} fn
|
9 | * @return {Unit}
|
10 | * @api private
|
11 | */
|
12 |
|
13 | function math(n, fn){
|
14 | utils.assertType(n, 'unit', 'n');
|
15 | utils.assertString(fn, 'fn');
|
16 | return new nodes.Unit(Math[fn.string](n.val), n.type);
|
17 | }
|
18 | math.params = ['n', 'fn'];
|
19 | module.exports = math;
|