@algorithm.ts/gcd 4.0.4 → 4.0.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,111 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Return correct Bézout coefficients for mixed-sign integer inputs to `euclidean` while preserving the sign of the returned divisor.
8
+
9
+ ## 4.0.5
10
+
11
+ ### Patch Changes
12
+
13
+ - Release patch updates for packages with unreleased commits.
14
+ - @algorithm.ts/internal: :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts
15
+ :wrench: chore: migrate test runner from jest to vitest|:wrench: chore: fix nx config
16
+ - @algorithm.ts/base64: :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts
17
+ :wrench: chore: migrate test runner from jest to vitest|:wrench: chore: migrate workspace from
18
+ yarn to pnpm
19
+ - @algorithm.ts/bellman-ford: :wrench: chore: align scaffold with sora and upgrade workspace
20
+ dependencies :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench:
21
+ chore: migrate test runner from jest to vitest
22
+ - @algorithm.ts/binary-index-tree: :wrench: chore: remove nx and lerna in favor of pnpm workspace
23
+ scripts :wrench: chore: migrate test runner from jest to vitest|:wrench: chore: migrate
24
+ workspace from yarn to pnpm
25
+ - @algorithm.ts/binary-search: :wrench: chore: align scaffold with sora and upgrade workspace
26
+ dependencies :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench:
27
+ chore: migrate test runner from jest to vitest
28
+ - @algorithm.ts/bipartite-matching: :wrench: chore: align scaffold with sora and upgrade workspace
29
+ dependencies :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench:
30
+ chore: migrate test runner from jest to vitest
31
+ - @algorithm.ts/calculator: :wrench: chore: align scaffold with sora and upgrade workspace
32
+ dependencies :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench:
33
+ chore: migrate test runner from jest to vitest
34
+ - @algorithm.ts/diff: :wrench: chore: align scaffold with sora and upgrade workspace dependencies
35
+ :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench: chore: migrate
36
+ test runner from jest to vitest
37
+ - @algorithm.ts/dijkstra: :wrench: chore: align scaffold with sora and upgrade workspace
38
+ dependencies :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench:
39
+ chore: migrate test runner from jest to vitest
40
+ - @algorithm.ts/dinic: :wrench: chore: align scaffold with sora and upgrade workspace dependencies
41
+ :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench: chore: migrate
42
+ test runner from jest to vitest
43
+ - @algorithm.ts/dlx: :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts
44
+ :wrench: chore: migrate test runner from jest to vitest|:wrench: chore: migrate workspace from
45
+ yarn to pnpm
46
+ - @algorithm.ts/findset: :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts
47
+ :wrench: chore: migrate test runner from jest to vitest|:wrench: chore: migrate workspace from
48
+ yarn to pnpm
49
+ - @algorithm.ts/gcd: :wrench: chore: align scaffold with sora and upgrade workspace dependencies
50
+ :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench: chore: migrate
51
+ test runner from jest to vitest
52
+ - @algorithm.ts/gomoku: :wrench: chore: align scaffold with sora and upgrade workspace
53
+ dependencies :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench:
54
+ chore: migrate test runner from jest to vitest
55
+ - @algorithm.ts/graph.types: :wrench: chore: remove nx and lerna in favor of pnpm workspace
56
+ scripts
57
+ - @algorithm.ts/graph: :wrench: chore: align scaffold with sora and upgrade workspace dependencies
58
+ :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench: chore: migrate
59
+ test runner from jest to vitest
60
+ - @algorithm.ts/history: :wrench: chore: align scaffold with sora and upgrade workspace
61
+ dependencies :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench:
62
+ chore: migrate test runner from jest to vitest
63
+ - @algorithm.ts/huffman: :recycle: refactor(queue): migrate heap internals to zero-based indexing
64
+ :wrench: chore: align scaffold with sora and upgrade workspace dependencies|:wrench: chore:
65
+ remove nx and lerna in favor of pnpm workspace scripts
66
+ - @algorithm.ts/isap: :wrench: chore: align scaffold with sora and upgrade workspace dependencies
67
+ :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench: chore: migrate
68
+ test runner from jest to vitest
69
+ - @algorithm.ts/lcs: :wrench: chore: align scaffold with sora and upgrade workspace dependencies
70
+ :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench: chore: migrate
71
+ test runner from jest to vitest
72
+ - @algorithm.ts/lis: :wrench: chore: align scaffold with sora and upgrade workspace dependencies
73
+ :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench: chore: migrate
74
+ test runner from jest to vitest
75
+ - @algorithm.ts/manacher: :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts
76
+ :wrench: chore: migrate test runner from jest to vitest|:wrench: chore: migrate workspace from
77
+ yarn to pnpm
78
+ - @algorithm.ts/mcmf: :bug: fix(mcmf): return strict mincut edges by reachable partition :wrench:
79
+ chore: align scaffold with sora and upgrade workspace dependencies|:wrench: chore: remove nx and
80
+ lerna in favor of pnpm workspace scripts
81
+ - @algorithm.ts/permutation: :wrench: chore: remove nx and lerna in favor of pnpm workspace
82
+ scripts :wrench: chore: migrate test runner from jest to vitest|:wrench: chore: migrate
83
+ workspace from yarn to pnpm
84
+ - @algorithm.ts/prime: :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts
85
+ :wrench: chore: migrate test runner from jest to vitest|:wrench: chore: migrate workspace from
86
+ yarn to pnpm
87
+ - @algorithm.ts/queue: :recycle: refactor(queue): migrate heap internals to zero-based indexing
88
+ :wrench: chore: align scaffold with sora and upgrade workspace dependencies|:wrench: chore:
89
+ remove nx and lerna in favor of pnpm workspace scripts
90
+ - @algorithm.ts/roman: :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts
91
+ :wrench: chore: migrate test runner from jest to vitest|:wrench: chore: migrate workspace from
92
+ yarn to pnpm
93
+ - @algorithm.ts/shuffle: :wrench: chore: align scaffold with sora and upgrade workspace
94
+ dependencies :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench:
95
+ chore: migrate test runner from jest to vitest
96
+ - @algorithm.ts/sliding-window: :wrench: chore: align scaffold with sora and upgrade workspace
97
+ dependencies :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench:
98
+ chore: migrate test runner from jest to vitest
99
+ - @algorithm.ts/stack: :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts
100
+ :wrench: chore: migrate test runner from jest to vitest|:wrench: chore: migrate workspace from
101
+ yarn to pnpm
102
+ - @algorithm.ts/sudoku: :wrench: chore: align scaffold with sora and upgrade workspace
103
+ dependencies :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench:
104
+ chore: migrate test runner from jest to vitest
105
+ - @algorithm.ts/trie: :wrench: chore: align scaffold with sora and upgrade workspace dependencies
106
+ :wrench: chore: remove nx and lerna in favor of pnpm workspace scripts|:wrench: chore: migrate
107
+ test runner from jest to vitest
108
+
3
109
  All notable changes to this project will be documented in this file. See
4
110
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
111
 
package/README.md CHANGED
@@ -33,16 +33,16 @@
33
33
  src="https://img.shields.io/node/v/@algorithm.ts/gcd"
34
34
  />
35
35
  </a>
36
- <a href="https://github.com/facebook/jest">
36
+ <a href="https://github.com/vitest-dev/vitest">
37
37
  <img
38
38
  alt="Tested with Jest"
39
- src="https://img.shields.io/badge/tested_with-jest-9c465e.svg"
39
+ src="https://img.shields.io/badge/tested_with-vitest-6E9F18.svg"
40
40
  />
41
41
  </a>
42
- <a href="https://github.com/prettier/prettier">
42
+ <a href="https://biomejs.dev/">
43
43
  <img
44
- alt="Code Style: prettier"
45
- src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"
44
+ alt="Code Style: Biome"
45
+ src="https://img.shields.io/badge/code_style-Biome-60a5fa.svg?style=flat-square"
46
46
  />
47
47
  </a>
48
48
  </div>
@@ -64,10 +64,10 @@ A typescript implementation of the **gcd** and **Extended Euclidean** algorithm.
64
64
  npm install --save @algorithm.ts/gcd
65
65
  ```
66
66
 
67
- - yarn
67
+ - pnpm
68
68
 
69
69
  ```bash
70
- yarn add @algorithm.ts/gcd
70
+ pnpm add @algorithm.ts/gcd
71
71
  ```
72
72
 
73
73
  ## Usage
package/lib/cjs/index.cjs CHANGED
@@ -1,74 +1,78 @@
1
- 'use strict';
2
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region ../_internal/lib/esm/index.mjs
3
3
  const BIGINT_ZERO = BigInt(0);
4
4
  const BIGINT_ONE = BigInt(1);
5
-
5
+ //#endregion
6
+ //#region src/euclidean.ts
6
7
  function euclidean(a, b) {
7
- let x;
8
- let y;
9
- let d;
10
- solve(a, b);
11
- return [x, y, d];
12
- function solve(_a, _b) {
13
- if (_b === 0) {
14
- x = 1;
15
- y = 0;
16
- d = _a;
17
- }
18
- else {
19
- const A = _a % _b;
20
- const B = _b;
21
- solve(B, A);
22
- const X = y;
23
- const Y = x;
24
- x = X;
25
- y = Y - Math.floor(_a / _b) * X;
26
- }
27
- }
8
+ let x;
9
+ let y;
10
+ let d;
11
+ solve(a, b);
12
+ return [
13
+ x,
14
+ y,
15
+ d
16
+ ];
17
+ function solve(_a, _b) {
18
+ if (_b === 0) {
19
+ x = 1;
20
+ y = 0;
21
+ d = _a;
22
+ } else {
23
+ solve(_b, _a % _b);
24
+ const X = y;
25
+ const Y = x;
26
+ x = X;
27
+ y = Y - Math.trunc(_a / _b) * X;
28
+ }
29
+ }
28
30
  }
29
31
  function euclideanBigint(a, b) {
30
- let x;
31
- let y;
32
- let d;
33
- solve(a, b);
34
- return [x, y, d];
35
- function solve(_a, _b) {
36
- if (_b === BIGINT_ZERO) {
37
- x = BIGINT_ONE;
38
- y = BIGINT_ZERO;
39
- d = _a;
40
- }
41
- else {
42
- const A = _a % _b;
43
- const B = _b;
44
- solve(B, A);
45
- const X = y;
46
- const Y = x;
47
- x = X;
48
- y = Y - (_a / _b) * X;
49
- }
50
- }
32
+ let x;
33
+ let y;
34
+ let d;
35
+ solve(a, b);
36
+ return [
37
+ x,
38
+ y,
39
+ d
40
+ ];
41
+ function solve(_a, _b) {
42
+ if (_b === BIGINT_ZERO) {
43
+ x = BIGINT_ONE;
44
+ y = BIGINT_ZERO;
45
+ d = _a;
46
+ } else {
47
+ solve(_b, _a % _b);
48
+ const X = y;
49
+ const Y = x;
50
+ x = X;
51
+ y = Y - _a / _b * X;
52
+ }
53
+ }
51
54
  }
52
-
55
+ //#endregion
56
+ //#region src/gcd.ts
53
57
  function gcd(x, y) {
54
- let i = x;
55
- for (let j = y; j !== 0;) {
56
- const t = i;
57
- i = j;
58
- j = t % i;
59
- }
60
- return i;
58
+ let i = x;
59
+ for (let j = y; j !== 0;) {
60
+ const t = i;
61
+ i = j;
62
+ j = t % i;
63
+ }
64
+ return i;
61
65
  }
62
66
  function gcdBigint(x, y) {
63
- let i = x;
64
- for (let j = y; j !== BIGINT_ZERO;) {
65
- const t = i;
66
- i = j;
67
- j = t % i;
68
- }
69
- return i;
67
+ let i = x;
68
+ for (let j = y; j !== BIGINT_ZERO;) {
69
+ const t = i;
70
+ i = j;
71
+ j = t % i;
72
+ }
73
+ return i;
70
74
  }
71
-
75
+ //#endregion
72
76
  exports.euclidean = euclidean;
73
77
  exports.euclideanBigint = euclideanBigint;
74
78
  exports.gcd = gcd;
package/lib/esm/index.mjs CHANGED
@@ -1,70 +1,75 @@
1
+ //#region ../_internal/lib/esm/index.mjs
1
2
  const BIGINT_ZERO = BigInt(0);
2
3
  const BIGINT_ONE = BigInt(1);
3
-
4
+ //#endregion
5
+ //#region src/euclidean.ts
4
6
  function euclidean(a, b) {
5
- let x;
6
- let y;
7
- let d;
8
- solve(a, b);
9
- return [x, y, d];
10
- function solve(_a, _b) {
11
- if (_b === 0) {
12
- x = 1;
13
- y = 0;
14
- d = _a;
15
- }
16
- else {
17
- const A = _a % _b;
18
- const B = _b;
19
- solve(B, A);
20
- const X = y;
21
- const Y = x;
22
- x = X;
23
- y = Y - Math.floor(_a / _b) * X;
24
- }
25
- }
7
+ let x;
8
+ let y;
9
+ let d;
10
+ solve(a, b);
11
+ return [
12
+ x,
13
+ y,
14
+ d
15
+ ];
16
+ function solve(_a, _b) {
17
+ if (_b === 0) {
18
+ x = 1;
19
+ y = 0;
20
+ d = _a;
21
+ } else {
22
+ solve(_b, _a % _b);
23
+ const X = y;
24
+ const Y = x;
25
+ x = X;
26
+ y = Y - Math.trunc(_a / _b) * X;
27
+ }
28
+ }
26
29
  }
27
30
  function euclideanBigint(a, b) {
28
- let x;
29
- let y;
30
- let d;
31
- solve(a, b);
32
- return [x, y, d];
33
- function solve(_a, _b) {
34
- if (_b === BIGINT_ZERO) {
35
- x = BIGINT_ONE;
36
- y = BIGINT_ZERO;
37
- d = _a;
38
- }
39
- else {
40
- const A = _a % _b;
41
- const B = _b;
42
- solve(B, A);
43
- const X = y;
44
- const Y = x;
45
- x = X;
46
- y = Y - (_a / _b) * X;
47
- }
48
- }
31
+ let x;
32
+ let y;
33
+ let d;
34
+ solve(a, b);
35
+ return [
36
+ x,
37
+ y,
38
+ d
39
+ ];
40
+ function solve(_a, _b) {
41
+ if (_b === BIGINT_ZERO) {
42
+ x = BIGINT_ONE;
43
+ y = BIGINT_ZERO;
44
+ d = _a;
45
+ } else {
46
+ solve(_b, _a % _b);
47
+ const X = y;
48
+ const Y = x;
49
+ x = X;
50
+ y = Y - _a / _b * X;
51
+ }
52
+ }
49
53
  }
50
-
54
+ //#endregion
55
+ //#region src/gcd.ts
51
56
  function gcd(x, y) {
52
- let i = x;
53
- for (let j = y; j !== 0;) {
54
- const t = i;
55
- i = j;
56
- j = t % i;
57
- }
58
- return i;
57
+ let i = x;
58
+ for (let j = y; j !== 0;) {
59
+ const t = i;
60
+ i = j;
61
+ j = t % i;
62
+ }
63
+ return i;
59
64
  }
60
65
  function gcdBigint(x, y) {
61
- let i = x;
62
- for (let j = y; j !== BIGINT_ZERO;) {
63
- const t = i;
64
- i = j;
65
- j = t % i;
66
- }
67
- return i;
66
+ let i = x;
67
+ for (let j = y; j !== BIGINT_ZERO;) {
68
+ const t = i;
69
+ i = j;
70
+ j = t % i;
71
+ }
72
+ return i;
68
73
  }
69
-
74
+ //#endregion
70
75
  export { euclidean, euclideanBigint, gcd, gcdBigint };
@@ -1,3 +1,4 @@
1
+ //#region src/euclidean.d.ts
1
2
  /**
2
3
  * Extended Euclidean algorithm for solving the smallest
3
4
  * integer solution (|x| + |y| smallest) of the equation `Ax + By = gcd(x,y)`.
@@ -7,7 +8,7 @@
7
8
  * @returns
8
9
  * @see https://me.guanghechen.com/post/math/number-theory/%E6%A8%A1%E6%96%B9%E7%A8%8B/basic/
9
10
  */
10
- declare function euclidean(a: number, b: number): [number, number, number];
11
+ export declare function euclidean(a: number, b: number): [number, number, number];
11
12
  /**
12
13
  * Bigint version.
13
14
  *
@@ -16,8 +17,9 @@ declare function euclidean(a: number, b: number): [number, number, number];
16
17
  * @returns
17
18
  * @see https://me.guanghechen.com/post/math/number-theory/%E6%A8%A1%E6%96%B9%E7%A8%8B/basic/
18
19
  */
19
- declare function euclideanBigint(a: bigint, b: bigint): [bigint, bigint, bigint];
20
-
20
+ export declare function euclideanBigint(a: bigint, b: bigint): [bigint, bigint, bigint];
21
+ //#endregion
22
+ //#region src/gcd.d.ts
21
23
  /**
22
24
  * Find the greatest common divisor of x and y
23
25
  *
@@ -25,7 +27,7 @@ declare function euclideanBigint(a: bigint, b: bigint): [bigint, bigint, bigint]
25
27
  * @param y
26
28
  * @returns
27
29
  */
28
- declare function gcd(x: number, y: number): number;
30
+ export declare function gcd(x: number, y: number): number;
29
31
  /**
30
32
  * Bigint version.
31
33
  *
@@ -33,6 +35,6 @@ declare function gcd(x: number, y: number): number;
33
35
  * @param y
34
36
  * @returns
35
37
  */
36
- declare function gcdBigint(x: bigint, y: bigint): bigint;
37
-
38
- export { euclidean, euclideanBigint, gcd, gcdBigint };
38
+ export declare function gcdBigint(x: bigint, y: bigint): bigint;
39
+ //#endregion
40
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algorithm.ts/gcd",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "description": "GCD + Euclidean algorithm",
5
5
  "author": {
6
6
  "name": "guanghechen",
@@ -8,10 +8,10 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/guanghechen/algorithm.ts/tree/@algorithm.ts/gcd@4.0.3",
11
+ "url": "https://github.com/guanghechen/algorithm.ts/tree/@algorithm.ts/gcd@4.0.4",
12
12
  "directory": "packages/gcd"
13
13
  },
14
- "homepage": "https://github.com/guanghechen/algorithm.ts/tree/@algorithm.ts/gcd@4.0.3/packages/gcd#readme",
14
+ "homepage": "https://github.com/guanghechen/algorithm.ts/tree/@algorithm.ts/gcd@4.0.4/packages/gcd#readme",
15
15
  "keywords": [
16
16
  "algorithm",
17
17
  "gcd",
@@ -37,7 +37,13 @@
37
37
  "README.md"
38
38
  ],
39
39
  "devDependencies": {
40
- "@algorithm.ts/internal": "0.0.0"
40
+ "@algorithm.ts/internal": "^0.0.1"
41
41
  },
42
- "gitHead": "f2094261a9b538d3f285957ce7edb42eff75073c"
43
- }
42
+ "scripts": {
43
+ "clean": "rimraf lib",
44
+ "build": "tsdown --config ../../tsdown.config.mjs",
45
+ "test": "vitest run --config ../../vitest.config.ts",
46
+ "test:coverage": "vitest run --config ../../vitest.config.ts --coverage",
47
+ "test:update": "vitest run --config ../../vitest.config.ts -u"
48
+ }
49
+ }