本文整理汇总了TypeScript中levelup.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: levelup
import levelup from 'levelup'
import encoding from 'encoding-down'
import level from 'level-js'
export default levelup(encoding(level('worker'), {valueEncoding: 'json'}))
示例2: 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
});
}
}
示例3: levelup
app.get('/leveldb', (req, res) => {
const db = levelup(LEVELDB_PATH);
db.get(LEVELDB_KEY, (err, value) => {
if (err) { res.json(null); }
res.json(value);
db.close(); // どのタイミングでcloseすればいいのかイマイチわからない。
});
// db.close();
});
示例4: init
init() {
this.inst = levelup( leveldown( path.resolve( this.dir, "commands" ) ) );
}
示例5: createDb
export function createDb(options: CreateDbOptions): LevelUp {
return levelup(leveldown(options.dbPath));
}
示例6: encode
import levelup from 'levelup';
import { AbstractLevelDOWN } from 'abstract-leveldown';
interface StringEncoding {
encode(val: any): string;
decode(val: string): any;
buffer: boolean;
type: string;
}
declare const stringEncoding: StringEncoding;
const db = levelup(new AbstractLevelDOWN('here'), {
keyEncoding: stringEncoding,
valueEncoding: stringEncoding
});
db.open();
db.close();
db.open((error) => {
});
db.close((error) => {
});
db.put("key", {});
db.put("key", {}, (error) => {});
db.put("key", {}, { sync: true}, (error) => {});
db.get("key", {keyEncoding: "json"}, (error, val) => {});
db.get("key", {fillCache: true}, (error, val) => {});