本文整理匯總了TypeScript中leveldown.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Error
constructor(params) {
const { path, createIfMissing, errorIfExists } = params;
let basePath;
if (!path) {
basePath = `${os.homedir()}/.bitcore`;
try {
fs.mkdirSync(basePath);
} catch (e) {
if (e.errno !== -17) {
console.error('Unable to create bitcore storage directory');
}
}
}
this.path = path || `${basePath}/bitcoreWallet`;
if (!createIfMissing) {
const walletExists =
fs.existsSync(this.path) &&
fs.existsSync(this.path + '/LOCK') &&
fs.existsSync(this.path + '/LOG');
if (!walletExists) {
throw new Error('Not a valid wallet path');
}
}
if (StorageCache[this.path]) {
this.db = StorageCache[this.path];
} else {
this.db = StorageCache[this.path] = levelup(leveldown(this.path), {
createIfMissing,
errorIfExists
});
}
}
示例2: constructor
constructor(path: string) {
this.path = path;
mkDirByPathSync(path);
this.db = (levelup as any)(leveldown(this.path));
}
示例3: init
init() {
this.inst = levelup( leveldown( path.resolve( this.dir, "commands" ) ) );
}
示例4: LevelDOWN
import LevelDOWN from 'leveldown';
// can use new, or not.
const a = new LevelDOWN("./tmp/leveldown");
const b = LevelDOWN("./tmp/leveldown");
const down = new LevelDOWN("./tmp/leveldown");
down.open(() => {
down.put("key", "value", (err?) => { });
down.put(Buffer.from([1]), "value", { something: true }, (err?) => { });
down.get("key", (err?) => { });
down.get(Buffer.from([1]), { something: true }, (err: Error | undefined, value: any) => { });
down.close(() => {
// do nothing
});
});
示例5: createDb
export function createDb(options: CreateDbOptions): LevelUp {
return levelup(leveldown(options.dbPath));
}