本文整理汇总了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();
}
示例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);
}
}
示例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);
示例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;
}
示例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
})();
示例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;
}
示例7: model
model() : any {
const cachedModel = this.entityCache.cachedModel;
if(isBlank(cachedModel)) {
return this.store.createRecord(this.modelName);
} else {
this.entityCache.clearCachedModel();
return cachedModel;
}
}
示例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;
}
示例9: deserialize
deserialize(serialized: any | null) {
const location: any = {};
if(!isBlank(serialized)) {
location.lat = serialized.lat;
location.lng = serialized.lng;
}
return location;
}
示例10: serialize
serialize(deserialized: any | null) {
const serializedLocation: any = {};
if(!isBlank(deserialized)) {
serializedLocation['lat'] = deserialized.lat;
serializedLocation['lng'] = deserialized.lng;
}
return serializedLocation;
}