Skip to content

Commit

Permalink
feat: add util for using nested key definitions in ngrx-local-storage…
Browse files Browse the repository at this point in the history
…-sync (#519)

* feat: add util for using nested key definitions in ngrx-local-storage-sync

* fix: rename method

---------

Co-authored-by: SchettlerKoehler <[email protected]>
  • Loading branch information
bastianjakobi and SchettlerKoehler authored Oct 9, 2024
1 parent 3993c50 commit 81137cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libs/ngrx-accelerator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export * from './lib/utils/effects/filter-for-query-params-changed'
export * from './lib/utils/selectors/create-child-selectors'

// Local Storage
export * from './lib/utils/local-storage/lazy-loading-merge-reducer'
export * from './lib/utils/local-storage/lazy-loading-merge-reducer'
export * from './lib/utils/local-storage/create-nested-key-configuration'
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export interface Options {
serialize?: (state: any) => any
deserialize?: (state: any) => any
reviver?: (key: string, value: any) => any
replacer?: ((key: string, value: any) => any) | string[]
encrypt?: (message: string) => string
decrypt?: (message: string) => string
filter?: string[]
space?: string | number
}

type CommonKeyConfigurationTypes = Options | ((key: string, value: any) => any)

export interface KeyConfiguration {
[key: string]: string[] | number[] | KeyConfiguration[] | CommonKeyConfigurationTypes
}

export interface NestedKeyConfiguration {
[key: string]: (string | number | NestedKeyConfiguration)[] | CommonKeyConfigurationTypes
}

export function createNestedKeyConfiguration(nestedKeyConfiguration: (string | NestedKeyConfiguration)[]): KeyConfiguration[] {
return nestedKeyConfiguration as KeyConfiguration[]
}

0 comments on commit 81137cf

Please sign in to comment.