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


TypeScript urijs.default函数代码示例

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


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

示例1: URI

#!/usr/bin/env node

import request from 'request-promise';
import URI from 'urijs';
import program from 'commander';
import Bluebird from 'bluebird';

const CONCURRENCY = 5;
const SENTRY_API_TOKEN = process.env.SENTRY_API_TOKEN;
const BASE_URI = URI('https://sentry.io/api/0/');

let eventId = 0;

program
  .version('3.0.0')
  .usage('[options] <event_id>')
  .arguments('<event_id>')
  .action(event_id => {
    eventId = event_id;
  })
  .option('-p, --pages [pages]', 'number of pages to fetch. defaults to 1', parseInt)
  .option('-o, --organisation [organisation]', 'organisation. required for extended events')
  .option('-n, --project-name [project-name]', 'project name. required for extended events')
  .option('-x, --extended-event', 'enable extended event')
  .parse(process.argv);

validate();

getSentryEventData()
  .then(JSON.stringify)
  .then(console.log)
开发者ID:busbud,项目名称:get-sentry-event-data,代码行数:31,代码来源:index.ts

示例2: fetchPrograms

  public async fetchPrograms(queryOptions: ApiRequestPrograms = {}): Promise<ApiResponsePrograms> {
    const url =
      URI(API_URL)
        .segment('programs')
        .segment('items')
        .suffix('json')
        .query(this.queryParamsWithCredentials(queryOptions))
        .toString()

    const response = await this.fetcher(url)
    return this.retrieveJSONOrError(response)
  }
开发者ID:jsalonen,项目名称:yle-api,代码行数:12,代码来源:client.ts

示例3: trackStreamStart

  public async trackStreamStart(programId: string, mediaId: string): Promise<void> {
    const url =
      URI(API_URL)
        .segment('tracking')
        .segment('streamstart')
        .query(this.queryParamsWithCredentials({
          program_id: programId,
          media_id: mediaId
        }))
        .toString()

    const response = await this.fetcher(url)
    if (!response.ok) {
      return Promise.reject(`Track stream failed: ${response.status} ${response.statusText}`)
    }
  }
开发者ID:jsalonen,项目名称:yle-api,代码行数:16,代码来源:client.ts

示例4: getImageUrl

  public getImageUrl(
    programImageId: string,
    format: CloudinaryImageFormat = 'jpg',
    transformations?: CloudinaryImageTransformations
  ): string {
    let url = URI(IMAGES_URL)
    if (transformations) {
      url = url.segment(makeImageTransformationString(transformations))
    }

    return (
      url
        .segment(programImageId)
        .suffix(format)
        .toString()
    )
  }
开发者ID:jsalonen,项目名称:yle-api,代码行数:17,代码来源:client.ts

示例5: fetchPlayouts

  public async fetchPlayouts(
    programId: string,
    mediaId: string,
    protocol: PlayoutProtocol,
    decryptMediaUrls = true
  ): Promise<ApiResponseMediaPlayouts> {
    const decryptKey = this.apiAuth.decryptKey
    if (decryptMediaUrls && !decryptKey) {
      const decryptKeyMissingError = () => {
        throw new Error('Missing media decryption key')
      }
      throw decryptKeyMissingError
    }

    const url =
      URI(API_URL)
        .segment('media')
        .segment('playouts')
        .suffix('json')
        .query(this.queryParamsWithCredentials({
          program_id: programId,
          media_id: mediaId,
          protocol
        }))
        .toString()

    const maybeDecryptMediaUrls = (playouts: ApiResponseMediaPlayouts) => {
      if (!decryptMediaUrls) {
        return playouts
      } else {
        return this.decryptMediaUrls(playouts, this.apiAuth.decryptKey as string)
      }
    }

    const response = await this.fetcher(url)

    return this
      .retrieveJSONOrError(response)
      .then(maybeDecryptMediaUrls)
  }
开发者ID:jsalonen,项目名称:yle-api,代码行数:40,代码来源:client.ts


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