1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.createFraction = void 0;
|
7 |
|
8 | var _factory = require("../../../utils/factory");
|
9 |
|
10 | var _collection = require("../../../utils/collection");
|
11 |
|
12 | var name = 'fraction';
|
13 | var dependencies = ['typed', 'Fraction'];
|
14 | var createFraction = (0, _factory.factory)(name, dependencies, function (_ref) {
|
15 | var typed = _ref.typed,
|
16 | Fraction = _ref.Fraction;
|
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 | return typed('fraction', {
|
44 | number: function number(x) {
|
45 | if (!isFinite(x) || isNaN(x)) {
|
46 | throw new Error(x + ' cannot be represented as a fraction');
|
47 | }
|
48 |
|
49 | return new Fraction(x);
|
50 | },
|
51 | string: function string(x) {
|
52 | return new Fraction(x);
|
53 | },
|
54 | 'number, number': function numberNumber(numerator, denominator) {
|
55 | return new Fraction(numerator, denominator);
|
56 | },
|
57 | "null": function _null(x) {
|
58 | return new Fraction(0);
|
59 | },
|
60 | BigNumber: function BigNumber(x) {
|
61 | return new Fraction(x.toString());
|
62 | },
|
63 | Fraction: function Fraction(x) {
|
64 | return x;
|
65 | },
|
66 | Object: function Object(x) {
|
67 | return new Fraction(x);
|
68 | },
|
69 | 'Array | Matrix': function ArrayMatrix(x) {
|
70 | return (0, _collection.deepMap)(x, this);
|
71 | }
|
72 | });
|
73 | });
|
74 | exports.createFraction = createFraction; |
\ | No newline at end of file |