mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-02 06:22:42 -08:00
initial commit
This commit is contained in:
16
vendor/texthooker-ui/src/stores/transformer/writeable-object-sibject.ts
vendored
Normal file
16
vendor/texthooker-ui/src/stores/transformer/writeable-object-sibject.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { writableStorageSubject } from './writable-storage-subject';
|
||||
|
||||
function createwritteableObjectSubject<T>(fallback: string) {
|
||||
return writableStorageSubject(
|
||||
(x) => JSON.parse(x || fallback) as T,
|
||||
(x) => JSON.stringify(x)
|
||||
);
|
||||
}
|
||||
|
||||
export function writeableObjectSubject<T>() {
|
||||
return createwritteableObjectSubject<T>('{}');
|
||||
}
|
||||
|
||||
export function writeableArraySubject<T>() {
|
||||
return createwritteableObjectSubject<T[]>('[]');
|
||||
}
|
||||
Reference in New Issue
Block a user