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


TypeScript bluebird.default函数代码示例

本文整理汇总了TypeScript中bluebird.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getTextlintDependencyNames

export const createConfigFile = (options: CreateConfigFileOption) => {
    const dir = options.dir;
    return getTextlintDependencyNames(dir).then(pkgNames => {
        const rcFile = `.${Config.CONFIG_FILE_NAME}rc`;
        const filePath = path.resolve(dir, rcFile);
        if (isFile(filePath)) {
            Logger.error(`${rcFile} is already existed.`);
            return Promise.resolve(1);
        }
        const filters = pkgNames
            .filter(pkgName => {
                return pkgName.indexOf(TextlintPackageNamePrefix.filterRule) !== -1;
            })
            .map(filterName => {
                return filterName.replace(TextlintPackageNamePrefix.filterRule, "");
            });
        const rules = pkgNames
            .filter(pkgName => {
                return pkgName.indexOf(TextlintPackageNamePrefix.rule) !== -1;
            })
            .map(filterName => {
                return filterName.replace(TextlintPackageNamePrefix.rule, "");
            });
        const defaultTextlintRc = {
            filters: arrayToObject(filters, true),
            rules: arrayToObject(rules, true)
        };
        const output = JSON.stringify(defaultTextlintRc, null, 2);
        fs.writeFileSync(filePath, output);
        if (options.verbose) {
            Logger.log(`${rcFile} is created.`);
        }
        return Promise.resolve(0);
    });
};
开发者ID:textlint,项目名称:textlint,代码行数:35,代码来源:config-initializer.ts

示例2: getTextlintDependencyNames

    array.forEach(item => {
        object[item] = defaultValue;
    });
    return object;
};
/**
 * Initializer class for config of textlint.
 */
export const configInit = {
    /**
     * Create .textlintrc file
     * @params {string} dir The directory of .textlintrc file
     * @returns {Promise.<number>} The exit code for the operation.
     */
    initializeConfig(dir: string) {
        return getTextlintDependencyNames(dir).then(pkgNames => {
            const rcFile = `.${Config.CONFIG_FILE_NAME}rc`;
            const filePath = path.resolve(dir, rcFile);
            if (isFile(filePath)) {
                Logger.error(`${rcFile} is already existed.`);
                return Promise.resolve(1);
            }
            const filters = pkgNames
                .filter(pkgName => {
                    return pkgName.indexOf(Config.FILTER_RULE_NAME_PREFIX) !== -1;
                })
                .map(filterName => {
                    return filterName.replace(Config.FILTER_RULE_NAME_PREFIX, "");
                });
            const rules = pkgNames
                .filter(pkgName => {
开发者ID:,项目名称:,代码行数:31,代码来源:

示例3: co

    return co(function *initiateRecovery() {
      const keys = [];
      const userKey = params.userKey; // Box A
      let backupKey = params.backupKey; // Box B
      const bitgoXpub = params.bitgoKey; // Box C
      const destinationAddress = params.recoveryDestination;
      const passphrase = params.walletPassphrase;

      const isKrsRecovery = backupKey.startsWith('xpub') && !userKey.startsWith('xpub');
      const isUnsignedSweep = backupKey.startsWith('xpub') && userKey.startsWith('xpub');

      if (isKrsRecovery && _.isUndefined(config.krsProviders[params.krsProvider])) {
        throw new Error('unknown key recovery service provider');
      }

      const validatePassphraseKey = function(userKey, passphrase): Promise<HDNode> {
        try {
          if (!userKey.startsWith('xprv') && !isUnsignedSweep) {
            userKey = sjcl.decrypt(passphrase, userKey);
          }
          const userHDNode = HDNode.fromBase58(userKey);
          return Promise.resolve(userHDNode);
        } catch (e) {
          throw new Error('Failed to decrypt user key with passcode - try again!');
        }
      };

      const key = yield validatePassphraseKey(userKey, passphrase);

      keys.push(key);

      // Validate the backup key
      try {
        if (!backupKey.startsWith('xprv') && !isKrsRecovery && !isUnsignedSweep) {
          backupKey = sjcl.decrypt(passphrase, backupKey);
        }
        const backupHDNode = HDNode.fromBase58(backupKey);
        keys.push(backupHDNode);
      } catch (e) {
        throw new Error('Failed to decrypt backup key with passcode - try again!');
      }
      try {
        const bitgoHDNode = HDNode.fromBase58(bitgoXpub);
        keys.push(bitgoHDNode);
      } catch (e) {
        if (this.getFamily() !== 'xrp') {
          // in XRP recoveries, the BitGo xpub is optional
          throw new Error('Failed to parse bitgo xpub!');
        }
      }
      // Validate the destination address
      if (!this.isValidAddress(destinationAddress)) {
        throw new Error('Invalid destination address!');
      }

      return keys;
    }).call(this);
开发者ID:BitGo,项目名称:BitGoJS,代码行数:57,代码来源:xrp.ts

示例4: a

async function a(): Bluebird<void> {
  try {
    const b = async function b(): Bluebird<void> {
      try {
        await Bluebird.resolve(); // -- remove this and it compiles
      } catch (error) { }
    };

    await b(); // -- or remove this and it compiles
  } catch (error) { }
}
开发者ID:01alchemist,项目名称:TypeScript,代码行数:11,代码来源:transformNestedGeneratorsWithTry.ts

示例5: formatSourceFile

 function formatSourceFile(path, contents, callback) {
     return withTempFile(path, contents).then((tempFilePath) => {
         const req = {
             typehint: "FormatOneSourceReq",
             file: {
                 file: path,
                 contentsIn: tempFilePath
             }
         }
         return client.post(req);
     });
 }
开发者ID:tomverran,项目名称:ensime-node,代码行数:12,代码来源:server-api.ts

示例6: typecheckBuffer

 function typecheckBuffer(path: string, text: string) {
     withTempFile(path, text).then((tempFilePath) => {
         const msg = {
             typehint: "TypecheckFileReq",
             fileInfo: {
                 file: path,
                 contentsIn: tempFilePath
             }
         }
         return client.post(msg);
     });
 } 
开发者ID:tomverran,项目名称:ensime-node,代码行数:12,代码来源:server-api.ts

示例7: getCompletions

 function getCompletions(filePath: string, bufferText, offset, noOfAutocompleteSuggestions) {
     return withTempFile(filePath, bufferText).then((tempFile) => {
         const msg = {
             typehint: "CompletionsReq",
             fileInfo: {
                 file: filePath,
                 contentsIn: tempFile
             },
             point: offset,
             maxResults: noOfAutocompleteSuggestions,
             caseSens: false,
             reload: true
         }
         return client.post(msg);
     });
 } 
开发者ID:tomverran,项目名称:ensime-node,代码行数:16,代码来源:server-api.ts

示例8: putStatusToStream

 .catch((error) => {
     console.log(error);
     putStatusToStream(makeFailurePutRequest(emailDataList, error))
 })
开发者ID:sndrs,项目名称:email-signup,代码行数:4,代码来源:triggersubscriberhandler.ts


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