umt 1.0.15 → 1.1.0

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 (87) hide show
  1. package/module/Array/arraysJoin.js +1 -10
  2. package/module/Array/getArraysCommon.d.ts +1 -1
  3. package/module/Array/getArraysCommon.js +1 -14
  4. package/module/Array/getArraysDiff.d.ts +3 -3
  5. package/module/Array/getArraysDiff.js +2 -2
  6. package/module/Array/index.d.ts +7 -3
  7. package/module/Array/index.js +10 -28
  8. package/module/Array/quickSort.js +3 -1
  9. package/module/Date/index.d.ts +8 -3
  10. package/module/Date/index.js +14 -17
  11. package/module/Date/new.d.ts +4 -0
  12. package/module/Date/new.js +12 -0
  13. package/module/Date/now.d.ts +1 -1
  14. package/module/Date/now.js +9 -5
  15. package/module/Math/calculator/core.js +37 -40
  16. package/module/Math/calculator/exchange.js +2 -2
  17. package/module/Math/calculator/index.js +5 -4
  18. package/module/Math/calculator/literalExpression.js +4 -4
  19. package/module/Math/division.js +13 -9
  20. package/module/Math/factorial.js +5 -4
  21. package/module/Math/factorize.js +4 -3
  22. package/module/Math/gcd.js +14 -10
  23. package/module/Math/getDecimalLength.js +1 -1
  24. package/module/Math/index.d.ts +79 -40
  25. package/module/Math/index.js +81 -125
  26. package/module/Math/isDouble.js +3 -2
  27. package/module/Math/isNumber.js +3 -2
  28. package/module/Math/isPrimeNumber.js +28 -6
  29. package/module/Math/lcm.js +5 -3
  30. package/module/Math/mathConverter.js +16 -17
  31. package/module/Math/multiples.js +1 -1
  32. package/module/Math/multiplication.js +5 -3
  33. package/module/Math/nCr.js +2 -1
  34. package/module/Math/nHr.js +2 -1
  35. package/module/Math/nPr.js +14 -11
  36. package/module/Math/primeFactorization.js +5 -4
  37. package/module/Math/random.d.ts +2 -2
  38. package/module/Math/random.js +2 -2
  39. package/module/Math/reduce.js +1 -1
  40. package/module/Math/repeatedTrial.js +4 -4
  41. package/module/Math/solveEquation.d.ts +18 -0
  42. package/module/Math/solveEquation.js +72 -0
  43. package/module/Math/subtract.js +0 -6
  44. package/module/Math/valueSwap.js +7 -5
  45. package/module/Object/index.d.ts +12 -0
  46. package/module/Object/index.js +15 -0
  47. package/module/Object/objectUnion.d.ts +5 -0
  48. package/module/Object/objectUnion.js +7 -0
  49. package/module/Simple/Date/index.d.ts +1 -1
  50. package/module/Simple/Date/index.js +2 -16
  51. package/module/Simple/Date/now.js +7 -7
  52. package/module/Simple/Tool/birthday.d.ts +1 -1
  53. package/module/Simple/Tool/birthday.js +6 -6
  54. package/module/Simple/Tool/dayOfWeekSimple.d.ts +2 -2
  55. package/module/Simple/Tool/dayOfWeekSimple.js +9 -6
  56. package/module/Simple/Tool/deviationValueSimple.js +4 -3
  57. package/module/Simple/Tool/index.d.ts +6 -4
  58. package/module/Simple/Tool/index.js +6 -22
  59. package/module/Simple/index.d.ts +4 -3
  60. package/module/Simple/index.js +6 -21
  61. package/module/String/index.d.ts +8 -0
  62. package/module/String/index.js +15 -0
  63. package/module/String/reverseString.d.ts +1 -0
  64. package/module/String/reverseString.js +7 -0
  65. package/module/Tool/birthday.js +1 -2
  66. package/module/Tool/dayOfWeek.d.ts +2 -2
  67. package/module/Tool/dayOfWeek.js +2 -2
  68. package/module/Tool/index.d.ts +8 -3
  69. package/module/Tool/index.js +12 -31
  70. package/module/Tool/isBrowser.js +1 -1
  71. package/module/index.d.ts +14 -6
  72. package/module/index.js +25 -33
  73. package/module/tsconfig.tsbuildinfo +1 -1
  74. package/module/types/clockType.d.ts +9 -0
  75. package/module/types/dateType.d.ts +11 -0
  76. package/module/types/dateType.js +2 -0
  77. package/module/types/int.d.ts +4 -4
  78. package/module/types/logicType.d.ts +9 -8
  79. package/package.json +16 -8
  80. package/.markdownlint.json +0 -6
  81. package/.nvmrc +0 -1
  82. package/jest.config.js +0 -16
  83. package/make_test.py +0 -24
  84. package/module/Math/softmax.d.ts +0 -5
  85. package/module/Math/softmax.js +0 -40
  86. package/module/types/monType.d.ts +0 -8
  87. /package/module/types/{monType.js → clockType.js} +0 -0
@@ -7,15 +7,6 @@ exports.arraysJoin = void 0;
7
7
  * @param {any[]} ...arrays
8
8
  */
9
9
  const arraysJoin = (array, ...arrays) => {
10
- if (!array || !Array.isArray(array)) {
11
- throw new Error('Invalid array');
12
- }
13
- for (const i of arrays) {
14
- if (!i || !Array.isArray(i)) {
15
- throw new Error('Invalid array');
16
- }
17
- array.push(...i);
18
- }
19
- return [...new Set(array)];
10
+ return [...new Set(array.concat(...arrays))];
20
11
  };
21
12
  exports.arraysJoin = arraysJoin;
@@ -3,4 +3,4 @@
3
3
  * @param {any[]} array
4
4
  * @param {any[]} ...arrays
5
5
  */
6
- export declare const getArraysCommon: (array: any[], ...arrays: any[]) => any[];
6
+ export declare const getArraysCommon: (array: any[], ...arrays: any[]) => unknown[];
@@ -6,24 +6,11 @@ exports.getArraysCommon = void 0;
6
6
  * @param {any[]} array
7
7
  * @param {any[]} ...arrays
8
8
  */
9
+ // rome-ignore lint/suspicious/noExplicitAny: <explanation>
9
10
  const getArraysCommon = (array, ...arrays) => {
10
11
  const result = [array, ...arrays].reduce((prev, current) => {
11
12
  return prev.filter((item) => current.includes(item));
12
13
  });
13
14
  return result;
14
- // const result: any[] = [];
15
- // for (const i of array) {
16
- // let flag = true;
17
- // for (const j of arrays) {
18
- // if (!j.includes(i)) {
19
- // flag = false;
20
- // break;
21
- // }
22
- // }
23
- // if (flag) {
24
- // result.push(i);
25
- // }
26
- // }
27
- // return result;
28
15
  };
29
16
  exports.getArraysCommon = getArraysCommon;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * 共通しない要素をとりだす
3
- * @param {any[]} array
4
- * @param {any[]} ...arrays
3
+ * @param {unknown[]} array
4
+ * @param {unknown[]} ...arrays
5
5
  */
6
- export declare const getArraysDiff: (array: any[], ...arrays: any[]) => any[];
6
+ export declare const getArraysDiff: (array: unknown[], ...arrays: unknown[]) => unknown[];
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getArraysDiff = void 0;
4
4
  /**
5
5
  * 共通しない要素をとりだす
6
- * @param {any[]} array
7
- * @param {any[]} ...arrays
6
+ * @param {unknown[]} array
7
+ * @param {unknown[]} ...arrays
8
8
  */
9
9
  const getArraysDiff = (array, ...arrays) => {
10
10
  const result = array
@@ -5,11 +5,15 @@ import { quickSort } from './quickSort';
5
5
  import { sum } from './sum';
6
6
  export { arraysJoin, getArraysCommon, getArraysDiff, quickSort, sum };
7
7
  export declare class UMTArrayClass {
8
- #private;
8
+ private localArraysJoin;
9
+ private localGetArraysCommon;
10
+ private localGetArraysDiff;
11
+ private localQuickSort;
12
+ private locaLsum;
9
13
  constructor();
10
14
  get arraysJoin(): <A extends any[], B extends any[], C extends A & B>(array: A, ...arrays: B[]) => C;
11
- get getArraysCommon(): (array: any[], ...arrays: any[]) => any[];
12
- get getArraysDiff(): (array: any[], ...arrays: any[]) => any[];
15
+ get getArraysCommon(): (array: any[], ...arrays: any[]) => unknown[];
16
+ get getArraysDiff(): (array: unknown[], ...arrays: unknown[]) => unknown[];
13
17
  get quickSort(): <A extends any[]>(array: A, startID?: number, endID?: number) => A;
14
18
  get sum(): (x: number[]) => number;
15
19
  }
@@ -1,16 +1,4 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _UMTArrayClass_Local_arraysJoin, _UMTArrayClass_Local_getArraysCommon, _UMTArrayClass_Local_getArraysDiff, _UMTArrayClass_Local_quickSort, _UMTArrayClass_Local_sum;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.UMT_Array = exports.UMTArrayClass = exports.sum = exports.quickSort = exports.getArraysDiff = exports.getArraysCommon = exports.arraysJoin = void 0;
16
4
  const arraysJoin_1 = require("./arraysJoin");
@@ -25,33 +13,27 @@ const sum_1 = require("./sum");
25
13
  Object.defineProperty(exports, "sum", { enumerable: true, get: function () { return sum_1.sum; } });
26
14
  class UMTArrayClass {
27
15
  constructor() {
28
- _UMTArrayClass_Local_arraysJoin.set(this, void 0);
29
- _UMTArrayClass_Local_getArraysCommon.set(this, void 0);
30
- _UMTArrayClass_Local_getArraysDiff.set(this, void 0);
31
- _UMTArrayClass_Local_quickSort.set(this, void 0);
32
- _UMTArrayClass_Local_sum.set(this, void 0);
33
- __classPrivateFieldSet(this, _UMTArrayClass_Local_arraysJoin, arraysJoin_1.arraysJoin, "f");
34
- __classPrivateFieldSet(this, _UMTArrayClass_Local_getArraysCommon, getArraysCommon_1.getArraysCommon, "f");
35
- __classPrivateFieldSet(this, _UMTArrayClass_Local_getArraysDiff, getArraysDiff_1.getArraysDiff, "f");
36
- __classPrivateFieldSet(this, _UMTArrayClass_Local_quickSort, quickSort_1.quickSort, "f");
37
- __classPrivateFieldSet(this, _UMTArrayClass_Local_sum, sum_1.sum, "f");
16
+ this.localArraysJoin = arraysJoin_1.arraysJoin;
17
+ this.localGetArraysCommon = getArraysCommon_1.getArraysCommon;
18
+ this.localGetArraysDiff = getArraysDiff_1.getArraysDiff;
19
+ this.localQuickSort = quickSort_1.quickSort;
20
+ this.locaLsum = sum_1.sum;
38
21
  }
39
22
  get arraysJoin() {
40
- return __classPrivateFieldGet(this, _UMTArrayClass_Local_arraysJoin, "f");
23
+ return this.localArraysJoin;
41
24
  }
42
25
  get getArraysCommon() {
43
- return __classPrivateFieldGet(this, _UMTArrayClass_Local_getArraysCommon, "f");
26
+ return this.localGetArraysCommon;
44
27
  }
45
28
  get getArraysDiff() {
46
- return __classPrivateFieldGet(this, _UMTArrayClass_Local_getArraysDiff, "f");
29
+ return this.localGetArraysDiff;
47
30
  }
48
31
  get quickSort() {
49
- return __classPrivateFieldGet(this, _UMTArrayClass_Local_quickSort, "f");
32
+ return this.localQuickSort;
50
33
  }
51
34
  get sum() {
52
- return __classPrivateFieldGet(this, _UMTArrayClass_Local_sum, "f");
35
+ return this.locaLsum;
53
36
  }
54
37
  }
55
38
  exports.UMTArrayClass = UMTArrayClass;
56
- _UMTArrayClass_Local_arraysJoin = new WeakMap(), _UMTArrayClass_Local_getArraysCommon = new WeakMap(), _UMTArrayClass_Local_getArraysDiff = new WeakMap(), _UMTArrayClass_Local_quickSort = new WeakMap(), _UMTArrayClass_Local_sum = new WeakMap();
57
39
  exports.UMT_Array = new UMTArrayClass();
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.quickSort = void 0;
4
+ const random_1 = require("../Math/random");
4
5
  /**
5
6
  * 配列を高速にソート
6
7
  * @param {any[]} array
7
8
  * @param {number} startID
8
9
  * @param {number} endID
9
10
  */
11
+ // rome-ignore lint/suspicious/noExplicitAny: <explanation>
10
12
  const quickSort = (array, startID = 0, endID = array.length - 1) => {
11
- const pivot = array[Math.floor((startID + endID) / 2)];
13
+ const pivot = array[(0, random_1.random)(endID, startID)];
12
14
  let left = startID;
13
15
  let right = endID;
14
16
  while (true) {
@@ -1,8 +1,13 @@
1
- import { now } from './now';
2
- export { now };
1
+ import { newDateInt, newDateStr } from "./new";
2
+ import { now } from "./now";
3
+ export { now, newDateInt, newDateStr };
3
4
  export declare class UMTDateClass {
4
- #private;
5
+ private localNow;
6
+ private localNewDateInt;
7
+ private localNewDateStr;
5
8
  constructor();
6
9
  get now(): (timeDifference?: number) => Date;
10
+ get newDateInt(): <T extends import("../types/dateType").monTypeInt>(yer: number, mon: T, day: import("../types/dateType").dayTypeInt<T>, hours?: import("../types/clockType").hoursTypeInt, minutes?: import("../types/clockType").minutesTypeInt, seconds?: import("../types/clockType").minutesTypeInt, milliseconds?: import("../types/clockType").millisecondsTypeInt) => Date;
11
+ get newDateStr(): <T extends import("../types/dateType").monTypeZero>(date: `${number}-${T}-${import("../types/dateType").dayType<T extends import("../types/dateType").monTypeZero ? T : never>}`, timeDifference?: import("../types/clockType").hoursType) => Date;
7
12
  }
8
13
  export declare const UMT_Date: UMTDateClass;
@@ -1,29 +1,26 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _UMTDateClass_Local_now;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.UMT_Date = exports.UMTDateClass = exports.now = void 0;
3
+ exports.UMT_Date = exports.UMTDateClass = exports.newDateStr = exports.newDateInt = exports.now = void 0;
4
+ const new_1 = require("./new");
5
+ Object.defineProperty(exports, "newDateInt", { enumerable: true, get: function () { return new_1.newDateInt; } });
6
+ Object.defineProperty(exports, "newDateStr", { enumerable: true, get: function () { return new_1.newDateStr; } });
16
7
  const now_1 = require("./now");
17
8
  Object.defineProperty(exports, "now", { enumerable: true, get: function () { return now_1.now; } });
18
9
  class UMTDateClass {
19
10
  constructor() {
20
- _UMTDateClass_Local_now.set(this, void 0);
21
- __classPrivateFieldSet(this, _UMTDateClass_Local_now, now_1.now, "f");
11
+ this.localNow = now_1.now;
12
+ this.localNewDateInt = new_1.newDateInt;
13
+ this.localNewDateStr = new_1.newDateStr;
22
14
  }
23
15
  get now() {
24
- return __classPrivateFieldGet(this, _UMTDateClass_Local_now, "f");
16
+ return this.localNow;
17
+ }
18
+ get newDateInt() {
19
+ return this.localNewDateInt;
20
+ }
21
+ get newDateStr() {
22
+ return this.localNewDateStr;
25
23
  }
26
24
  }
27
25
  exports.UMTDateClass = UMTDateClass;
28
- _UMTDateClass_Local_now = new WeakMap();
29
26
  exports.UMT_Date = new UMTDateClass();
@@ -0,0 +1,4 @@
1
+ import { dayType, dayTypeInt, monTypeInt, monTypeZero } from "../types/dateType";
2
+ import { hoursType, hoursTypeInt, millisecondsTypeInt, minutesTypeInt, secondsTypeInt } from "../types/clockType";
3
+ export declare const newDateInt: <T extends monTypeInt>(yer: number, mon: T, day: dayTypeInt<T>, hours?: hoursTypeInt, minutes?: minutesTypeInt, seconds?: secondsTypeInt, milliseconds?: millisecondsTypeInt) => Date;
4
+ export declare const newDateStr: <T extends monTypeZero>(date: `${number}-${T}-${dayType<T extends monTypeZero ? T : never>}`, timeDifference?: hoursType) => Date;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newDateStr = exports.newDateInt = void 0;
4
+ const newDateInt = (yer, mon, day, hours = 0, minutes = 0, seconds = 0, milliseconds = 0) => {
5
+ const date = new Date(yer, mon - 1, day + 1, hours, minutes, seconds, milliseconds);
6
+ return date;
7
+ };
8
+ exports.newDateInt = newDateInt;
9
+ const newDateStr = (date, timeDifference = "00") => {
10
+ return new Date(`${date}T00:00:00+${timeDifference}:00`);
11
+ };
12
+ exports.newDateStr = newDateStr;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @param {number} [timeDifference=9] 時差(時)
2
+ * @param {number} [timeDifference=0] 時差(時)
3
3
  * @returns {Date} 現在時刻
4
4
  */
5
5
  export declare const now: (timeDifference?: number) => Date;
@@ -2,11 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.now = void 0;
4
4
  /**
5
- * @param {number} [timeDifference=9] 時差(時)
5
+ * @param {number} [timeDifference=0] 時差(時)
6
6
  * @returns {Date} 現在時刻
7
7
  */
8
- const now = (timeDifference = 9) => new Date(Date.now() +
9
- (new Date().getTimezoneOffset() + timeDifference * 60) *
10
- 60 *
11
- 1000);
8
+ const now = (timeDifference = 9) => {
9
+ const n = timeDifference * 2;
10
+ return new Date(Date.now() +
11
+ (new Date().getTimezoneOffset() +
12
+ (new Date().getTimezoneOffset() === 0 ? timeDifference : n) * 60) *
13
+ 60 *
14
+ 1000);
15
+ };
12
16
  exports.now = now;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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");
4
+ const addition_1 = require("../../Math/addition");
5
+ const division_1 = require("../../Math/division");
6
+ const multiplication_1 = require("../../Math/multiplication");
7
+ const subtract_1 = require("../../Math/subtract");
8
8
  const exchange_1 = require("./exchange");
9
9
  /**
10
10
  * 電卓
@@ -13,79 +13,76 @@ const exchange_1 = require("./exchange");
13
13
  * @param {string} x 計算式
14
14
  */
15
15
  const calculatorCore = (x, ex) => {
16
+ let copyX = x;
16
17
  //符号反転
17
- x = x.replace(/--/g, '+');
18
- x = x.replace(/\+\+/g, '+');
19
- x = x.replace(/\+-/g, '+0-');
20
- x = x.replace(/\-\+/g, '+0-');
18
+ copyX = copyX.replace(/--/g, "+");
19
+ copyX = copyX.replace(/\+\+/g, "+");
20
+ copyX = copyX.replace(/\+-/g, "+0-");
21
+ copyX = copyX.replace(/\-\+/g, "+0-");
21
22
  //円計算
22
23
  while (true) {
23
24
  if (ex) {
24
25
  for (const i in ex) {
25
- if (x.indexOf(i) != -1) {
26
- const $ = x.match(new RegExp(`\\${i}` + '([0-9]+)'));
26
+ if (copyX.indexOf(i) !== -1) {
27
+ const $ = copyX.match(new RegExp(`\\${i}([0-9]+)`));
27
28
  if ($) {
28
- x = x.replace($[0], (0, exchange_1.exchange)($[0], ex));
29
+ copyX = copyX.replace($[0], (0, exchange_1.exchange)($[0], ex));
29
30
  }
30
31
  }
31
32
  }
32
33
  }
33
34
  //括弧の処理
34
- if (x.indexOf('(') != -1 || x.indexOf(')') != -1) {
35
+ if (copyX.indexOf("(") !== -1 || copyX.indexOf(")") !== -1) {
35
36
  //括弧の中身をぬく
36
- const y = x.match(/\(\d+\.?(\d+)?(\*|\/|\+|\-)\d+\.?(\d+)?\)/);
37
+ const y = copyX.match(/\(\d+\.?(\d+)?(\*|\/|\+|\-)\d+\.?(\d+)?\)/);
37
38
  if (y) {
38
39
  //括弧の中身を計算
39
- x = x.replace(y[0], (0, exports.calculatorCore)(y[0].replace(/\(|\)/g, '')));
40
+ copyX = copyX.replace(y[0], (0, exports.calculatorCore)(y[0].replace(/\(|\)/g, "")));
40
41
  }
41
42
  else {
42
- x = x.replace(`(${x.slice(x.indexOf('(') + 1, x.indexOf(')'))})`, (0, exports.calculatorCore)(x.slice(x.indexOf('(') + 1, x.indexOf(')'))));
43
+ copyX = copyX.replace(`(${copyX.slice(copyX.indexOf("(") + 1, copyX.indexOf(")"))})`, (0, exports.calculatorCore)(copyX.slice(copyX.indexOf("(") + 1, copyX.indexOf(")"))));
43
44
  }
44
45
  }
45
- else if (x.indexOf('^') != -1 ||
46
- x.indexOf('*') != -1 ||
47
- x.indexOf('/') != -1) {
46
+ else if (copyX.indexOf("^") !== -1 ||
47
+ copyX.indexOf("*") !== -1 ||
48
+ copyX.indexOf("/") !== -1) {
48
49
  //掛け算と割り算の処理
49
50
  const y = [
50
- x.match(/\d+\.?(\d+)?(\*|\/|\^)\d+\.?(\d+)?/),
51
- [''],
51
+ copyX.match(/\d+\.?(\d+)?(\*|\/|\^)\d+\.?(\d+)?/),
52
+ [""],
52
53
  ];
53
54
  if (y[0]) {
54
- y[1] = y[0][0]
55
- .split(/(\d+\.\d+)|(\d+)/g)
56
- .filter((n) => {
57
- return typeof n != 'undefined' && n != '';
55
+ y[1] = y[0][0].split(/(\d+\.\d+)|(\d+)/g).filter((n) => {
56
+ return typeof n !== "undefined" && n !== "";
58
57
  });
59
- x = x.replace(y[0][0], `${y[1][1] == '^'
58
+ copyX = copyX.replace(y[0][0], `${y[1][1] === "^"
60
59
  ? Math.pow(+y[1][0], +y[1][2])
61
- : y[1][1] == '*'
60
+ : y[1][1] === "*"
62
61
  ? (0, multiplication_1.multiplication)(+y[1][0], +y[1][2])
63
- : y[1][1] == '/'
62
+ : y[1][1] === "/"
64
63
  ? (0, division_1.division)(+y[1][0], +y[1][2])
65
- : '0'}`);
64
+ : "0"}`);
66
65
  }
67
66
  }
68
- else if (x.indexOf('+') != -1 || x.indexOf('-') != -1) {
67
+ else if (copyX.indexOf("+") !== -1 || copyX.indexOf("-") !== -1) {
69
68
  //加算と減算の処理
70
- let y = [
71
- x.match(/\d+\.?(\d+)?(\+|\-)\d+\.?(\d+)?/),
72
- [''],
69
+ const y = [
70
+ copyX.match(/\d+\.?(\d+)?(\+|\-)\d+\.?(\d+)?/),
71
+ [""],
73
72
  ];
74
73
  if (y[0]) {
75
- y[1] = y[0][0]
76
- .split(/(\d+\.\d+)|(\d+)/g)
77
- .filter((n) => {
78
- return typeof n != 'undefined' && n !== '';
74
+ y[1] = y[0][0].split(/(\d+\.\d+)|(\d+)/g).filter((n) => {
75
+ return typeof n !== "undefined" && n !== "";
79
76
  });
80
- x = x.replace(y[0][0], `${y[1][1] == '+'
77
+ copyX = copyX.replace(y[0][0], `${y[1][1] === "+"
81
78
  ? (0, addition_1.addition)(Number(y[1][0]), Number(y[1][2]))
82
- : y[1][1] == '-'
79
+ : y[1][1] === "-"
83
80
  ? (0, subtract_1.subtract)(Number(y[1][0]), Number(y[1][2]))
84
- : '0'}`);
81
+ : "0"}`);
85
82
  }
86
83
  }
87
84
  else {
88
- return x;
85
+ return copyX;
89
86
  }
90
87
  }
91
88
  };
@@ -8,9 +8,9 @@ const multiplication_1 = require("../multiplication");
8
8
  const exchange = (n, props) => {
9
9
  if (props) {
10
10
  for (const i in props) {
11
- if (n.indexOf(i) != -1) {
11
+ if (n.indexOf(i) !== -1) {
12
12
  if ((0, isNumber_1.isNumber)(props[i])) {
13
- let x = (0, multiplication_1.multiplication)(Number(n.slice(i.length)), Number(props[i]));
13
+ const x = (0, multiplication_1.multiplication)(Number(n.slice(i.length)), Number(props[i]));
14
14
  if (isNaN(x)) {
15
15
  return n;
16
16
  }
@@ -11,12 +11,13 @@ const literalExpression_1 = require("./literalExpression");
11
11
  * @param {object} exchange 為替
12
12
  */
13
13
  const calculator = (x, exchange) => {
14
- x = x.replace(/\s+/g, ''); // Remove spaces
15
- if (x.indexOf('=') != -1) {
16
- return (0, literalExpression_1.literalExpression)(x); // If the expression contains an equal sign, then it is a literal expression
14
+ let copyX = x;
15
+ copyX = copyX.replace(/\s+/g, ""); // Remove spaces
16
+ if (copyX.indexOf("=") !== -1) {
17
+ return (0, literalExpression_1.literalExpression)(copyX); // If the expression contains an equal sign, then it is a literal expression
17
18
  }
18
19
  else {
19
- return (0, core_1.calculatorCore)(x, exchange);
20
+ return (0, core_1.calculatorCore)(copyX, exchange);
20
21
  }
21
22
  };
22
23
  exports.calculator = calculator;
@@ -9,7 +9,7 @@ const core_1 = require("./core");
9
9
  * @param {string} x
10
10
  */
11
11
  const literalExpression = (x) => {
12
- let cache = [[], ''];
12
+ const cache = [[], ''];
13
13
  for (const i of x.split('=')) {
14
14
  if (/[a-zA-Z]+/.test(i) === false) {
15
15
  cache[1] = i;
@@ -17,7 +17,7 @@ const literalExpression = (x) => {
17
17
  else {
18
18
  cache[0] = i
19
19
  .split(/([0-9]+[a-zA-Z]+)|([^a-zA-Z]+)/)
20
- .filter((n) => n !== '' && typeof n != 'undefined');
20
+ .filter((n) => n !== '' && typeof n !== 'undefined');
21
21
  }
22
22
  }
23
23
  if (cache[0][1]) {
@@ -40,7 +40,7 @@ const literalExpression = (x) => {
40
40
  : (0, core_1.calculatorCore)(cache[1]);
41
41
  cache[0] = cache[0][0]
42
42
  .split(/([0-9]+)|([a-zA-Z]+)/)
43
- .filter((n) => n !== '' && typeof n != 'undefined');
43
+ .filter((n) => n !== '' && typeof n !== 'undefined');
44
44
  if (isNaN(Number(cache[0][0]))) {
45
45
  return cache[1];
46
46
  }
@@ -49,7 +49,7 @@ const literalExpression = (x) => {
49
49
  if (cacheGcd !== 1) {
50
50
  return `${(0, division_1.division)(Number(cache[1]), cacheGcd)}/${(0, division_1.division)(Number(cache[0][0]), cacheGcd)}`;
51
51
  }
52
- return cache[0][0] == '1'
52
+ return cache[0][0] === '1'
53
53
  ? `${cache[1]}/${cache[0][0]}`
54
54
  : cache[1];
55
55
  }
@@ -12,18 +12,22 @@ const valueSwap_1 = require("./valueSwap");
12
12
  */
13
13
  exports.division = ((x, y, isFloor = true) => {
14
14
  const [decimalLengthX, decimalLengthY] = (0, valueSwap_1.valueSwap)((0, getDecimalLength_1.getDecimalLength)(x), (0, getDecimalLength_1.getDecimalLength)(y));
15
- const n = decimalLengthX == decimalLengthY
15
+ let copyX = x;
16
+ let copyY = y;
17
+ const n = decimalLengthX === decimalLengthY
16
18
  ? 1
17
19
  : Math.pow(10, decimalLengthY - decimalLengthX);
18
- x = +(x + '').replace('.', '');
19
- y = +(y + '').replace('.', '');
20
+ copyX = +`${copyX}`.replace(".", "");
21
+ copyY = +`${copyY}`.replace(".", "");
20
22
  return isFloor
21
- ? x > y
22
- ? x / y / n
23
- : (x / y) * n
23
+ ? copyX > copyY
24
+ ? copyX / copyY / n
25
+ : (copyX / copyY) * n
24
26
  : [
25
- x > y ? (x - (x % y)) / y / n : ((x - (x % y)) / y) * n,
26
- x % y,
27
+ copyX > copyY
28
+ ? (copyX - (copyX % copyY)) / copyY / n
29
+ : ((copyX - (copyX % copyY)) / copyY) * n,
30
+ copyX % copyY,
27
31
  ];
28
- // return isFloor ? x / y : [(x - (x % y)) / y, x % y];
32
+ // return isFloor ? copyX / copyY : [(copyX - (copyX % copyY)) / copyY, copyX % copyY];
29
33
  });
@@ -8,10 +8,11 @@ exports.factorial = void 0;
8
8
  */
9
9
  const factorial = (x) => {
10
10
  let result = 1;
11
- if (x !== 0) {
12
- while (x > 1) {
13
- result *= x;
14
- x--;
11
+ let copyX = x;
12
+ if (copyX !== 0) {
13
+ while (copyX > 1) {
14
+ result *= copyX;
15
+ copyX--;
15
16
  }
16
17
  }
17
18
  return result;
@@ -8,10 +8,11 @@ exports.factorize = void 0;
8
8
  */
9
9
  const factorize = (n) => {
10
10
  const result = [];
11
- for (let i = 2; i <= n; i++) {
12
- while (n % i === 0) {
11
+ let copyN = n;
12
+ for (let i = 2; i <= copyN; i++) {
13
+ while (copyN % i === 0) {
13
14
  result.push(i);
14
- n /= i;
15
+ copyN /= i;
15
16
  }
16
17
  }
17
18
  return result;
@@ -10,21 +10,25 @@ const valueSwap_1 = require("./valueSwap");
10
10
  * @returns number
11
11
  */
12
12
  const gcd = (x, y, ...z) => {
13
- if (x === 0 || y === 0)
13
+ let copyX = x;
14
+ let copyY = y;
15
+ const copyZ = z;
16
+ if (copyX === 0 || copyY === 0) {
14
17
  return 0;
15
- [x, y] = (0, valueSwap_1.valueSwap)(x, y);
18
+ }
19
+ [copyX, copyY] = (0, valueSwap_1.valueSwap)(copyX, copyY);
16
20
  /* ユークリッドの互除法 */
17
- let r = y % x;
21
+ let r = copyY % copyX;
18
22
  while (r !== 0) {
19
- y = x;
20
- x = r;
21
- r = y % x;
23
+ copyY = copyX;
24
+ copyX = r;
25
+ r = copyY % copyX;
22
26
  }
23
- if (z.length > 0) {
24
- for (let i = 0; i < z.length; i++) {
25
- x = (0, exports.gcd)(x, z[i]);
27
+ if (copyZ.length > 0) {
28
+ for (let i = 0; i < copyZ.length; i++) {
29
+ copyX = (0, exports.gcd)(copyX, copyZ[i]);
26
30
  }
27
31
  }
28
- return x;
32
+ return copyX;
29
33
  };
30
34
  exports.gcd = gcd;
@@ -7,7 +7,7 @@ exports.getDecimalLength = void 0;
7
7
  * @returns number
8
8
  */
9
9
  const getDecimalLength = (value) => {
10
- let x = (value + '').split('.')[1];
10
+ const x = `${value}`.split('.')[1];
11
11
  if (typeof x !== 'undefined' && x.length > 0) {
12
12
  return x.length;
13
13
  }