cmath-js 1.2.1 → 1.3.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
@@ -17,6 +17,7 @@ These functions accept either a `bigint` or an integer `number`:
17
17
  - [`countl_zero`](https://en.cppreference.com/w/cpp/numeric/countl_zero)
18
18
  - [`countr_one`](https://en.cppreference.com/w/cpp/numeric/countr_one)
19
19
  - [`countr_zero`](https://en.cppreference.com/w/cpp/numeric/countr_zero)
20
+ - [`div`](https://en.cppreference.com/w/cpp/numeric/math/div)
20
21
  - [`gcd`](https://en.cppreference.com/w/cpp/numeric/gcd)
21
22
  - [`lcm`](https://en.cppreference.com/w/cpp/numeric/lcm)
22
23
  - [`popcount`](https://en.cppreference.com/w/cpp/numeric/popcount)
@@ -1 +1,2 @@
1
+ export { iota } from "./iota.js";
1
2
  export { signbit } from "./signbit.js";
@@ -1,2 +1,3 @@
1
+ export { iota } from "./iota.js";
1
2
  export { signbit } from "./signbit.js";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/all-numbers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/all-numbers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type div_t_bigint } from "./div_bigint";
2
+ import { type div_t_number } from "./div_number";
3
+ export { type div_t_bigint };
4
+ export { type div_t_number };
5
+ export declare function div(aInteger: bigint, bInteger: bigint): div_t_bigint;
6
+ export declare function div(aInteger: number, bInteger: number): div_t_number;
@@ -0,0 +1,8 @@
1
+ import { div_bigint } from "./div_bigint";
2
+ import { div_number } from "./div_number";
3
+ export function div(aInteger, bInteger) {
4
+ return typeof aInteger === "number"
5
+ ? div_number(aInteger, bInteger)
6
+ : div_bigint(aInteger, bInteger);
7
+ }
8
+ //# sourceMappingURL=div.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"div.js","sourceRoot":"","sources":["../../src/integers/div.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAqB,MAAM,cAAc,CAAC;AAO7D,MAAM,UAAU,GAAG,CAClB,QAAyB,EACzB,QAAyB;IAEzB,OAAO,OAAO,QAAQ,KAAK,QAAQ;QAClC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAkB,CAAC;QAC1C,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAkB,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface div_t_bigint {
2
+ quot: bigint;
3
+ rem: bigint;
4
+ }
5
+ export declare function div_bigint(aInteger: bigint, bInteger: bigint): div_t_bigint;
@@ -0,0 +1,13 @@
1
+ export function div_bigint(aInteger, bInteger) {
2
+ if (bInteger === 0n) {
3
+ return {
4
+ quot: 0n,
5
+ rem: 0n,
6
+ };
7
+ }
8
+ return {
9
+ quot: aInteger / bInteger,
10
+ rem: aInteger % bInteger,
11
+ };
12
+ }
13
+ //# sourceMappingURL=div_bigint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"div_bigint.js","sourceRoot":"","sources":["../../src/integers/div_bigint.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,QAAgB;IAG5D,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;QACrB,OAAO;YACN,IAAI,EAAE,EAAE;YACR,GAAG,EAAE,EAAE;SACP,CAAC;IACH,CAAC;IAED,OAAO;QACN,IAAI,EAAE,QAAQ,GAAG,QAAQ;QACzB,GAAG,EAAE,QAAQ,GAAG,QAAQ;KACxB,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface div_t_number {
2
+ quot: number;
3
+ rem: number;
4
+ }
5
+ export declare function div_number(aInteger: number, bInteger: number): div_t_number;
@@ -0,0 +1,11 @@
1
+ export function div_number(aInteger, bInteger) {
2
+ let quot = Math.trunc(aInteger / bInteger) || 0;
3
+ if (!Number.isFinite(quot)) {
4
+ quot = 0;
5
+ }
6
+ return {
7
+ quot,
8
+ rem: aInteger % bInteger || 0,
9
+ };
10
+ }
11
+ //# sourceMappingURL=div_number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"div_number.js","sourceRoot":"","sources":["../../src/integers/div_number.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,QAAgB;IAM5D,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,IAAI,GAAG,CAAC,CAAC;IACV,CAAC;IAED,OAAO;QACN,IAAI;QACJ,GAAG,EAAE,QAAQ,GAAG,QAAQ,IAAI,CAAC;KAC7B,CAAC;AACH,CAAC"}
@@ -3,6 +3,7 @@ export { countl_one } from "./countl_one.js";
3
3
  export { countl_zero } from "./countl_zero.js";
4
4
  export { countr_one } from "./countr_one.js";
5
5
  export { countr_zero } from "./countr_zero.js";
6
+ export { div, type div_t_bigint, type div_t_number } from "./div.js";
6
7
  export { gcd } from "./gcd.js";
7
8
  export { lcm } from "./lcm.js";
8
9
  export { popcount } from "./popcount.js";
@@ -3,6 +3,7 @@ export { countl_one } from "./countl_one.js";
3
3
  export { countl_zero } from "./countl_zero.js";
4
4
  export { countr_one } from "./countr_one.js";
5
5
  export { countr_zero } from "./countr_zero.js";
6
+ export { div } from "./div.js";
6
7
  export { gcd } from "./gcd.js";
7
8
  export { lcm } from "./lcm.js";
8
9
  export { popcount } from "./popcount.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAwC,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/oskarlh/cmath-js.git"
7
7
  },
8
- "version": "1.2.1",
8
+ "version": "1.3.0",
9
9
  "exports": "./dist/index.js",
10
10
  "types": "./dist/index.d.ts",
11
11
  "type": "module",