本文整理匯總了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) => {});