本文整理汇总了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));
}