forked from josdejong/mathjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplitUnit.js
More file actions
33 lines (30 loc) · 716 Bytes
/
splitUnit.js
File metadata and controls
33 lines (30 loc) · 716 Bytes
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
'use strict'
function factory (type, config, load, typed) {
/**
* Split a unit in an array of units whose sum is equal to the original unit.
*
* Syntax:
*
* splitUnit(unit: Unit, parts: Array.<Unit>)
*
* Example:
*
* math.splitUnit(new Unit(1, 'm'), ['feet', 'inch'])
* // [ 3 feet, 3.3700787401575 inch ]
*
* See also:
*
* unit
*
* @param {Array} [parts] An array of strings or valueless units.
* @return {Array} An array of units.
*/
const splitUnit = typed('splitUnit', {
'Unit, Array': function (unit, parts) {
return unit.splitUnit(parts)
}
})
return splitUnit
}
exports.name = 'splitUnit'
exports.factory = factory