umt 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/.markdownlint.json +4 -1
  2. package/README.md +11 -4
  3. package/module/Array/arraysJoin.d.ts +1 -2
  4. package/module/Array/arraysJoin.js +2 -1
  5. package/module/Array/getArraysCommon.d.ts +6 -0
  6. package/module/Array/getArraysCommon.js +25 -0
  7. package/module/Array/getArraysDiff.d.ts +1 -2
  8. package/module/Array/getArraysDiff.js +15 -7
  9. package/module/Array/index.d.ts +16 -5
  10. package/module/Array/index.js +54 -11
  11. package/module/Array/quickSort.d.ts +1 -2
  12. package/module/Array/quickSort.js +4 -3
  13. package/module/Array/sum.d.ts +1 -0
  14. package/module/Array/sum.js +8 -0
  15. package/module/Compiler/core.d.ts +5 -0
  16. package/module/Compiler/core.js +19 -0
  17. package/module/Compiler/token.d.ts +10 -0
  18. package/module/Compiler/token.js +120 -0
  19. package/module/Date/index.d.ts +7 -1
  20. package/module/Date/index.js +26 -5
  21. package/module/Date/now.d.ts +5 -2
  22. package/module/Date/now.js +10 -3
  23. package/module/Math/addition.d.ts +2 -2
  24. package/module/Math/addition.js +8 -9
  25. package/module/Math/average.d.ts +2 -2
  26. package/module/Math/average.js +3 -1
  27. package/module/Math/calculator/core.d.ts +1 -5
  28. package/module/Math/calculator/core.js +76 -55
  29. package/module/Math/calculator/exchange.d.ts +1 -5
  30. package/module/Math/calculator/exchange.js +16 -12
  31. package/module/Math/calculator/index.d.ts +2 -5
  32. package/module/Math/calculator/index.js +13 -8
  33. package/module/Math/calculator/literalExpression.d.ts +2 -2
  34. package/module/Math/calculator/literalExpression.js +20 -13
  35. package/module/Math/degToRad.d.ts +2 -2
  36. package/module/Math/degToRad.js +3 -1
  37. package/module/Math/deviationValue.d.ts +8 -0
  38. package/module/Math/deviationValue.js +14 -0
  39. package/module/Math/division.d.ts +7 -2
  40. package/module/Math/division.js +20 -9
  41. package/module/Math/factorial.d.ts +2 -2
  42. package/module/Math/factorial.js +10 -4
  43. package/module/Math/factorize.d.ts +2 -2
  44. package/module/Math/factorize.js +3 -1
  45. package/module/Math/gcd.d.ts +2 -2
  46. package/module/Math/gcd.js +6 -7
  47. package/module/Math/getDecimalLength.d.ts +2 -2
  48. package/module/Math/getDecimalLength.js +3 -1
  49. package/module/Math/index.d.ts +94 -33
  50. package/module/Math/index.js +278 -67
  51. package/module/Math/isDouble.d.ts +3 -2
  52. package/module/Math/isDouble.js +4 -1
  53. package/module/Math/isNumber.d.ts +3 -3
  54. package/module/Math/isNumber.js +4 -2
  55. package/module/Math/isPrimeNumber.d.ts +2 -2
  56. package/module/Math/isPrimeNumber.js +5 -6
  57. package/module/Math/lcm.d.ts +2 -2
  58. package/module/Math/lcm.js +7 -8
  59. package/module/Math/mathConverter.d.ts +5 -0
  60. package/module/Math/mathConverter.js +48 -0
  61. package/module/Math/mathSeparator.d.ts +5 -0
  62. package/module/Math/mathSeparator.js +21 -0
  63. package/module/Math/max.d.ts +1 -2
  64. package/module/Math/max.js +3 -2
  65. package/module/Math/min.d.ts +1 -2
  66. package/module/Math/min.js +3 -2
  67. package/module/Math/multiples.d.ts +1 -2
  68. package/module/Math/multiples.js +2 -1
  69. package/module/Math/multiplication.d.ts +1 -2
  70. package/module/Math/multiplication.js +4 -6
  71. package/module/Math/nCr.d.ts +1 -2
  72. package/module/Math/nCr.js +4 -6
  73. package/module/Math/nHr.d.ts +1 -2
  74. package/module/Math/nHr.js +4 -6
  75. package/module/Math/nPr.d.ts +1 -2
  76. package/module/Math/nPr.js +2 -1
  77. package/module/Math/primeFactorization.d.ts +1 -2
  78. package/module/Math/primeFactorization.js +2 -1
  79. package/module/Math/quotient.d.ts +1 -2
  80. package/module/Math/quotient.js +2 -1
  81. package/module/Math/radToDeg.d.ts +1 -2
  82. package/module/Math/radToDeg.js +2 -1
  83. package/module/Math/random.d.ts +3 -2
  84. package/module/Math/random.js +5 -2
  85. package/module/Math/reduce.d.ts +1 -2
  86. package/module/Math/reduce.js +5 -7
  87. package/module/Math/repeatedTrial.d.ts +2 -2
  88. package/module/Math/repeatedTrial.js +7 -8
  89. package/module/Math/roundOff.d.ts +7 -0
  90. package/module/Math/roundOff.js +14 -0
  91. package/module/Math/softmax.d.ts +5 -0
  92. package/module/Math/softmax.js +40 -0
  93. package/module/Math/standardDeviation.d.ts +1 -2
  94. package/module/Math/standardDeviation.js +5 -7
  95. package/module/Math/subtract.d.ts +1 -2
  96. package/module/Math/subtract.js +9 -9
  97. package/module/Math/toBinary.d.ts +5 -2
  98. package/module/Math/toBinary.js +4 -4
  99. package/module/Math/toCelsius.d.ts +1 -2
  100. package/module/Math/toCelsius.js +4 -6
  101. package/module/Math/toKelvin.d.ts +1 -2
  102. package/module/Math/toKelvin.js +4 -6
  103. package/module/Math/valueSwap.d.ts +2 -2
  104. package/module/Math/valueSwap.js +3 -1
  105. package/module/Simple/Date/index.d.ts +5 -0
  106. package/module/Simple/Date/index.js +27 -0
  107. package/module/Simple/Date/now.d.ts +1 -0
  108. package/module/Simple/Date/now.js +17 -0
  109. package/module/Simple/Math/dayOfWeek.d.ts +6 -0
  110. package/module/Simple/Math/dayOfWeek.js +31 -0
  111. package/module/Simple/Math/deviationValue.d.ts +5 -0
  112. package/module/Simple/Math/deviationValue.js +14 -0
  113. package/module/Simple/Math/index.d.ts +10 -0
  114. package/module/Simple/Math/index.js +33 -0
  115. package/module/Simple/Tool/birthday.d.ts +9 -0
  116. package/module/Simple/Tool/birthday.js +26 -0
  117. package/module/Simple/Tool/index.d.ts +5 -0
  118. package/module/Simple/Tool/index.js +27 -0
  119. package/module/Simple/index.d.ts +11 -0
  120. package/module/Simple/index.js +40 -0
  121. package/module/Tool/birthday.d.ts +8 -2
  122. package/module/Tool/birthday.js +15 -10
  123. package/module/Tool/dayOfWeek.d.ts +5 -6
  124. package/module/Tool/dayOfWeek.js +12 -2
  125. package/module/Tool/index.d.ts +18 -3
  126. package/module/Tool/index.js +58 -9
  127. package/module/Tool/isBrowser.d.ts +1 -0
  128. package/module/Tool/isBrowser.js +4 -0
  129. package/module/Tool/isNode.d.ts +1 -0
  130. package/module/Tool/isNode.js +4 -0
  131. package/module/Tool/isNodeWebkit.d.ts +1 -0
  132. package/module/Tool/isNodeWebkit.js +6 -0
  133. package/module/Tool/pipeFunction.d.ts +1 -2
  134. package/module/Tool/pipeFunction.js +3 -2
  135. package/module/index.d.ts +10 -11
  136. package/module/index.js +49 -33
  137. package/module/tsconfig.tsbuildinfo +1 -1
  138. package/module/types/int.d.ts +4 -0
  139. package/module/{Math/value.js → types/int.js} +0 -2
  140. package/module/types/logicType.d.ts +8 -0
  141. package/module/types/logicType.js +2 -0
  142. package/module/types/monType.d.ts +4 -0
  143. package/module/types/monType.js +2 -0
  144. package/package.json +18 -18
  145. package/.env +0 -1
  146. package/.github/dependabot.yml +0 -11
  147. package/.github/workflows/node.js.yml +0 -30
  148. package/module/Array/getArraysIntersect.d.ts +0 -7
  149. package/module/Array/getArraysIntersect.js +0 -15
  150. package/module/Math/euclideanAlgorithm.d.ts +0 -8
  151. package/module/Math/euclideanAlgorithm.js +0 -31
  152. package/module/Math/value.d.ts +0 -2
  153. package/sider.yml +0 -60
  154. package/test.js +0 -5
@@ -1,71 +1,92 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const addition_1 = __importDefault(require("../addition"));
7
- const division_1 = __importDefault(require("../division"));
8
- const multiplication_1 = __importDefault(require("../multiplication"));
9
- const subtract_1 = __importDefault(require("../subtract"));
10
- const exchange_1 = __importDefault(require("./exchange"));
3
+ exports.calculatorCore = void 0;
4
+ const addition_1 = require("../addition");
5
+ const division_1 = require("../division");
6
+ const multiplication_1 = require("../multiplication");
7
+ const subtract_1 = require("../subtract");
8
+ const exchange_1 = require("./exchange");
9
+ /**
10
+ * 電卓
11
+ * ()や符号に対応
12
+ * xなどの文字は未対応
13
+ * @param {string} x 計算式
14
+ */
11
15
  const calculatorCore = (x, ex) => {
16
+ //符号反転
12
17
  x = x.replace(/--/g, '+');
13
18
  x = x.replace(/\+\+/g, '+');
14
19
  x = x.replace(/\+-/g, '+0-');
15
20
  x = x.replace(/\-\+/g, '+0-');
16
- if (x.indexOf('$') != -1) {
21
+ //円計算
22
+ while (true) {
17
23
  if (ex) {
18
- const $ = x.match(/(\$[0-9]+)/);
19
- if ($) {
20
- return calculatorCore(x.replace($[0], (0, exchange_1.default)({ n: $[0], $: ex.$ })), ex);
24
+ for (const i in ex) {
25
+ if (x.indexOf(i) != -1) {
26
+ const $ = x.match(new RegExp(`\\${i}` + '([0-9]+)'));
27
+ if ($) {
28
+ x = x.replace($[0], (0, exchange_1.exchange)($[0], ex));
29
+ }
30
+ }
21
31
  }
22
32
  }
23
- }
24
- if (x.indexOf('(') != -1 || x.indexOf(')') != -1) {
25
- const y = x.match(/\(\d+\.?(\d+)?(\*|\/|\+|\-)\d+\.?(\d+)?\)/);
26
- if (y) {
27
- return calculatorCore(x.replace(y[0], calculatorCore(y[0].replace(/\(|\)/g, ''))), ex);
33
+ //括弧の処理
34
+ if (x.indexOf('(') != -1 || x.indexOf(')') != -1) {
35
+ //括弧の中身をぬく
36
+ const y = x.match(/\(\d+\.?(\d+)?(\*|\/|\+|\-)\d+\.?(\d+)?\)/);
37
+ if (y) {
38
+ //括弧の中身を計算
39
+ x = x.replace(y[0], (0, exports.calculatorCore)(y[0].replace(/\(|\)/g, '')));
40
+ }
41
+ else {
42
+ x = x.replace(`(${x.slice(x.indexOf('(') + 1, x.indexOf(')'))})`, (0, exports.calculatorCore)(x.slice(x.indexOf('(') + 1, x.indexOf(')'))));
43
+ }
28
44
  }
29
- else {
30
- return calculatorCore(x.replace(`(${x.slice(x.indexOf('(') + 1, x.indexOf(')'))})`, calculatorCore(x.slice(x.indexOf('(') + 1, x.indexOf(')')))), ex);
45
+ else if (x.indexOf('^') != -1 ||
46
+ x.indexOf('*') != -1 ||
47
+ x.indexOf('/') != -1) {
48
+ //掛け算と割り算の処理
49
+ const y = [
50
+ x.match(/\d+\.?(\d+)?(\*|\/|\^)\d+\.?(\d+)?/),
51
+ [''],
52
+ ];
53
+ if (y[0]) {
54
+ y[1] = y[0][0]
55
+ .split(/(\d+\.\d+)|(\d+)/g)
56
+ .filter((n) => {
57
+ return typeof n != 'undefined' && n != '';
58
+ });
59
+ x = x.replace(y[0][0], `${y[1][1] == '^'
60
+ ? Math.pow(+y[1][0], +y[1][2])
61
+ : y[1][1] == '*'
62
+ ? (0, multiplication_1.multiplication)(+y[1][0], +y[1][2])
63
+ : y[1][1] == '/'
64
+ ? (0, division_1.division)(+y[1][0], +y[1][2])
65
+ : '0'}`);
66
+ }
31
67
  }
32
- }
33
- else if (x.indexOf('*') != -1 || x.indexOf('/') != -1) {
34
- const y = [
35
- x.match(/\d+\.?(\d+)?(\*|\/)\d+\.?(\d+)?/),
36
- [''],
37
- ];
38
- if (y[0]) {
39
- y[1] = y[0][0].split(/(\d+\.\d+)|(\d+)/g).filter((n) => {
40
- return typeof n != 'undefined' && n != '';
41
- });
42
- return calculatorCore(x.replace(y[0][0], `${y[1][1] == '*'
43
- ? (0, multiplication_1.default)(Number(y[1][0]), Number(y[1][2]))
44
- : y[1][1] == '/'
45
- ? (0, division_1.default)(Number(y[1][0]), Number(y[1][2]))[0]
46
- : '0'}`), ex);
68
+ else if (x.indexOf('+') != -1 || x.indexOf('-') != -1) {
69
+ //加算と減算の処理
70
+ let y = [
71
+ x.match(/\d+\.?(\d+)?(\+|\-)\d+\.?(\d+)?/),
72
+ [''],
73
+ ];
74
+ if (y[0]) {
75
+ y[1] = y[0][0]
76
+ .split(/(\d+\.\d+)|(\d+)/g)
77
+ .filter((n) => {
78
+ return typeof n != 'undefined' && n !== '';
79
+ });
80
+ x = x.replace(y[0][0], `${y[1][1] == '+'
81
+ ? (0, addition_1.addition)(Number(y[1][0]), Number(y[1][2]))
82
+ : y[1][1] == '-'
83
+ ? (0, subtract_1.subtract)(Number(y[1][0]), Number(y[1][2]))
84
+ : '0'}`);
85
+ }
47
86
  }
48
- return x;
49
- }
50
- else if (x.indexOf('+') != -1 || x.indexOf('-') != -1) {
51
- let y = [
52
- x.match(/\d+\.?(\d+)?(\+|\-)\d+\.?(\d+)?/),
53
- [''],
54
- ];
55
- if (y[0]) {
56
- y[1] = y[0][0].split(/(\d+\.\d+)|(\d+)/g).filter((n) => {
57
- return typeof n != 'undefined' && n !== '';
58
- });
59
- return calculatorCore(x.replace(y[0][0], `${y[1][1] == '+'
60
- ? (0, addition_1.default)(Number(y[1][0]), Number(y[1][2]))
61
- : y[1][1] == '-'
62
- ? (0, subtract_1.default)(Number(y[1][0]), Number(y[1][2]))
63
- : '0'}`), ex);
87
+ else {
88
+ return x;
64
89
  }
65
- return x;
66
- }
67
- else {
68
- return x;
69
90
  }
70
91
  };
71
- exports.default = calculatorCore;
92
+ exports.calculatorCore = calculatorCore;
@@ -1,5 +1 @@
1
- declare const exchange: ({ n, $ }: {
2
- n: string;
3
- $?: number | undefined;
4
- }) => string;
5
- export default exchange;
1
+ export declare const exchange: <T extends object>(n: string, props?: T | undefined) => string;
@@ -1,20 +1,24 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const multiplication_1 = __importDefault(require("../multiplication"));
7
- const exchange = ({ n, $ }) => {
8
- if ($) {
9
- if (n[0] === '$') {
10
- return String((0, multiplication_1.default)(Number(n.slice(1)), $));
11
- }
12
- else {
13
- return n;
3
+ exports.exchange = void 0;
4
+ const isNumber_1 = require("../isNumber");
5
+ const multiplication_1 = require("../multiplication");
6
+ const exchange = (n, props) => {
7
+ if (props) {
8
+ for (const i in props) {
9
+ if (n[0] == i) {
10
+ if ((0, isNumber_1.isNumber)(props[i])) {
11
+ return String((0, multiplication_1.multiplication)(Number(n.slice(1)), Number(props[i])));
12
+ }
13
+ }
14
+ else {
15
+ return n;
16
+ }
14
17
  }
18
+ return n;
15
19
  }
16
20
  else {
17
21
  return n;
18
22
  }
19
23
  };
20
- exports.default = exchange;
24
+ exports.exchange = exchange;
@@ -3,9 +3,6 @@
3
3
  * ()や符号に対応
4
4
  * 一文字までの方程式に対応
5
5
  * @param {string} x
6
+ * @param {object} ex 為替
6
7
  */
7
- interface Props {
8
- $?: number;
9
- }
10
- declare const calculator: (x: string, ex?: Props) => string;
11
- export default calculator;
8
+ export declare const calculator: <T extends object>(x: string, ex?: T | undefined) => string;
@@ -1,17 +1,22 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const core_1 = __importDefault(require("./core"));
7
- const literalExpression_1 = __importDefault(require("./literalExpression"));
3
+ exports.calculator = void 0;
4
+ const core_1 = require("./core");
5
+ const literalExpression_1 = require("./literalExpression");
6
+ /**
7
+ * 電卓
8
+ * ()や符号に対応
9
+ * 一文字までの方程式に対応
10
+ * @param {string} x
11
+ * @param {object} ex 為替
12
+ */
8
13
  const calculator = (x, ex) => {
9
14
  x = x.replace(/\s+/g, '');
10
15
  if (x.indexOf('=') != -1) {
11
- return (0, literalExpression_1.default)(x);
16
+ return (0, literalExpression_1.literalExpression)(x);
12
17
  }
13
18
  else {
14
- return (0, core_1.default)(x, ex);
19
+ return (0, core_1.calculatorCore)(x, ex);
15
20
  }
16
21
  };
17
- exports.default = calculator;
22
+ exports.calculator = calculator;
@@ -1,5 +1,5 @@
1
1
  /**
2
+ * 方程式計算
2
3
  * @param {string} x
3
4
  */
4
- declare const literalExpression: (x: string) => string;
5
- export default literalExpression;
5
+ export declare const literalExpression: (x: string) => string;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const division_1 = __importDefault(require("../division"));
7
- const gcd_1 = __importDefault(require("../gcd"));
8
- const core_1 = __importDefault(require("./core"));
3
+ exports.literalExpression = void 0;
4
+ const division_1 = require("../division");
5
+ const gcd_1 = require("../gcd");
6
+ const core_1 = require("./core");
9
7
  /**
8
+ * 方程式計算
10
9
  * @param {string} x
11
10
  */
12
11
  const literalExpression = (x) => {
@@ -22,6 +21,7 @@ const literalExpression = (x) => {
22
21
  }
23
22
  }
24
23
  if (cache[0][1]) {
24
+ cache[0][1] = (0, core_1.calculatorCore)(cache[0][1]);
25
25
  if (cache[0][1].indexOf('+') !== -1) {
26
26
  cache[0][1] = cache[0][1].replace(/\+/g, 'plus');
27
27
  }
@@ -36,15 +36,22 @@ const literalExpression = (x) => {
36
36
  }
37
37
  }
38
38
  cache[1] = cache[0][1]
39
- ? (0, core_1.default)(`${cache[1]}${cache[0][1]}`)
40
- : (0, core_1.default)(cache[1]);
39
+ ? (0, core_1.calculatorCore)(`${cache[1]}${cache[0][1]}`)
40
+ : (0, core_1.calculatorCore)(cache[1]);
41
41
  cache[0] = cache[0][0]
42
42
  .split(/([0-9]+)|([a-zA-Z]+)/)
43
43
  .filter((n) => n !== '' && typeof n != 'undefined');
44
- const cacheGcd = (0, gcd_1.default)(Number(cache[0][0]), Number(cache[1]));
45
- if (cacheGcd !== 1) {
46
- return `${(0, division_1.default)(Number(cache[1]), cacheGcd)[0]}/${(0, division_1.default)(Number(cache[0][0]), cacheGcd)[0]}`;
44
+ if (isNaN(Number(cache[0][0]))) {
45
+ return cache[1];
46
+ }
47
+ else {
48
+ const cacheGcd = (0, gcd_1.gcd)(Number(cache[0][0]), Number(cache[1]));
49
+ if (cacheGcd !== 1) {
50
+ return `${(0, division_1.division)(Number(cache[1]), cacheGcd)}/${(0, division_1.division)(Number(cache[0][0]), cacheGcd)}`;
51
+ }
52
+ return cache[0][0] == '1'
53
+ ? `${cache[1]}/${cache[0][0]}`
54
+ : cache[1];
47
55
  }
48
- return `${Number(cache[1])}/${Number(cache[0][0])}`;
49
56
  };
50
- exports.default = literalExpression;
57
+ exports.literalExpression = literalExpression;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * 角度をラジアンに変換
3
3
  * @param {number} x
4
+ * @returns number
4
5
  */
5
- declare const degToRad: (x: number) => number;
6
- export default degToRad;
6
+ export declare const degToRad: (x: number) => number;
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.degToRad = void 0;
3
4
  /**
4
5
  * 角度をラジアンに変換
5
6
  * @param {number} x
7
+ * @returns number
6
8
  */
7
9
  const degToRad = (x) => {
8
10
  return x * (Math.PI / 180);
9
11
  };
10
- exports.default = degToRad;
12
+ exports.degToRad = degToRad;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 偏差値を計算する
3
+ * @param {number} value
4
+ * @param {number} averageValue
5
+ * @param {number} standardDeviationValue
6
+ * @returns number
7
+ */
8
+ export declare const deviationValue: (value: number, averageValue: number, standardDeviationValue: number) => number;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deviationValue = void 0;
4
+ /**
5
+ * 偏差値を計算する
6
+ * @param {number} value
7
+ * @param {number} averageValue
8
+ * @param {number} standardDeviationValue
9
+ * @returns number
10
+ */
11
+ const deviationValue = (value, averageValue, standardDeviationValue) => {
12
+ return (((value - averageValue) / standardDeviationValue) * 10 + 50);
13
+ };
14
+ exports.deviationValue = deviationValue;
@@ -1,7 +1,12 @@
1
+ export interface DIVISION {
2
+ (x: number, y: number, isFloor?: true): number;
3
+ (x: number, y: number, isFloor?: false): number[];
4
+ }
1
5
  /**
2
6
  * 誤差のない割り算
3
7
  * @param {number} x
4
8
  * @param {number} y
9
+ * @param {boolean} [isFloor=true]
10
+ * @returns number
5
11
  */
6
- declare const division: (x: number, y: number) => number[];
7
- export default division;
12
+ export declare const division: DIVISION;
@@ -1,18 +1,29 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const getDecimalLength_1 = __importDefault(require("./getDecimalLength"));
3
+ exports.division = void 0;
4
+ const getDecimalLength_1 = require("./getDecimalLength");
5
+ const valueSwap_1 = require("./valueSwap");
7
6
  /**
8
7
  * 誤差のない割り算
9
8
  * @param {number} x
10
9
  * @param {number} y
10
+ * @param {boolean} [isFloor=true]
11
+ * @returns number
11
12
  */
12
- const division = (x, y) => {
13
- const n = 10 ** ((0, getDecimalLength_1.default)(x) + (0, getDecimalLength_1.default)(y));
13
+ exports.division = ((x, y, isFloor = true) => {
14
+ const [decimalLengthX, decimalLengthY] = (0, valueSwap_1.valueSwap)((0, getDecimalLength_1.getDecimalLength)(x), (0, getDecimalLength_1.getDecimalLength)(y));
15
+ const n = decimalLengthX == decimalLengthY
16
+ ? 1
17
+ : Math.pow(10, decimalLengthY - decimalLengthX);
14
18
  x = +(x + '').replace('.', '');
15
19
  y = +(y + '').replace('.', '');
16
- return [x / y / n, (x % y) / n];
17
- };
18
- exports.default = division;
20
+ return isFloor
21
+ ? x > y
22
+ ? x / y / n
23
+ : (x / y) * n
24
+ : [
25
+ x > y ? (x - (x % y)) / y / n : ((x - (x % y)) / y) * n,
26
+ x % y,
27
+ ];
28
+ // return isFloor ? x / y : [(x - (x % y)) / y, x % y];
29
+ });
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * 階乗
3
3
  * @param {number} x
4
+ * @returns number
4
5
  */
5
- declare const factorial: (x: number) => number;
6
- export default factorial;
6
+ export declare const factorial: (x: number) => number;
@@ -1,13 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.factorial = void 0;
3
4
  /**
4
5
  * 階乗
5
6
  * @param {number} x
7
+ * @returns number
6
8
  */
7
9
  const factorial = (x) => {
8
- if (x === 0) {
9
- return 1;
10
+ let result = 1;
11
+ if (x !== 0) {
12
+ while (x > 1) {
13
+ result *= x;
14
+ x--;
15
+ }
10
16
  }
11
- return x * factorial(x - 1);
17
+ return result;
12
18
  };
13
- exports.default = factorial;
19
+ exports.factorial = factorial;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * 因数分解
3
3
  * @param {number} n
4
+ * @returns number[]
4
5
  */
5
- declare const factorize: (n: number) => number[];
6
- export default factorize;
6
+ export declare const factorize: (n: number) => number[];
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.factorize = void 0;
3
4
  /**
4
5
  * 因数分解
5
6
  * @param {number} n
7
+ * @returns number[]
6
8
  */
7
9
  const factorize = (n) => {
8
10
  const result = [];
@@ -14,4 +16,4 @@ const factorize = (n) => {
14
16
  }
15
17
  return result;
16
18
  };
17
- exports.default = factorize;
19
+ exports.factorize = factorize;
@@ -3,6 +3,6 @@
3
3
  * @param {number} x
4
4
  * @param {number} y
5
5
  * @param {number} ...z
6
+ * @returns number
6
7
  */
7
- declare const gcd: (x: number, y: number, ...z: number[]) => number;
8
- export default gcd;
8
+ export declare const gcd: (x: number, y: number, ...z: number[]) => number;
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const valueSwap_1 = __importDefault(require("./valueSwap"));
3
+ exports.gcd = void 0;
4
+ const valueSwap_1 = require("./valueSwap");
7
5
  /**
8
6
  * 自然数の最大公約数
9
7
  * @param {number} x
10
8
  * @param {number} y
11
9
  * @param {number} ...z
10
+ * @returns number
12
11
  */
13
12
  const gcd = (x, y, ...z) => {
14
13
  if (x === 0 || y === 0)
15
14
  return 0;
16
- [x, y] = (0, valueSwap_1.default)(x, y);
15
+ [x, y] = (0, valueSwap_1.valueSwap)(x, y);
17
16
  /* ユークリッドの互除法 */
18
17
  let r = y % x;
19
18
  while (r !== 0) {
@@ -23,9 +22,9 @@ const gcd = (x, y, ...z) => {
23
22
  }
24
23
  if (z.length > 0) {
25
24
  for (let i = 0; i < z.length; i++) {
26
- x = gcd(x, z[i]);
25
+ x = (0, exports.gcd)(x, z[i]);
27
26
  }
28
27
  }
29
28
  return x;
30
29
  };
31
- exports.default = gcd;
30
+ exports.gcd = gcd;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * 小数点以下の桁数
3
3
  * @param {number} value
4
+ * @returns number
4
5
  */
5
- declare const getDecimalLength: (value: number) => number;
6
- export default getDecimalLength;
6
+ export declare const getDecimalLength: (value: number) => number;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDecimalLength = void 0;
3
4
  /**
4
5
  * 小数点以下の桁数
5
6
  * @param {number} value
7
+ * @returns number
6
8
  */
7
9
  const getDecimalLength = (value) => {
8
10
  let x = (value + '').split('.')[1];
@@ -11,4 +13,4 @@ const getDecimalLength = (value) => {
11
13
  }
12
14
  return 0;
13
15
  };
14
- exports.default = getDecimalLength;
16
+ exports.getDecimalLength = getDecimalLength;