当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript LevelUp.batch方法代码示例

本文整理汇总了TypeScript中levelup.LevelUp.batch方法的典型用法代码示例。如果您正苦于以下问题:TypeScript LevelUp.batch方法的具体用法?TypeScript LevelUp.batch怎么用?TypeScript LevelUp.batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在levelup.LevelUp的用法示例。


在下文中一共展示了LevelUp.batch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: buildExistingFilesDb

  public async buildExistingFilesDb(watchPath: string): Promise<number> {
    try {
      const cwd = watchPath;

      const files = await globPromise(`**/*`, {
        cwd
      });

      const filePayload: FilePayload = {
        jobStatus: FileJobStatus.Existing,
        jobType: FileJobType.Unknown
      };

      const existingFiles = files.map(
        (filepath: string): AbstractBatch => ({
          key: path.resolve(cwd, filepath),
          type: 'put',
          value: filePayload
        })
      );

      await this.files.batch(existingFiles);

      return existingFiles.length;
    } catch (error) {
      throw error;
    }
  }
开发者ID:mshick,项目名称:arrivals-osx,代码行数:28,代码来源:dispatcher.ts

示例2: addKeys

 async addKeys(params: {
   name: string;
   keys: Wallet.KeyImport[];
   encryptionKey: string;
 }) {
   const { name, keys, encryptionKey } = params;
   const ops = keys.map(key => {
     let { pubKey } = key;
     pubKey =
       pubKey || new bitcoreLib.PrivateKey(key.privKey).publicKey.toString();
     let payload = {};
     if (pubKey && key.privKey && encryptionKey) {
       const encKey = Encryption.encryptPrivateKey(
         JSON.stringify(key),
         Buffer.from(pubKey, 'hex'),
         Buffer.from(encryptionKey, 'hex')
       );
       payload = { encKey, pubKey };
     }
     return {
       type: 'put',
       key: `key|${name}|${key.address}`,
       value: JSON.stringify(payload)
     };
   });
   if (ops.length > 1) {
     return this.db.batch(ops);
   } else {
     this.db.put(ops[0].key, ops[0].value);
   }
 }
开发者ID:bitpay,项目名称:bitcore,代码行数:31,代码来源:storage.ts

示例3: callback

 this.get(null, data => {
   const batch = this.db.batch();
   for (const key in data) {
     batch.del(key);
   }
   batch.write(() => {
     callback();
   });
 });
开发者ID:laquereric,项目名称:wexond,代码行数:9,代码来源:storage-area.ts

示例4: set

  public set(items: any, callback: any) {
    if (items === Object(items)) {
      const batch = this.db.batch();

      for (const key in items) {
        batch.put(key, JSON.stringify(items[key]).toString());
      }

      batch.write(() => {
        callback();
      });
    }
  }
开发者ID:laquereric,项目名称:wexond,代码行数:13,代码来源:storage-area.ts

示例5: remove

  public remove(keys: any, callback: any) {
    if (typeof keys === 'string') {
      this.db.del(keys, err => {
        callback();
      });
    } else if (Array.isArray(keys)) {
      const batch = this.db.batch();

      for (const key of keys) {
        batch.del(key);
      }

      batch.write(() => {
        callback();
      });
    } else {
      // error
    }
  }
开发者ID:laquereric,项目名称:wexond,代码行数:19,代码来源:storage-area.ts

示例6: addKeys

  async addKeys(params) {
    const { name, keys, encryptionKey } = params;
    const ops = keys.map(key => {
      let { pubKey } = key;
      pubKey =
        pubKey || new bitcoreLib.PrivateKey(key.privKey).publicKey.toString();
      let payload = {};
      if (pubKey && key.privKey && encryptionKey) {
        const encKey = Encryption.encryptPrivateKey(
          JSON.stringify(key),
          Buffer.from(pubKey, 'hex'),
          Buffer.from(encryptionKey, 'hex')
        );
        payload = { encKey, pubKey };
      }
      return {
        type: 'put',
        key: `key|${name}|${key.address}`,
        value: JSON.stringify(payload)
      };
    });

    return this.db.batch(ops);
  }
开发者ID:bitjson,项目名称:bitcore,代码行数:24,代码来源:storage.ts


注:本文中的levelup.LevelUp.batch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。