当前位置: 首页>>代码示例>>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;未经允许,请勿转载。