@signpostmarv/intermediary-number 0.2.0 → 0.3.1

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/index.js CHANGED
@@ -2,3 +2,4 @@ export * from './lib/IntermediaryNumber';
2
2
  export * from './lib/IntermediaryNumberTypes';
3
3
  export * from './lib/Numbers';
4
4
  export * from './lib/NumberStrings';
5
+ //# sourceMappingURL=index.js.map
package/lib/Docs.json.js CHANGED
@@ -4,3 +4,4 @@ export class NotAnAmountString extends Error {
4
4
  export function is_string(maybe) {
5
5
  return 'string' === typeof maybe;
6
6
  }
7
+ //# sourceMappingURL=Docs.json.js.map
@@ -653,6 +653,9 @@ export class TokenScan {
653
653
  return this.parsed.compare(value);
654
654
  }
655
655
  divide(value) {
656
+ if (IntermediaryNumber.reuse_or_create(value).isOne()) {
657
+ return this;
658
+ }
656
659
  return new TokenScan([
657
660
  this,
658
661
  '/',
@@ -684,6 +687,9 @@ export class TokenScan {
684
687
  return this.parsed.max(first, ...remaining);
685
688
  }
686
689
  minus(value) {
690
+ if (IntermediaryNumber.reuse_or_create(value).isZero()) {
691
+ return this;
692
+ }
687
693
  return new TokenScan([
688
694
  this,
689
695
  '-',
@@ -698,6 +704,9 @@ export class TokenScan {
698
704
  ]);
699
705
  }
700
706
  plus(value) {
707
+ if (IntermediaryNumber.reuse_or_create(value).isZero()) {
708
+ return this;
709
+ }
701
710
  return new TokenScan([
702
711
  this,
703
712
  '+',
@@ -709,6 +718,9 @@ export class TokenScan {
709
718
  return IntermediaryCalculation.is(parsed) ? parsed.resolve() : parsed;
710
719
  }
711
720
  times(value) {
721
+ if (IntermediaryNumber.reuse_or_create(value).isOne()) {
722
+ return this;
723
+ }
712
724
  return new TokenScan([
713
725
  this,
714
726
  'x',
@@ -739,9 +751,12 @@ export class TokenScan {
739
751
  toStringCalculation() {
740
752
  if (this.value instanceof Array) {
741
753
  const left_operand = this.value[0];
754
+ const right_operand = IntermediaryNumber.reuse_or_create(this.value[2]);
742
755
  return `${(left_operand.parsed instanceof IntermediaryNumber)
743
756
  ? left_operand.toString()
744
- : `(${left_operand.toStringCalculation()})`} ${this.value[1]} ${IntermediaryNumber.reuse_or_create(this.value[2]).toStringCalculation()}`;
757
+ : `(${left_operand.toStringCalculation()})`} ${this.value[1]} ${(right_operand instanceof IntermediaryNumber)
758
+ ? right_operand.toStringCalculation()
759
+ : `(${right_operand.toStringCalculation()})`}`;
745
760
  }
746
761
  return this.value;
747
762
  }
@@ -978,3 +993,4 @@ export class TokenScan {
978
993
  }
979
994
  }
980
995
  //#endregion
996
+ //# sourceMappingURL=IntermediaryNumber.js.map
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=IntermediaryNumberTypes.js.map
@@ -51,3 +51,4 @@ export class NumberStrings {
51
51
  }
52
52
  }
53
53
  }
54
+ //# sourceMappingURL=NumberStrings.js.map
package/lib/Numbers.js CHANGED
@@ -47,3 +47,4 @@ export class Numbers {
47
47
  return result;
48
48
  }
49
49
  }
50
+ //# sourceMappingURL=Numbers.js.map
package/package.json CHANGED
@@ -9,24 +9,22 @@
9
9
  },
10
10
  "funding": "https://github.com/SignpostMarv/Intermediary-Number?sponsor=1",
11
11
  "exports": "./index.js",
12
+ "types": "./index.d.ts",
12
13
  "devDependencies": {
13
- "@eslint/js": "^9.4.0",
14
- "@stdlib/types": "^0.3.2",
15
14
  "@types/eslint": "^8.56.10",
16
15
  "@types/node": "^20.14.2",
17
- "c8": "^9.1.0",
16
+ "c8": "^10.1.2",
18
17
  "eslint": "^8.57.0",
19
18
  "glob": "^10.4.1",
20
19
  "prettier": "^3.3.2",
21
20
  "ts-node": "^10.9.2",
22
- "tslib": "^2.6.3",
23
- "typescript": "^5.4.5",
21
+ "typescript": "~5.4.5",
24
22
  "typescript-eslint": "^7.13.0"
25
23
  },
26
24
  "dependencies": {
27
- "@satisfactory-clips-archive/custom-assert": "^0.1.2",
25
+ "@satisfactory-clips-archive/custom-assert": "^0.1.4",
28
26
  "bignumber.js": "^9.1.2",
29
27
  "fraction.js": "^4.3.7"
30
28
  },
31
- "version": "0.2.0"
29
+ "version": "0.3.1"
32
30
  }