本文整理汇总了TypeScript中tns-core-modules/utils/types.isDefined函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isDefined函数的具体用法?TypeScript isDefined怎么用?TypeScript isDefined使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isDefined函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fetch
fetch("https://httpbin.org/get").then(function (response) {
// Argument (response) is Response!
// var all = response.headers.getAll();
// >> (hide)
TKUnit.assert(types.isDefined(response.headers), "response.headers should be defined! Actual result is: " + response.headers);
done(null);
// << (hide)
}).catch(failOnError(done));
示例2: function
export var test_fetch_defined = function () {
TKUnit.assert(types.isDefined((fetch)), "Method fetch() should be defined!");
};
示例3: _createImageSourceFromSrc
/**
* @internal
*/
_createImageSourceFromSrc(): void {
var value = this.src;
if (types.isString(value)) {
value = value.trim();
this.imageSource = null;
this["_url"] = value;
// this._setValue(SVGImage.isLoadingProperty, true);
this.isLoading = true;
var source = new definition.ImageSourceSVG();
var imageLoaded = () => {
let currentValue = this.src;
if (!types.isString(this.src) || value !== currentValue.trim()) {
return;
}
this.imageSource = source;
// imageSourceProperty.nativeValueChange(this, source);
// this._setValue(SVGImage.isLoadingProperty, false);
this.isLoading = false;
}
//WRONG IMplementation, it can't load data uri, just base xml encode
if (utils.isDataURI(value)) {
var base64Data = value.split(",")[1];
if (types.isDefined(base64Data)) {
if (this.loadMode === SYNC) {
source.loadFromBase64(base64Data);
imageLoaded();
} else if (this.loadMode === ASYNC) {
source.fromBase64(base64Data).then(imageLoaded);
}
}
}
else if (definition.isFileOrResourcePath(value)) {
if (value.indexOf(utils.RESOURCE_PREFIX) === 0) {
let resPath = value.substr(utils.RESOURCE_PREFIX.length);
if (this.loadMode === SYNC) {
source.loadFromResource(resPath);
imageLoaded();
} else if (this.loadMode === ASYNC) {
this.imageSource = null;
source.fromResource(resPath).then(imageLoaded);
}
} else {
if (this.loadMode === SYNC) {
source.loadFromFile(value);
imageLoaded();
} else if (this.loadMode === ASYNC) {
this.imageSource = null;
source.fromFile(value).then(imageLoaded);
}
}
} else {
this.imageSource = null;
definition.fromUrl(value).then((r) => {
if (this["_url"] === value) {
this.imageSource = r;
// this._setValue(SVGImage.isLoadingProperty, false);
this.isLoading = false;
}
});
}
}
else if (value instanceof definition.ImageSourceSVG) {
// Support binding the imageSource trough the src property
this.imageSource = value;
// this._setValue(SVGImage.isLoadingProperty, false);
this.isLoading = false;
}
else {
this.imageSource = definition.fromNativeSource(value);
// this._setValue(SVGImage.isLoadingProperty, false);
this.isLoading = false;
}
}