added doga
This commit is contained in:
1 parent
5174ab4cc4
commit
13254e5623
1149 files changed
+80161
No files matched your search
+3
@@ -0,0 +1,3 @@
|
||||
import { LowSync } from '../index.js';
|
||||
export declare function LocalStoragePreset<Data>(key: string, defaultData: Data): LowSync<Data>;
|
||||
export declare function SessionStoragePreset<Data>(key: string, defaultData: Data): LowSync<Data>;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { LocalStorage } from '../adapters/browser/LocalStorage.js';
|
||||
import { SessionStorage } from '../adapters/browser/SessionStorage.js';
|
||||
import { LowSync } from '../index.js';
|
||||
export function LocalStoragePreset(key, defaultData) {
|
||||
const adapter = new LocalStorage(key);
|
||||
const db = new LowSync(adapter, defaultData);
|
||||
db.read();
|
||||
return db;
|
||||
}
|
||||
export function SessionStoragePreset(key, defaultData) {
|
||||
const adapter = new SessionStorage(key);
|
||||
const db = new LowSync(adapter, defaultData);
|
||||
db.read();
|
||||
return db;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/// <reference types="node" resolution-mode="require"/>
|
||||
import { PathLike } from 'node:fs';
|
||||
import { Low, LowSync } from '../core/Low.js';
|
||||
export declare function JSONFilePreset<Data>(filename: PathLike, defaultData: Data): Promise<Low<Data>>;
|
||||
export declare function JSONFileSyncPreset<Data>(filename: PathLike, defaultData: Data): LowSync<Data>;
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { Memory, MemorySync } from '../adapters/Memory.js';
|
||||
import { JSONFile, JSONFileSync } from '../adapters/node/JSONFile.js';
|
||||
import { Low, LowSync } from '../core/Low.js';
|
||||
export async function JSONFilePreset(filename, defaultData) {
|
||||
const adapter = process.env.NODE_ENV === 'test'
|
||||
? new Memory()
|
||||
: new JSONFile(filename);
|
||||
const db = new Low(adapter, defaultData);
|
||||
await db.read();
|
||||
return db;
|
||||
}
|
||||
export function JSONFileSyncPreset(filename, defaultData) {
|
||||
const adapter = process.env.NODE_ENV === 'test'
|
||||
? new MemorySync()
|
||||
: new JSONFileSync(filename);
|
||||
const db = new LowSync(adapter, defaultData);
|
||||
db.read();
|
||||
return db;
|
||||
}
|
||||
Reference in new issue
Block a user