Skip to content

Commit 1ccdec1

Browse files
committed
🔧 prettier 3.0 changes
1 parent 86722a1 commit 1ccdec1

File tree

9 files changed

+39
-35
lines changed

9 files changed

+39
-35
lines changed

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npm run pretty-quick
4+
npx lint-staged

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"version": "3.0.0",
44
"description": "Node.js Standary Utility Functions",
55
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
67
"repository": {
78
"type": "git",
89
"url": "git@github.com:stackbox-dev/nodejs-stdlib.git"
910
},
1011
"scripts": {
1112
"prepare": "husky install",
12-
"pretty": "prettier --loglevel warn --write \"./src/**/*.{js,ts,json}\"",
13-
"pretty-quick": "pretty-quick --staged --pattern \"./src/**/*.{js,ts,json}\"",
13+
"pretty": "prettier --write \"./src/**/*.{js,ts,json,md}\"",
1414
"clean": "rimraf dist",
1515
"test": "jest",
1616
"transpile": "tsc",
@@ -24,12 +24,15 @@
2424
"@types/node": "^20.5.0",
2525
"husky": "^8.0.3",
2626
"jest": "^29.6.2",
27+
"lint-staged": "^14.0.0",
2728
"npm-run-all": "^4.1.5",
2829
"prettier": "^3.0.2",
29-
"pretty-quick": "^3.1.1",
3030
"rimraf": "^5.0.1",
3131
"ts-jest": "^29.1.1",
3232
"ts-node": "^10.9.1",
3333
"typescript": "^5.1.6"
34+
},
35+
"lint-staged": {
36+
"*.{js,ts,json,md}": "prettier --write"
3437
}
3538
}

src/geo.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ test("haversine", () => {
1010

1111
test("bearing", () => {
1212
expect((bearing(52.205, 0.119, 48.857, 2.351) * 180) / Math.PI).toBe(
13-
156.16658258153174
13+
156.16658258153174,
1414
);
1515
});

src/geo.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const haversine = (
3333
lat1: number,
3434
lon1: number,
3535
lat2: number,
36-
lon2: number
36+
lon2: number,
3737
) => {
3838
// in degrees
3939
// convert to radians
@@ -56,7 +56,7 @@ export const bearing = (
5656
lat1: number,
5757
lon1: number,
5858
lat2: number,
59-
lon2: number
59+
lon2: number,
6060
) => {
6161
// convert to radians
6262
lat1 = convToRad(lat1);
@@ -67,7 +67,7 @@ export const bearing = (
6767
const dLon = lon2 - lon1;
6868
return atan2(
6969
sin(dLon) * cos(lat2),
70-
cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon)
70+
cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon),
7171
);
7272
};
7373

@@ -77,7 +77,7 @@ export const bearingInDegs = (
7777
lat1: number,
7878
lon1: number,
7979
lat2: number,
80-
lon2: number
80+
lon2: number,
8181
) => {
8282
const rads = bearing(lat1, lon1, lat2, lon2);
8383
const degs = convToDeg(rads);

src/graph/detect-cycle.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ const t1: [string, string, number][] = [
44
[
55
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
66
"57fea751-6c21-4eb1-9262-ea97ff45553c",
7-
1
7+
1,
88
],
99
[
1010
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
1111
"f03626f2-1852-45b8-b6ad-b59bde38b3fd",
12-
1
12+
1,
1313
],
1414
[
1515
"9c550989-3e19-4cf5-ab28-b8e0881e2dac",
1616
"5c1a9dca-f58a-4f49-9909-576c48ab20c1",
17-
1
17+
1,
1818
],
1919
[
2020
"57fea751-6c21-4eb1-9262-ea97ff45553c",
2121
"322c07a4-06ce-4766-964c-2ccc7d977cbc",
22-
1
22+
1,
2323
],
2424
];
2525

@@ -31,17 +31,17 @@ const t2: [string, string, number][] = [
3131
[
3232
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
3333
"57fea751-6c21-4eb1-9262-ea97ff45553c",
34-
2
34+
2,
3535
],
3636
[
3737
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
3838
"f03626f2-1852-45b8-b6ad-b59bde38b3fd",
39-
2
39+
2,
4040
],
4141
[
4242
"57fea751-6c21-4eb1-9262-ea97ff45553c",
4343
"322c07a4-06ce-4766-964c-2ccc7d977cbc",
44-
2
44+
2,
4545
],
4646
];
4747

@@ -53,17 +53,17 @@ const t3: [string, string, number][] = [
5353
[
5454
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
5555
"57fea751-6c21-4eb1-9262-ea97ff45553c",
56-
3
56+
3,
5757
],
5858
[
5959
"57fea751-6c21-4eb1-9262-ea97ff45553c",
6060
"f03626f2-1852-45b8-b6ad-b59bde38b3fd",
61-
3
61+
3,
6262
],
6363
[
6464
"f03626f2-1852-45b8-b6ad-b59bde38b3fd",
6565
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
66-
3
66+
3,
6767
],
6868
];
6969

src/graph/floyd-warshal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Edge, TransitiveClosure, INF, add } from "./interfaces";
22
import { getNodesFromEdges } from "./utils";
33

44
export function buildDAGTransitiveClosure<T>(
5-
edges: Edge<T>[]
5+
edges: Edge<T>[],
66
): TransitiveClosure<T>[] {
77
const nodes = getNodesFromEdges(edges);
88
const N = nodes.length;
@@ -25,7 +25,7 @@ export function buildDAGTransitiveClosure<T>(
2525
// N - number of nodes/vertexes, edges - array of [from, to, distance]
2626
export function buildDMUsingFloydWarshal(
2727
N: number,
28-
edges: [number, number, number][]
28+
edges: [number, number, number][],
2929
) {
3030
const dm: number[][] = [];
3131
for (let i = 0; i < N; i++) {

src/graph/topo-sort.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ const t1: [string, string, number][] = [
55
[
66
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
77
"57fea751-6c21-4eb1-9262-ea97ff45553c",
8-
1
8+
1,
99
],
1010
[
1111
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
1212
"f03626f2-1852-45b8-b6ad-b59bde38b3fd",
13-
1
13+
1,
1414
],
1515
[
1616
"9c550989-3e19-4cf5-ab28-b8e0881e2dac",
1717
"5c1a9dca-f58a-4f49-9909-576c48ab20c1",
18-
1
18+
1,
1919
],
2020
[
2121
"57fea751-6c21-4eb1-9262-ea97ff45553c",
2222
"322c07a4-06ce-4766-964c-2ccc7d977cbc",
23-
1
23+
1,
2424
],
2525
];
2626

@@ -39,17 +39,17 @@ const t2: [string, string, number][] = [
3939
[
4040
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
4141
"57fea751-6c21-4eb1-9262-ea97ff45553c",
42-
1
42+
1,
4343
],
4444
[
4545
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
4646
"f03626f2-1852-45b8-b6ad-b59bde38b3fd",
47-
1
47+
1,
4848
],
4949
[
5050
"57fea751-6c21-4eb1-9262-ea97ff45553c",
5151
"322c07a4-06ce-4766-964c-2ccc7d977cbc",
52-
1
52+
1,
5353
],
5454
];
5555

@@ -66,17 +66,17 @@ const t3: [string, string, number][] = [
6666
[
6767
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
6868
"57fea751-6c21-4eb1-9262-ea97ff45553c",
69-
1
69+
1,
7070
],
7171
[
7272
"57fea751-6c21-4eb1-9262-ea97ff45553c",
7373
"f03626f2-1852-45b8-b6ad-b59bde38b3fd",
74-
1
74+
1,
7575
],
7676
[
7777
"f03626f2-1852-45b8-b6ad-b59bde38b3fd",
7878
"5ab489c9-824c-4f2b-a021-54dedd2db6bd",
79-
1
79+
1,
8080
],
8181
];
8282

src/lang.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type PickNullableFields<
99
NK extends keyof T = {
1010
[K in keyof T]: null extends T[K] ? K : never;
1111
}[keyof T],
12-
NP = Pick<T, NK>
12+
NP = Pick<T, NK>,
1313
> = { [K in keyof NP]: NonNullable<NP[K]> };
1414

1515
export const compareNum: CompareFn<number> = (a, b) =>
@@ -105,7 +105,7 @@ export const arrayToIntSequence = (arr: number[]): IntSequence[] => {
105105

106106
export const areIntSequencesOverlapping = (
107107
s1: IntSequence[],
108-
s2: IntSequence[]
108+
s2: IntSequence[],
109109
) => {
110110
for (const p1 of s1) {
111111
for (const p2 of s2) {
@@ -118,7 +118,7 @@ export const areIntSequencesOverlapping = (
118118
export const groupBy = <T, U, V>(
119119
iterable: Iterable<T>,
120120
keyFunc: (val: T) => U,
121-
groupTransform: (group: T[]) => V
121+
groupTransform: (group: T[]) => V,
122122
): Map<U, V> => {
123123
const groupMap = new Map<U, T[]>();
124124

@@ -204,7 +204,7 @@ export function streamToBuffer(stream: NodeJS.ReadableStream): Promise<Buffer> {
204204
stream.on("data", (chunk) => chunks.push(chunk));
205205
stream.on("error", (err) => reject(err));
206206
stream.on("end", () =>
207-
resolve(chunks.length === 1 ? chunks[0] : Buffer.concat(chunks))
207+
resolve(chunks.length === 1 ? chunks[0] : Buffer.concat(chunks)),
208208
);
209209
});
210210
}

0 commit comments

Comments
 (0)