1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.createFloor = void 0;
|
7 |
|
8 | var _factory = require("../../utils/factory");
|
9 |
|
10 | var _collection = require("../../utils/collection");
|
11 |
|
12 | var _number = require("../../utils/number");
|
13 |
|
14 | var _nearlyEqual = require("../../utils/bignumber/nearlyEqual");
|
15 |
|
16 | var name = 'floor';
|
17 | var dependencies = ['typed', 'config', 'round'];
|
18 | var createFloor = (0, _factory.factory)(name, dependencies, function (_ref) {
|
19 | var typed = _ref.typed,
|
20 | config = _ref.config,
|
21 | round = _ref.round;
|
22 |
|
23 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | var floor = typed('floor', {
|
51 | number: function number(x) {
|
52 | if ((0, _number.nearlyEqual)(x, round(x), config.epsilon)) {
|
53 | return round(x);
|
54 | } else {
|
55 | return Math.floor(x);
|
56 | }
|
57 | },
|
58 | Complex: function Complex(x) {
|
59 | return x.floor();
|
60 | },
|
61 | BigNumber: function BigNumber(x) {
|
62 | if ((0, _nearlyEqual.nearlyEqual)(x, round(x), config.epsilon)) {
|
63 | return round(x);
|
64 | } else {
|
65 | return x.floor();
|
66 | }
|
67 | },
|
68 | Fraction: function Fraction(x) {
|
69 | return x.floor();
|
70 | },
|
71 | 'Array | Matrix': function ArrayMatrix(x) {
|
72 |
|
73 | return (0, _collection.deepMap)(x, floor, true);
|
74 | }
|
75 | });
|
76 | return floor;
|
77 | });
|
78 | exports.createFloor = createFloor; |
\ | No newline at end of file |