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.
- package/.markdownlint.json +4 -1
- package/README.md +11 -4
- package/module/Array/arraysJoin.d.ts +1 -2
- package/module/Array/arraysJoin.js +2 -1
- package/module/Array/getArraysCommon.d.ts +6 -0
- package/module/Array/getArraysCommon.js +25 -0
- package/module/Array/getArraysDiff.d.ts +1 -2
- package/module/Array/getArraysDiff.js +15 -7
- package/module/Array/index.d.ts +16 -5
- package/module/Array/index.js +54 -11
- package/module/Array/quickSort.d.ts +1 -2
- package/module/Array/quickSort.js +4 -3
- package/module/Array/sum.d.ts +1 -0
- package/module/Array/sum.js +8 -0
- package/module/Compiler/core.d.ts +5 -0
- package/module/Compiler/core.js +19 -0
- package/module/Compiler/token.d.ts +10 -0
- package/module/Compiler/token.js +120 -0
- package/module/Date/index.d.ts +7 -1
- package/module/Date/index.js +26 -5
- package/module/Date/now.d.ts +5 -2
- package/module/Date/now.js +10 -3
- package/module/Math/addition.d.ts +2 -2
- package/module/Math/addition.js +8 -9
- package/module/Math/average.d.ts +2 -2
- package/module/Math/average.js +3 -1
- package/module/Math/calculator/core.d.ts +1 -5
- package/module/Math/calculator/core.js +76 -55
- package/module/Math/calculator/exchange.d.ts +1 -5
- package/module/Math/calculator/exchange.js +16 -12
- package/module/Math/calculator/index.d.ts +2 -5
- package/module/Math/calculator/index.js +13 -8
- package/module/Math/calculator/literalExpression.d.ts +2 -2
- package/module/Math/calculator/literalExpression.js +20 -13
- package/module/Math/degToRad.d.ts +2 -2
- package/module/Math/degToRad.js +3 -1
- package/module/Math/deviationValue.d.ts +8 -0
- package/module/Math/deviationValue.js +14 -0
- package/module/Math/division.d.ts +7 -2
- package/module/Math/division.js +20 -9
- package/module/Math/factorial.d.ts +2 -2
- package/module/Math/factorial.js +10 -4
- package/module/Math/factorize.d.ts +2 -2
- package/module/Math/factorize.js +3 -1
- package/module/Math/gcd.d.ts +2 -2
- package/module/Math/gcd.js +6 -7
- package/module/Math/getDecimalLength.d.ts +2 -2
- package/module/Math/getDecimalLength.js +3 -1
- package/module/Math/index.d.ts +94 -33
- package/module/Math/index.js +278 -67
- package/module/Math/isDouble.d.ts +3 -2
- package/module/Math/isDouble.js +4 -1
- package/module/Math/isNumber.d.ts +3 -3
- package/module/Math/isNumber.js +4 -2
- package/module/Math/isPrimeNumber.d.ts +2 -2
- package/module/Math/isPrimeNumber.js +5 -6
- package/module/Math/lcm.d.ts +2 -2
- package/module/Math/lcm.js +7 -8
- package/module/Math/mathConverter.d.ts +5 -0
- package/module/Math/mathConverter.js +48 -0
- package/module/Math/mathSeparator.d.ts +5 -0
- package/module/Math/mathSeparator.js +21 -0
- package/module/Math/max.d.ts +1 -2
- package/module/Math/max.js +3 -2
- package/module/Math/min.d.ts +1 -2
- package/module/Math/min.js +3 -2
- package/module/Math/multiples.d.ts +1 -2
- package/module/Math/multiples.js +2 -1
- package/module/Math/multiplication.d.ts +1 -2
- package/module/Math/multiplication.js +4 -6
- package/module/Math/nCr.d.ts +1 -2
- package/module/Math/nCr.js +4 -6
- package/module/Math/nHr.d.ts +1 -2
- package/module/Math/nHr.js +4 -6
- package/module/Math/nPr.d.ts +1 -2
- package/module/Math/nPr.js +2 -1
- package/module/Math/primeFactorization.d.ts +1 -2
- package/module/Math/primeFactorization.js +2 -1
- package/module/Math/quotient.d.ts +1 -2
- package/module/Math/quotient.js +2 -1
- package/module/Math/radToDeg.d.ts +1 -2
- package/module/Math/radToDeg.js +2 -1
- package/module/Math/random.d.ts +3 -2
- package/module/Math/random.js +5 -2
- package/module/Math/reduce.d.ts +1 -2
- package/module/Math/reduce.js +5 -7
- package/module/Math/repeatedTrial.d.ts +2 -2
- package/module/Math/repeatedTrial.js +7 -8
- package/module/Math/roundOff.d.ts +7 -0
- package/module/Math/roundOff.js +14 -0
- package/module/Math/softmax.d.ts +5 -0
- package/module/Math/softmax.js +40 -0
- package/module/Math/standardDeviation.d.ts +1 -2
- package/module/Math/standardDeviation.js +5 -7
- package/module/Math/subtract.d.ts +1 -2
- package/module/Math/subtract.js +9 -9
- package/module/Math/toBinary.d.ts +5 -2
- package/module/Math/toBinary.js +4 -4
- package/module/Math/toCelsius.d.ts +1 -2
- package/module/Math/toCelsius.js +4 -6
- package/module/Math/toKelvin.d.ts +1 -2
- package/module/Math/toKelvin.js +4 -6
- package/module/Math/valueSwap.d.ts +2 -2
- package/module/Math/valueSwap.js +3 -1
- package/module/Simple/Date/index.d.ts +5 -0
- package/module/Simple/Date/index.js +27 -0
- package/module/Simple/Date/now.d.ts +1 -0
- package/module/Simple/Date/now.js +17 -0
- package/module/Simple/Math/dayOfWeek.d.ts +6 -0
- package/module/Simple/Math/dayOfWeek.js +31 -0
- package/module/Simple/Math/deviationValue.d.ts +5 -0
- package/module/Simple/Math/deviationValue.js +14 -0
- package/module/Simple/Math/index.d.ts +10 -0
- package/module/Simple/Math/index.js +33 -0
- package/module/Simple/Tool/birthday.d.ts +9 -0
- package/module/Simple/Tool/birthday.js +26 -0
- package/module/Simple/Tool/index.d.ts +5 -0
- package/module/Simple/Tool/index.js +27 -0
- package/module/Simple/index.d.ts +11 -0
- package/module/Simple/index.js +40 -0
- package/module/Tool/birthday.d.ts +8 -2
- package/module/Tool/birthday.js +15 -10
- package/module/Tool/dayOfWeek.d.ts +5 -6
- package/module/Tool/dayOfWeek.js +12 -2
- package/module/Tool/index.d.ts +18 -3
- package/module/Tool/index.js +58 -9
- package/module/Tool/isBrowser.d.ts +1 -0
- package/module/Tool/isBrowser.js +4 -0
- package/module/Tool/isNode.d.ts +1 -0
- package/module/Tool/isNode.js +4 -0
- package/module/Tool/isNodeWebkit.d.ts +1 -0
- package/module/Tool/isNodeWebkit.js +6 -0
- package/module/Tool/pipeFunction.d.ts +1 -2
- package/module/Tool/pipeFunction.js +3 -2
- package/module/index.d.ts +10 -11
- package/module/index.js +49 -33
- package/module/tsconfig.tsbuildinfo +1 -1
- package/module/types/int.d.ts +4 -0
- package/module/{Math/value.js → types/int.js} +0 -2
- package/module/types/logicType.d.ts +8 -0
- package/module/types/logicType.js +2 -0
- package/module/types/monType.d.ts +4 -0
- package/module/types/monType.js +2 -0
- package/package.json +18 -18
- package/.env +0 -1
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/node.js.yml +0 -30
- package/module/Array/getArraysIntersect.d.ts +0 -7
- package/module/Array/getArraysIntersect.js +0 -15
- package/module/Math/euclideanAlgorithm.d.ts +0 -8
- package/module/Math/euclideanAlgorithm.js +0 -31
- package/module/Math/value.d.ts +0 -2
- package/sider.yml +0 -60
- package/test.js +0 -5
package/.markdownlint.json
CHANGED
package/README.md
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
# UMT
|
|
1
|
+
# UMT Main Package
|
|
2
2
|
|
|
3
3
|
個人的に作った便利関数集
|
|
4
|
-
|
|
5
4
|
個人用途なので破壊的変更がある可能性があります。
|
|
5
|
+
Main Packageに依存関係はありません。
|
|
6
|
+
JavaScriptからの呼び出しに対応しています。
|
|
7
|
+
|
|
8
|
+
## Doc
|
|
9
|
+
|
|
10
|
+
- [Doc](./doc/index.md)
|
|
6
11
|
|
|
7
|
-
##
|
|
12
|
+
## Install
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
```bash
|
|
15
|
+
yarn add umt
|
|
16
|
+
```
|
|
@@ -3,5 +3,4 @@
|
|
|
3
3
|
* @param {any[]} array
|
|
4
4
|
* @param {any[]} ...arrays
|
|
5
5
|
*/
|
|
6
|
-
declare const arraysJoin: <A extends any[], B extends any[], C extends A
|
|
7
|
-
export default arraysJoin;
|
|
6
|
+
export declare const arraysJoin: <A extends any[], B extends any[], C extends A & B>(array: A, ...arrays: B[]) => C;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arraysJoin = void 0;
|
|
3
4
|
/**
|
|
4
5
|
* 重複をしないで結合
|
|
5
6
|
* @param {any[]} array
|
|
@@ -11,4 +12,4 @@ const arraysJoin = (array, ...arrays) => {
|
|
|
11
12
|
}
|
|
12
13
|
return [...new Set(array)];
|
|
13
14
|
};
|
|
14
|
-
exports.
|
|
15
|
+
exports.arraysJoin = arraysJoin;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getArraysCommon = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 共通の要素をとりだす
|
|
6
|
+
* @param {any[]} array
|
|
7
|
+
* @param {any[]} ...arrays
|
|
8
|
+
*/
|
|
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
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
exports.getArraysCommon = getArraysCommon;
|
|
@@ -3,5 +3,4 @@
|
|
|
3
3
|
* @param {any[]} array
|
|
4
4
|
* @param {any[]} ...arrays
|
|
5
5
|
*/
|
|
6
|
-
declare const getArraysDiff:
|
|
7
|
-
export default getArraysDiff;
|
|
6
|
+
export declare const getArraysDiff: (array: any[], ...arrays: any[]) => any[];
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getArraysDiff = void 0;
|
|
3
4
|
/**
|
|
4
5
|
* 共通しない要素をとりだす
|
|
5
6
|
* @param {any[]} array
|
|
6
7
|
* @param {any[]} ...arrays
|
|
7
8
|
*/
|
|
8
9
|
const getArraysDiff = (array, ...arrays) => {
|
|
9
|
-
|
|
10
|
-
for (const i of
|
|
11
|
-
|
|
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
|
+
}
|
|
12
22
|
}
|
|
13
|
-
|
|
14
|
-
const arr02 = [...new Set(hasArr)];
|
|
15
|
-
return [...arr01, ...arr02].filter((value) => !arr01.includes(value) || !arr02.includes(value));
|
|
23
|
+
return result;
|
|
16
24
|
};
|
|
17
|
-
exports.
|
|
25
|
+
exports.getArraysDiff = getArraysDiff;
|
package/module/Array/index.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import arraysJoin from './arraysJoin';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import quickSort from './quickSort';
|
|
5
|
-
|
|
1
|
+
import { arraysJoin } from './arraysJoin';
|
|
2
|
+
import { getArraysCommon } from './getArraysCommon';
|
|
3
|
+
import { getArraysDiff } from './getArraysDiff';
|
|
4
|
+
import { quickSort } from './quickSort';
|
|
5
|
+
import { sum } from './sum';
|
|
6
|
+
export { arraysJoin, getArraysCommon, getArraysDiff, quickSort, sum };
|
|
7
|
+
export declare class UMTArrayClass {
|
|
8
|
+
#private;
|
|
9
|
+
constructor();
|
|
10
|
+
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[];
|
|
13
|
+
get quickSort(): <A extends any[]>(array: A, startID?: number, endID?: number) => A;
|
|
14
|
+
get sum(): (x: number[]) => number;
|
|
15
|
+
}
|
|
16
|
+
export declare const UMT_Array: UMTArrayClass;
|
package/module/Array/index.js
CHANGED
|
@@ -1,14 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
4
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_LocalarraysJoin, _UMTArrayClass_LocalgetArraysCommon, _UMTArrayClass_LocalgetArraysDiff, _UMTArrayClass_LocalquickSort, _UMTArrayClass_Localsum;
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const arraysJoin_1 =
|
|
8
|
-
exports
|
|
9
|
-
const
|
|
10
|
-
exports
|
|
11
|
-
const
|
|
12
|
-
exports
|
|
13
|
-
const quickSort_1 =
|
|
14
|
-
exports
|
|
15
|
+
exports.UMT_Array = exports.UMTArrayClass = exports.sum = exports.quickSort = exports.getArraysDiff = exports.getArraysCommon = exports.arraysJoin = void 0;
|
|
16
|
+
const arraysJoin_1 = require("./arraysJoin");
|
|
17
|
+
Object.defineProperty(exports, "arraysJoin", { enumerable: true, get: function () { return arraysJoin_1.arraysJoin; } });
|
|
18
|
+
const getArraysCommon_1 = require("./getArraysCommon");
|
|
19
|
+
Object.defineProperty(exports, "getArraysCommon", { enumerable: true, get: function () { return getArraysCommon_1.getArraysCommon; } });
|
|
20
|
+
const getArraysDiff_1 = require("./getArraysDiff");
|
|
21
|
+
Object.defineProperty(exports, "getArraysDiff", { enumerable: true, get: function () { return getArraysDiff_1.getArraysDiff; } });
|
|
22
|
+
const quickSort_1 = require("./quickSort");
|
|
23
|
+
Object.defineProperty(exports, "quickSort", { enumerable: true, get: function () { return quickSort_1.quickSort; } });
|
|
24
|
+
const sum_1 = require("./sum");
|
|
25
|
+
Object.defineProperty(exports, "sum", { enumerable: true, get: function () { return sum_1.sum; } });
|
|
26
|
+
class UMTArrayClass {
|
|
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");
|
|
38
|
+
}
|
|
39
|
+
get arraysJoin() {
|
|
40
|
+
return __classPrivateFieldGet(this, _UMTArrayClass_LocalarraysJoin, "f");
|
|
41
|
+
}
|
|
42
|
+
get getArraysCommon() {
|
|
43
|
+
return __classPrivateFieldGet(this, _UMTArrayClass_LocalgetArraysCommon, "f");
|
|
44
|
+
}
|
|
45
|
+
get getArraysDiff() {
|
|
46
|
+
return __classPrivateFieldGet(this, _UMTArrayClass_LocalgetArraysDiff, "f");
|
|
47
|
+
}
|
|
48
|
+
get quickSort() {
|
|
49
|
+
return __classPrivateFieldGet(this, _UMTArrayClass_LocalquickSort, "f");
|
|
50
|
+
}
|
|
51
|
+
get sum() {
|
|
52
|
+
return __classPrivateFieldGet(this, _UMTArrayClass_Localsum, "f");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
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();
|
|
57
|
+
exports.UMT_Array = new UMTArrayClass();
|
|
@@ -4,5 +4,4 @@
|
|
|
4
4
|
* @param {number} startID
|
|
5
5
|
* @param {number} endID
|
|
6
6
|
*/
|
|
7
|
-
declare const quickSort: <A extends any[]>(array: A, startID?: number, endID?: number) => A;
|
|
8
|
-
export default quickSort;
|
|
7
|
+
export declare const quickSort: <A extends any[]>(array: A, startID?: number, endID?: number) => A;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.quickSort = void 0;
|
|
3
4
|
/**
|
|
4
5
|
* 配列を高速にソート
|
|
5
6
|
* @param {any[]} array
|
|
@@ -27,11 +28,11 @@ const quickSort = (array, startID = 0, endID = array.length - 1) => {
|
|
|
27
28
|
right--;
|
|
28
29
|
}
|
|
29
30
|
if (startID < left - 1) {
|
|
30
|
-
quickSort(array, startID, left - 1);
|
|
31
|
+
(0, exports.quickSort)(array, startID, left - 1);
|
|
31
32
|
}
|
|
32
33
|
if (right + 1 < endID) {
|
|
33
|
-
quickSort(array, right + 1, endID);
|
|
34
|
+
(0, exports.quickSort)(array, right + 1, endID);
|
|
34
35
|
}
|
|
35
36
|
return array;
|
|
36
37
|
};
|
|
37
|
-
exports.
|
|
38
|
+
exports.quickSort = quickSort;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sum: (x: number[]) => number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const compilerCore: (code: string, tokenList: [string, RegExp, number | null][], UncategorizedTokenList: [string, RegExp, number | null][], process: (code: string, tokenList: [string, RegExp, number | null][], x: {
|
|
2
|
+
name: string;
|
|
3
|
+
value: string;
|
|
4
|
+
count: number;
|
|
5
|
+
}) => string) => string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compilerCore = void 0;
|
|
4
|
+
const token_1 = require("./token");
|
|
5
|
+
const compilerCore = (code, tokenList, UncategorizedTokenList, process) => {
|
|
6
|
+
const tokenCodes = (0, token_1.compilerToken)(code, tokenList, UncategorizedTokenList);
|
|
7
|
+
console.log('====================================');
|
|
8
|
+
console.log(tokenCodes[0].token);
|
|
9
|
+
console.log('====================================');
|
|
10
|
+
let outCode = '';
|
|
11
|
+
for (const tokenCode of tokenCodes) {
|
|
12
|
+
for (const n of tokenCode.token) {
|
|
13
|
+
outCode += process(code, tokenList, n);
|
|
14
|
+
}
|
|
15
|
+
outCode += '\n';
|
|
16
|
+
}
|
|
17
|
+
return outCode;
|
|
18
|
+
};
|
|
19
|
+
exports.compilerCore = compilerCore;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const compilerToken: (code: string, tokenList: [string, RegExp, number | null][], UncategorizedTokenList: [string, RegExp, number | null][]) => {
|
|
2
|
+
code: string;
|
|
3
|
+
token: {
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
count: number;
|
|
7
|
+
index: number;
|
|
8
|
+
}[];
|
|
9
|
+
outCode: string;
|
|
10
|
+
}[];
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compilerToken = void 0;
|
|
4
|
+
const compilerToken = (code, tokenList, UncategorizedTokenList) => {
|
|
5
|
+
const tokenListMax = Math.max(...tokenList.map((n) => { var _a; return (_a = n[2]) !== null && _a !== void 0 ? _a : 0; }));
|
|
6
|
+
let list = [];
|
|
7
|
+
const tokenListName = tokenList.map((n) => n[0]);
|
|
8
|
+
let outCode = [
|
|
9
|
+
code.split('\n'),
|
|
10
|
+
code.split('\n'),
|
|
11
|
+
];
|
|
12
|
+
console.log('====================================');
|
|
13
|
+
console.log(outCode);
|
|
14
|
+
console.log('====================================');
|
|
15
|
+
let count = {};
|
|
16
|
+
tokenList.forEach((token) => {
|
|
17
|
+
if (token[2] === null) {
|
|
18
|
+
return (token[2] = tokenListMax + 1);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return token;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
tokenList.sort((a, b) => {
|
|
25
|
+
if (a[2] === null) {
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
else if (b[2] === null) {
|
|
29
|
+
return -1;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return a[2] - b[2];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
for (const token of tokenList) {
|
|
36
|
+
code.split('\n')
|
|
37
|
+
.filter((n) => n !== '')
|
|
38
|
+
.forEach((_, index) => {
|
|
39
|
+
count = {};
|
|
40
|
+
outCode[1][index] = outCode[1][index].replace(new RegExp(token[1], 'g'), (match) => {
|
|
41
|
+
try {
|
|
42
|
+
count[token[0]].value += 1;
|
|
43
|
+
}
|
|
44
|
+
catch (_a) {
|
|
45
|
+
count[token[0]] = {
|
|
46
|
+
value: 0,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
list[index].push({
|
|
51
|
+
name: token[0],
|
|
52
|
+
value: match,
|
|
53
|
+
count: count[token[0]].value,
|
|
54
|
+
index: outCode[1][index].indexOf(match),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (_b) {
|
|
58
|
+
list[index] = [
|
|
59
|
+
{
|
|
60
|
+
name: token[0],
|
|
61
|
+
value: match,
|
|
62
|
+
count: 0,
|
|
63
|
+
index: outCode[1][index].indexOf(match),
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
outCode[1][index] = outCode[1][index].replace(match, ` ${token[0]} `);
|
|
68
|
+
return ` ${token[0]} `;
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
outCode[1].forEach((i, index) => {
|
|
73
|
+
for (const token of i
|
|
74
|
+
.split(' ')
|
|
75
|
+
.filter((n) => n !== '')
|
|
76
|
+
.filter((n) => tokenListName.indexOf(n) === -1)) {
|
|
77
|
+
UncategorizedTokenList.forEach((n) => {
|
|
78
|
+
token.replace(n[1], (match) => {
|
|
79
|
+
try {
|
|
80
|
+
count[n[0]].value += 1;
|
|
81
|
+
}
|
|
82
|
+
catch (_a) {
|
|
83
|
+
count[n[0]] = {
|
|
84
|
+
value: 0,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
list[index].push({
|
|
89
|
+
name: n[0],
|
|
90
|
+
value: match,
|
|
91
|
+
count: count[n[0]].value,
|
|
92
|
+
index: outCode[0][index].indexOf(match),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (_b) {
|
|
96
|
+
list[index] = [
|
|
97
|
+
{
|
|
98
|
+
name: n[0],
|
|
99
|
+
value: match,
|
|
100
|
+
count: 0,
|
|
101
|
+
index: outCode[0][index].indexOf(match),
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
outCode[0][index] = outCode[0][index].replace(match, ` ${n[0]} `);
|
|
106
|
+
outCode[1][index] = outCode[1][index].replace(token, ` ${n[0]} `);
|
|
107
|
+
return ` ${n[0]} `;
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return code.split('\n').map((n, index) => {
|
|
113
|
+
return {
|
|
114
|
+
code: n,
|
|
115
|
+
token: list[index].sort((a, b) => a.index - b.index),
|
|
116
|
+
outCode: outCode[1][index],
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
exports.compilerToken = compilerToken;
|
package/module/Date/index.d.ts
CHANGED
package/module/Date/index.js
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
4
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_Localnow;
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.now = void 0;
|
|
7
|
-
const now_1 =
|
|
8
|
-
exports
|
|
15
|
+
exports.UMT_Date = exports.UMTDateClass = exports.now = void 0;
|
|
16
|
+
const now_1 = require("./now");
|
|
17
|
+
Object.defineProperty(exports, "now", { enumerable: true, get: function () { return now_1.now; } });
|
|
18
|
+
class UMTDateClass {
|
|
19
|
+
constructor() {
|
|
20
|
+
_UMTDateClass_Localnow.set(this, void 0);
|
|
21
|
+
__classPrivateFieldSet(this, _UMTDateClass_Localnow, now_1.now, "f");
|
|
22
|
+
}
|
|
23
|
+
get now() {
|
|
24
|
+
return __classPrivateFieldGet(this, _UMTDateClass_Localnow, "f");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.UMTDateClass = UMTDateClass;
|
|
28
|
+
_UMTDateClass_Localnow = new WeakMap();
|
|
29
|
+
exports.UMT_Date = new UMTDateClass();
|
package/module/Date/now.d.ts
CHANGED
package/module/Date/now.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.now = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @param {number} [timeDifference=9] 時差(時)
|
|
6
|
+
* @returns {Date} 現在時刻
|
|
7
|
+
*/
|
|
8
|
+
const now = (timeDifference = 9) => new Date(Date.now() +
|
|
9
|
+
(new Date().getTimezoneOffset() + timeDifference * 60) *
|
|
10
|
+
60 *
|
|
11
|
+
1000);
|
|
12
|
+
exports.now = now;
|
package/module/Math/addition.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
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
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
3
|
+
exports.addition = void 0;
|
|
4
|
+
const getDecimalLength_1 = require("./getDecimalLength");
|
|
5
|
+
const max_1 = require("./max");
|
|
6
|
+
const multiplication_1 = require("./multiplication");
|
|
9
7
|
/**
|
|
10
8
|
* 誤差のない足し算
|
|
11
9
|
* @param {number} x
|
|
12
10
|
* @param {number} y
|
|
11
|
+
* @returns number
|
|
13
12
|
*/
|
|
14
13
|
const addition = (x, y) => {
|
|
15
|
-
const z = Math.pow(10, (0, max_1.
|
|
16
|
-
return ((0, multiplication_1.
|
|
14
|
+
const z = Math.pow(10, (0, max_1.max)((0, getDecimalLength_1.getDecimalLength)(x), (0, getDecimalLength_1.getDecimalLength)(y)));
|
|
15
|
+
return ((0, multiplication_1.multiplication)(x, z) + (0, multiplication_1.multiplication)(y, z)) / z;
|
|
17
16
|
};
|
|
18
|
-
exports.
|
|
17
|
+
exports.addition = addition;
|
package/module/Math/average.d.ts
CHANGED
package/module/Math/average.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.average = void 0;
|
|
3
4
|
/**
|
|
4
5
|
* 平均値
|
|
5
6
|
* @param {number[]} numbers
|
|
7
|
+
* @returns number
|
|
6
8
|
*/
|
|
7
9
|
const average = (numbers) => {
|
|
8
10
|
const sum = numbers.reduce((a, b) => a + b, 0);
|
|
9
11
|
const avg = sum / numbers.length;
|
|
10
12
|
return avg;
|
|
11
13
|
};
|
|
12
|
-
exports.
|
|
14
|
+
exports.average = average;
|
|
@@ -4,8 +4,4 @@
|
|
|
4
4
|
* xなどの文字は未対応
|
|
5
5
|
* @param {string} x 計算式
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
$?: number;
|
|
9
|
-
}
|
|
10
|
-
declare const calculatorCore: (x: string, ex?: Props) => string;
|
|
11
|
-
export default calculatorCore;
|
|
7
|
+
export declare const calculatorCore: <T extends object>(x: string, ex?: T | undefined) => string;
|