prototype-helper 0.1.0 → 0.1.4

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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "editor.quickSuggestions": {
3
+ "other": true,
4
+ "comments": true,
5
+ "strings": true
6
+ }
7
+ }
package/@types/index.d.ts CHANGED
@@ -1 +0,0 @@
1
- export {};
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ <img src="https://capsule-render.vercel.app/api?type=waving&color=343a40&height=210&section=header&text=Typescript Prototype Helper&fontSize=50&fontAlignY=35&fontColor=adb5bd" />
2
+ <!-- <h1 align="center">Typescript Prototype Helper</h1> -->
3
+
4
+ <p align="center">
5
+ <a href="https://github.com/prettier/prettier">
6
+ <img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge">
7
+ </a>
8
+ <a href="https://www.npmjs.com/package/prototype-helper">
9
+ <img alt="code style: prettier" src="https://img.shields.io/npm/v/prototype-helper.svg?style=for-the-badge">
10
+ </a>
11
+ <a href="https://github.com/k22pr/prototype-helper/blob/master/LICENSE">
12
+ <img alt="code style: prettier" src="https://img.shields.io/github/license/mashape/apistatus.svg?style=for-the-badge">
13
+ </a>
14
+ <img alt="npm" src="https://img.shields.io/npm/dm/prototype-helper?style=for-the-badge">
15
+ <!-- <img alt="AppVeyor tests (compact)" src="https://img.shields.io/appveyor/tests/k22pr/prototype-helper?compact_message&style=for-the-badge"> -->
16
+
17
+ </p>
18
+ <p align="center">
19
+ Adds a convenient prototype function package.
20
+ </p>
21
+
22
+ # Prototype Helper
23
+
24
+ ## Number
25
+
26
+ ### toComma()
27
+
28
+ It is a function that attaches a three-digit comma.
29
+
30
+ ```ts
31
+ let test = 123;
32
+ test.toComma(); // "123"
33
+ test = 123456;
34
+ test.toComma(); // "123,456"
35
+ //
36
+ ```
37
+
38
+ ### ampersand()
39
+
40
+ Ampsand that safely handles floating point errors.
41
+
42
+ ```ts
43
+ console.log(35 % 0.8); // 0.5999999999999981
44
+ console.log((35).ampersand(0.8)); // 0.6
45
+ ```
46
+
47
+ ### safeAdd()
48
+
49
+ Addition to safely handling floating point errors.
50
+
51
+ Calculate only up to 15 decimal places.
52
+
53
+ ```ts
54
+ console.log(0.1 + 0.2); // 0.30000000000000004
55
+ console.log((0.1).safeAdd(0.2)); // 0.3
56
+ ```
57
+
58
+ ### safeSubtract()
59
+
60
+ Subtraction that safely handles floating point errors.
61
+
62
+ Calculate only up to 15 decimal places.
63
+
64
+ ```ts
65
+ console.log(0.1 - 0.3); // -0.19999999999999998
66
+ console.log((0.1).safeSubtract(0.3)); // 0.2
67
+ ```
68
+
69
+ ### safeDivision()
70
+
71
+ Division that safely handles floating point errors.
72
+
73
+ Calculate only up to 15 decimal places.
74
+
75
+ ```ts
76
+ console.log(0.2 / 0.6); // 0.33333333333333337
77
+ console.log((0.2).safeDivision(0.6)); // 0.3333333333333333
78
+ ```
79
+
80
+ ### safeMultiply()
81
+
82
+ Division that safely handles floating point errors.
83
+
84
+ Calculate only up to 15 decimal places.
85
+
86
+ ```ts
87
+ console.log(0.1 * 0.2); // 0.020000000000000004
88
+ console.log((0.1).safeMultiply(0.2)); // 0.02
89
+ ```
90
+
91
+ ### fixNumber()
92
+
93
+ Fix the number of digits to be marked.
94
+
95
+ ```ts
96
+ console.log("30222.50380000".fixPoint(5)); // 30222.50380
97
+ console.log((30222).fixPoint(3)); // 30222.000
98
+ console.log((30222.12).fixPoint(5).toComma()); // 30,222.12000
99
+ ```
100
+
101
+ ### fixPoint()
102
+
103
+ Fix the decimal place to be marked.
104
+
105
+ ```ts
106
+ console.log("30222.50380000".fixPoint(5)); // 30222.50380
107
+ console.log((30222).fixPoint(3)); // 30222.000
108
+ console.log((30222.12).fixPoint(5).toComma()); // 30,222.12000
109
+ ```
110
+
111
+ ---
112
+
113
+ ## String
114
+
115
+ ### toComma()
116
+
117
+ It is a function that attaches a three-digit comma.
118
+
119
+ ```ts
120
+ let test = "123";
121
+ test.toComma(); // "123"
122
+ test = "123456";
123
+ test.toComma(); // "123,456"
124
+ //
125
+ ```
126
+
127
+ ### fixNumber()
128
+
129
+ Fix the number of digits to be marked.
130
+
131
+ ```ts
132
+ console.log("30222".fixPoint(5)); // 30222
133
+ console.log("30222".fixPoint(5)); // 30222
134
+ ```
135
+
136
+ ### fixPoint()
137
+
138
+ Fix the decimal place to be marked.
139
+
140
+ ```ts
141
+ console.log("30222.50380000".fixPoint(5)); // 30222.50380
142
+ console.log((30222).fixPoint(3)); // 30222.000
143
+ console.log((30222.12).fixPoint(5).toComma()); // 30,222.12000
144
+ console.log("30222.50380000".fixPoint(8).fixNumber(8)); // 00030222.50380000
145
+ ```
146
+
147
+ ## Object
148
+
149
+ ## Array
150
+
151
+ ---
152
+
153
+ # Extention Helper
154
+
155
+ ## Math
156
+
157
+ ### round10(x: number, point?: number)
158
+
159
+ ### floor10(x: number, point?: number)
160
+
161
+ ### ceil10(x: number, point?: number)
162
+
163
+ A function that allows you to use decimal points for discarding/rounding/round.
164
+
165
+ I used the code of the MDN below.
166
+
167
+ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil#decimal_adjustment
168
+
169
+ ```ts
170
+ console.log(Math.round10(112.5345, 3)); //112.535
171
+ console.log(Math.floor10(112.5345, 3)); //112.534
172
+ console.log(Math.ceil10(112.5345, 3)); //112.535
173
+ ```
174
+
175
+ ### randomRange(a: number, b: number, point?: number)
176
+
177
+ Create random numbers within that range.
178
+
179
+ (Includes maximum and minimum values.)
180
+
181
+ ```ts
182
+ console.log(Math.randomRange(112.5, 200, 1)); //135.1
183
+ console.log(Math.randomRange(0, 200)); //169
184
+ ```
185
+
186
+ ### clamp(input: number, min: number, max: number)
187
+
188
+ ```ts
189
+ console.log(Math.clamp(10, 3, 5)); // 5
190
+ console.log(Math.clamp(1, 3, 5)); // 3
191
+ console.log(Math.clamp(4, 3, 5)); // 4
192
+ ```
package/package.json CHANGED
@@ -1,10 +1,28 @@
1
1
  {
2
2
  "name": "prototype-helper",
3
- "version": "0.1.0",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/k22pr/prototype-helper.git"
10
+ },
11
+ "keywords": [
12
+ "typescript",
13
+ "prototype",
14
+ "extension",
15
+ "override",
16
+ "helper"
17
+ ],
18
+ "author": "서버지기",
19
+ "license": "MIT",
20
+ "bugs": {
21
+ "url": "https://github.com/k22pr/prototype-helper/issues"
22
+ },
23
+ "homepage": "https://github.com/k22pr/prototype-helper#readme",
5
24
  "dependencies": {
6
- "consola": "^2.15.3",
7
- "dayjs": "^1.10.5"
25
+ "consola": "^2.15.3"
8
26
  },
9
27
  "devDependencies": {
10
28
  "@types/jest": "^26.0.23",
@@ -22,7 +40,7 @@
22
40
  "build": "jest && tsc",
23
41
  "dev": "nodemon --exec ts-node ./src/test.ts",
24
42
  "test": "jest --detectOpenHandles --forceExit",
25
- "publish": "npm run build && npm publish"
43
+ "publish": "yarn build && npm publish"
26
44
  },
27
45
  "nodemonConfig": {
28
46
  "ignore": [
@@ -47,6 +65,11 @@
47
65
  "js",
48
66
  "json"
49
67
  ],
68
+ "moduleDirectories": [
69
+ "node_modules",
70
+ "bower_components",
71
+ "src"
72
+ ],
50
73
  "globals": {
51
74
  "ts-jest": {
52
75
  "diagnostics": true
package/tsconfig.json CHANGED
@@ -17,7 +17,8 @@
17
17
  "emitDecoratorMetadata": true,
18
18
  "strict": true,
19
19
  "allowSyntheticDefaultImports": true,
20
- "resolveJsonModule": true
20
+ "resolveJsonModule": true,
21
+ "declaration": true
21
22
  },
22
23
  "include": ["./src/**/*.ts"],
23
24
  "exclude": ["node_modules", "**/*.spec.ts"],
@@ -1,4 +0,0 @@
1
- "use strict";
2
- // const test = [1, 2, 3, 4, 5, 6, 7, 8, 9];
3
- // test.findIndex;
4
- //# sourceMappingURL=array.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/extension/array.ts"],"names":[],"mappings":";AAIA,4CAA4C;AAE5C,kBAAkB"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./array");
4
- require("./string");
5
- require("./number");
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extension/index.ts"],"names":[],"mappings":";;AAAA,mBAAiB;AACjB,oBAAkB;AAClB,oBAAkB"}
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Number.prototype.toComma = function () {
3
- if (`$[this}`.length == 0)
4
- return "0";
5
- return `${this}`.toComma();
6
- };
7
- Number.prototype.ampersand = function (amp) {
8
- const prepValue = Number(this) % amp;
9
- const tmp = prepValue.toString().split(".");
10
- if (tmp[1]) {
11
- const pointValue = hexfloatNotation(`0.${tmp[1]}`.toNumber());
12
- return Number(tmp[0] + (pointValue % amp));
13
- }
14
- return prepValue;
15
- };
16
- function hexfloatNotation(number, numberPoint = 8) {
17
- const tmp = number.toString().split(".");
18
- if (tmp[1]) {
19
- const size = Math.round(number * Math.pow(10, numberPoint)) / Math.pow(10, numberPoint);
20
- return Number(tmp[0] + size);
21
- }
22
- else {
23
- return Number(tmp);
24
- }
25
- }
26
- Number.prototype.safeDivision = function (value) {
27
- return (Number(this) / value).toFixed(16).toNumber();
28
- };
29
- Number.prototype.safeMultiply = function (value) {
30
- return (Number(this) * value).toFixed(16).toNumber();
31
- };
32
- Number.prototype.safeAdd = function (value) {
33
- return (Number(this) + value).toFixed(16).toNumber();
34
- };
35
- Number.prototype.safeAdd = function (value) {
36
- return (Number(this) + value).toFixed(16).toNumber();
37
- };
38
- Number.prototype.safeSubtract = function (value) {
39
- return (Number(this) - value).toFixed(16).toNumber();
40
- };
41
- //# sourceMappingURL=number.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"number.js","sourceRoot":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,SAAS,CAAC,YAAY,GAAG,UAAU,KAAa;IACrD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,KAAa;IACrD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,KAAa;IAChD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,KAAa;IAChD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AACvD,CAAC,CAAC;AACF,MAAM,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,KAAa;IACrD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AACvD,CAAC,CAAC"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./string");
4
- require("./number");
5
- test("number - toComma", () => {
6
- expect((123).toComma()).toBe("123");
7
- expect((123456).toComma()).toBe("123,456");
8
- });
9
- test("number - safe operations", () => {
10
- expect((35).ampersand(0.8)).toBe(0.6);
11
- expect((0.1).safeAdd(0.2)).toBe(0.3);
12
- expect((0.1).safeSubtract(0.2)).toBe(-0.1);
13
- expect((0.1).safeMultiply(0.2)).toBe(0.02);
14
- expect((0.1).safeDivision(0.2)).toBe(0.5);
15
- });
16
- //# sourceMappingURL=number.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"number.test.js","sourceRoot":"","sources":["../../src/extension/number.test.ts"],"names":[],"mappings":";;AAAA,oBAAkB;AAClB,oBAAkB;AAElB,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAC5B,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACpC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- function deepClone(obj) {
3
- if (obj === null || typeof obj !== "object") {
4
- return obj;
5
- }
6
- const result = Array.isArray(obj) ? [] : {};
7
- for (let key of Object.keys(obj)) {
8
- result[key] = deepClone(obj[key]);
9
- }
10
- return result;
11
- }
12
- Object.prototype.deepCopy = deepClone(this);
13
- //# sourceMappingURL=object.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/extension/object.ts"],"names":[],"mappings":";AAIA,SAAS,SAAS,CAAC,GAAQ;IACzB,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3C,OAAO,GAAG,CAAC;KACZ;IAED,MAAM,MAAM,GAAQ,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEjD,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAChC,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;KACnC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- String.prototype.leadingChars = function (chars, length) {
3
- return (chars.toString().repeat(length) + this).substr(-length);
4
- };
5
- String.prototype.padZero = function (length) {
6
- let padString = this.toString();
7
- return padString.padStart(length, "0");
8
- };
9
- String.prototype.toComma = function (length = 0) {
10
- if (this.length == 0 || this == "NaN")
11
- return "0";
12
- const tmp = this.split(".");
13
- let num = tmp[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",").padZero(length);
14
- num += tmp.length != 1 && tmp[1].length != 0 ? `.${tmp[1]}` : "";
15
- return num;
16
- };
17
- String.prototype.toNumber = function () {
18
- return Number(this.replace(/,/gi, ""));
19
- };
20
- //# sourceMappingURL=string.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/extension/string.ts"],"names":[],"mappings":";AAcA,MAAM,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,KAAsB,EAAE,MAAc;IAC9E,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,MAAc;IACjD,IAAI,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAChC,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,SAAiB,CAAC;IACrD,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK;QAAE,OAAO,GAAG,CAAC;IAClD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE5B,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,QAAQ,GAAG;IAC1B,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./string");
4
- test("string - toComma()", () => {
5
- expect("123".toComma().length).toBe(3);
6
- expect("123456".toComma().length).toBe(7);
7
- expect("24816246784".toComma()).toBe("24,816,246,784");
8
- expect("24,816,246,784".toNumber()).toBe(24816246784);
9
- });
10
- test("string - pad extension", () => {
11
- expect("300".padZero(10)).toBe("0000000300");
12
- });
13
- //# sourceMappingURL=string.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string.test.js","sourceRoot":"","sources":["../../src/extension/string.test.ts"],"names":[],"mappings":";;AAAA,oBAAkB;AAElB,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAC9B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE1C,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAEvD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACxD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE;IAClC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
package/dist/index.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("dotenv").config();
4
- require("./extension");
5
- require("./override");
6
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;AAC3B,uBAAqB;AACrB,sBAAoB"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const consola = require("consola");
4
- function showMessage(type, ...message) {
5
- consola[type](...message);
6
- }
7
- console.log = function (...message) {
8
- if (process.env.NODE_ENV != "production")
9
- showMessage("info", ...message);
10
- };
11
- console.info = function (...message) {
12
- if (process.env.NODE_ENV != "production")
13
- showMessage("info", ...message);
14
- };
15
- console.warn = function (...message) {
16
- showMessage("warn", ...message);
17
- };
18
- console.error = function (...message) {
19
- showMessage("error", ...message);
20
- };
21
- globalThis.console = console;
22
- //# sourceMappingURL=console.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/override/console.ts"],"names":[],"mappings":";;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEnC,SAAS,WAAW,CAAC,IAA+B,EAAE,GAAG,OAAY;IACnE,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;AAC5B,CAAC;AACD,OAAO,CAAC,GAAG,GAAG,UAAU,GAAG,OAAY;IACrC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,YAAY;QAAE,WAAW,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;AAC5E,CAAC,CAAC;AACF,OAAO,CAAC,IAAI,GAAG,UAAU,GAAG,OAAY;IACtC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,YAAY;QAAE,WAAW,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;AAC5E,CAAC,CAAC;AACF,OAAO,CAAC,IAAI,GAAG,UAAU,GAAG,OAAY;IACtC,WAAW,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;AAClC,CAAC,CAAC;AACF,OAAO,CAAC,KAAK,GAAG,UAAU,GAAG,OAAY;IACvC,WAAW,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("../extension");
4
- require("./console");
5
- require("./math");
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/override/index.ts"],"names":[],"mappings":";;AAAA,wBAAsB;AAEtB,qBAAmB;AACnB,kBAAgB"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- if (!Math.round10) {
4
- Math.round10 = decimalAdjust("round");
5
- }
6
- if (!Math.floor10) {
7
- Math.floor10 = decimalAdjust("floor");
8
- }
9
- if (!Math.ceil10) {
10
- Math.ceil10 = decimalAdjust("ceil");
11
- }
12
- if (!Math.randomRange) {
13
- Math.randomRange = function (a, b, point = 0) {
14
- return Math.floor10(Math.random() * (b - a + 1) + a, point);
15
- };
16
- }
17
- function decimalAdjust(type) {
18
- const func = Math[type];
19
- return (number, precision = 0) => {
20
- precision =
21
- precision == null ? 0 : precision >= 0 ? Math.min(precision, 292) : Math.max(precision, -292);
22
- if (precision) {
23
- // Shift with exponential notation to avoid floating-point issues.
24
- // See [MDN](https://mdn.io/round#Examples) for more details.
25
- let pair = `${number}e`.split("e");
26
- const value = func(`${pair[0]}e${+pair[1] + precision}`.toNumber());
27
- pair = `${value}e`.split("e");
28
- return +`${pair[0]}e${+pair[1] - precision}`;
29
- }
30
- return func(number);
31
- };
32
- }
33
- globalThis.Math = Math;
34
- //# sourceMappingURL=math.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"math.js","sourceRoot":"","sources":["../../src/override/math.ts"],"names":[],"mappings":";;AAYA,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;IACjB,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;CACvC;AACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;IACjB,IAAI,CAA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CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC;SAC9C;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AAED,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC"}
package/dist/test.js DELETED
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // import "./index";
4
- require("../dist");
5
- // console.log("hello");
6
- // console.warn("warn log");
7
- // console.error("error log");
8
- // console.log("300".padZero(10));
9
- // console.log("300".toComma(10));
10
- // console.log("24816246784".toComma());
11
- // console.log("24816246784".toNumber());
12
- // console.log((24816246784).toComma());
13
- // console.log(35 % 0.8);
14
- //0.5999999999999981
15
- // console.log((35).ampersand(0.8));
16
- //0.6
17
- // console.log(0.1 * 0.2);
18
- // console.log((0.1).safeMultiply(0.2));
19
- // console.log(0.2 / 0.2);
20
- // console.log((0.1).safeDivision(0.2));
21
- console.log(Math);
22
- console.warn(Math.round);
23
- // console.log(Math.round10(112.5345, 3));
24
- // console.log(Math.round(112.5));
25
- // console.log(Math.randomRange(112.5, 200, 1));
26
- const hello = [1, 2, 3, 4, 5, 6, 7, 8, 9];
27
- // hello.findIndex;
28
- //# sourceMappingURL=test.js.map
package/dist/test.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;AAAA,oBAAoB;AACpB,mBAAiB;AAEjB,wBAAwB;AACxB,4BAA4B;AAC5B,8BAA8B;AAE9B,kCAAkC;AAClC,kCAAkC;AAClC,wCAAwC;AACxC,yCAAyC;AAEzC,wCAAwC;AAExC,yBAAyB;AACzB,oBAAoB;AACpB,oCAAoC;AACpC,KAAK;AAEL,0BAA0B;AAC1B,wCAAwC;AACxC,0BAA0B;AAC1B,wCAAwC;AACxC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAClB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,0CAA0C;AAC1C,kCAAkC;AAClC,gDAAgD;AAEhD,MAAM,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE1C,mBAAmB"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function deepClone(obj) {
4
- if (obj === null || typeof obj !== "object") {
5
- return obj;
6
- }
7
- const result = Array.isArray(obj) ? [] : {};
8
- for (let key of Object.keys(obj)) {
9
- result[key] = deepClone(obj[key]);
10
- }
11
- return result;
12
- }
13
- exports.default = deepClone;
14
- //# sourceMappingURL=deepCopy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deepCopy.js","sourceRoot":"","sources":["../../src/utils/deepCopy.ts"],"names":[],"mappings":";;AAAA,SAAS,SAAS,CAAC,GAAQ;IACzB,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3C,OAAO,GAAG,CAAC;KACZ;IAED,MAAM,MAAM,GAAQ,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEjD,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAChC,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;KACnC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,kBAAe,SAAS,CAAC"}