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


TypeScript bluebird.props函数代码示例

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


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

示例1: co

BitGo.prototype.checkFunded = co(function *checkFunded() {
  // We are testing both BTC and ETH funds here, to make sure that
  // we don't spend for already 'failed' test runs (e.g., spending ETH when we don't have enough BTC)

  // Test we have enough ETH
  yield this.authenticateTestUser(this.testUserOTP());
  const testWalletId = BitGo.V2.TEST_ETH_WALLET_ID;

  const {
    tethWallet,
    tbtcWallet,
    unspentWallet,
    sweep1Wallet
  } = yield Promise.props({
    tethWallet: this.coin('teth').wallets().get({ id: testWalletId }),
    tbtcWallet: this.coin('tbtc').wallets().getWallet({ id: BitGo.V2.TEST_WALLET1_ID }),
    unspentWallet:  this.coin('tbtc').wallets().getWallet({ id: BitGo.V2.TEST_WALLET2_UNSPENTS_ID }),
    sweep1Wallet: this.coin('tbtc').wallets().getWallet({ id: BitGo.V2.TEST_SWEEP1_ID }),
  });

  const spendableBalance = tethWallet.spendableBalanceString;

  let balance = new BigNumber(spendableBalance);

  // Check our balance is over 60000 (we spend 50000, add some cushion)
  if (balance.lt(60000)) {
    throw new Error(`The TETH wallet ${testWalletId} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
  }

  // Check we have enough in the wallet to run test suite
  tbtcWallet.should.have.property('spendableBalanceString');
  balance = new BigNumber(tbtcWallet.spendableBalanceString());

  // Check our balance is over 0.05 tBTC (we spend 0.04, add some cushion)
  let minimumBalance = 0.05 * 1e8;
  if (balance.lt(minimumBalance)) {
    throw new Error(`The TBTC wallet ${tbtcWallet.id()} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
  }

  // Check we have enough in the wallet to run test suite
  unspentWallet.should.have.property('spendableBalanceString');
  balance = new BigNumber(unspentWallet.spendableBalanceString());

  // Check our balance is over 0.05 tBTC (we spend 0.04, add some cushion)
  minimumBalance = 0.05 * 1e8;
  if (balance.lt(minimumBalance)) {
    throw new Error(`The TBTC wallet ${unspentWallet.id()} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
  }

  // Check we have enough in the wallet to run test suite
  sweep1Wallet.should.have.property('spendableBalanceString');
  balance = new BigNumber(sweep1Wallet.spendableBalanceString());

  // Since we will lose our unspents value to fees, make sure there is a large enough balance to continue
  minimumBalance = 0.05 * 1e8;

  if (balance.lt(minimumBalance)) {
    throw new Error(`The TBTC wallet ${sweep1Wallet.id()} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
  }
});
开发者ID:BitGo,项目名称:BitGoJS,代码行数:60,代码来源:test_bitgo.ts

示例2:

          .then(() => {
            let Project: any = Injector.get("model:auth:Projects");
            if (scopes) {
              if (routeInfo.auth.credentials.scope === "admin") return;

              return Promise
                .props({
                  linkedId: scopes.linked(routeInfo),
                  type: scopes.project(routeInfo)
                })
                .then((res: any) => {
                  return Project
                    .filter({
                      userId: routeInfo.auth.credentials.id,
                      linkedId: res.linkedId,
                      type: res.type
                    })
                })
                .then(projects => {
                  if (projects.length === 0 || (!projects[0].owner && _.intersection(scopes.value, projects[0].scopes).length === 0)) {
                    return Promise.reject(Boom.forbidden(`Missing permission ${scopes.value} on this resource`));
                  }
                });
            }
          }).then(() => {
开发者ID:UnwrittenFun,项目名称:strictly-hapi,代码行数:25,代码来源:bootstrap.ts

示例3: promiseTribeAndAuthorization

export function promiseTribeAndAuthorization(request, tribeId = request.params.tribeId) {
    return Promise.props({
        tribe: request.dataService.requestTribe(tribeId),
        authorizedTribeIds: loadAuthorizedTribeIds(request.user, request.dataService)
    }).then(function (hash: any) {
        return {isAuthorized: hash.tribe != null && contains(hash.tribe.id, hash.authorizedTribeIds), tribe: hash.tribe};
    })
}
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:8,代码来源:AuthorizedTribesFetcher.ts

示例4: expect

                .then(function (response) {
                    let expectedPins = resultPins.concat(newPin);
                    expect(clean(response.body)).toEqual(clean(newPin));

                    return Bluebird.props({
                        expectedPins: expectedPins,
                        results: dataService.requestPins(tribeId)
                    });
                })
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:9,代码来源:pins-spec.ts

示例5: requestAuthorizedTribes

export function requestAuthorizedTribes(user, dataService) {
    return Promise.props({
        tribes: dataService.requestTribes(),
        authorizedTribeIds: this.loadAuthorizedTribeIds(user, dataService)
    })
        .then(function (hash: any) {
            const {authorizedTribeIds, tribes} = hash;
            return filterToAuthorizedTribes(authorizedTribeIds, tribes);
        });
}
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:10,代码来源:AuthorizedTribesFetcher.ts

示例6: extractItemsBy

      R.values(filteredAssociations).map(async field => {
        const selectable = R.pathOr([], ['options', 'selectable'])(field);
        logger.debug(TAG, { field, selectable });
        if (selectable) {
          const primaryKey = _.first(AppContext.adapters.models.getPrimaryKeys(selectable));
          const fieldsOfAssociations = AppContext.adapters.models.getFieldsOfAssociations();

          const foreignOpts = [
            {
              modelName: selectable,
              association: fieldsOfAssociations[selectable],
              onSearch: _.debounce(async (value, callback) => {
                logger.log(TAG, 'onSearch', { value });

                AppContext.adapters.models
                  .loadAssociation(selectable, { keywords: value })
                  .then(response => {
                    const items = extractItemsBy(primaryKey)([response]);
                    callback(items);
                  })
                  .catch(reason => {
                    logger.error(TAG, reason);
                  });
              }, 500),
            },
          ];
          logger.debug(TAG, { fieldsOfAssociations, foreignOpts });

          try {
            const results = await bluebird.props({
              itemsResponse: AppContext.adapters.models.loadAssociation(selectable),
              existItemsResponse: AppContext.adapters.models.loadAssociationByIds(
                selectable,
                field.value,
              ),
            });

            // 当前方法只处理了单个外键的情况,没有考虑如联合主键的处理
            const foreignKeysResponse = {
              [selectable]: {
                items: _.compact(extractItemsBy(primaryKey)([results.itemsResponse])),
                existItems: _.compact(extractItemsBy(primaryKey)([results.existItemsResponse])),
              },
            };
            logger.debug(TAG, { foreignOpts, foreignKeysResponse });
            return { ...field, foreignOpts, associations: foreignKeysResponse };
          } catch (e) {
            logger.error(TAG, e);
          }
        }
        logger.warn(TAG, 'no foreignKeys with association', { field });
        return { ...field, type: DynamicFormTypes.Input };
      }),
开发者ID:danielwii,项目名称:asuna-admin,代码行数:53,代码来源:async.ts

示例7:

                .then(function (response) {
                    let pairsAsSaved = response.body;

                    return Bluebird.props(
                        {
                            pairsAsSaved: pairsAsSaved,
                            history: agent.get(path)
                                .expect(200)
                                .then(function (response) {
                                    return response.body
                                })
                        }
                    );
                })
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:14,代码来源:history-spec.ts

示例8:

fooArrProm = fooArrProm.some(num);

// $ExpectType Bluebird<never>
fooProm.some(num);

fooProm = fooArrProm.race();

// $ExpectType Bluebird<never>
fooProm.race();

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

let propsValue: { num: number, str: string };
Bluebird.resolve({ num: 1, str: Bluebird.resolve('a') }).props().then(val => { propsValue = val; });
Bluebird.props({ num: 1, str: Bluebird.resolve('a') }).then(val => { propsValue = val; });
Bluebird.props(Bluebird.props({ num: 1, str: Bluebird.resolve('a') })).then(val => { propsValue = val; });

let propsMapValue: Map<number, string>;
Bluebird.resolve(new Map<number, string>()).props().then(val => { propsMapValue = val; });
Bluebird.resolve(new Map<number, PromiseLike<string>>()).props().then(val => { propsMapValue = val; });
Bluebird.props(new Map<number, string>()).then(val => { propsMapValue = val; });
Bluebird.props(new Map<number, PromiseLike<string>>()).then(val => { propsMapValue = val; });

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Bluebird.all([fooProm, barProm]).then(result => {
  	foo = result[0];
  	bar = result[1];
});
开发者ID:csrakowski,项目名称:DefinitelyTyped,代码行数:29,代码来源:bluebird-tests.ts

示例9: co

    return co(function *() {
      const disableNetworking = !!verification.disableNetworking;

      const tx = new stellar.Transaction(txPrebuild.txBase64);

      if (txParams.recipients.length !== 1) {
        throw new Error('cannot specify more than 1 recipient');
      }

      // Stellar txs are made up of operations. We only care about Create Account and Payment for sending funds.
      const outputOperations = _.filter(tx.operations, operation =>
        operation.type === 'createAccount' || operation.type === 'payment'
      );

      if (_.isEmpty(outputOperations)) {
        throw new Error('transaction prebuild does not have any operations');
      }

      _.forEach(txParams.recipients, (expectedOutput, index) => {
        const expectedOutputAddress = this.getAddressDetails(expectedOutput.address);
        const output = outputOperations[index];
        if (output.destination !== expectedOutputAddress.address) {
          throw new Error('transaction prebuild does not match expected recipient');
        }

        const expectedOutputAmount = new BigNumber(expectedOutput.amount);
        // The output amount is expressed as startingBalance in createAccount operations and as amount in payment operations.
        let outputAmount = (output.type === 'createAccount') ? output.startingBalance : output.amount;
        outputAmount = new BigNumber(this.bigUnitsToBaseUnits(outputAmount));

        if (!outputAmount.eq(expectedOutputAmount)) {
          throw new Error('transaction prebuild does not match expected amount');
        }
      });

      // Verify the user signature, if the tx is half-signed
      if (!_.isEmpty(tx.signatures)) {
        const userSignature = tx.signatures[0].signature();

        // obtain the keychains and key signatures
        let keychains = verification.keychains;
        if (!keychains && disableNetworking) {
          throw new Error('cannot fetch keychains without networking');
        } else if (!keychains) {
          keychains = yield Promise.props({
            user: this.keychains().get({ id: wallet._wallet.keys[0] }),
            backup: this.keychains().get({ id: wallet._wallet.keys[1] }),
            bitgo: this.keychains().get({ id: wallet._wallet.keys[2] })
          });
        }

        if (this.verifySignature(keychains.backup.pub, tx.hash(), userSignature)) {
          throw new Error('transaction signed with wrong key');
        }
        if (!this.verifySignature(keychains.user.pub, tx.hash(), userSignature)) {
          throw new Error('transaction signature invalid');
        }
      }

      return true;
    }).call(this).asCallback(callback);
开发者ID:BitGo,项目名称:BitGoJS,代码行数:61,代码来源:xlm.ts

示例10: Promise

    return new Promise((resolve, reject) => {
        Fs.readFile(filename, (err, data) => {
            if (err) {
                reject(err)
            } else {
                resolve(data.toString())
            }
        })
    });
}

function writeFile(filename, data) {
    return new Promise((resolve, reject) => {
        Fs.writeFile(filename, data, (err) => {
            if (err) {
                reject(err)
            } else {
                resolve()
            }
        })
    });
}

Promise.props({
    template: readFile('index.template.html'),
    cvmd: readFile('cv.md')
})
.then((props) => props.template.replace('{{bodyContents}}', Marked(props.cvmd)))
.then((html) => writeFile('cv.html', html))

开发者ID:andyfischer,项目名称:andyfischer.github.io,代码行数:29,代码来源:Build.ts


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