Skip to content

Commit

Permalink
Fix class definition type
Browse files Browse the repository at this point in the history
  • Loading branch information
MacFJA committed Oct 11, 2022
1 parent 2bc3f3a commit ef7cc92
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .docs/How-To/05-Missing-Encryption-Behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Change behavior with missing encryption
order: 5
---

# This article is not applicable anymore. (since v2.1.?)
# This article is not applicable anymore. (since v2.2.0)

---

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix class definition type not wide enough ([Issue#32])

## [2.2.0]

### Added
Expand Down Expand Up @@ -160,4 +164,5 @@ First version
[Issue#23]: https://github.com/MacFJA/svelte-persistent-store/issues/23
[Issue#26]: https://github.com/MacFJA/svelte-persistent-store/issues/26
[Issue#31]: https://github.com/MacFJA/svelte-persistent-store/issues/31
[Issue#32]: https://github.com/MacFJA/svelte-persistent-store/issues/32
[PR#8]: https://github.com/MacFJA/svelte-persistent-store/pull/8
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"README.md"
],
"dependencies": {
"@macfja/serializer": "^1.1.1",
"@macfja/serializer": "^1.1.2",
"browser-cookies": "^1.2.0",
"idb-keyval": "^5.1.3",
"sjcl-codec-hex": "^1.0.0",
Expand Down
9 changes: 5 additions & 4 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
serialize as defaultSerializer,
deserialize as defaultDeserializer,
addGlobalAllowedClass,
type ClassDefinition,
} from "@macfja/serializer"
import { get as getCookie, set as setCookie, erase as removeCookie } from "browser-cookies"
import { get, set, createStore, del } from "idb-keyval"
Expand Down Expand Up @@ -48,7 +49,7 @@ const warnStorageNotFound = (storageName) => {
* Add a class to the allowed list of classes to be serialized
* @param classDef The class to add to the list
*/
export const addSerializableClass = (classDef: FunctionConstructor): void => {
export const addSerializableClass = (classDef: ClassDefinition<any>): void => {
addSerializable(classDef)
}

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

/**
* Set the serialization functions to use
* @param {(data: any) => string} serializer The function to use to transform any data into a string
* @param {(input: string) => any} deserializer The function to use to transform back string into the original data (reverse of the serializer)
* @param {(classConstructor: FunctionConstructor) => void} [addSerializableClass] The function to use to add a class in the serializer/deserializer allowed class
* @param {(classConstructor: ClassDefinition<any>) => void} [addSerializableClass] The function to use to add a class in the serializer/deserializer allowed class
*/
export function setSerialization(
serializer: (data: any) => string,
deserializer: (input: string) => any,
addSerializableClass?: (classConstructor: FunctionConstructor) => void
addSerializableClass?: (classConstructor: ClassDefinition<any>) => void
): void {
serialize = serializer
deserialize = deserializer
Expand Down

0 comments on commit ef7cc92

Please sign in to comment.