當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript leveldown.default函數代碼示例

本文整理匯總了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
     });
   }
 }
開發者ID:bitjson,項目名稱:bitcore,代碼行數:32,代碼來源:storage.ts

示例2: constructor

  constructor(path: string) {
    this.path = path;

    mkDirByPathSync(path);

    this.db = (levelup as any)(leveldown(this.path));
  }
開發者ID:laquereric,項目名稱:wexond,代碼行數:7,代碼來源:storage-area.ts

示例3: init

 init() {
     this.inst = levelup( leveldown( path.resolve( this.dir, "commands" ) ) );
 }
開發者ID:hleclerc,項目名稱:nsmake,代碼行數:3,代碼來源:Db.ts

示例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
  });
});
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:19,代碼來源:leveldown-tests.ts

示例5: createDb

export function createDb(options: CreateDbOptions): LevelUp {
  return levelup(leveldown(options.dbPath));
}
開發者ID:mshick,項目名稱:arrivals-osx,代碼行數:3,代碼來源:db.ts


注:本文中的leveldown.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。