當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。