zerosurge 16.0.0 → 17.0.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.
- package/.github/workflows/lint.yml +20 -0
- package/.github/workflows/smoke.yml +10 -0
- package/dist/index.d.ts +14 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -20
- package/dist/index.js.map +1 -1
- package/eslint.config.mjs +22 -0
- package/index.test.js +2 -0
- package/package.json +8 -4
- package/src/index.ts +45 -37
- package/src/types/@10xly/strict-equals.d.ts +9 -9
- package/src/types/@rightpad/concat.d.ts +10 -9
- package/src/types/betterloggingwithecho.d.ts +9 -9
- package/src/types/literally.d.ts +8 -8
- package/src/types/minecraft-seed-input.d.ts +1 -0
- package/src/types/my-simple-add-test.d.ts +20 -20
- package/src/types/not-not.d.ts +9 -8
- package/src/types/to-str.d.ts +8 -8
- package/src/types/yanoop.d.ts +26 -24
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: 10xly Code Quality
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["**"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["**"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
quality-check:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-node@v4
|
|
15
|
+
with:
|
|
16
|
+
node-version: "25"
|
|
17
|
+
- name: Install
|
|
18
|
+
run: npm install
|
|
19
|
+
- name: Run 10xly Lint
|
|
20
|
+
run: npx eslint . --max-warnings 0
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the literal type for the numerical value zero.
|
|
3
|
-
*/
|
|
4
|
-
export type Zero = 0;
|
|
5
1
|
/**
|
|
6
2
|
* Defines the available strategies for deriving the value zero.
|
|
7
3
|
*/
|
|
@@ -16,22 +12,25 @@ export declare enum ZeroCalculationMethod {
|
|
|
16
12
|
/**
|
|
17
13
|
* Configuration options for the zero calculation process.
|
|
18
14
|
*/
|
|
19
|
-
export
|
|
20
|
-
/** The specific mathematical or string-based method to use. */
|
|
21
|
-
method: ZeroCalculationMethod;
|
|
15
|
+
export interface ReturnZeroOptions {
|
|
22
16
|
/** Whether to output progress and status updates to the console. */
|
|
23
17
|
loggingEnabled: boolean;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
export declare function returnZero(options: ReturnZeroOptions): Zero | undefined;
|
|
18
|
+
/** The specific mathematical or string-based method to use. */
|
|
19
|
+
method: ZeroCalculationMethod;
|
|
20
|
+
}
|
|
21
|
+
/** Number 0 but a type **/
|
|
22
|
+
type Zero = 0;
|
|
31
23
|
/**
|
|
32
24
|
* Validates if a given value is strictly equal to zero.
|
|
33
25
|
* * @param value - Any value to be tested for zero-equality.
|
|
34
26
|
* @returns True if the value matches the calculated zero, otherwise false.
|
|
35
27
|
*/
|
|
36
|
-
export declare function isZero(value:
|
|
28
|
+
export declare function isZero(value: unknown): value is Zero;
|
|
29
|
+
/**
|
|
30
|
+
* Executes a calculation to retrieve the value zero using the specified method.
|
|
31
|
+
* * @param options - Configuration for the calculation and logging behavior.
|
|
32
|
+
* @returns The calculated value of zero, or exits on an invalid method.
|
|
33
|
+
*/
|
|
34
|
+
export declare function returnZero(options: ReturnZeroOptions): undefined | Zero;
|
|
35
|
+
export {};
|
|
37
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,oBAAY,qBAAqB;IAC/B,kFAAkF;IAElF,kBAAkB,IAAA;IAClB,0DAA0D;IAE1D,oBAAoB,IAAA;IACpB,8DAA8D;IAE9D,2BAA2B,IAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,cAAc,EAAE,OAAO,CAAA;IACvB,+DAA+D;IAC/D,MAAM,EAAE,qBAAqB,CAAA;CAC9B;AAED,2BAA2B;AAE3B,KAAK,IAAI,GAAG,CAAC,CAAA;AA0Bb;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAUpD;AAED;;;;GAIG;AAEH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CA2CvE"}
|
package/dist/index.js
CHANGED
|
@@ -4,31 +4,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ZeroCalculationMethod = void 0;
|
|
7
|
-
exports.returnZero = returnZero;
|
|
8
7
|
exports.isZero = isZero;
|
|
8
|
+
exports.returnZero = returnZero;
|
|
9
|
+
const strict_equals_1 = __importDefault(require("@10xly/strict-equals"));
|
|
10
|
+
const concat_1 = __importDefault(require("@rightpad/concat"));
|
|
9
11
|
const betterloggingwithecho_1 = __importDefault(require("betterloggingwithecho"));
|
|
10
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const minecraft_seed_input_1 = __importDefault(require("minecraft-seed-input"));
|
|
12
|
-
const string_creashaks_organzine_1 = __importDefault(require("string-creashaks-organzine"));
|
|
13
13
|
const immediate_error_1 = require("immediate-error");
|
|
14
|
+
const literally_1 = __importDefault(require("literally"));
|
|
15
|
+
const minecraft_seed_input_1 = __importDefault(require("minecraft-seed-input"));
|
|
16
|
+
const my_simple_add_test_1 = require("my-simple-add-test");
|
|
17
|
+
const not_not_1 = __importDefault(require("not-not"));
|
|
14
18
|
const random_number_1 = __importDefault(require("random-number"));
|
|
15
|
-
const
|
|
19
|
+
const string_creashaks_organzine_1 = __importDefault(require("string-creashaks-organzine"));
|
|
16
20
|
const to_str_1 = __importDefault(require("to-str"));
|
|
17
|
-
const my_simple_add_test_1 = require("my-simple-add-test");
|
|
18
|
-
const strict_equals_1 = __importDefault(require("@10xly/strict-equals"));
|
|
19
21
|
const yanoop_1 = require("yanoop");
|
|
20
|
-
const not_not_1 = __importDefault(require("not-not"));
|
|
21
|
-
const literally_1 = __importDefault(require("literally"));
|
|
22
22
|
/**
|
|
23
23
|
* Defines the available strategies for deriving the value zero.
|
|
24
24
|
*/
|
|
25
25
|
var ZeroCalculationMethod;
|
|
26
26
|
(function (ZeroCalculationMethod) {
|
|
27
27
|
/** Uses the CreashaksOrganzine string and Minecraft seed input to derive zero. */
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/prefer-enum-initializers, @typescript-eslint/naming-convention
|
|
28
29
|
ZeroCalculationMethod[ZeroCalculationMethod["CreashaksOrganzine"] = 0] = "CreashaksOrganzine";
|
|
29
30
|
/** Accesses the default value of the Number prototype. */
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/prefer-enum-initializers, @typescript-eslint/naming-convention
|
|
30
32
|
ZeroCalculationMethod[ZeroCalculationMethod["NumberPrototypeValue"] = 1] = "NumberPrototypeValue";
|
|
31
33
|
/** Generates a random number and subtracts it from itself. */
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/prefer-enum-initializers, @typescript-eslint/naming-convention
|
|
32
35
|
ZeroCalculationMethod[ZeroCalculationMethod["RandomNumberSelfSubtraction"] = 2] = "RandomNumberSelfSubtraction";
|
|
33
36
|
})(ZeroCalculationMethod || (exports.ZeroCalculationMethod = ZeroCalculationMethod = {}));
|
|
34
37
|
/**
|
|
@@ -51,11 +54,26 @@ class Logger {
|
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Validates if a given value is strictly equal to zero.
|
|
59
|
+
* * @param value - Any value to be tested for zero-equality.
|
|
60
|
+
* @returns True if the value matches the calculated zero, otherwise false.
|
|
61
|
+
*/
|
|
62
|
+
function isZero(value) {
|
|
63
|
+
return (0, strict_equals_1.default)(value,
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
65
|
+
returnZero({
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
67
|
+
loggingEnabled: (0, yanoop_1.doop)((0, not_not_1.default)((0, literally_1.default)(void /false/))),
|
|
68
|
+
method: ZeroCalculationMethod.CreashaksOrganzine,
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
54
71
|
/**
|
|
55
72
|
* Executes a calculation to retrieve the value zero using the specified method.
|
|
56
73
|
* * @param options - Configuration for the calculation and logging behavior.
|
|
57
74
|
* @returns The calculated value of zero, or exits on an invalid method.
|
|
58
75
|
*/
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
59
77
|
function returnZero(options) {
|
|
60
78
|
const logger = new Logger(options.loggingEnabled);
|
|
61
79
|
const method = options.method;
|
|
@@ -65,12 +83,14 @@ function returnZero(options) {
|
|
|
65
83
|
logger.log(chalk_1.default.cyan("[zerosurge] Using CreashaksOrganzine method"));
|
|
66
84
|
const result = (0, minecraft_seed_input_1.default)(string_creashaks_organzine_1.default);
|
|
67
85
|
logger.log(chalk_1.default.green("[zerosurge] Zero calculated succesfully"));
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
68
87
|
return result;
|
|
69
88
|
}
|
|
70
89
|
case ZeroCalculationMethod.NumberPrototypeValue: {
|
|
71
90
|
logger.log(chalk_1.default.cyan("[zerosurge] Using NumberPrototypeValue method"));
|
|
72
91
|
const result = Number.prototype.valueOf();
|
|
73
92
|
logger.log(chalk_1.default.green("[zerosurge] Zero calculated succesfully"));
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
74
94
|
return result;
|
|
75
95
|
}
|
|
76
96
|
case ZeroCalculationMethod.RandomNumberSelfSubtraction: {
|
|
@@ -79,22 +99,12 @@ function returnZero(options) {
|
|
|
79
99
|
logger.log(chalk_1.default.cyan((0, concat_1.default)("[zerosurge] Generated random number ", (0, to_str_1.default)(random))));
|
|
80
100
|
const result = (0, my_simple_add_test_1.subtract)(random, random);
|
|
81
101
|
logger.log(chalk_1.default.green("[zerosurge] Zero calculated succesfully"));
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
82
103
|
return result;
|
|
83
104
|
}
|
|
84
105
|
default: {
|
|
85
|
-
(0, immediate_error_1.immediateError)(chalk_1.default.red("[zerosurge] Unknown or undefined method for calculating zero, exiting"), immediate_error_1.ErrorType.TypeError);
|
|
106
|
+
return (0, immediate_error_1.immediateError)(chalk_1.default.red("[zerosurge] Unknown or undefined method for calculating zero, exiting"), immediate_error_1.ErrorType.TypeError);
|
|
86
107
|
}
|
|
87
108
|
}
|
|
88
109
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Validates if a given value is strictly equal to zero.
|
|
91
|
-
* * @param value - Any value to be tested for zero-equality.
|
|
92
|
-
* @returns True if the value matches the calculated zero, otherwise false.
|
|
93
|
-
*/
|
|
94
|
-
function isZero(value) {
|
|
95
|
-
return (0, strict_equals_1.default)(value, returnZero({
|
|
96
|
-
method: ZeroCalculationMethod.CreashaksOrganzine,
|
|
97
|
-
loggingEnabled: (0, yanoop_1.doop)((0, not_not_1.default)((0, literally_1.default)(void /false/))),
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
110
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.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AAK,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC,CAAA;YAClE,uEAAuE;YACvE,OAAO,MAAc,CAAA;QACvB,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,IAAA,gCAAc,EACnB,eAAK,CAAC,GAAG,CACP,uEAAuE,CACxE,EACD,2BAAS,CAAC,SAAS,CACpB,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import config from "@10xly/eslint-config"
|
|
2
|
+
import tseslint from "typescript-eslint"
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
...config,
|
|
6
|
+
{
|
|
7
|
+
ignores: ["dist/**"],
|
|
8
|
+
},
|
|
9
|
+
...tseslint.configs.all.map(c => ({
|
|
10
|
+
...c,
|
|
11
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
12
|
+
})),
|
|
13
|
+
{
|
|
14
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
15
|
+
languageOptions: {
|
|
16
|
+
parserOptions: {
|
|
17
|
+
projectService: true,
|
|
18
|
+
tsconfigRootDir: import.meta.dirname,
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
]
|
package/index.test.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zerosurge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0",
|
|
4
4
|
"description": "The future is here.",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "node index.test",
|
|
8
|
-
"build": "tsc"
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"release": "npm run build"
|
|
9
10
|
},
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
@@ -130,13 +131,16 @@
|
|
|
130
131
|
"yanoop": "^1.0.0"
|
|
131
132
|
},
|
|
132
133
|
"devDependencies": {
|
|
134
|
+
"@10xly/eslint-config": "*",
|
|
133
135
|
"@types/node": "^24.10.0",
|
|
134
136
|
"@types/random-number": "^0.0.4",
|
|
135
137
|
"assert-fn": "^1.0.1",
|
|
136
138
|
"attempt-statement": "^1.1.0",
|
|
139
|
+
"eslint": "^9.39.3",
|
|
137
140
|
"kleur": "^4.1.5",
|
|
138
141
|
"logtoconsole": "^1.0.7",
|
|
139
142
|
"n0p3-es2015-cjs": "^1.0.1",
|
|
140
|
-
"typescript": "^5.9.3"
|
|
143
|
+
"typescript": "^5.9.3",
|
|
144
|
+
"typescript-eslint": "^8.56.1"
|
|
141
145
|
}
|
|
142
146
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,34 +1,46 @@
|
|
|
1
|
+
import isEqual from "@10xly/strict-equals"
|
|
2
|
+
import concat from "@rightpad/concat"
|
|
1
3
|
import echo from "betterloggingwithecho"
|
|
2
4
|
import chalk from "chalk"
|
|
5
|
+
import { ErrorType, immediateError } from "immediate-error"
|
|
6
|
+
import literally from "literally"
|
|
3
7
|
import seed from "minecraft-seed-input"
|
|
4
|
-
import
|
|
5
|
-
import
|
|
8
|
+
import { subtract } from "my-simple-add-test"
|
|
9
|
+
import notNot from "not-not"
|
|
6
10
|
import rn from "random-number"
|
|
7
|
-
import
|
|
11
|
+
import creashaksOrganzine from "string-creashaks-organzine"
|
|
8
12
|
import toStr from "to-str"
|
|
9
|
-
import { subtract } from "my-simple-add-test"
|
|
10
|
-
import isEqual from "@10xly/strict-equals"
|
|
11
13
|
import { doop } from "yanoop"
|
|
12
|
-
import notNot from "not-not"
|
|
13
|
-
import literally from "literally"
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Represents the literal type for the numerical value zero.
|
|
17
|
-
*/
|
|
18
|
-
export type Zero = 0
|
|
19
14
|
|
|
20
15
|
/**
|
|
21
16
|
* Defines the available strategies for deriving the value zero.
|
|
22
17
|
*/
|
|
23
18
|
export enum ZeroCalculationMethod {
|
|
24
19
|
/** Uses the CreashaksOrganzine string and Minecraft seed input to derive zero. */
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/prefer-enum-initializers, @typescript-eslint/naming-convention
|
|
25
21
|
CreashaksOrganzine,
|
|
26
22
|
/** Accesses the default value of the Number prototype. */
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/prefer-enum-initializers, @typescript-eslint/naming-convention
|
|
27
24
|
NumberPrototypeValue,
|
|
28
25
|
/** Generates a random number and subtracts it from itself. */
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/prefer-enum-initializers, @typescript-eslint/naming-convention
|
|
29
27
|
RandomNumberSelfSubtraction,
|
|
30
28
|
}
|
|
31
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Configuration options for the zero calculation process.
|
|
32
|
+
*/
|
|
33
|
+
export interface ReturnZeroOptions {
|
|
34
|
+
/** Whether to output progress and status updates to the console. */
|
|
35
|
+
loggingEnabled: boolean
|
|
36
|
+
/** The specific mathematical or string-based method to use. */
|
|
37
|
+
method: ZeroCalculationMethod
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Number 0 but a type **/
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
42
|
+
type Zero = 0
|
|
43
|
+
|
|
32
44
|
/**
|
|
33
45
|
* Internal utility for handling output based on the provided configuration.
|
|
34
46
|
*/
|
|
@@ -38,7 +50,7 @@ class Logger {
|
|
|
38
50
|
/**
|
|
39
51
|
* @param loggingEnabled - Determines if log messages should be emitted.
|
|
40
52
|
*/
|
|
41
|
-
constructor(loggingEnabled: boolean) {
|
|
53
|
+
public constructor(loggingEnabled: boolean) {
|
|
42
54
|
this.loggingEnabled = loggingEnabled
|
|
43
55
|
}
|
|
44
56
|
|
|
@@ -46,7 +58,7 @@ class Logger {
|
|
|
46
58
|
* Outputs a message if logging is currently active.
|
|
47
59
|
* @param message - The content to log.
|
|
48
60
|
*/
|
|
49
|
-
log(message: string) {
|
|
61
|
+
public log(message: string): void {
|
|
50
62
|
if (this.loggingEnabled) {
|
|
51
63
|
echo(message)
|
|
52
64
|
}
|
|
@@ -54,13 +66,20 @@ class Logger {
|
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
/**
|
|
57
|
-
*
|
|
69
|
+
* Validates if a given value is strictly equal to zero.
|
|
70
|
+
* * @param value - Any value to be tested for zero-equality.
|
|
71
|
+
* @returns True if the value matches the calculated zero, otherwise false.
|
|
58
72
|
*/
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
export function isZero(value: unknown): value is Zero {
|
|
74
|
+
return isEqual(
|
|
75
|
+
value,
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
77
|
+
returnZero({
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
79
|
+
loggingEnabled: doop(notNot(literally(void /false/))),
|
|
80
|
+
method: ZeroCalculationMethod.CreashaksOrganzine,
|
|
81
|
+
})
|
|
82
|
+
)
|
|
64
83
|
}
|
|
65
84
|
|
|
66
85
|
/**
|
|
@@ -68,7 +87,8 @@ export type ReturnZeroOptions = {
|
|
|
68
87
|
* * @param options - Configuration for the calculation and logging behavior.
|
|
69
88
|
* @returns The calculated value of zero, or exits on an invalid method.
|
|
70
89
|
*/
|
|
71
|
-
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
91
|
+
export function returnZero(options: ReturnZeroOptions): undefined | Zero {
|
|
72
92
|
const logger: Logger = new Logger(options.loggingEnabled)
|
|
73
93
|
const method: ZeroCalculationMethod = options.method
|
|
74
94
|
|
|
@@ -79,12 +99,14 @@ export function returnZero(options: ReturnZeroOptions): Zero | undefined {
|
|
|
79
99
|
logger.log(chalk.cyan("[zerosurge] Using CreashaksOrganzine method"))
|
|
80
100
|
const result: number = seed(creashaksOrganzine)
|
|
81
101
|
logger.log(chalk.green("[zerosurge] Zero calculated succesfully"))
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
82
103
|
return result as Zero
|
|
83
104
|
}
|
|
84
105
|
case ZeroCalculationMethod.NumberPrototypeValue: {
|
|
85
106
|
logger.log(chalk.cyan("[zerosurge] Using NumberPrototypeValue method"))
|
|
86
107
|
const result: number = Number.prototype.valueOf()
|
|
87
108
|
logger.log(chalk.green("[zerosurge] Zero calculated succesfully"))
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
88
110
|
return result as Zero
|
|
89
111
|
}
|
|
90
112
|
case ZeroCalculationMethod.RandomNumberSelfSubtraction: {
|
|
@@ -97,10 +119,11 @@ export function returnZero(options: ReturnZeroOptions): Zero | undefined {
|
|
|
97
119
|
)
|
|
98
120
|
const result: number = subtract(random, random)
|
|
99
121
|
logger.log(chalk.green("[zerosurge] Zero calculated succesfully"))
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
100
123
|
return result as Zero
|
|
101
124
|
}
|
|
102
125
|
default: {
|
|
103
|
-
immediateError(
|
|
126
|
+
return immediateError(
|
|
104
127
|
chalk.red(
|
|
105
128
|
"[zerosurge] Unknown or undefined method for calculating zero, exiting"
|
|
106
129
|
),
|
|
@@ -108,19 +131,4 @@ export function returnZero(options: ReturnZeroOptions): Zero | undefined {
|
|
|
108
131
|
)
|
|
109
132
|
}
|
|
110
133
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Validates if a given value is strictly equal to zero.
|
|
115
|
-
* * @param value - Any value to be tested for zero-equality.
|
|
116
|
-
* @returns True if the value matches the calculated zero, otherwise false.
|
|
117
|
-
*/
|
|
118
|
-
export function isZero(value: any): boolean {
|
|
119
|
-
return isEqual(
|
|
120
|
-
value,
|
|
121
|
-
returnZero({
|
|
122
|
-
method: ZeroCalculationMethod.CreashaksOrganzine,
|
|
123
|
-
loggingEnabled: doop(notNot(literally(void /false/))),
|
|
124
|
-
})
|
|
125
|
-
)
|
|
126
134
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
declare module "@10xly/strict-equals" {
|
|
2
|
-
/**
|
|
3
|
-
* Performs a strict equality comparison between two values.
|
|
4
|
-
* @param a - The first value to compare.
|
|
5
|
-
* @param b - The second value to compare.
|
|
6
|
-
*/
|
|
7
|
-
function isEqual<T>(a: T, b: T): boolean
|
|
8
|
-
|
|
9
|
-
export = isEqual
|
|
1
|
+
declare module "@10xly/strict-equals" {
|
|
2
|
+
/**
|
|
3
|
+
* Performs a strict equality comparison between two values.
|
|
4
|
+
* @param a - The first value to compare.
|
|
5
|
+
* @param b - The second value to compare.
|
|
6
|
+
*/
|
|
7
|
+
function isEqual<T>(a: T, b: T): boolean
|
|
8
|
+
|
|
9
|
+
export = isEqual
|
|
10
10
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
declare module "@rightpad/concat" {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Concatenates multiple strings into a single string.
|
|
5
|
-
* @param strings - The strings to join together.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
declare module "@rightpad/concat" {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Concatenates multiple strings into a single string.
|
|
5
|
+
* @param strings - The strings to join together.
|
|
6
|
+
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
|
+
function concat(...strings: string[]): string
|
|
9
|
+
|
|
10
|
+
export = concat
|
|
10
11
|
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
// This declares the module 'betterloggingwithecho'
|
|
2
1
|
declare module "betterloggingwithecho" {
|
|
3
|
-
interface EchoProperty {
|
|
4
|
-
/**
|
|
5
|
-
* Sets a custom function to handle the logging output.
|
|
6
|
-
* @param logFunction A function that takes any number of arguments and returns nothing.
|
|
7
|
-
*/
|
|
8
|
-
setLogFunction(logFunction: (...args: any[]) => void): void
|
|
9
|
-
}
|
|
10
|
-
|
|
11
2
|
interface EchoFunction extends EchoProperty {
|
|
12
3
|
/**
|
|
13
4
|
* Logs a string message to the console (or the custom log function, if set).
|
|
@@ -16,6 +7,15 @@ declare module "betterloggingwithecho" {
|
|
|
16
7
|
(message: string): void
|
|
17
8
|
}
|
|
18
9
|
|
|
10
|
+
interface EchoProperty {
|
|
11
|
+
/**
|
|
12
|
+
* Sets a custom function to handle the logging output.
|
|
13
|
+
* @param logFunction A function that takes any number of arguments and returns nothing.
|
|
14
|
+
*/
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/method-signature-style, @typescript-eslint/prefer-readonly-parameter-types, @typescript-eslint/no-explicit-any
|
|
16
|
+
setLogFunction(logFunction: (...args: any[]) => void): void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
19
|
// Export the combined type as the default export of the module
|
|
20
20
|
const echo: EchoFunction
|
|
21
21
|
export default echo
|
package/src/types/literally.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
declare module "literally" {
|
|
2
|
-
/**
|
|
3
|
-
* Returns a function that always returns the provided value.
|
|
4
|
-
* @param value - The value to wrap in a constant function.
|
|
5
|
-
*/
|
|
6
|
-
function constant<const T>(value: T): () => T
|
|
7
|
-
|
|
8
|
-
export = constant
|
|
1
|
+
declare module "literally" {
|
|
2
|
+
/**
|
|
3
|
+
* Returns a function that always returns the provided value.
|
|
4
|
+
* @param value - The value to wrap in a constant function.
|
|
5
|
+
*/
|
|
6
|
+
function constant<const T>(value: T): () => T
|
|
7
|
+
|
|
8
|
+
export = constant
|
|
9
9
|
}
|
|
@@ -4,6 +4,7 @@ declare module "minecraft-seed-input" {
|
|
|
4
4
|
* * @param input The value to be converted into a seed (can be a string, number, etc.).
|
|
5
5
|
* @returns The generated numerical seed (e.g., a 64-bit integer represented as a JavaScript number).
|
|
6
6
|
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
8
|
function seed(input: any): number
|
|
8
9
|
|
|
9
10
|
export = seed
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
declare module "my-simple-add-test" {
|
|
2
|
-
/**
|
|
3
|
-
* Calculates the sum of two numbers.
|
|
4
|
-
* @param a - The first number.
|
|
5
|
-
* @param b - The second number.
|
|
6
|
-
*/
|
|
7
|
-
function add(a: number, b: number): number
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Calculates the difference between two numbers.
|
|
11
|
-
* @param a - The number to be subtracted from.
|
|
12
|
-
* @param b - The number to subtract.
|
|
13
|
-
*/
|
|
14
|
-
function subtract(a: number, b: number): number
|
|
15
|
-
|
|
16
|
-
namespace add {
|
|
17
|
-
export { add, subtract }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export = add
|
|
1
|
+
declare module "my-simple-add-test" {
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the sum of two numbers.
|
|
4
|
+
* @param a - The first number.
|
|
5
|
+
* @param b - The second number.
|
|
6
|
+
*/
|
|
7
|
+
function add(a: number, b: number): number
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the difference between two numbers.
|
|
11
|
+
* @param a - The number to be subtracted from.
|
|
12
|
+
* @param b - The number to subtract.
|
|
13
|
+
*/
|
|
14
|
+
function subtract(a: number, b: number): number
|
|
15
|
+
|
|
16
|
+
namespace add {
|
|
17
|
+
export { add, subtract }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export = add
|
|
21
21
|
}
|
package/src/types/not-not.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
declare module "not-not" {
|
|
2
|
-
/**
|
|
3
|
-
* Returns a function that returns the truthiness of the original function's result.
|
|
4
|
-
* @param f - The function to evaluate.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
declare module "not-not" {
|
|
2
|
+
/**
|
|
3
|
+
* Returns a function that returns the truthiness of the original function's result.
|
|
4
|
+
* @param f - The function to evaluate.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types, @typescript-eslint/no-explicit-any
|
|
7
|
+
function notNot<T extends (...args: any[]) => any>(f: T): (...args: Parameters<T>) => boolean
|
|
8
|
+
|
|
9
|
+
export = notNot
|
|
9
10
|
}
|
package/src/types/to-str.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
declare module "to-str" {
|
|
2
|
-
/**
|
|
3
|
-
* Converts a value to a string.
|
|
4
|
-
* @param value - The value to convert.
|
|
5
|
-
*/
|
|
6
|
-
function toStr
|
|
7
|
-
|
|
8
|
-
export = toStr
|
|
1
|
+
declare module "to-str" {
|
|
2
|
+
/**
|
|
3
|
+
* Converts a value to a string.
|
|
4
|
+
* @param value - The value to convert.
|
|
5
|
+
*/
|
|
6
|
+
function toStr(value: unknown): string
|
|
7
|
+
|
|
8
|
+
export = toStr
|
|
9
9
|
}
|
package/src/types/yanoop.d.ts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
declare module "yanoop" {
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
declare module "yanoop" {
|
|
2
|
+
/**
|
|
3
|
+
* Performs the given function if present, with the given arguments.
|
|
4
|
+
* @param fn - The function to execute.
|
|
5
|
+
* @param args - Arguments to pass to the function.
|
|
6
|
+
* @returns The result of the function, or undefined if fn is not a function.
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types, @typescript-eslint/no-explicit-any
|
|
9
|
+
function doop<T extends (...args: any[]) => any>(
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
11
|
+
fn: T | unknown,
|
|
12
|
+
...args: Parameters<T>
|
|
13
|
+
): ReturnType<T> | undefined
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Does nothing.
|
|
17
|
+
*/
|
|
18
|
+
function noop(): void
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Throws error if present.
|
|
22
|
+
* @param err - The error to throw.
|
|
23
|
+
*/
|
|
24
|
+
function throwop(err?: unknown): void
|
|
25
|
+
|
|
26
|
+
export { doop, noop, throwop }
|
|
25
27
|
}
|