Skip to content

Commit 9b76ffb

Browse files
authored
Merge pull request #35 from MacFJA/add-serializable-class-type
Fix class definition type
2 parents 2bc3f3a + ab449e9 commit 9b76ffb

File tree

6 files changed

+29
-21
lines changed

6 files changed

+29
-21
lines changed

.docs/How-To/05-Missing-Encryption-Behavior.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Change behavior with missing encryption
33
order: 5
44
---
55

6-
# This article is not applicable anymore. (since v2.1.?)
6+
# This article is not applicable anymore. (since v2.2.0)
77

88
---
99

.github/workflows/quality.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ jobs:
1212
lint:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v3
1616
- name: Setup node with version 16
17-
uses: actions/setup-node@v2
17+
uses: actions/setup-node@v3
1818
with:
19-
node-version: "16.x"
20-
registry-url: "https://registry.npmjs.org"
19+
node-version: 16
2120
- name: Install dependencies
2221
run: npm ci
2322
- name: Run Lint
@@ -26,12 +25,11 @@ jobs:
2625
test:
2726
runs-on: ubuntu-latest
2827
steps:
29-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v3
3029
- name: Setup node with version 16
31-
uses: actions/setup-node@v2
30+
uses: actions/setup-node@v3
3231
with:
33-
node-version: "16.x"
34-
registry-url: "https://registry.npmjs.org"
32+
node-version: 16
3533
- name: Install dependencies
3634
run: npm ci
3735
- name: Prepare test

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Fix class definition type not wide enough ([Issue#32])
12+
13+
### Changed
14+
15+
- (dev) Update Github actions versions.
16+
917
## [2.2.0]
1018

1119
### Added
@@ -160,4 +168,5 @@ First version
160168
[Issue#23]: https://github.com/MacFJA/svelte-persistent-store/issues/23
161169
[Issue#26]: https://github.com/MacFJA/svelte-persistent-store/issues/26
162170
[Issue#31]: https://github.com/MacFJA/svelte-persistent-store/issues/31
171+
[Issue#32]: https://github.com/MacFJA/svelte-persistent-store/issues/32
163172
[PR#8]: https://github.com/MacFJA/svelte-persistent-store/pull/8

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"README.md"
2020
],
2121
"dependencies": {
22-
"@macfja/serializer": "^1.1.1",
22+
"@macfja/serializer": "^1.1.2",
2323
"browser-cookies": "^1.2.0",
2424
"idb-keyval": "^5.1.3",
2525
"sjcl-codec-hex": "^1.0.0",

src/core.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
serialize as defaultSerializer,
33
deserialize as defaultDeserializer,
44
addGlobalAllowedClass,
5+
type ClassDefinition,
56
} from "@macfja/serializer"
67
import { get as getCookie, set as setCookie, erase as removeCookie } from "browser-cookies"
78
import { get, set, createStore, del } from "idb-keyval"
@@ -48,7 +49,7 @@ const warnStorageNotFound = (storageName) => {
4849
* Add a class to the allowed list of classes to be serialized
4950
* @param classDef The class to add to the list
5051
*/
51-
export const addSerializableClass = (classDef: FunctionConstructor): void => {
52+
export const addSerializableClass = (classDef: ClassDefinition<any>): void => {
5253
addSerializable(classDef)
5354
}
5455

@@ -68,20 +69,20 @@ export let serialize = defaultSerializer
6869
export let deserialize = defaultDeserializer
6970
/**
7071
* The function used to add a class in the serializer allowed class
71-
* @type {(classConstructor: FunctionConstructor) => void}
72+
* @type {(classConstructor: ClassDefinition<any>) => void}
7273
*/
7374
let addSerializable = addGlobalAllowedClass
7475

7576
/**
7677
* Set the serialization functions to use
7778
* @param {(data: any) => string} serializer The function to use to transform any data into a string
7879
* @param {(input: string) => any} deserializer The function to use to transform back string into the original data (reverse of the serializer)
79-
* @param {(classConstructor: FunctionConstructor) => void} [addSerializableClass] The function to use to add a class in the serializer/deserializer allowed class
80+
* @param {(classConstructor: ClassDefinition<any>) => void} [addSerializableClass] The function to use to add a class in the serializer/deserializer allowed class
8081
*/
8182
export function setSerialization(
8283
serializer: (data: any) => string,
8384
deserializer: (input: string) => any,
84-
addSerializableClass?: (classConstructor: FunctionConstructor) => void
85+
addSerializableClass?: (classConstructor: ClassDefinition<any>) => void
8586
): void {
8687
serialize = serializer
8788
deserialize = deserializer

0 commit comments

Comments
 (0)