Skip to content

Commit 495a34e

Browse files
committed
chore(api): freeze puid.info
- Assign info via Object.freeze({...}) in both Node and web entries\n- Avoids accidental mutation and lets us drop immutable-data suppressions\n- Tests remain green
1 parent 30dc8be commit 495a34e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/lib/puid.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,14 @@ export default (puidConfig: PuidConfig = {}): PuidResult => {
101101

102102
const puid: Puid = (): string => bitsMuncher()
103103

104-
105-
puid.info = {
104+
puid.info = Object.freeze({
106105
bits: round2(puidBitsPerChar * puidLen),
107106
bitsPerChar: round2(puidBitsPerChar),
108107
chars: puidChars,
109108
charsName: charsName(puidChars),
110109
ere: round2(ere),
111110
length: puidLen
112-
}
111+
})
113112

114113
return { generator: puid }
115114
}

src/lib/puid.web.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,14 @@ export default (puidConfig: PuidConfig = {}): PuidResult => {
5858

5959
const puid: Puid = (): string => bitsMuncher()
6060

61-
// eslint-disable-next-line functional/immutable-data
62-
puid.info = {
61+
puid.info = Object.freeze({
6362
bits: round2(puidBitsPerChar * puidLen),
6463
bitsPerChar: round2(puidBitsPerChar),
6564
chars: puidChars,
6665
charsName: charsName(puidChars),
6766
ere: round2(ere),
6867
length: puidLen
69-
}
68+
})
7069

7170
return { generator: puid }
7271
}

0 commit comments

Comments
 (0)