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


TypeScript is.fn函数代码示例

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


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

示例1: createTable

  /**
   * Create a table given a tableId or configuration object.
   *
   * @see [Tables: insert API Documentation]{@link https://cloud.google.com/bigquery/docs/reference/v2/tables/insert}
   *
   * @param {string} id Table id.
   * @param {object} [options] See a
   *     [Table resource](https://cloud.google.com/bigquery/docs/reference/v2/tables#resource).
   * @param {string|object} [options.schema] A comma-separated list of name:type
   *     pairs. Valid types are "string", "integer", "float", "boolean", and
   *     "timestamp". If the type is omitted, it is assumed to be "string".
   *     Example: "name:string, age:integer". Schemas can also be specified as a
   *     JSON array of fields, which allows for nested and repeated fields. See
   *     a [Table resource](http://goo.gl/sl8Dmg) for more detailed information.
   * @param {function} [callback] The callback function.
   * @param {?error} callback.err An error returned while making this request
   * @param {Table} callback.table The newly created table.
   * @param {object} callback.apiResponse The full API response.
   * @returns {Promise}
   *
   * @example
   * const BigQuery = require('@google-cloud/bigquery');
   * const bigquery = new BigQuery();
   * const dataset = bigquery.dataset('institutions');
   *
   * const tableId = 'institution_data';
   *
   * const options = {
   *   // From the data.gov CSV dataset (http://goo.gl/kSE7z6):
   *   schema: 'UNITID,INSTNM,ADDR,CITY,STABBR,ZIP,FIPS,OBEREG,CHFNM,...'
   * };
   *
   * dataset.createTable(tableId, options, (err, table, apiResponse) => {});
   *
   * //-
   * // If the callback is omitted, we'll return a Promise.
   * //-
   * dataset.createTable(tableId, options).then((data) => {
   *   const table = data[0];
   *   const apiResponse = data[1];
   * });
   */
  createTable(id, options, callback) {
    if (is.fn(options)) {
      callback = options;
      options = {};
    }

    const body = Table.formatMetadata_(options);

    body.tableReference = {
      datasetId: this.id,
      projectId: this.bigQuery.projectId,
      tableId: id,
    };

    this.request(
      {
        method: 'POST',
        uri: '/tables',
        json: body,
      },
      (err, resp) => {
        if (err) {
          callback(err, null, resp);
          return;
        }

        const table = this.table(resp.tableReference.tableId, {
          location: resp.location,
        });

        table.metadata = resp;
        callback(null, table, resp);
      }
    );
  };
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:77,代码来源:dataset.ts

示例2: extend

 createMethod: (id, options, callback) => {
   if (is.fn(options)) {
     callback = options;
     options = {};
   }
   options = extend({}, options, {location: this.location});
   return bigQuery.createDataset(id, options, callback);
 },
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:8,代码来源:dataset.ts

示例3: getQueryResults

  /**
   * @callback QueryResultsCallback
   * @param {?Error} err An error returned while making this request.
   * @param {array} rows The results of the job.
   */
  /**
   * @callback ManualQueryResultsCallback
   * @param {?Error} err An error returned while making this request.
   * @param {array} rows The results of the job.
   * @param {?object} nextQuery A pre-made configuration object for your next
   *     request. This will be `null` if no additional results are available.
   *     If the query is not yet complete, you may get empty `rows` and
   *     non-`null` `nextQuery` that you should use for your next request.
   * @param {object} apiResponse The full API response.
   */
  /**
   * Get the results of a job.
   *
   * @see [Jobs: getQueryResults API Documentation]{@link https://cloud.google.com/bigquery/docs/reference/v2/jobs/getQueryResults}
   *
   * @param {object} [options] Configuration object.
   * @param {boolean} [options.autoPaginate=true] Have pagination handled
   *     automatically.
   * @param {number} [options.maxApiCalls] Maximum number of API calls to make.
   * @param {number} [options.maxResults] Maximum number of results to read.
   * @param {string} [options.pageToken] Page token, returned by a previous call,
   *     to request the next page of results. Note: This is automatically added to
   *     the `nextQuery` argument of your callback.
   * @param {number} [options.startIndex] Zero-based index of the starting row.
   * @param {number} [options.timeoutMs] How long to wait for the query to
   *     complete, in milliseconds, before returning. Default is to return
   *     immediately. If the timeout passes before the job completes, the request
   *     will fail with a `TIMEOUT` error.
   * @param {QueryResultsCallback|ManualQueryResultsCallback} [callback] The
   *     callback function. If `autoPaginate` is set to false a
   *     {@link ManualQueryResultsCallback} should be used.
   * @returns {Promise}
   *
   * @example
   * const BigQuery = require('@google-cloud/bigquery');
   * const bigquery = new BigQuery();
   *
   * const job = bigquery.job('job-id');
   *
   * //-
   * // Get all of the results of a query.
   * //-
   * job.getQueryResults((err, rows) => {
   *   if (!err) {
   *     // rows is an array of results.
   *   }
   * });
   *
   * //-
   * // Customize the results you want to fetch.
   * //-
   * job.getQueryResults({
   *   maxResults: 100
   * }, (err, rows) => {});
   *
   * //-
   * // To control how many API requests are made and page through the results
   * // manually, set `autoPaginate` to `false`.
   * //-
   * function manualPaginationCallback(err, rows, nextQuery, apiResponse) {
   *   if (nextQuery) {
   *     // More results exist.
   *     job.getQueryResults(nextQuery, manualPaginationCallback);
   *   }
   * }
   *
   * job.getQueryResults({
   *   autoPaginate: false
   * }, manualPaginationCallback);
   *
   * //-
   * // If the callback is omitted, we'll return a Promise.
   * //-
   * job.getQueryResults().then((data) => {
   *   const rows = data[0];
   * });
   */
  getQueryResults(options, callback) {
    if (is.fn(options)) {
      callback = options;
      options = {};
    }

    options = extend(
      {
        location: this.location,
      },
      options
    );

    this.bigQuery.request(
      {
        uri: '/queries/' + this.id,
        qs: options,
      },
//.........这里部分代码省略.........
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:101,代码来源:job.ts

示例4: function

BigQuery.prototype.getJobs = function(options, callback) {
  const that = this;

  if (is.fn(options)) {
    callback = options;
    options = {};
  }

  options = options || {};

  this.request(
    {
      uri: '/jobs',
      qs: options,
      useQuerystring: true,
    },
    function(err, resp) {
      if (err) {
        callback(err, null, null, resp);
        return;
      }

      let nextQuery = null;

      if (resp.nextPageToken) {
        nextQuery = extend({}, options, {
          pageToken: resp.nextPageToken,
        });
      }

      const jobs = (resp.jobs || []).map(function(jobObject) {
        const job = that.job(jobObject.jobReference.jobId, {
          location: jobObject.jobReference.location,
        });

        job.metadata = jobObject;
        return job;
      });

      callback(null, jobs, nextQuery, resp);
    }
  );
};
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:43,代码来源:index.ts

示例5: getTables

  /**
   * Get a list of tables.
   *
   * @see [Tables: list API Documentation]{@link https://cloud.google.com/bigquery/docs/reference/v2/tables/list}
   *
   * @param {object} [options] Configuration object.
   * @param {boolean} [options.autoPaginate=true] Have pagination handled automatically.
   * @param {number} [options.maxApiCalls] Maximum number of API calls to make.
   * @param {number} [options.maxResults] Maximum number of results to return.
   * @param {string} [options.pageToken] Token returned from a previous call, to
   *     request the next page of results.
   * @param {function} [callback] The callback function.
   * @param {?error} callback.err An error returned while making this request
   * @param {Table[]} callback.tables The list of tables from
   *     your Dataset.
   * @returns {Promise}
   *
   * @example
   * const BigQuery = require('@google-cloud/bigquery');
   * const bigquery = new BigQuery();
   * const dataset = bigquery.dataset('institutions');
   *
   * dataset.getTables((err, tables) => {
   *   // tables is an array of `Table` objects.
   * });
   *
   * //-
   * // To control how many API requests are made and page through the results
   * // manually, set `autoPaginate` to `false`.
   * //-
   * function manualPaginationCallback(err, tables, nextQuery, apiResponse) {
   *   if (nextQuery) {
   *     // More results exist.
   *     dataset.getTables(nextQuery, manualPaginationCallback);
   *   }
   * }
   *
   * dataset.getTables({
   *   autoPaginate: false
   * }, manualPaginationCallback);
   *
   * //-
   * // If the callback is omitted, we'll return a Promise.
   * //-
   * dataset.getTables().then((data) => {
   *   const tables = data[0];
   * });
   */
  getTables(options, callback) {
    if (is.fn(options)) {
      callback = options;
      options = {};
    }

    options = options || {};

    this.request(
      {
        uri: '/tables',
        qs: options,
      },
      (err, resp) => {
        if (err) {
          callback(err, null, null, resp);
          return;
        }

        let nextQuery = null;
        if (resp.nextPageToken) {
          nextQuery = extend({}, options, {
            pageToken: resp.nextPageToken,
          });
        }

        const tables = (resp.tables || []).map(tableObject => {
          const table = this.table(tableObject.tableReference.tableId, {
            location: tableObject.location,
          });
          table.metadata = tableObject;
          return table;
        });
        callback(null, tables, nextQuery, resp);
      }
    );
  };
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:85,代码来源:dataset.ts


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