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


TypeScript utils.isNone函数代码示例

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


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

示例1: testIsNoneType

function testIsNoneType() {
    const maybeUndefined: string | undefined = 'not actually undefined';
    if (utils.isNone(maybeUndefined)) {
        return;
    }

    const anotherString = maybeUndefined + 'another string';
    utils.isNone(); // $ExpectType boolean
}
开发者ID:mnahkies,项目名称:DefinitelyTyped,代码行数:9,代码来源:utils.ts

示例2: getHeader

/**
 * Do a case-insensitive lookup of an HTTP header
 *
 * @function getHeader
 * @private
 */
export default function getHeader(
  headers: Headers | undefined,
  name: string | undefined
): string | undefined | null {
  if (isNone(headers) || isNone(name)) {
    return undefined;
  }

  const matchedKey = A(Object.keys(headers)).find(key => {
    return key.toLowerCase() === name.toLowerCase();
  });

  return matchedKey ? headers[matchedKey] : undefined;
}
开发者ID:knownasilya,项目名称:ember-ajax,代码行数:20,代码来源:get-header.ts

示例3: updateData

 updateData(data, initial) {
   let recordDatas: RelationshipRecordData[] | undefined;
   if (isNone(data)) {
     recordDatas = undefined;
   } else {
     recordDatas = new Array(data.length);
     for (let i = 0; i < data.length; i++) {
       recordDatas[i] = this.recordData.storeWrapper.recordDataFor(data[i].type, data[i].id);
     }
   }
   if (initial) {
     this.setInitialRecordDatas(recordDatas);
   } else {
     this.updateRecordDatasFromAdapter(recordDatas);
   }
 }
开发者ID:code0100fun,项目名称:data,代码行数:16,代码来源:has-many.ts

示例4: isNone

(function() {
    /** isNone */
    const maybeUndefined: string | undefined = 'not actually undefined';
    if (isNone(maybeUndefined)) {
        return;
    }
    const anotherString = maybeUndefined + 'another string';
    isNone();              // $ExpectType boolean
    isNone(null);          // $ExpectType boolean
    isNone(undefined);     // $ExpectType boolean
    isNone('');            // $ExpectType boolean
    isNone([]);            // $ExpectType boolean
    isNone(function() {}); // $ExpectType boolean
})();
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:14,代码来源:ember__utils-tests.ts

示例5: isNone

(function() {
    /** isNone */
    const maybeUndefined: string | undefined = 'not actually undefined';
    if (isNone(maybeUndefined)) {
        return;
    }
    const anotherString = maybeUndefined + 'another string';
    // TODO fix upstream in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/256
    // isNone();              // $ExpectType boolean
    isNone(null);          // $ExpectType boolean
    isNone(undefined);     // $ExpectType boolean
    isNone('');            // $ExpectType boolean
    isNone([]);            // $ExpectType boolean
    isNone(function() {}); // $ExpectType boolean
})();
开发者ID:mnahkies,项目名称:DefinitelyTyped,代码行数:15,代码来源:ember__utils-tests.ts

示例6: updateData

  updateData(data: JsonApiResourceIdentity, initial: boolean) {
    let recordData;
    if (isNone(data)) {
      recordData = null;
    }
    assert(
      `Ember Data expected the data for the ${
        this.key
      } relationship on a ${this.recordData.toString()} to be in a JSON API format and include an \`id\` and \`type\` property but it found ${inspect(
        data
      )}. Please check your serializer and make sure it is serializing the relationship payload into a JSON API format.`,
      data === null || (data.id !== undefined && data.type !== undefined)
    );

    if (recordData !== null) {
      recordData = this.recordData.storeWrapper.recordDataFor(data.type, (data.id as string));
    }
    if (initial) {
      this.setInitialCanonicalRecordData(recordData);
    } else {
      this.setCanonicalRecordData(recordData);
    }
  }
开发者ID:code0100fun,项目名称:data,代码行数:23,代码来源:belongs-to.ts

示例7: normalizeErrorResponse

   * ```
   *
   * In cases where the server returns an array, then there should be one item
   * in the array for each of the payload.  If your server returns a JSON API
   * formatted payload already, it will just be returned directly.
   *
   * If your server returns something other than a JSON API format, it's
   * suggested that you override this method to convert your own errors into the
   * one described above.
   */
  normalizeErrorResponse(
    status: number,
    _headers: Headers,
    payload?: Payload
  ): JsonApiErrorObject[] {
    payload = isNone(payload) ? {} : payload;

    if (isJsonApiErrorResponse(payload)) {
      return payload.errors.map(function(error) {
        if (isObject(error)) {
          const ret = assign({}, error);
          ret.status = `${error.status}`;
          return ret;
        } else {
          return {
            status: `${status}`,
            title: error
          };
        }
      });
    } else if (isJsonApiErrorObjectArray(payload)) {
开发者ID:knownasilya,项目名称:ember-ajax,代码行数:31,代码来源:normalize-error-response.ts

示例8: testIsNone

function testIsNone() {
    utils.isNone(); // $ExpectType boolean
    utils.isNone(''); // $ExpectType boolean
    utils.isNone('', ''); // $ExpectError
}
开发者ID:mnahkies,项目名称:DefinitelyTyped,代码行数:5,代码来源:utils.ts


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