Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should raise an error when call with invalid argument', () => {
// $ExpectError: first argument must be a string
Asset.fromURI(1);
});
});
function _getAssetForSource(source) {
if (source instanceof Asset) {
return source;
}
if (!isWeb && typeof source === 'string') {
return Asset.fromURI(source);
}
if (isWeb || typeof source === 'number') {
return Asset.fromModule(source);
}
// @ts-ignore Error: Type 'string' is not assignable to type 'Asset'
// We can't have a string here, we would have thrown an error if !isWeb
// or returned Asset.fromModule if isWeb.
return source;
}
async function _loadSingleFontAsync(name, asset) {
export function getAssetForSource(source: FontSource): Asset | FontResource {
if (source instanceof Asset) {
return source;
}
if (typeof source === 'string') {
return Asset.fromURI(source);
} else if (typeof source === 'number') {
return Asset.fromModule(source);
} else if (typeof source === 'object' && typeof source.uri !== 'undefined') {
return getAssetForSource(source.uri);
}
// @ts-ignore Error: Type 'string' is not assignable to type 'Asset'
// We can't have a string here, we would have thrown an error if !isWeb
// or returned Asset.fromModule if isWeb.
return source;
}
export function getAssetForSource(source) {
if (source instanceof Asset) {
return source;
}
if (typeof source === 'string') {
return Asset.fromURI(source);
}
else if (typeof source === 'number') {
return Asset.fromModule(source);
}
else if (typeof source === 'object' && typeof source.uri !== 'undefined') {
return getAssetForSource(source.uri);
}
// @ts-ignore Error: Type 'string' is not assignable to type 'Asset'
// We can't have a string here, we would have thrown an error if !isWeb
// or returned Asset.fromModule if isWeb.
return source;
}
export async function loadSingleFontAsync(name, input) {
function _getAssetForSource(source: FontSource): Asset {
if (source instanceof Asset) {
return source;
}
if (!isWeb && typeof source === 'string') {
return Asset.fromURI(source);
}
if (isWeb || typeof source === 'number') {
return Asset.fromModule(source);
}
// @ts-ignore Error: Type 'string' is not assignable to type 'Asset'
// We can't have a string here, we would have thrown an error if !isWeb
// or returned Asset.fromModule if isWeb.
return source;
}
it('should passes when used properly', () => {
Asset.fromURI('uri').downloadAsync();
});