@signpostmarv/intermediary-number 0.4.0 → 0.5.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
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Intermediary Number
5
5
 
6
- Intermediary Number classes & utilities for the [Production Calculator](https://github.com/SignpostMarv/Satisfactory-Production-Calculator) for Satisfactory built upon [Docs.json.ts](https://github.com/Satisfactory-Clips-Archive/Docs.json.ts).
6
+ Intermediary Number classes & utilities for the [Production Calculator](https://github.com/satifactory-dev/Satisfactory-Production-Calculator) for Satisfactory built upon [Docs.json.ts](https://github.com/satisfactory-dev/Docs.json.ts).
7
7
 
8
8
  ## Using
9
9
 
@@ -30,5 +30,5 @@ Please refer to the tests in the meantime.
30
30
 
31
31
  ## Issues
32
32
 
33
- - Issue tracker for all the related projects except Docs.json.ts are [available on GitHub](https://github.com/users/SignpostMarv/projects/1).
34
- - [Issues with Docs.json.ts currently need to be viewed separately](https://github.com/Satisfactory-Clips-Archive/Docs.json.ts/issues).
33
+ - Issue tracker for all the related projects except Docs.json.ts are [available on GitHub](https://github.com/orgs/satisfactory-dev/projects/1).
34
+ - [Issues with Docs.json.ts currently need to be viewed separately](https://github.com/satisfactory-dev/Docs.json.ts/issues).
@@ -0,0 +1,20 @@
1
+ import config from '@signpostmarv/eslint-config';
2
+ import parser from '@typescript-eslint/parser';
3
+
4
+ export default [
5
+ {
6
+ languageOptions: {
7
+ parser,
8
+ parserOptions: {
9
+ project: ['./tsconfig.eslint.json'],
10
+ },
11
+ },
12
+ },
13
+ ...config,
14
+ {
15
+ ignores: [
16
+ '**/*.js',
17
+ '**/*.d.ts',
18
+ ]
19
+ }
20
+ ];
@@ -54,6 +54,7 @@ interface CanDoMath<ResultType extends CanDoMath_result_types = CanDoMath_result
54
54
  times(value: math_types): ResultType;
55
55
  abs(): (operand_types);
56
56
  max(first: math_types, ...remaining: math_types[]): math_types;
57
+ min(first: math_types, ...remaining: math_types[]): math_types;
57
58
  }
58
59
  interface CanResolveMath<T extends CanDoMath_result_types = CanDoMath_result_types> extends CanDoMath<T, string> {
59
60
  resolve(): IntermediaryNumber;
@@ -76,6 +77,7 @@ interface CanDoMathWithDispose<ResultType extends CanDoMath_result_types = CanDo
76
77
  interface CanResolveMathWithDispose<T extends CanDoMath_result_types = CanDoMath_result_types> extends CanResolveMath<T>, CanDoMathWithDispose<T, string> {
77
78
  }
78
79
  export declare function dispose(value: operand_types): void;
80
+ export declare function is_operation_value(maybe: string): asserts maybe is operation_types;
79
81
  export declare class IntermediaryNumber implements CanDoMathWithDispose {
80
82
  private readonly value;
81
83
  static readonly One: IntermediaryNumber;
@@ -92,6 +94,7 @@ export declare class IntermediaryNumber implements CanDoMathWithDispose {
92
94
  isOne(): boolean;
93
95
  isZero(): boolean;
94
96
  max(first: math_types, ...remaining: math_types[]): math_types;
97
+ min(first: math_types, ...remaining: math_types[]): math_types;
95
98
  minus(value: math_types): operand_types;
96
99
  modulo(value: math_types): operand_types;
97
100
  plus(value: math_types): operand_types;
@@ -131,6 +134,7 @@ export declare class IntermediaryCalculation implements CanResolveMathWithDispos
131
134
  isOne(): boolean;
132
135
  isZero(): boolean;
133
136
  max(first: math_types, ...remaining: math_types[]): math_types;
137
+ min(first: math_types, ...remaining: math_types[]): math_types;
134
138
  minus(value: math_types): operand_types;
135
139
  modulo(value: math_types): operand_types;
136
140
  plus(value: math_types): operand_types;
@@ -182,6 +186,7 @@ export declare class TokenScan implements CanResolveMathWithDispose {
182
186
  isOne(): boolean;
183
187
  isZero(): boolean;
184
188
  max(first: math_types, ...remaining: math_types[]): math_types;
189
+ min(first: math_types, ...remaining: math_types[]): math_types;
185
190
  minus(value: math_types): TokenScan;
186
191
  modulo(value: math_types): TokenScan;
187
192
  plus(value: math_types): TokenScan;
@@ -86,6 +86,16 @@ function max(first, second, ...remaining) {
86
86
  }
87
87
  return IntermediaryNumber.reuse_or_create(max);
88
88
  }
89
+ function min(first, second, ...remaining) {
90
+ let min = IntermediaryNumber.reuse_or_create(first);
91
+ for (const entry of [second, ...remaining]) {
92
+ const maybe = IntermediaryNumber.reuse_or_create(entry);
93
+ if (-1 === maybe.compare(min)) {
94
+ min = maybe;
95
+ }
96
+ }
97
+ return IntermediaryNumber.reuse_or_create(min);
98
+ }
89
99
  //#region TokenScan utility functions
90
100
  function default_tokenizer_state() {
91
101
  return {
@@ -105,7 +115,7 @@ function is_nesting_close(maybe) {
105
115
  function is_numeric(maybe) {
106
116
  return 'numeric' === maybe.type;
107
117
  }
108
- function is_operation_value(maybe) {
118
+ export function is_operation_value(maybe) {
109
119
  if (!(maybe.length === 1
110
120
  && '+-/x*%'.includes(maybe))) {
111
121
  throw new TokenScanError(`Expected operation value, found "${maybe}"`);
@@ -167,6 +177,9 @@ export class IntermediaryNumber {
167
177
  max(first, ...remaining) {
168
178
  return max(this, first, ...remaining);
169
179
  }
180
+ min(first, ...remaining) {
181
+ return min(this, first, ...remaining);
182
+ }
170
183
  minus(value) {
171
184
  return do_math(this, '-', value);
172
185
  }
@@ -428,6 +441,9 @@ export class IntermediaryCalculation {
428
441
  max(first, ...remaining) {
429
442
  return max(this, first, ...remaining);
430
443
  }
444
+ min(first, ...remaining) {
445
+ return min(this, first, ...remaining);
446
+ }
431
447
  minus(value) {
432
448
  return do_math(this, '-', value);
433
449
  }
@@ -686,6 +702,9 @@ export class TokenScan {
686
702
  max(first, ...remaining) {
687
703
  return this.parsed.max(first, ...remaining);
688
704
  }
705
+ min(first, ...remaining) {
706
+ return this.parsed.min(first, ...remaining);
707
+ }
689
708
  minus(value) {
690
709
  if (IntermediaryNumber.reuse_or_create(value).isZero()) {
691
710
  return this;
package/package.json CHANGED
@@ -11,6 +11,7 @@
11
11
  "exports": "./index.js",
12
12
  "types": "./index.d.ts",
13
13
  "devDependencies": {
14
+ "@signpostmarv/eslint-config": "^0.1.0",
14
15
  "@types/eslint": "^8.56.10",
15
16
  "@types/node": "^20.14.2",
16
17
  "c8": "^10.1.2",
@@ -22,9 +23,9 @@
22
23
  "typescript-eslint": "^7.13.0"
23
24
  },
24
25
  "dependencies": {
25
- "@satisfactory-clips-archive/custom-assert": "^0.2.1",
26
+ "@satisfactory-dev/custom-assert": "^0.2.2",
26
27
  "bignumber.js": "^9.1.2",
27
28
  "fraction.js": "^4.3.7"
28
29
  },
29
- "version": "0.4.0"
30
+ "version": "0.5.0"
30
31
  }