umt 1.0.13 → 1.0.15

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 (40) hide show
  1. package/jest.config.js +16 -0
  2. package/make_test.py +24 -0
  3. package/module/Array/getArraysCommon.js +17 -13
  4. package/module/Array/getArraysDiff.js +5 -13
  5. package/module/Array/index.js +17 -17
  6. package/module/Date/index.js +5 -5
  7. package/module/Math/average.js +4 -2
  8. package/module/Math/calculator/calculatorInitialization.js +2 -2
  9. package/module/Math/calculator/exchange.js +8 -12
  10. package/module/Math/deviationValue.js +3 -1
  11. package/module/Math/index.d.ts +2 -4
  12. package/module/Math/index.js +116 -123
  13. package/module/Math/isDouble.d.ts +2 -3
  14. package/module/Math/isDouble.js +2 -3
  15. package/module/Math/lcm.js +3 -0
  16. package/module/Math/{roundOff.d.ts → roundOf.d.ts} +0 -0
  17. package/module/Math/{roundOff.js → roundOf.js} +0 -0
  18. package/module/Math/softmax.js +2 -2
  19. package/module/Math/toCelsius.d.ts +5 -0
  20. package/module/Math/toCelsius.js +5 -0
  21. package/module/Simple/Date/index.js +5 -5
  22. package/module/Simple/{Math/dayOfWeek.d.ts → Tool/dayOfWeekSimple.d.ts} +2 -2
  23. package/module/Simple/{Math/dayOfWeek.js → Tool/dayOfWeekSimple.js} +0 -0
  24. package/module/Simple/{Math/deviationValue.d.ts → Tool/deviationValueSimple.d.ts} +0 -0
  25. package/module/Simple/{Math/deviationValue.js → Tool/deviationValueSimple.js} +0 -0
  26. package/module/Simple/Tool/index.d.ts +6 -0
  27. package/module/Simple/Tool/index.js +17 -5
  28. package/module/Simple/index.d.ts +3 -5
  29. package/module/Simple/index.js +10 -16
  30. package/module/Tool/index.js +20 -20
  31. package/module/index.d.ts +1 -1
  32. package/module/index.js +17 -17
  33. package/module/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +39 -28
  35. package/module/Compiler/core.d.ts +0 -5
  36. package/module/Compiler/core.js +0 -19
  37. package/module/Compiler/token.d.ts +0 -10
  38. package/module/Compiler/token.js +0 -120
  39. package/module/Simple/Math/index.d.ts +0 -10
  40. package/module/Simple/Math/index.js +0 -33
package/jest.config.js ADDED
@@ -0,0 +1,16 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+ roots: ['<rootDir>/tests'],
6
+ collectCoverage: true,
7
+ collectCoverageFrom: [
8
+ '<rootDir>/module/**/*.{js,ts}',
9
+ '<rootDir>/src/**/*.{js,ts}',
10
+ '!**/node_modules/**',
11
+ '!**/{index,random}.{js,ts}',
12
+ '!**/Date/**',
13
+ ],
14
+ coverageDirectory: 'coverage_dir',
15
+ coverageReporters: ['text'],
16
+ };
package/make_test.py ADDED
@@ -0,0 +1,24 @@
1
+ import os
2
+ import pathlib
3
+ paths = ["Array", "Math", "Simple"]
4
+ for path in paths:
5
+ path = f"src/{path}"
6
+ files = os.listdir(path)
7
+ files_file = [f for f in files if os.path.isfile(os.path.join(path, f))]
8
+ for file in files_file:
9
+ if(file == "index.ts" or file == ".DS_Store" or file in "random"):
10
+ continue
11
+ path = pathlib.Path(path)
12
+ p_dir = path.name
13
+ p_dir = f"tests/{p_dir}/"
14
+ file = pathlib.Path(file).stem
15
+ if not os.path.exists(p_dir):
16
+ os.makedirs(p_dir)
17
+ if os.path.isfile(p_dir + file + ".test.ts"):
18
+ continue
19
+ pathlib.Path(p_dir + file + ".test.ts").touch()
20
+ with open(p_dir + file + ".test.ts", "w") as f:
21
+ f.write(
22
+ """import { %s } from "../../module/%s/%s";
23
+ test('{%s}', () => {});
24
+ """ % (file, path.name, file, file))
@@ -7,19 +7,23 @@ exports.getArraysCommon = void 0;
7
7
  * @param {any[]} ...arrays
8
8
  */
9
9
  const getArraysCommon = (array, ...arrays) => {
10
- const result = [];
11
- for (const i of array) {
12
- let flag = true;
13
- for (const j of arrays) {
14
- if (!j.includes(i)) {
15
- flag = false;
16
- break;
17
- }
18
- }
19
- if (flag) {
20
- result.push(i);
21
- }
22
- }
10
+ const result = [array, ...arrays].reduce((prev, current) => {
11
+ return prev.filter((item) => current.includes(item));
12
+ });
23
13
  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;
24
28
  };
25
29
  exports.getArraysCommon = getArraysCommon;
@@ -7,19 +7,11 @@ exports.getArraysDiff = void 0;
7
7
  * @param {any[]} ...arrays
8
8
  */
9
9
  const getArraysDiff = (array, ...arrays) => {
10
- const result = [];
11
- for (const i of array) {
12
- let flag = true;
13
- for (const j of arrays) {
14
- if (j.includes(i)) {
15
- flag = false;
16
- break;
17
- }
18
- }
19
- if (flag) {
20
- result.push(i);
21
- }
22
- }
10
+ const result = array
11
+ .concat(...arrays)
12
+ .filter((val, _index, arr) => {
13
+ return arr.indexOf(val) === arr.lastIndexOf(val);
14
+ });
23
15
  return result;
24
16
  };
25
17
  exports.getArraysDiff = getArraysDiff;
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
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
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _UMTArrayClass_LocalarraysJoin, _UMTArrayClass_LocalgetArraysCommon, _UMTArrayClass_LocalgetArraysDiff, _UMTArrayClass_LocalquickSort, _UMTArrayClass_Localsum;
13
+ var _UMTArrayClass_Local_arraysJoin, _UMTArrayClass_Local_getArraysCommon, _UMTArrayClass_Local_getArraysDiff, _UMTArrayClass_Local_quickSort, _UMTArrayClass_Local_sum;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.UMT_Array = exports.UMTArrayClass = exports.sum = exports.quickSort = exports.getArraysDiff = exports.getArraysCommon = exports.arraysJoin = void 0;
16
16
  const arraysJoin_1 = require("./arraysJoin");
@@ -25,33 +25,33 @@ const sum_1 = require("./sum");
25
25
  Object.defineProperty(exports, "sum", { enumerable: true, get: function () { return sum_1.sum; } });
26
26
  class UMTArrayClass {
27
27
  constructor() {
28
- _UMTArrayClass_LocalarraysJoin.set(this, void 0);
29
- _UMTArrayClass_LocalgetArraysCommon.set(this, void 0);
30
- _UMTArrayClass_LocalgetArraysDiff.set(this, void 0);
31
- _UMTArrayClass_LocalquickSort.set(this, void 0);
32
- _UMTArrayClass_Localsum.set(this, void 0);
33
- __classPrivateFieldSet(this, _UMTArrayClass_LocalarraysJoin, arraysJoin_1.arraysJoin, "f");
34
- __classPrivateFieldSet(this, _UMTArrayClass_LocalgetArraysCommon, getArraysCommon_1.getArraysCommon, "f");
35
- __classPrivateFieldSet(this, _UMTArrayClass_LocalgetArraysDiff, getArraysDiff_1.getArraysDiff, "f");
36
- __classPrivateFieldSet(this, _UMTArrayClass_LocalquickSort, quickSort_1.quickSort, "f");
37
- __classPrivateFieldSet(this, _UMTArrayClass_Localsum, sum_1.sum, "f");
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");
38
38
  }
39
39
  get arraysJoin() {
40
- return __classPrivateFieldGet(this, _UMTArrayClass_LocalarraysJoin, "f");
40
+ return __classPrivateFieldGet(this, _UMTArrayClass_Local_arraysJoin, "f");
41
41
  }
42
42
  get getArraysCommon() {
43
- return __classPrivateFieldGet(this, _UMTArrayClass_LocalgetArraysCommon, "f");
43
+ return __classPrivateFieldGet(this, _UMTArrayClass_Local_getArraysCommon, "f");
44
44
  }
45
45
  get getArraysDiff() {
46
- return __classPrivateFieldGet(this, _UMTArrayClass_LocalgetArraysDiff, "f");
46
+ return __classPrivateFieldGet(this, _UMTArrayClass_Local_getArraysDiff, "f");
47
47
  }
48
48
  get quickSort() {
49
- return __classPrivateFieldGet(this, _UMTArrayClass_LocalquickSort, "f");
49
+ return __classPrivateFieldGet(this, _UMTArrayClass_Local_quickSort, "f");
50
50
  }
51
51
  get sum() {
52
- return __classPrivateFieldGet(this, _UMTArrayClass_Localsum, "f");
52
+ return __classPrivateFieldGet(this, _UMTArrayClass_Local_sum, "f");
53
53
  }
54
54
  }
55
55
  exports.UMTArrayClass = UMTArrayClass;
56
- _UMTArrayClass_LocalarraysJoin = new WeakMap(), _UMTArrayClass_LocalgetArraysCommon = new WeakMap(), _UMTArrayClass_LocalgetArraysDiff = new WeakMap(), _UMTArrayClass_LocalquickSort = new WeakMap(), _UMTArrayClass_Localsum = new WeakMap();
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
57
  exports.UMT_Array = new UMTArrayClass();
@@ -10,20 +10,20 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
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
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _UMTDateClass_Localnow;
13
+ var _UMTDateClass_Local_now;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.UMT_Date = exports.UMTDateClass = exports.now = void 0;
16
16
  const now_1 = require("./now");
17
17
  Object.defineProperty(exports, "now", { enumerable: true, get: function () { return now_1.now; } });
18
18
  class UMTDateClass {
19
19
  constructor() {
20
- _UMTDateClass_Localnow.set(this, void 0);
21
- __classPrivateFieldSet(this, _UMTDateClass_Localnow, now_1.now, "f");
20
+ _UMTDateClass_Local_now.set(this, void 0);
21
+ __classPrivateFieldSet(this, _UMTDateClass_Local_now, now_1.now, "f");
22
22
  }
23
23
  get now() {
24
- return __classPrivateFieldGet(this, _UMTDateClass_Localnow, "f");
24
+ return __classPrivateFieldGet(this, _UMTDateClass_Local_now, "f");
25
25
  }
26
26
  }
27
27
  exports.UMTDateClass = UMTDateClass;
28
- _UMTDateClass_Localnow = new WeakMap();
28
+ _UMTDateClass_Local_now = new WeakMap();
29
29
  exports.UMT_Date = new UMTDateClass();
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.average = void 0;
4
+ const addition_1 = require("./addition");
5
+ const division_1 = require("./division");
4
6
  /**
5
7
  * 平均値
6
8
  * @param {number[]} numbers
7
9
  * @returns number
8
10
  */
9
11
  const average = (numbers) => {
10
- const sum = numbers.reduce((a, b) => a + b, 0);
11
- const avg = sum / numbers.length;
12
+ const sum = numbers.reduce((a, b) => (0, addition_1.addition)(a, b), 0);
13
+ const avg = (0, division_1.division)(sum, numbers.length);
12
14
  return avg;
13
15
  };
14
16
  exports.average = average;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.calculatorInitialization = void 0;
4
- const core_1 = require("./core");
4
+ const _1 = require(".");
5
5
  /**
6
6
  * Initializes the calculator.
7
7
  * @param {object} exchange - current exchange rate
@@ -12,6 +12,6 @@ const calculatorInitialization = (exchange) => {
12
12
  * @param {string} x - amount of money
13
13
  * @return {string} - converted amount of money
14
14
  */
15
- return (x) => (0, core_1.calculatorCore)(x, exchange);
15
+ return (x) => (0, _1.calculator)(x, exchange);
16
16
  };
17
17
  exports.calculatorInitialization = calculatorInitialization;
@@ -6,30 +6,26 @@ const multiplication_1 = require("../multiplication");
6
6
  // The function accepts two parameters, the first is n, a string, and the second is props, an object.
7
7
  // props is an optional parameter.
8
8
  const exchange = (n, props) => {
9
- // If the props parameter exists, then the following code will be executed.
10
9
  if (props) {
11
- // Loop through the object props.
12
10
  for (const i in props) {
13
- // If the first character of the string n is equal to the key of the current object item,
14
- // then the following code will be executed.
15
- if (n[0] == i) {
16
- // If the value of the current object item is a number, then the following code will be executed.
11
+ if (n.indexOf(i) != -1) {
17
12
  if ((0, isNumber_1.isNumber)(props[i])) {
18
- // Return the result of the multiplication of the number n after the first character and the value of the current object item.
19
- return String((0, multiplication_1.multiplication)(Number(n.slice(1)), Number(props[i])));
13
+ let x = (0, multiplication_1.multiplication)(Number(n.slice(i.length)), Number(props[i]));
14
+ if (isNaN(x)) {
15
+ return n;
16
+ }
17
+ else {
18
+ return String((0, multiplication_1.multiplication)(Number(n.slice(i.length)), Number(props[i])));
19
+ }
20
20
  }
21
21
  }
22
22
  else {
23
- // If the first character of the string n is not equal to the key of the current object item,
24
- // then return the original string n.
25
23
  return n;
26
24
  }
27
25
  }
28
- // If the string n does not have a corresponding key in the object props, then return the original string n.
29
26
  return n;
30
27
  }
31
28
  else {
32
- // If the props parameter does not exist, then return the original string n.
33
29
  return n;
34
30
  }
35
31
  };
@@ -8,7 +8,9 @@ exports.deviationValue = void 0;
8
8
  * @param {number} standardDeviationValue
9
9
  * @returns number
10
10
  */
11
- const deviationValue = (value, averageValue, standardDeviationValue) => {
11
+ const deviationValue = (value, // current sensor value
12
+ averageValue, // average value of all sensor values
13
+ standardDeviationValue) => {
12
14
  return (((value - averageValue) / standardDeviationValue) * 10 + 50);
13
15
  };
14
16
  exports.deviationValue = deviationValue;
@@ -28,15 +28,14 @@ import { radToDeg } from './radToDeg';
28
28
  import { random } from './random';
29
29
  import { reduce } from './reduce';
30
30
  import { repeatedTrial } from './repeatedTrial';
31
- import { roundOf } from './roundOff';
32
- import { softmax } from './softmax';
31
+ import { roundOf } from './roundOf';
33
32
  import { standardDeviation } from './standardDeviation';
34
33
  import { subtract } from './subtract';
35
34
  import { toBinary } from './toBinary';
36
35
  import { toCelsius } from './toCelsius';
37
36
  import { toKelvin } from './toKelvin';
38
37
  import { valueSwap } from './valueSwap';
39
- export { addition, average, calculator, calculatorInitialization, degToRad, deviationValue, division, factorial, factorize, gcd, getDecimalLength, isDouble, isNumber, isPrimeNumber, lcm, mathConverter, mathSeparator, max, min, multiples, multiplication, nCr, nHr, nPr, primeFactorization, quotient, radToDeg, random, reduce, repeatedTrial, roundOf, softmax, standardDeviation, subtract, toBinary, toCelsius, toKelvin, valueSwap, };
38
+ export { addition, average, calculator, calculatorInitialization, degToRad, deviationValue, division, factorial, factorize, gcd, getDecimalLength, isDouble, isNumber, isPrimeNumber, lcm, mathConverter, mathSeparator, max, min, multiples, multiplication, nCr, nHr, nPr, primeFactorization, quotient, radToDeg, random, reduce, repeatedTrial, roundOf, standardDeviation, subtract, toBinary, toCelsius, toKelvin, valueSwap, };
40
39
  export declare class UMTMathClass {
41
40
  #private;
42
41
  constructor();
@@ -85,7 +84,6 @@ export declare class UMTMathClass {
85
84
  y: number;
86
85
  }) => number[];
87
86
  get roundOf(): (num: number, precision: number) => number;
88
- get softmax(): (x: number[]) => number[];
89
87
  get standardDeviation(): (values: number[]) => number;
90
88
  get subtract(): (x: number, y: number) => number;
91
89
  get toBinary(): import("./toBinary").TOBINARY;