umt 1.0.6 → 1.0.7

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 (118) hide show
  1. package/.github/workflows/node.js.yml +1 -1
  2. package/.nvmrc +1 -0
  3. package/README.md +3 -1
  4. package/module/Array/arraysJoin.d.ts +7 -0
  5. package/module/{arraysJoin.js → Array/arraysJoin.js} +5 -0
  6. package/module/Array/getArraysDiff.d.ts +7 -0
  7. package/module/{getArraysDiff.js → Array/getArraysDiff.js} +5 -0
  8. package/module/Array/getArraysIntersect.d.ts +7 -0
  9. package/module/{getArraysIntersect.js → Array/getArraysIntersect.js} +5 -0
  10. package/module/Array/index.d.ts +5 -0
  11. package/module/Array/index.js +14 -0
  12. package/module/Array/quickSort.d.ts +8 -0
  13. package/module/{quickSort.js → Array/quickSort.js} +7 -1
  14. package/module/Date/index.d.ts +2 -0
  15. package/module/Date/index.js +8 -0
  16. package/module/Date/now.d.ts +2 -0
  17. package/module/Date/now.js +5 -0
  18. package/module/{addition.d.ts → Math/addition.d.ts} +5 -0
  19. package/module/{addition.js → Math/addition.js} +6 -1
  20. package/module/Math/average.d.ts +6 -0
  21. package/module/Math/average.js +12 -0
  22. package/module/Math/calculator/core.d.ts +8 -0
  23. package/module/{calculator.js → Math/calculator/core.js} +18 -15
  24. package/module/Math/calculator/index.d.ts +8 -0
  25. package/module/Math/calculator/index.js +23 -0
  26. package/module/Math/calculator/literalExpression.d.ts +5 -0
  27. package/module/Math/calculator/literalExpression.js +50 -0
  28. package/module/{degToRad.d.ts → Math/degToRad.d.ts} +4 -0
  29. package/module/{degToRad.js → Math/degToRad.js} +4 -0
  30. package/module/{division.d.ts → Math/division.d.ts} +5 -0
  31. package/module/{division.js → Math/division.js} +6 -1
  32. package/module/{euclideanAlgorithm.d.ts → Math/euclideanAlgorithm.d.ts} +6 -0
  33. package/module/{euclideanAlgorithm.js → Math/euclideanAlgorithm.js} +7 -0
  34. package/module/Math/factorial.d.ts +6 -0
  35. package/module/Math/factorial.js +13 -0
  36. package/module/Math/factorize.d.ts +6 -0
  37. package/module/Math/factorize.js +17 -0
  38. package/module/Math/gcd.d.ts +8 -0
  39. package/module/Math/gcd.js +31 -0
  40. package/module/{getDecimalLength.d.ts → Math/getDecimalLength.d.ts} +4 -0
  41. package/module/{getDecimalLength.js → Math/getDecimalLength.js} +4 -0
  42. package/module/Math/index.d.ts +33 -0
  43. package/module/Math/index.js +70 -0
  44. package/module/{isDouble.d.ts → Math/isDouble.d.ts} +4 -0
  45. package/module/{isDouble.js → Math/isDouble.js} +4 -0
  46. package/module/Math/isNumber.d.ts +7 -0
  47. package/module/{isNumber.js → Math/isNumber.js} +5 -0
  48. package/module/{isPrimeNumber.d.ts → Math/isPrimeNumber.d.ts} +4 -0
  49. package/module/{isPrimeNumber.js → Math/isPrimeNumber.js} +4 -0
  50. package/module/{lcm.d.ts → Math/lcm.d.ts} +5 -0
  51. package/module/{lcm.js → Math/lcm.js} +7 -2
  52. package/module/Math/max.d.ts +6 -0
  53. package/module/Math/max.js +8 -0
  54. package/module/{min.d.ts → Math/min.d.ts} +4 -0
  55. package/module/{min.js → Math/min.js} +4 -0
  56. package/module/Math/multiples.d.ts +7 -0
  57. package/module/Math/multiples.js +15 -0
  58. package/module/{multiplication.d.ts → Math/multiplication.d.ts} +5 -0
  59. package/module/{multiplication.js → Math/multiplication.js} +6 -1
  60. package/module/{nCr.d.ts → Math/nCr.d.ts} +5 -0
  61. package/module/{nCr.js → Math/nCr.js} +6 -0
  62. package/module/Math/nHr.d.ts +7 -0
  63. package/module/{nCrs.js → Math/nHr.js} +7 -2
  64. package/module/{nPr.d.ts → Math/nPr.d.ts} +5 -0
  65. package/module/{nPr.js → Math/nPr.js} +6 -0
  66. package/module/{primeFactorization.d.ts → Math/primeFactorization.d.ts} +4 -0
  67. package/module/{primeFactorization.js → Math/primeFactorization.js} +4 -0
  68. package/module/{quotient.d.ts → Math/quotient.d.ts} +5 -0
  69. package/module/{quotient.js → Math/quotient.js} +5 -0
  70. package/module/{radToDeg.d.ts → Math/radToDeg.d.ts} +4 -0
  71. package/module/{radToDeg.js → Math/radToDeg.js} +4 -0
  72. package/module/{random.d.ts → Math/random.d.ts} +4 -0
  73. package/module/{random.js → Math/random.js} +4 -0
  74. package/module/{reduce.d.ts → Math/reduce.d.ts} +5 -0
  75. package/module/{reduce.js → Math/reduce.js} +8 -3
  76. package/module/{repeatedTrial.d.ts → Math/repeatedTrial.d.ts} +6 -0
  77. package/module/Math/repeatedTrial.js +24 -0
  78. package/module/Math/standardDeviation.d.ts +6 -0
  79. package/module/Math/standardDeviation.js +22 -0
  80. package/module/{subtract.d.ts → Math/subtract.d.ts} +5 -0
  81. package/module/{subtract.js → Math/subtract.js} +6 -1
  82. package/module/{toBinary.d.ts → Math/toBinary.d.ts} +5 -0
  83. package/module/{toBinary.js → Math/toBinary.js} +5 -0
  84. package/module/Math/toCelsius.d.ts +2 -0
  85. package/module/Math/toCelsius.js +8 -0
  86. package/module/Math/toKelvin.d.ts +2 -0
  87. package/module/Math/toKelvin.js +8 -0
  88. package/module/Math/value.d.ts +2 -0
  89. package/module/Math/value.js +4 -0
  90. package/module/Math/valueSwap.d.ts +7 -0
  91. package/module/{valueSwap.js → Math/valueSwap.js} +5 -0
  92. package/module/Tool/birthday.d.ts +2 -0
  93. package/module/Tool/birthday.js +17 -0
  94. package/module/Tool/dayOfWeek.d.ts +6 -0
  95. package/module/Tool/dayOfWeek.js +4 -0
  96. package/module/Tool/index.d.ts +4 -0
  97. package/module/Tool/index.js +12 -0
  98. package/module/Tool/pipeFunction.d.ts +6 -0
  99. package/module/Tool/pipeFunction.js +4 -0
  100. package/module/index.d.ts +8 -75
  101. package/module/index.js +30 -93
  102. package/module/tsconfig.tsbuildinfo +1 -1
  103. package/package.json +3 -2
  104. package/test.js +5 -0
  105. package/.github/workflows/npm-publish.yml +0 -34
  106. package/module/arraysJoin.d.ts +0 -2
  107. package/module/calculator.d.ts +0 -2
  108. package/module/fact.d.ts +0 -2
  109. package/module/fact.js +0 -11
  110. package/module/getArraysDiff.d.ts +0 -2
  111. package/module/getArraysIntersect.d.ts +0 -2
  112. package/module/isNumber.d.ts +0 -2
  113. package/module/max.d.ts +0 -2
  114. package/module/max.js +0 -4
  115. package/module/nCrs.d.ts +0 -2
  116. package/module/quickSort.d.ts +0 -2
  117. package/module/repeatedTrial.js +0 -15
  118. package/module/valueSwap.d.ts +0 -2
@@ -15,7 +15,7 @@ jobs:
15
15
 
16
16
  strategy:
17
17
  matrix:
18
- node-version: [12.x, 14.x, 16.x]
18
+ node-version: [16.x]
19
19
  # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
20
20
 
21
21
  steps:
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ v16.10.0
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  個人的に作った便利関数集
4
4
 
5
+ 個人用途なので破壊的変更がある可能性があります。
6
+
5
7
  ## doc
6
8
 
7
- <https://umt.vercel.app/>
9
+ <https://umt.oshaburikitchin.com/>
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 重複をしないで結合
3
+ * @param {any[]} array
4
+ * @param {any[]} ...arrays
5
+ */
6
+ declare const arraysJoin: <A extends any[], B extends any[], C extends A | B>(array: A, ...arrays: B[]) => C;
7
+ export default arraysJoin;
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 重複をしないで結合
5
+ * @param {any[]} array
6
+ * @param {any[]} ...arrays
7
+ */
3
8
  const arraysJoin = (array, ...arrays) => {
4
9
  for (const i of arrays) {
5
10
  array.push(...i);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 共通しない要素をとりだす
3
+ * @param {any[]} array
4
+ * @param {any[]} ...arrays
5
+ */
6
+ declare const getArraysDiff: <A extends any[], B extends any[], C extends A | B>(array: A, ...arrays: B[]) => C;
7
+ export default getArraysDiff;
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 共通しない要素をとりだす
5
+ * @param {any[]} array
6
+ * @param {any[]} ...arrays
7
+ */
3
8
  const getArraysDiff = (array, ...arrays) => {
4
9
  let hasArr = [];
5
10
  for (const i of arrays) {
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 共通の要素をとりだす
3
+ * @param {any[]} array
4
+ * @param {any[]} ...arrays
5
+ */
6
+ declare const getArraysIntersect: <A extends any[], B extends any[], C extends A | B>(array: A, ...arrays: B[]) => C;
7
+ export default getArraysIntersect;
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 共通の要素をとりだす
5
+ * @param {any[]} array
6
+ * @param {any[]} ...arrays
7
+ */
3
8
  const getArraysIntersect = (array, ...arrays) => {
4
9
  let hasArr = [];
5
10
  for (const i of arrays) {
@@ -0,0 +1,5 @@
1
+ import arraysJoin from './arraysJoin';
2
+ import getArraysDiff from './getArraysDiff';
3
+ import getArraysIntersect from './getArraysIntersect';
4
+ import quickSort from './quickSort';
5
+ export { arraysJoin, getArraysDiff, getArraysIntersect, quickSort };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.quickSort = exports.getArraysIntersect = exports.getArraysDiff = exports.arraysJoin = void 0;
7
+ const arraysJoin_1 = __importDefault(require("./arraysJoin"));
8
+ exports.arraysJoin = arraysJoin_1.default;
9
+ const getArraysDiff_1 = __importDefault(require("./getArraysDiff"));
10
+ exports.getArraysDiff = getArraysDiff_1.default;
11
+ const getArraysIntersect_1 = __importDefault(require("./getArraysIntersect"));
12
+ exports.getArraysIntersect = getArraysIntersect_1.default;
13
+ const quickSort_1 = __importDefault(require("./quickSort"));
14
+ exports.quickSort = quickSort_1.default;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 配列を高速にソート
3
+ * @param {any[]} array
4
+ * @param {number} startID
5
+ * @param {number} endID
6
+ */
7
+ declare const quickSort: <A extends any[]>(array: A, startID?: number, endID?: number) => A;
8
+ export default quickSort;
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const quickSort = (array, startID, endID) => {
3
+ /**
4
+ * 配列を高速にソート
5
+ * @param {any[]} array
6
+ * @param {number} startID
7
+ * @param {number} endID
8
+ */
9
+ const quickSort = (array, startID = 0, endID = array.length - 1) => {
4
10
  const pivot = array[Math.floor((startID + endID) / 2)];
5
11
  let left = startID;
6
12
  let right = endID;
@@ -0,0 +1,2 @@
1
+ import now from './now';
2
+ export { now };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.now = void 0;
7
+ const now_1 = __importDefault(require("./now"));
8
+ exports.now = now_1.default;
@@ -0,0 +1,2 @@
1
+ declare const now: () => Date;
2
+ export default now;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const now = () => new Date(Date.now() +
4
+ (new Date().getTimezoneOffset() + 9 * 60) * 60 * 1000);
5
+ exports.default = now;
@@ -1,2 +1,7 @@
1
+ /**
2
+ * 誤差のない足し算
3
+ * @param {number} x
4
+ * @param {number} y
5
+ */
1
6
  declare const addition: (x: number, y: number) => number;
2
7
  export default addition;
@@ -6,8 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const getDecimalLength_1 = __importDefault(require("./getDecimalLength"));
7
7
  const max_1 = __importDefault(require("./max"));
8
8
  const multiplication_1 = __importDefault(require("./multiplication"));
9
+ /**
10
+ * 誤差のない足し算
11
+ * @param {number} x
12
+ * @param {number} y
13
+ */
9
14
  const addition = (x, y) => {
10
- const z = Math.pow(10, (0, max_1.default)((0, getDecimalLength_1.default)(x), (0, getDecimalLength_1.default)(y)));
15
+ const z = Math.pow(10, (0, max_1.default)([(0, getDecimalLength_1.default)(x), (0, getDecimalLength_1.default)(y)]));
11
16
  return ((0, multiplication_1.default)(x, z) + (0, multiplication_1.default)(y, z)) / z;
12
17
  };
13
18
  exports.default = addition;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 平均値
3
+ * @param {number[]} numbers
4
+ */
5
+ declare const average: (numbers: number[]) => number;
6
+ export default average;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 平均値
5
+ * @param {number[]} numbers
6
+ */
7
+ const average = (numbers) => {
8
+ const sum = numbers.reduce((a, b) => a + b, 0);
9
+ const avg = sum / numbers.length;
10
+ return avg;
11
+ };
12
+ exports.default = average;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 電卓
3
+ * ()や符号に対応
4
+ * xなどの文字は未対応
5
+ * @param {string} x 計算式
6
+ */
7
+ declare const calculatorCore: (x: string) => string;
8
+ export default calculatorCore;
@@ -3,27 +3,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  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
- let n = 0;
11
- const calculator = (x) => {
12
- if (n === 0) {
13
- x = x.replace(/\s+/g, '');
14
- n++;
15
- }
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
+ /**
11
+ * 電卓
12
+ * ()や符号に対応
13
+ * xなどの文字は未対応
14
+ * @param {string} x 計算式
15
+ */
16
+ const calculatorCore = (x) => {
16
17
  x = x.replace(/--/g, '+');
17
18
  x = x.replace(/\+\+/g, '+');
18
19
  x = x.replace(/\+-/g, '+0-');
19
20
  x = x.replace(/\-\+/g, '+0-');
21
+ console.log(x);
22
+ console.log('====================================');
20
23
  if (x.indexOf('(') != -1 || x.indexOf(')') != -1) {
21
24
  const y = x.match(/\(\d+\.?(\d+)?(\*|\/|\+|\-)\d+\.?(\d+)?\)/);
22
25
  if (y) {
23
- return calculator(x.replace(y[0], calculator(y[0].replace(/\(|\)/g, ''))));
26
+ return calculatorCore(x.replace(y[0], calculatorCore(y[0].replace(/\(|\)/g, ''))));
24
27
  }
25
28
  else {
26
- return calculator(x.replace(`(${x.slice(x.indexOf('(') + 1, x.indexOf(')'))})`, calculator(x.slice(x.indexOf('(') + 1, x.indexOf(')')))));
29
+ return calculatorCore(x.replace(`(${x.slice(x.indexOf('(') + 1, x.indexOf(')'))})`, calculatorCore(x.slice(x.indexOf('(') + 1, x.indexOf(')')))));
27
30
  }
28
31
  }
29
32
  else if (x.indexOf('*') != -1 || x.indexOf('/') != -1) {
@@ -35,7 +38,7 @@ const calculator = (x) => {
35
38
  y[1] = y[0][0].split(/(\d+\.\d+)|(\d+)/g).filter((n) => {
36
39
  return typeof n != 'undefined' && n != '';
37
40
  });
38
- return calculator(x.replace(y[0][0], `${y[1][1] == '*'
41
+ return calculatorCore(x.replace(y[0][0], `${y[1][1] == '*'
39
42
  ? (0, multiplication_1.default)(Number(y[1][0]), Number(y[1][2]))
40
43
  : y[1][1] == '/'
41
44
  ? (0, division_1.default)(Number(y[1][0]), Number(y[1][2]))[0]
@@ -52,7 +55,7 @@ const calculator = (x) => {
52
55
  y[1] = y[0][0].split(/(\d+\.\d+)|(\d+)/g).filter((n) => {
53
56
  return typeof n != 'undefined' && n !== '';
54
57
  });
55
- return calculator(x.replace(y[0][0], `${y[1][1] == '+'
58
+ return calculatorCore(x.replace(y[0][0], `${y[1][1] == '+'
56
59
  ? (0, addition_1.default)(Number(y[1][0]), Number(y[1][2]))
57
60
  : y[1][1] == '-'
58
61
  ? (0, subtract_1.default)(Number(y[1][0]), Number(y[1][2]))
@@ -64,4 +67,4 @@ const calculator = (x) => {
64
67
  return x;
65
68
  }
66
69
  };
67
- exports.default = calculator;
70
+ exports.default = calculatorCore;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 電卓
3
+ * ()や符号に対応
4
+ * 一文字までの方程式に対応
5
+ * @param {string} x
6
+ */
7
+ declare const calculator: (x: string) => string;
8
+ export default calculator;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = __importDefault(require("./core"));
7
+ const literalExpression_1 = __importDefault(require("./literalExpression"));
8
+ /**
9
+ * 電卓
10
+ * ()や符号に対応
11
+ * 一文字までの方程式に対応
12
+ * @param {string} x
13
+ */
14
+ const calculator = (x) => {
15
+ x = x.replace(/\s+/g, '');
16
+ if (x.indexOf('=') != -1) {
17
+ return (0, literalExpression_1.default)(x);
18
+ }
19
+ else {
20
+ return (0, core_1.default)(x);
21
+ }
22
+ };
23
+ exports.default = calculator;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @param {string} x
3
+ */
4
+ declare const literalExpression: (x: string) => string;
5
+ export default literalExpression;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ 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"));
9
+ /**
10
+ * @param {string} x
11
+ */
12
+ const literalExpression = (x) => {
13
+ let cache = [[], ''];
14
+ for (const i of x.split('=')) {
15
+ if (/[a-zA-Z]+/.test(i) === false) {
16
+ cache[1] = i;
17
+ }
18
+ else {
19
+ cache[0] = i
20
+ .split(/([0-9]+[a-zA-Z]+)|([^a-zA-Z]+)/)
21
+ .filter((n) => n !== '' && typeof n != 'undefined');
22
+ }
23
+ }
24
+ if (cache[0][1]) {
25
+ if (cache[0][1].indexOf('+') !== -1) {
26
+ cache[0][1] = cache[0][1].replace(/\+/g, 'plus');
27
+ }
28
+ if (cache[0][1].indexOf('-') !== -1) {
29
+ cache[0][1] = cache[0][1].replace(/\-/g, 'minus');
30
+ }
31
+ if (cache[0][1].indexOf('plus') !== 1) {
32
+ cache[0][1] = cache[0][1].replace(/plus/g, '-');
33
+ }
34
+ if (cache[0][1].indexOf('minus') !== 1) {
35
+ cache[0][1] = cache[0][1].replace(/minus/g, '+');
36
+ }
37
+ }
38
+ cache[1] = cache[0][1]
39
+ ? (0, core_1.default)(`${cache[1]}${cache[0][1]}`)
40
+ : (0, core_1.default)(cache[1]);
41
+ cache[0] = cache[0][0]
42
+ .split(/([0-9]+)|([a-zA-Z]+)/)
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]}`;
47
+ }
48
+ return `${Number(cache[1])}/${Number(cache[0][0])}`;
49
+ };
50
+ exports.default = literalExpression;
@@ -1,2 +1,6 @@
1
+ /**
2
+ * 角度をラジアンに変換
3
+ * @param {number} x
4
+ */
1
5
  declare const degToRad: (x: number) => number;
2
6
  export default degToRad;
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 角度をラジアンに変換
5
+ * @param {number} x
6
+ */
3
7
  const degToRad = (x) => {
4
8
  return x * (Math.PI / 180);
5
9
  };
@@ -1,2 +1,7 @@
1
+ /**
2
+ * 誤差のない割り算
3
+ * @param {number} x
4
+ * @param {number} y
5
+ */
1
6
  declare const division: (x: number, y: number) => number[];
2
7
  export default division;
@@ -4,8 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const getDecimalLength_1 = __importDefault(require("./getDecimalLength"));
7
+ /**
8
+ * 誤差のない割り算
9
+ * @param {number} x
10
+ * @param {number} y
11
+ */
7
12
  const division = (x, y) => {
8
- const n = Math.pow(10, ((0, getDecimalLength_1.default)(x) + (0, getDecimalLength_1.default)(y)));
13
+ const n = 10 ** ((0, getDecimalLength_1.default)(x) + (0, getDecimalLength_1.default)(y));
9
14
  x = +(x + '').replace('.', '');
10
15
  y = +(y + '').replace('.', '');
11
16
  return [x / y / n, (x % y) / n];
@@ -1,2 +1,8 @@
1
+ /**
2
+ * 自然数の最大公約数
3
+ * @param {number} x
4
+ * @param {number} y
5
+ * @param {number} ...z
6
+ */
1
7
  declare const euclideanAlgorithm: (x: number, y: number, ...z: number[]) => number;
2
8
  export default euclideanAlgorithm;
@@ -4,10 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const valueSwap_1 = __importDefault(require("./valueSwap"));
7
+ /**
8
+ * 自然数の最大公約数
9
+ * @param {number} x
10
+ * @param {number} y
11
+ * @param {number} ...z
12
+ */
7
13
  const euclideanAlgorithm = (x, y, ...z) => {
8
14
  if (x === 0 || y === 0)
9
15
  return 0;
10
16
  [x, y] = (0, valueSwap_1.default)(x, y);
17
+ /* ユークリッドの互除法 */
11
18
  let r = y % x;
12
19
  while (r !== 0) {
13
20
  y = x;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 階乗
3
+ * @param {number} x
4
+ */
5
+ declare const factorial: (x: number) => number;
6
+ export default factorial;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 階乗
5
+ * @param {number} x
6
+ */
7
+ const factorial = (x) => {
8
+ if (x === 0) {
9
+ return 1;
10
+ }
11
+ return x * factorial(x - 1);
12
+ };
13
+ exports.default = factorial;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 因数分解
3
+ * @param {number} n
4
+ */
5
+ declare const factorize: (n: number) => number[];
6
+ export default factorize;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 因数分解
5
+ * @param {number} n
6
+ */
7
+ const factorize = (n) => {
8
+ const result = [];
9
+ for (let i = 2; i <= n; i++) {
10
+ while (n % i === 0) {
11
+ result.push(i);
12
+ n /= i;
13
+ }
14
+ }
15
+ return result;
16
+ };
17
+ exports.default = factorize;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 自然数の最大公約数
3
+ * @param {number} x
4
+ * @param {number} y
5
+ * @param {number} ...z
6
+ */
7
+ declare const gcd: (x: number, y: number, ...z: number[]) => number;
8
+ export default gcd;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const valueSwap_1 = __importDefault(require("./valueSwap"));
7
+ /**
8
+ * 自然数の最大公約数
9
+ * @param {number} x
10
+ * @param {number} y
11
+ * @param {number} ...z
12
+ */
13
+ const gcd = (x, y, ...z) => {
14
+ if (x === 0 || y === 0)
15
+ return 0;
16
+ [x, y] = (0, valueSwap_1.default)(x, y);
17
+ /* ユークリッドの互除法 */
18
+ let r = y % x;
19
+ while (r !== 0) {
20
+ y = x;
21
+ x = r;
22
+ r = y % x;
23
+ }
24
+ if (z.length > 0) {
25
+ for (let i = 0; i < z.length; i++) {
26
+ x = gcd(x, z[i]);
27
+ }
28
+ }
29
+ return x;
30
+ };
31
+ exports.default = gcd;
@@ -1,2 +1,6 @@
1
+ /**
2
+ * 小数点以下の桁数
3
+ * @param {number} value
4
+ */
1
5
  declare const getDecimalLength: (value: number) => number;
2
6
  export default getDecimalLength;
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 小数点以下の桁数
5
+ * @param {number} value
6
+ */
3
7
  const getDecimalLength = (value) => {
4
8
  let x = (value + '').split('.')[1];
5
9
  if (typeof x !== 'undefined' && x.length > 0) {
@@ -0,0 +1,33 @@
1
+ import addition from './addition';
2
+ import average from './average';
3
+ import calculator from './calculator';
4
+ import degToRad from './degToRad';
5
+ import division from './division';
6
+ import gcd from './gcd';
7
+ import factorial from './factorial';
8
+ import factorize from './factorize';
9
+ import getDecimalLength from './getDecimalLength';
10
+ import isDouble from './isDouble';
11
+ import isNumber from './isNumber';
12
+ import isPrimeNumber from './isPrimeNumber';
13
+ import lcm from './lcm';
14
+ import max from './max';
15
+ import min from './min';
16
+ import multiples from './multiples';
17
+ import multiplication from './multiplication';
18
+ import nCr from './nCr';
19
+ import nHr from './nHr';
20
+ import nPr from './nPr';
21
+ import primeFactorization from './primeFactorization';
22
+ import quotient from './quotient';
23
+ import radToDeg from './radToDeg';
24
+ import random from './random';
25
+ import reduce from './reduce';
26
+ import repeatedTrial from './repeatedTrial';
27
+ import standardDeviation from './standardDeviation';
28
+ import subtract from './subtract';
29
+ import toBinary from './toBinary';
30
+ import toCelsius from './toCelsius';
31
+ import toKelvin from './toKelvin';
32
+ import valueSwap from './valueSwap';
33
+ export { factorial, lcm, nCr, nHr, nPr, quotient, reduce, repeatedTrial, max, min, isDouble, isNumber, valueSwap, getDecimalLength, subtract, multiplication, addition, division, isPrimeNumber, toBinary, degToRad, radToDeg, primeFactorization, calculator, random, gcd, average, standardDeviation, factorize, multiples, toKelvin, toCelsius, };