sushi 6.1.4 → 6.1.5
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/_cjs/generic/math/percent.js +12 -0
- package/_cjs/generic/math/percent.js.map +1 -1
- package/_esm/generic/math/percent.js +12 -0
- package/_esm/generic/math/percent.js.map +1 -1
- package/_types/generic/math/percent.d.ts +5 -0
- package/_types/generic/math/percent.d.ts.map +1 -1
- package/generic/math/percent.ts +17 -0
- package/package.json +1 -1
|
@@ -4,6 +4,18 @@ exports.Percent = void 0;
|
|
|
4
4
|
const number_js_1 = require("../format/number.js");
|
|
5
5
|
const fraction_js_1 = require("./fraction.js");
|
|
6
6
|
class Percent extends fraction_js_1.Fraction {
|
|
7
|
+
add(other) {
|
|
8
|
+
return new Percent(super.add(other));
|
|
9
|
+
}
|
|
10
|
+
sub(other) {
|
|
11
|
+
return new Percent(super.sub(other));
|
|
12
|
+
}
|
|
13
|
+
mul(other) {
|
|
14
|
+
return new Percent(super.mul(other));
|
|
15
|
+
}
|
|
16
|
+
div(other) {
|
|
17
|
+
return new Percent(super.div(other));
|
|
18
|
+
}
|
|
7
19
|
toString(args = { fixed: 2 }) {
|
|
8
20
|
const num = this.toNumber() * 100;
|
|
9
21
|
const str = (0, number_js_1.numberToFixed)(num, args);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"percent.js","sourceRoot":"","sources":["../../../generic/math/percent.ts"],"names":[],"mappings":";;;AAAA,mDAAmD;
|
|
1
|
+
{"version":3,"file":"percent.js","sourceRoot":"","sources":["../../../generic/math/percent.ts"],"names":[],"mappings":";;;AAAA,mDAAmD;AAEnD,+CAAwC;AAExC,MAAa,OAAQ,SAAQ,sBAAQ;IACnB,GAAG,CAAC,KAA2B;QAC7C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACtC,CAAC;IAEe,GAAG,CAAC,KAA2B;QAC7C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACtC,CAAC;IAEe,GAAG,CAAC,KAA2B;QAC7C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACtC,CAAC;IAEe,GAAG,CAAC,KAA2B;QAC7C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACtC,CAAC;IAQe,QAAQ,CACtB,OAA4C,EAAE,KAAK,EAAE,CAAC,EAAE;QAExD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAA;QACjC,MAAM,GAAG,GAAG,IAAA,yBAAa,EAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QAEpC,OAAO,GAAG,CAAA;IACZ,CAAC;IAEM,eAAe,CACpB,OAA4C,EAAE,KAAK,EAAE,CAAC,EAAE;QAExD,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAA;IAClC,CAAC;CACF;AArCD,0BAqCC"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { numberToFixed } from '../format/number.js';
|
|
2
2
|
import { Fraction } from './fraction.js';
|
|
3
3
|
export class Percent extends Fraction {
|
|
4
|
+
add(other) {
|
|
5
|
+
return new Percent(super.add(other));
|
|
6
|
+
}
|
|
7
|
+
sub(other) {
|
|
8
|
+
return new Percent(super.sub(other));
|
|
9
|
+
}
|
|
10
|
+
mul(other) {
|
|
11
|
+
return new Percent(super.mul(other));
|
|
12
|
+
}
|
|
13
|
+
div(other) {
|
|
14
|
+
return new Percent(super.div(other));
|
|
15
|
+
}
|
|
4
16
|
/**
|
|
5
17
|
*
|
|
6
18
|
* @param args.maxFixed - The maximum number of fixed decimal places to display, only if relevant, eg. "0" for 0, "1.23" for 0.0123, etc.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"percent.js","sourceRoot":"","sources":["../../../generic/math/percent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"percent.js","sourceRoot":"","sources":["../../../generic/math/percent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,OAAO,OAAQ,SAAQ,QAAQ;IACnB,GAAG,CAAC,KAA2B;QAC7C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACtC,CAAC;IAEe,GAAG,CAAC,KAA2B;QAC7C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACtC,CAAC;IAEe,GAAG,CAAC,KAA2B;QAC7C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACtC,CAAC;IAEe,GAAG,CAAC,KAA2B;QAC7C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACtC,CAAC;IAED;;;;;OAKG;IACa,QAAQ,CACtB,OAA4C,EAAE,KAAK,EAAE,CAAC,EAAE;QAExD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAA;QACjC,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QAEpC,OAAO,GAAG,CAAA;IACZ,CAAC;IAEM,eAAe,CACpB,OAA4C,EAAE,KAAK,EAAE,CAAC,EAAE;QAExD,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAA;IAClC,CAAC;CACF"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { numberToFixed } from '../format/number.js';
|
|
2
|
+
import type { BigintIsh } from '../types/bigintish.js';
|
|
2
3
|
import { Fraction } from './fraction.js';
|
|
3
4
|
export declare class Percent extends Fraction {
|
|
5
|
+
add(other: Fraction | BigintIsh): Percent;
|
|
6
|
+
sub(other: Fraction | BigintIsh): Fraction;
|
|
7
|
+
mul(other: Fraction | BigintIsh): Percent;
|
|
8
|
+
div(other: Fraction | BigintIsh): Percent;
|
|
4
9
|
/**
|
|
5
10
|
*
|
|
6
11
|
* @param args.maxFixed - The maximum number of fixed decimal places to display, only if relevant, eg. "0" for 0, "1.23" for 0.0123, etc.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"percent.d.ts","sourceRoot":"","sources":["../../../generic/math/percent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,OAAQ,SAAQ,QAAQ;
|
|
1
|
+
{"version":3,"file":"percent.d.ts","sourceRoot":"","sources":["../../../generic/math/percent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,OAAQ,SAAQ,QAAQ;IACnB,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO;IAIzC,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ;IAI1C,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO;IAIzC,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO;IAIzD;;;;;OAKG;IACa,QAAQ,CACtB,IAAI,GAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAgB,GACvD,MAAM;IAOF,eAAe,CACpB,IAAI,GAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAgB,GACvD,MAAM;CAGV"}
|
package/generic/math/percent.ts
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import { numberToFixed } from '../format/number.js'
|
|
2
|
+
import type { BigintIsh } from '../types/bigintish.js'
|
|
2
3
|
import { Fraction } from './fraction.js'
|
|
3
4
|
|
|
4
5
|
export class Percent extends Fraction {
|
|
6
|
+
public override add(other: Fraction | BigintIsh): Percent {
|
|
7
|
+
return new Percent(super.add(other))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public override sub(other: Fraction | BigintIsh): Fraction {
|
|
11
|
+
return new Percent(super.sub(other))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public override mul(other: Fraction | BigintIsh): Percent {
|
|
15
|
+
return new Percent(super.mul(other))
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public override div(other: Fraction | BigintIsh): Percent {
|
|
19
|
+
return new Percent(super.div(other))
|
|
20
|
+
}
|
|
21
|
+
|
|
5
22
|
/**
|
|
6
23
|
*
|
|
7
24
|
* @param args.maxFixed - The maximum number of fixed decimal places to display, only if relevant, eg. "0" for 0, "1.23" for 0.0123, etc.
|