當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript utils.isBlank函數代碼示例

本文整理匯總了TypeScript中@ember/utils.isBlank函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isBlank函數的具體用法?TypeScript isBlank怎麽用?TypeScript isBlank使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isBlank函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: compute

  compute([model, belongsToRelationshipName] : [Model, string]) : string | undefined {
    if(isBlank(model)) {
      return;
    }

    return model.belongsTo(belongsToRelationshipName).id();
  }
開發者ID:pjcarly,項目名稱:ember-mist-components,代碼行數:7,代碼來源:belongsto.ts

示例2: addRecentlyViewed

  /**
   * Add a model to the recently viewed records
   * @param model The model you want to add
   */
  addRecentlyViewed(model: DrupalModel) : void {
    if(!isBlank(model)) {
      let newRecentlyViewedRecord = {
        type: this.fieldInformation.getModelName(model),
        name: model.name,
        id: model.id
      };

      const oldRecentlyViewedRecords = this.records;

      let newRecentlyViewedRecords = [];
      newRecentlyViewedRecords.push(newRecentlyViewedRecord);

      let index = 1;
      for(let oldRecentlyViewedRecord of oldRecentlyViewedRecords) {
        if(!(oldRecentlyViewedRecord.id === newRecentlyViewedRecord.id && oldRecentlyViewedRecord.type === newRecentlyViewedRecord.type)) {
          newRecentlyViewedRecords.push(oldRecentlyViewedRecord);
          index++;

          if(index >= 10) {
            break;
          }
        }
      }

      this.storage.set('recentlyViewedRecords', newRecentlyViewedRecords);
    }
  }
開發者ID:pjcarly,項目名稱:ember-mist-components,代碼行數:32,代碼來源:recently-viewed.ts

示例3: String

  return Object.keys(paramMap).reduce((url: string, paramKey: string): string => {
    // If the query string already contains the initial question mark append
    //   kv-pair with ampersand
    const separator = String(url).includes('?') ? '&' : '?';
    let paramValue = paramMap[paramKey];

    if (Array.isArray(paramValue)) {
      paramValue = paramValue.toString();
    }

    if (isBlank(paramValue)) {
      return url;
    }

    if (useEncoding) {
      // Malformed URL will cause decodeURIComponent to throw
      //   handle and encode queryValue in such instance
      try {
        // Check if queryValue is already encoded,
        //   otherwise encode queryValue before composing url
        //   e.g. if user directly enters query in location bar
        if (decode(paramValue) === paramValue) {
          paramValue = encode(paramValue);
        }
      } catch (err) {
        if (err instanceof URIError) {
          paramValue = encode(paramValue);
        }

        throw err;
      }
    }

    return `${url}${separator}${paramKey}=${paramValue}`;
  }, baseUrl);
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:35,代碼來源:build-url.ts

示例4: deserialize

  deserialize(serialized: any | null) {
    const address: any = {};

    if(!isBlank(serialized)) {
      address.countryCode = serialized['country-code'];
      address.administrativeArea = serialized['administrative-area'];
      address.locality = serialized['locality'];
      address.dependentLocality = serialized['dependent-locality'];
      address.postalCode = serialized['postal-code'];
      address.sortingCode = serialized['sorting-code'];
      address.addressLine1 = serialized['address-line1'];
      address.addressLine2 = serialized['address-line2'];
    } else {
      address.countryCode = null;
      address.administrativeArea = null;
      address.locality = null;
      address.dependentLocality = null;
      address.postalCode = null;
      address.sortingCode = null;
      address.addressLine1 = null;
      address.addressLine2 = null;
    }

    return address;
  }
開發者ID:pjcarly,項目名稱:ember-mist-components,代碼行數:25,代碼來源:address.ts

示例5: isBlank

(function() {
    /** isBlank */

    // TODO fix upstream in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/254
    // isBlank(); // $ExpectType boolean
    isBlank(null); // $ExpectType boolean
    isBlank(undefined); // $ExpectType boolean
    isBlank(''); // $ExpectType boolean
    isBlank([]); // $ExpectType boolean
    isBlank('\n\t'); // $ExpectType boolean
    isBlank('  '); // $ExpectType boolean
    isBlank({}); // $ExpectType boolean
    isBlank('\n\t Hello'); // $ExpectType boolean
    isBlank('Hello world'); // $ExpectType boolean
    isBlank([1, 2, 3]); // $ExpectType boolean
})();
開發者ID:mnahkies,項目名稱:DefinitelyTyped,代碼行數:16,代碼來源:ember__utils-tests.ts

示例6: records

  /**
   * Returns the Recently Viewed records currently in local storage, if nothing is found an empty array is returned
   */
  @computed('storage.recentlyViewedRecords.[]')
  get records() : RecentlyViewedRecord[] {
    let oldRecentlyViewedRecords : RecentlyViewedRecord[] = this.storage.get('recentlyViewedRecords');
    if(isBlank(oldRecentlyViewedRecords)) {
      oldRecentlyViewedRecords = [];
    }

    return oldRecentlyViewedRecords;
  }
開發者ID:pjcarly,項目名稱:ember-mist-components,代碼行數:12,代碼來源:recently-viewed.ts

示例7: model

  model() : any {
    const cachedModel = this.entityCache.cachedModel;

    if(isBlank(cachedModel)) {
      return this.store.createRecord(this.modelName);
    } else {
      this.entityCache.clearCachedModel();
      return cachedModel;
    }
  }
開發者ID:pjcarly,項目名稱:ember-mist-components,代碼行數:10,代碼來源:model-new-route.ts

示例8: getActiveListViewForRoute

  /**
   * Returns the list view that should be selected
   * @param modelName The name of the model
   * @param routeName The name of the route
   */
  getActiveListViewForRoute(modelName: string, routeName: string) : string | number {
    const listViewSelections = this.storage.get('listViewSelections');

    let selection = 'All';
    if(!isBlank(listViewSelections) && listViewSelections.hasOwnProperty(routeName) && listViewSelections[routeName].hasOwnProperty(modelName)) {
      selection = listViewSelections[routeName][modelName];
    }

    return selection;
  }
開發者ID:pjcarly,項目名稱:ember-mist-components,代碼行數:15,代碼來源:list-view.ts

示例9: deserialize

  deserialize(serialized: any | null) {
    const location: any = {};

    if(!isBlank(serialized)) {
      location.lat = serialized.lat;
      location.lng = serialized.lng;
    }

    return location;
  }
開發者ID:pjcarly,項目名稱:ember-mist-components,代碼行數:10,代碼來源:geolocation.ts

示例10: serialize

  serialize(deserialized: any | null) {
    const serializedLocation: any = {};

    if(!isBlank(deserialized)) {
      serializedLocation['lat'] = deserialized.lat;
      serializedLocation['lng'] = deserialized.lng;
    }

    return serializedLocation;
  }
開發者ID:pjcarly,項目名稱:ember-mist-components,代碼行數:10,代碼來源:geolocation.ts


注:本文中的@ember/utils.isBlank函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。