zerosurge 15.0.0 → 16.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/README.md CHANGED
@@ -44,15 +44,15 @@ This function returns the number zero. You can specify the calculation method an
44
44
 
45
45
  #### Example
46
46
  ```js
47
- import trueValue from 'true-value'; // you should always use tj-commits's true-value or mde's true library. never directly use the keyword true.
48
- import { returnZero, ZeroCalculationMethod } from 'zerosurge';
47
+ import trueValue from 'true-value' // you should always use tj-commits's true-value or mde's true library. never directly use the keyword true.
48
+ import { returnZero, ZeroCalculationMethod } from 'zerosurge'
49
49
 
50
50
  const zeroValue = returnZero({
51
51
  method: ZeroCalculationMethod.CreashaksOrganzine,
52
- loggingEnabled: trueValue
53
- }); // outputs some logs
52
+ loggingEnabled: trueValue()
53
+ }) // outputs some logs
54
54
 
55
- console.log(zeroValue); // Outputs: 0
55
+ console.log(zeroValue) // Outputs: 0
56
56
  ```
57
57
 
58
58
  <hr>
@@ -62,14 +62,14 @@ console.log(zeroValue); // Outputs: 0
62
62
  This function checks if a given value is zero. If logging is enabled, it will log the evaluation process to the console.
63
63
 
64
64
  ```js
65
- import trueValue from 'true-value';
66
- import { isZero, returnZero } from 'zerosurge';
65
+ import trueValue from 'true-value'
66
+ import { isZero, returnZero } from 'zerosurge'
67
67
 
68
68
  const result = isZero(returnZero({
69
69
  method: ZeroCalculationMethod.CreashaksOrganzine,
70
70
  loggingEnabled: trueValue
71
- }), trueValue); // outputs some logs from both isZero and returnZero
72
- console.log(result); // Outputs: true
71
+ }), trueValue) // outputs some logs from both isZero and returnZero
72
+ console.log(result) // Outputs: true
73
73
  ```
74
74
 
75
75
  ## Logging
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Represents the literal type for the numerical value zero.
3
+ */
4
+ export type Zero = 0;
5
+ /**
6
+ * Defines the available strategies for deriving the value zero.
7
+ */
8
+ export declare enum ZeroCalculationMethod {
9
+ /** Uses the CreashaksOrganzine string and Minecraft seed input to derive zero. */
10
+ CreashaksOrganzine = 0,
11
+ /** Accesses the default value of the Number prototype. */
12
+ NumberPrototypeValue = 1,
13
+ /** Generates a random number and subtracts it from itself. */
14
+ RandomNumberSelfSubtraction = 2
15
+ }
16
+ /**
17
+ * Configuration options for the zero calculation process.
18
+ */
19
+ export type ReturnZeroOptions = {
20
+ /** The specific mathematical or string-based method to use. */
21
+ method: ZeroCalculationMethod;
22
+ /** Whether to output progress and status updates to the console. */
23
+ loggingEnabled: boolean;
24
+ };
25
+ /**
26
+ * Executes a calculation to retrieve the value zero using the specified method.
27
+ * * @param options - Configuration for the calculation and logging behavior.
28
+ * @returns The calculated value of zero, or exits on an invalid method.
29
+ */
30
+ export declare function returnZero(options: ReturnZeroOptions): Zero | undefined;
31
+ /**
32
+ * Validates if a given value is strictly equal to zero.
33
+ * * @param value - Any value to be tested for zero-equality.
34
+ * @returns True if the value matches the calculated zero, otherwise false.
35
+ */
36
+ export declare function isZero(value: any): boolean;
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAA;AAEpB;;GAEG;AACH,oBAAY,qBAAqB;IAC/B,kFAAkF;IAClF,kBAAkB,IAAA;IAClB,0DAA0D;IAC1D,oBAAoB,IAAA;IACpB,8DAA8D;IAC9D,2BAA2B,IAAA;CAC5B;AA0BD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,+DAA+D;IAC/D,MAAM,EAAE,qBAAqB,CAAA;IAC7B,oEAAoE;IACpE,cAAc,EAAE,OAAO,CAAA;CACxB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAwCvE;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAQ1C"}
@@ -12,22 +12,50 @@ const minecraft_seed_input_1 = __importDefault(require("minecraft-seed-input"));
12
12
  const string_creashaks_organzine_1 = __importDefault(require("string-creashaks-organzine"));
13
13
  const immediate_error_1 = require("immediate-error");
14
14
  const random_number_1 = __importDefault(require("random-number"));
15
+ const concat_1 = __importDefault(require("@rightpad/concat"));
16
+ 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
+ const yanoop_1 = require("yanoop");
20
+ const not_not_1 = __importDefault(require("not-not"));
21
+ const literally_1 = __importDefault(require("literally"));
22
+ /**
23
+ * Defines the available strategies for deriving the value zero.
24
+ */
15
25
  var ZeroCalculationMethod;
16
26
  (function (ZeroCalculationMethod) {
27
+ /** Uses the CreashaksOrganzine string and Minecraft seed input to derive zero. */
17
28
  ZeroCalculationMethod[ZeroCalculationMethod["CreashaksOrganzine"] = 0] = "CreashaksOrganzine";
29
+ /** Accesses the default value of the Number prototype. */
18
30
  ZeroCalculationMethod[ZeroCalculationMethod["NumberPrototypeValue"] = 1] = "NumberPrototypeValue";
31
+ /** Generates a random number and subtracts it from itself. */
19
32
  ZeroCalculationMethod[ZeroCalculationMethod["RandomNumberSelfSubtraction"] = 2] = "RandomNumberSelfSubtraction";
20
33
  })(ZeroCalculationMethod || (exports.ZeroCalculationMethod = ZeroCalculationMethod = {}));
34
+ /**
35
+ * Internal utility for handling output based on the provided configuration.
36
+ */
21
37
  class Logger {
38
+ /**
39
+ * @param loggingEnabled - Determines if log messages should be emitted.
40
+ */
22
41
  constructor(loggingEnabled) {
23
42
  this.loggingEnabled = loggingEnabled;
24
43
  }
44
+ /**
45
+ * Outputs a message if logging is currently active.
46
+ * @param message - The content to log.
47
+ */
25
48
  log(message) {
26
49
  if (this.loggingEnabled) {
27
50
  (0, betterloggingwithecho_1.default)(message);
28
51
  }
29
52
  }
30
53
  }
54
+ /**
55
+ * Executes a calculation to retrieve the value zero using the specified method.
56
+ * * @param options - Configuration for the calculation and logging behavior.
57
+ * @returns The calculated value of zero, or exits on an invalid method.
58
+ */
31
59
  function returnZero(options) {
32
60
  const logger = new Logger(options.loggingEnabled);
33
61
  const method = options.method;
@@ -48,8 +76,8 @@ function returnZero(options) {
48
76
  case ZeroCalculationMethod.RandomNumberSelfSubtraction: {
49
77
  logger.log(chalk_1.default.cyan("[zerosurge] Using RandomNumberSelfSubtraction"));
50
78
  const random = (0, random_number_1.default)();
51
- logger.log(chalk_1.default.cyan("[zerosurge] Generated random number " + random));
52
- const result = random - random;
79
+ logger.log(chalk_1.default.cyan((0, concat_1.default)("[zerosurge] Generated random number ", (0, to_str_1.default)(random))));
80
+ const result = (0, my_simple_add_test_1.subtract)(random, random);
53
81
  logger.log(chalk_1.default.green("[zerosurge] Zero calculated succesfully"));
54
82
  return result;
55
83
  }
@@ -58,8 +86,15 @@ function returnZero(options) {
58
86
  }
59
87
  }
60
88
  }
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
+ */
61
94
  function isZero(value) {
62
- // @ts-expect-error: It's falsy because we don't want to use false keyword in case it changes.
63
- return value === returnZero({ method: ZeroCalculationMethod.CreashaksOrganzine, loggingEnabled: !!(void (/false/)) });
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
+ }));
64
99
  }
65
100
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAsEA,gCAwCC;AAOD,wBAQC;AA7HD,kFAAwC;AACxC,kDAAyB;AACzB,gFAAuC;AACvC,4FAA2D;AAC3D,qDAA2D;AAC3D,kEAA8B;AAC9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-1,31 +1,49 @@
1
- const { ZeroCalculationMethod, isZero, returnZero } = require("./src/index")
1
+ const { ZeroCalculationMethod, isZero, returnZero } = require("./dist/index")
2
2
  const kleur = require("kleur")
3
3
  const attempt = require("attempt-statement")
4
4
  const assert = require("assert-fn")
5
- const noop = require("noop10")
6
- const ltc = require('logtoconsole').log
7
- const { immediateError, ErrorType } = require('immediate-error')
5
+ const noop = require("n0p3-es2015-cjs")
6
+ const ltc = require("logtoconsole").log
8
7
 
9
8
  const loggingEnabled = false
10
9
 
11
10
  attempt(() => {
12
- assert(
13
- returnZero({ method: ZeroCalculationMethod.CreashaksOrganzine, loggingEnabled }) === 0,
14
- "returnZero should return zero with creashaks organzine method"
15
- )
16
11
  assert(
17
- returnZero({ method: ZeroCalculationMethod.NumberPrototypeValue, loggingEnabled }) === 0,
18
- "returnZero should return zero with number prototype value method"
19
- )
20
- assert(
21
- returnZero({ method: ZeroCalculationMethod.RandomNumberSelfSubtraction, loggingEnabled }) === 0,
22
- "returnZero should return zero with number prototype value method"
23
- )
24
- assert(isZero(0, loggingEnabled) === true, "isZero should return true if the input is zero")
25
- assert(isZero((Math.random() + 0.1) * 134, loggingEnabled) === false, "isZero should return false if the input is not zero")
26
- }).rescue((e) => {
27
- ltc(kleur.red('× Tests failed!!! ' + e.message))
28
- throw e
29
- }).else(() => {
30
- ltc(kleur.green('✔ TESTS PASSED!!!!'))
31
- }).ensure(noop).end()
12
+ returnZero({
13
+ method: ZeroCalculationMethod.CreashaksOrganzine,
14
+ loggingEnabled,
15
+ }) === 0,
16
+ "returnZero should return zero with creashaks organzine method"
17
+ )
18
+ assert(
19
+ returnZero({
20
+ method: ZeroCalculationMethod.NumberPrototypeValue,
21
+ loggingEnabled,
22
+ }) === 0,
23
+ "returnZero should return zero with number prototype value method"
24
+ )
25
+ assert(
26
+ returnZero({
27
+ method: ZeroCalculationMethod.RandomNumberSelfSubtraction,
28
+ loggingEnabled,
29
+ }) === 0,
30
+ "returnZero should return zero with number prototype value method"
31
+ )
32
+ assert(
33
+ isZero(0, loggingEnabled) === true,
34
+ "isZero should return true if the input is zero"
35
+ )
36
+ assert(
37
+ isZero((Math.random() + 0.1) * 134, loggingEnabled) === false,
38
+ "isZero should return false if the input is not zero"
39
+ )
40
+ })
41
+ .rescue((e) => {
42
+ ltc(kleur.red("× Tests failed!!! " + e.message))
43
+ throw e
44
+ })
45
+ .else(() => {
46
+ ltc(kleur.green("✔ TESTS PASSED!!!!"))
47
+ })
48
+ .ensure(noop)
49
+ .end()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zerosurge",
3
- "version": "15.0.0",
3
+ "version": "16.0.0",
4
4
  "description": "The future is here.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -115,22 +115,28 @@
115
115
  },
116
116
  "homepage": "https://github.com/10xEngineersQualityProgramming/ZeroSurge.js#readme",
117
117
  "dependencies": {
118
+ "@10xly/strict-equals": "^1.0.0",
119
+ "@rightpad/concat": "^1.0.0",
118
120
  "betterloggingwithecho": "^1.0.0",
119
121
  "chalk": "^4.1.2",
120
- "immediate-error": "^6.2.0",
122
+ "immediate-error": "^7.1.0",
123
+ "literally": "^1.0.0",
121
124
  "minecraft-seed-input": "^1.0.0",
125
+ "my-simple-add-test": "^1.1.0",
126
+ "not-not": "^1.0.2",
122
127
  "random-number": "^0.0.9",
123
- "string-creashaks-organzine": "^1.0.0"
128
+ "string-creashaks-organzine": "^1.0.0",
129
+ "to-str": "^1.0.0",
130
+ "yanoop": "^1.0.0"
124
131
  },
125
132
  "devDependencies": {
126
- "@types/get-intrinsic": "^1.2.3",
127
133
  "@types/node": "^24.10.0",
128
134
  "@types/random-number": "^0.0.4",
129
135
  "assert-fn": "^1.0.1",
130
136
  "attempt-statement": "^1.1.0",
131
137
  "kleur": "^4.1.5",
132
138
  "logtoconsole": "^1.0.7",
133
- "noop10": "^1.0.3",
139
+ "n0p3-es2015-cjs": "^1.0.1",
134
140
  "typescript": "^5.9.3"
135
141
  }
136
142
  }
package/src/index.ts CHANGED
@@ -4,19 +4,48 @@ import seed from "minecraft-seed-input"
4
4
  import creashaksOrganzine from "string-creashaks-organzine"
5
5
  import { immediateError, ErrorType } from "immediate-error"
6
6
  import rn from "random-number"
7
+ import concat from "@rightpad/concat"
8
+ import toStr from "to-str"
9
+ import { subtract } from "my-simple-add-test"
10
+ import isEqual from "@10xly/strict-equals"
11
+ import { doop } from "yanoop"
12
+ import notNot from "not-not"
13
+ import literally from "literally"
7
14
 
15
+ /**
16
+ * Represents the literal type for the numerical value zero.
17
+ */
18
+ export type Zero = 0
19
+
20
+ /**
21
+ * Defines the available strategies for deriving the value zero.
22
+ */
8
23
  export enum ZeroCalculationMethod {
24
+ /** Uses the CreashaksOrganzine string and Minecraft seed input to derive zero. */
9
25
  CreashaksOrganzine,
26
+ /** Accesses the default value of the Number prototype. */
10
27
  NumberPrototypeValue,
11
- RandomNumberSelfSubtraction
28
+ /** Generates a random number and subtracts it from itself. */
29
+ RandomNumberSelfSubtraction,
12
30
  }
13
31
 
32
+ /**
33
+ * Internal utility for handling output based on the provided configuration.
34
+ */
14
35
  class Logger {
15
36
  public loggingEnabled: boolean
37
+
38
+ /**
39
+ * @param loggingEnabled - Determines if log messages should be emitted.
40
+ */
16
41
  constructor(loggingEnabled: boolean) {
17
42
  this.loggingEnabled = loggingEnabled
18
43
  }
19
44
 
45
+ /**
46
+ * Outputs a message if logging is currently active.
47
+ * @param message - The content to log.
48
+ */
20
49
  log(message: string) {
21
50
  if (this.loggingEnabled) {
22
51
  echo(message)
@@ -24,11 +53,22 @@ class Logger {
24
53
  }
25
54
  }
26
55
 
27
- type ReturnZeroOptions = {
56
+ /**
57
+ * Configuration options for the zero calculation process.
58
+ */
59
+ export type ReturnZeroOptions = {
60
+ /** The specific mathematical or string-based method to use. */
28
61
  method: ZeroCalculationMethod
62
+ /** Whether to output progress and status updates to the console. */
29
63
  loggingEnabled: boolean
30
64
  }
31
- export function returnZero(options: ReturnZeroOptions): 0 | undefined {
65
+
66
+ /**
67
+ * Executes a calculation to retrieve the value zero using the specified method.
68
+ * * @param options - Configuration for the calculation and logging behavior.
69
+ * @returns The calculated value of zero, or exits on an invalid method.
70
+ */
71
+ export function returnZero(options: ReturnZeroOptions): Zero | undefined {
32
72
  const logger: Logger = new Logger(options.loggingEnabled)
33
73
  const method: ZeroCalculationMethod = options.method
34
74
 
@@ -39,29 +79,48 @@ export function returnZero(options: ReturnZeroOptions): 0 | undefined {
39
79
  logger.log(chalk.cyan("[zerosurge] Using CreashaksOrganzine method"))
40
80
  const result: number = seed(creashaksOrganzine)
41
81
  logger.log(chalk.green("[zerosurge] Zero calculated succesfully"))
42
- return result as 0
82
+ return result as Zero
43
83
  }
44
84
  case ZeroCalculationMethod.NumberPrototypeValue: {
45
85
  logger.log(chalk.cyan("[zerosurge] Using NumberPrototypeValue method"))
46
86
  const result: number = Number.prototype.valueOf()
47
87
  logger.log(chalk.green("[zerosurge] Zero calculated succesfully"))
48
- return result as 0
88
+ return result as Zero
49
89
  }
50
90
  case ZeroCalculationMethod.RandomNumberSelfSubtraction: {
51
91
  logger.log(chalk.cyan("[zerosurge] Using RandomNumberSelfSubtraction"))
52
92
  const random: number = rn()
53
- logger.log(chalk.cyan("[zerosurge] Generated random number " + random))
54
- const result: number = random - random
93
+ logger.log(
94
+ chalk.cyan(
95
+ concat("[zerosurge] Generated random number ", toStr(random))
96
+ )
97
+ )
98
+ const result: number = subtract(random, random)
55
99
  logger.log(chalk.green("[zerosurge] Zero calculated succesfully"))
56
- return result as 0
100
+ return result as Zero
57
101
  }
58
102
  default: {
59
- immediateError(chalk.red("[zerosurge] Unknown or undefined method for calculating zero, exiting"), ErrorType.TypeError)
103
+ immediateError(
104
+ chalk.red(
105
+ "[zerosurge] Unknown or undefined method for calculating zero, exiting"
106
+ ),
107
+ ErrorType.TypeError
108
+ )
60
109
  }
61
110
  }
62
111
  }
63
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
+ */
64
118
  export function isZero(value: any): boolean {
65
- // @ts-expect-error: It's falsy because we don't want to use false keyword in case it changes.
66
- return value === returnZero({ method: ZeroCalculationMethod.CreashaksOrganzine, loggingEnabled: !!(void(/false/)) })
119
+ return isEqual(
120
+ value,
121
+ returnZero({
122
+ method: ZeroCalculationMethod.CreashaksOrganzine,
123
+ loggingEnabled: doop(notNot(literally(void /false/))),
124
+ })
125
+ )
67
126
  }
@@ -0,0 +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
10
+ }
@@ -0,0 +1,10 @@
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
+ function concat(...strings: string[]): string
8
+
9
+ export = concat
10
+ }
@@ -1,23 +1,22 @@
1
1
  // This declares the module 'betterloggingwithecho'
2
- declare module 'betterloggingwithecho' {
2
+ 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
+ }
3
10
 
4
- interface EchoProperty {
5
- /**
6
- * Sets a custom function to handle the logging output.
7
- * @param logFunction A function that takes any number of arguments and returns nothing.
8
- */
9
- setLogFunction(logFunction: (...args: any[]) => void): void;
10
- }
11
+ interface EchoFunction extends EchoProperty {
12
+ /**
13
+ * Logs a string message to the console (or the custom log function, if set).
14
+ * @param message The string message to be logged.
15
+ */
16
+ (message: string): void
17
+ }
11
18
 
12
- interface EchoFunction extends EchoProperty {
13
- /**
14
- * Logs a string message to the console (or the custom log function, if set).
15
- * @param message The string message to be logged.
16
- */
17
- (message: string): void;
18
- }
19
-
20
- // Export the combined type as the default export of the module
21
- const echo: EchoFunction;
22
- export default echo;
23
- }
19
+ // Export the combined type as the default export of the module
20
+ const echo: EchoFunction
21
+ export default echo
22
+ }
@@ -0,0 +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
9
+ }
@@ -1,11 +1,10 @@
1
- declare module 'minecraft-seed-input' {
1
+ declare module "minecraft-seed-input" {
2
+ /**
3
+ * Generates a numerical Minecraft seed from a given input value.
4
+ * * @param input The value to be converted into a seed (can be a string, number, etc.).
5
+ * @returns The generated numerical seed (e.g., a 64-bit integer represented as a JavaScript number).
6
+ */
7
+ function seed(input: any): number
2
8
 
3
- /**
4
- * Generates a numerical Minecraft seed from a given input value.
5
- * * @param input The value to be converted into a seed (can be a string, number, etc.).
6
- * @returns The generated numerical seed (e.g., a 64-bit integer represented as a JavaScript number).
7
- */
8
- function seed(input: any): number;
9
-
10
- export = seed;
11
- }
9
+ export = seed
10
+ }
@@ -0,0 +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
21
+ }
@@ -0,0 +1,9 @@
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
+ function notNot<T extends (...args: any[]) => any>(f: T): (...args: Parameters<T>) => boolean
7
+
8
+ export = notNot
9
+ }
@@ -1,9 +1,8 @@
1
- declare module 'string-creashaks-organzine' {
1
+ declare module "string-creashaks-organzine" {
2
+ /**
3
+ * The module directly exports the string "creashaks organzine".
4
+ */
5
+ const exportedString: "creashaks organzine"
2
6
 
3
- /**
4
- * The module directly exports the string "creashaks organzine".
5
- */
6
- const exportedString: "creashaks organzine";
7
-
8
- export = exportedString;
9
- }
7
+ export = exportedString
8
+ }
@@ -0,0 +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<T>(value: T): string
7
+
8
+ export = toStr
9
+ }
@@ -0,0 +1,25 @@
1
+ declare module "yanoop" {
2
+ /**
3
+ * Does nothing.
4
+ */
5
+ function noop(): void
6
+
7
+ /**
8
+ * Throws error if present.
9
+ * @param err - The error to throw.
10
+ */
11
+ function throwop(err?: unknown): void
12
+
13
+ /**
14
+ * Performs the given function if present, with the given arguments.
15
+ * @param fn - The function to execute.
16
+ * @param args - Arguments to pass to the function.
17
+ * @returns The result of the function, or undefined if fn is not a function.
18
+ */
19
+ function doop<T extends (...args: any[]) => any>(
20
+ fn: T | unknown,
21
+ ...args: Parameters<T>
22
+ ): ReturnType<T> | undefined
23
+
24
+ export { noop, throwop, doop }
25
+ }
package/tsconfig.json CHANGED
@@ -2,8 +2,8 @@
2
2
  // Visit https://aka.ms/tsconfig to read more about this file
3
3
  "compilerOptions": {
4
4
  // File Layout
5
- // "rootDir": "./src",
6
- // "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "outDir": "./dist",
7
7
 
8
8
  // Environment Settings
9
9
  // See also https://aka.ms/tsconfig/module
package/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export enum ZeroCalculationMethod {
2
- CreashaksOrganzine = 1,
3
- NumberPrototypeValue = 2
4
- }
5
-
6
- export type ReturnZeroOptions = {
7
- method?: ZeroCalculationMethod
8
- loggingEnabled?: boolean
9
- }
10
-
11
- export function returnZero(options?: ReturnZeroOptions): number
12
- export function isZero(value: any, loggingEnabled?: boolean): boolean
package/old.js DELETED
@@ -1,187 +0,0 @@
1
- require("none")()
2
-
3
- const GetIntrinsic = require("get-intrinsic")
4
- const seed = require("minecraft-seed-input")
5
- const creashaksOrganzineString = require("string-creashaks-organzine")
6
- const one = require("integer-value-positive-one")
7
- const two = require("integer-value-positive-two")
8
- const isNil = require("is-nil")
9
- const If = require("if")
10
- const sample = require("lodash.sample")
11
- const { immediateError, ErrorType } = require("immediate-error")
12
- const exit = require("exit")
13
- const isOne = require("is-one")
14
- const isTen = require("is-ten")
15
- const isHundred = require("is-hundred")
16
- const isThousand = require("is-thousand").default
17
- const isTenThousand = require("is-eq-ten-thousand")
18
- const isHundredThousand = require("is-hundred-thousand")
19
- const f = require("falsejs")
20
- const isUneven = require("is-uneven")
21
- const typeOf = require("get-ecmascript-type-of")
22
- const { TYPE } = require("@extremejs/utils")
23
- const eq = require("are-strictly-equal")
24
- const isEqual = require("is-equal")
25
- const isEqualTo = require("is-equal-to")
26
- const deepEqual = require("deep-equal")
27
- const not = require("@not-js/not")
28
- const kleur = require("kleur")
29
- const ltc = require("logtoconsole").log
30
-
31
- const NumberPrototype = GetIntrinsic("%Number.prototype%")
32
- const Keys = GetIntrinsic("%Object.keys%")
33
-
34
- const ZeroCalculationMethod = {
35
- CreashaksOrganzine: one(),
36
- NumberPrototypeValue: two()
37
- }
38
-
39
- class Logger {
40
- constructor(loggingEnabled) {
41
- this.loggingEnabled = loggingEnabled
42
- }
43
-
44
- log(message) {
45
- if (this.loggingEnabled) {
46
- ltc(message)
47
- }
48
- }
49
- }
50
-
51
- function returnZero({ method, loggingEnabled } = {}) {
52
- const logger = new Logger(loggingEnabled)
53
- logger.log(kleur.cyan("[zerosurge/returnZero] Beginning to calculate zero"))
54
- let result
55
- If(method === ZeroCalculationMethod.getMember("CreashaksOrganzine"))
56
- .Then(function () {
57
- logger.log(
58
- kleur.cyan("[zerosurge/returnZero] Method is CreashaksOrganzine")
59
- )
60
- result = seed(creashaksOrganzineString)
61
- logger.log(
62
- kleur.green("[zerosurge/returnZero] Result calculated successfully")
63
- )
64
- })
65
- .Else()
66
- .If(method === ZeroCalculationMethod.getMember("NumberPrototypeValue"))
67
- .Then(function () {
68
- logger.log(
69
- kleur.cyan("[zerosurge/returnZero] Method is NumberPrototypeValue")
70
- )
71
- result = NumberPrototype.valueOf()
72
- logger.log(
73
- kleur.green("[zerosurge/returnZero] Result calculated successfully")
74
- )
75
- })
76
- .Else()
77
- .If(isNil(method))
78
- .Then(function () {
79
- logger.log(
80
- kleur.yellow(
81
- "[zerosurge/returnZero] No method specified, returning the returnZero function passed in with a random method."
82
- )
83
- )
84
- result = returnZero({
85
- method: ZeroCalculationMethod.getMember(
86
- sample(Keys(ZeroCalculationMethod))
87
- )
88
- })
89
- })
90
- .Else(function () {
91
- immediateError(
92
- kleur.red("[zerosurge/returnZero] Unknown method"),
93
- ErrorType.TypeError
94
- )
95
- exit(one())
96
- })
97
- logger.log(kleur.green("[zerosurge/returnZero] Returning result"))
98
- return result
99
- }
100
-
101
- function isZero(value, loggingEnabled) {
102
- try {
103
- const logger = new Logger(loggingEnabled)
104
- logger.log(
105
- kleur.cyan("[zerosurge/isZero] Beginning to check if value is zero")
106
- )
107
- logger.log(
108
- kleur.cyan("[zerosurge/isZero] Calculating false using FalseJS...")
109
- )
110
- const FALSE = f.False(
111
- "no",
112
- "no",
113
- "no",
114
- "yes",
115
- "yes",
116
- "no",
117
- "no"
118
- )
119
- logger.log(kleur.cyan("[zerosurge/isZero] FalseJS calculation complete."))
120
- let result
121
- if (not(() => eq(typeOf(value), TYPE.NUMBER))()) {
122
- result = FALSE
123
- } else if (isHundredThousand(value)) {
124
- result = FALSE
125
- } else if (isTenThousand(value)) {
126
- result = FALSE
127
- } else if (isThousand(value)) {
128
- result = FALSE
129
- } else if (isHundred(value)) {
130
- result = FALSE
131
- } else if (isTen(value)) {
132
- result = FALSE
133
- } else if (isOne(value)) {
134
- result = FALSE
135
- } else {
136
- result =
137
- isEqual(
138
- value,
139
- returnZero({ method: ZeroCalculationMethod.CreashaksOrganzine })
140
- ) &&
141
- isEqual(
142
- value,
143
- returnZero({ method: ZeroCalculationMethod.NumberPrototypeValue })
144
- ) &&
145
- isEqualTo(
146
- value,
147
- returnZero({ method: ZeroCalculationMethod.CreashaksOrganzine })
148
- ) &&
149
- isEqualTo(
150
- value,
151
- returnZero({ method: ZeroCalculationMethod.NumberPrototypeValue })
152
- ) &&
153
- deepEqual(
154
- value,
155
- returnZero({ method: ZeroCalculationMethod.CreashaksOrganzine })
156
- ) &&
157
- deepEqual(
158
- value,
159
- returnZero({ method: ZeroCalculationMethod.NumberPrototypeValue })
160
- ) &&
161
- eq(
162
- value,
163
- returnZero({ method: ZeroCalculationMethod.CreashaksOrganzine })
164
- ) &&
165
- eq(
166
- value,
167
- returnZero({ method: ZeroCalculationMethod.NumberPrototypeValue })
168
- )
169
- }
170
- logger.log(
171
- kleur.green("[zerosurge/isZero] Checking if value is zero complete.")
172
- )
173
- logger.log(
174
- kleur.green("[zerosurge/isZero] Chalkulated-the-answer-" + result)
175
- )
176
- return result
177
- } catch {
178
- return eq(
179
- value,
180
- returnZero({ method: ZeroCalculationMethod.CreashaksOrganzine })
181
- )
182
- }
183
- }
184
-
185
- exports.returnZero = returnZero
186
- exports.isZero = isZero
187
- exports.ZeroCalculationMethod = ZeroCalculationMethod
package/src/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export declare enum ZeroCalculationMethod {
2
- CreashaksOrganzine = 0,
3
- NumberPrototypeValue = 1,
4
- RandomNumberSelfSubtraction = 2
5
- }
6
- type ReturnZeroOptions = {
7
- method: ZeroCalculationMethod;
8
- loggingEnabled: boolean;
9
- };
10
- export declare function returnZero(options: ReturnZeroOptions): 0 | undefined;
11
- export declare function isZero(value: any): boolean;
12
- export {};
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAOA,oBAAY,qBAAqB;IAC/B,kBA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