Skip to content

Commit 86922f7

Browse files
committed
Formattage
1 parent 34027ec commit 86922f7

File tree

10 files changed

+23
-21
lines changed

10 files changed

+23
-21
lines changed

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default [
1616
},
1717
},
1818
rules: {
19+
"@typescript-eslint/consistent-type-imports": "warn",
1920
"@typescript-eslint/no-non-null-assertion": "off",
2021
"@typescript-eslint/no-unused-vars": [
2122
"warn",

src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ export {
1414
toNested,
1515
} from "@/utils.js";
1616

17-
export {
18-
NestedKey,
19-
PossiblyNestedValue,
20-
} from "@/types.js";
17+
export { NestedKey, PossiblyNestedValue } from "@/types.js";
2118

2219
export { version } from "@/version.js";

src/nested.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
InternalDatabase,
1111
} from "@orbitdb/core";
1212
import type { HeliaLibp2p } from "helia";
13-
import { NestedKey, NestedValue, PossiblyNestedValue } from "./types";
13+
import type { NestedKey, NestedValue, PossiblyNestedValue } from "./types";
1414
import { flatten, isSubkey, joinKey, splitKey, toNested } from "./utils.js";
1515
import type { Libp2p } from "libp2p";
1616
import type { ServiceMap } from "@libp2p/interface";
@@ -101,7 +101,9 @@ export const NestedApi = ({ database }: { database: InternalDatabase }) => {
101101
return addOperation({ op: "DEL", key: joinedKey, value: null });
102102
};
103103

104-
const get = async (key: NestedKey): Promise<PossiblyNestedValue | undefined> => {
104+
const get = async (
105+
key: NestedKey,
106+
): Promise<PossiblyNestedValue | undefined> => {
105107
const joinedKey = typeof key === "string" ? key : joinKey(key);
106108
const relevantKeyValues: { key: string; value: DagCborEncodable }[] = [];
107109

@@ -125,7 +127,7 @@ export const NestedApi = ({ database }: { database: InternalDatabase }) => {
125127
(object: NestedValue): Promise<string[]>;
126128
(key: string, object: NestedValue): Promise<string[]>;
127129
};
128-
130+
129131
const putNested: PutNestedFunction = async (
130132
keyOrObject,
131133
object?: NestedValue | undefined,
@@ -197,4 +199,4 @@ export const NestedApi = ({ database }: { database: InternalDatabase }) => {
197199
};
198200
};
199201

200-
export default Nested;
202+
export default Nested;

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type RecursivePartial<T> = {
66

77
export type NestedKey = string | string[];
88

9-
export type PossiblyNestedValue = | DagCborEncodable | NestedValue;
9+
export type PossiblyNestedValue = DagCborEncodable | NestedValue;
1010
export type NestedValue = {
1111
[key: string]: DagCborEncodable | NestedValue;
12-
}
12+
};

src/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { DagCborEncodable } from "@orbitdb/core";
1+
import type { DagCborEncodable } from "@orbitdb/core";
22

3-
import { NestedKey, NestedValue, PossiblyNestedValue } from "./types";
3+
import type { NestedKey, NestedValue, PossiblyNestedValue } from "./types";
44

55
export const splitKey = (key: string): string[] => key.split("/");
66
export const joinKey = (key: string[]): string => key.join("/");
@@ -99,8 +99,8 @@ export const toNested = (
9999
if (typeof root[c] !== "object" || Array.isArray(root[c])) root[c] = {};
100100
root = root[c] as NestedValue;
101101
}
102-
const finalKeyComponent = keyComponents.pop()
102+
const finalKeyComponent = keyComponents.pop();
103103
if (finalKeyComponent) root[finalKeyComponent] = value;
104104
}
105105
return nested;
106-
};
106+
};

test/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// From @orbit-db/core (MIT)
2-
import { HeliaLibp2p, createHelia } from "helia";
2+
import type { HeliaLibp2p } from "helia";
3+
import { createHelia } from "helia";
34
import { bitswap } from "@helia/block-brokers";
45
import { createLibp2p } from "libp2p";
56
import { MemoryBlockstore } from "blockstore-core";

test/nested.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { type HeliaLibp2p } from "helia";
22

3-
import Nested, { NestedDatabaseType } from "@/nested.js";
3+
import type { NestedDatabaseType } from "@/nested.js";
4+
import Nested from "@/nested.js";
45
import { createTestHelia } from "./config.js";
56

6-
import { Identities, Identity, KeyStore, KeyStoreType } from "@orbitdb/core";
7+
import type { Identity, KeyStoreType } from "@orbitdb/core";
8+
import { Identities, KeyStore } from "@orbitdb/core";
79
import { expect } from "aegir/chai";
810
import { isBrowser } from "wherearewe";
911
import { fillKeys } from "./utils.js";
@@ -187,7 +189,7 @@ describe("Nested Database", () => {
187189
await db.del(["a", "c"]);
188190

189191
const actual = await db.all();
190-
expect(actual).to.deep.equal({ a: { } });
192+
expect(actual).to.deep.equal({ a: {} });
191193
});
192194

193195
it("add a nested value - list syntax", async () => {

test/types.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "aegir/chai";
2-
import {
2+
import type {
33
NestedMapToObject,
44
NestedObjectToMap,
55
RecursivePartial,

test/utils.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
} from "@/utils.js";
1010

1111
describe("Utils", () => {
12-
1312
describe("to nested", () => {
1413
it("nest values", () => {
1514
const actual = toNested([

test/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NestedDatabaseType } from "@/nested";
1+
import type { NestedDatabaseType } from "@/nested";
22

33
export const fillKeys = async (
44
db: NestedDatabaseType,

0 commit comments

Comments
 (0)