MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / toPositiveInt

Function toPositiveInt

packages/core/image-asset/image-asset-common.ts:38–50  ·  view source on GitHub ↗
(value: any)

Source from the content-addressed store, hash-verified

36}
37
38function toPositiveInt(value: any): number {
39 if (value == null) {
40 return 0;
41 }
42 if (typeof value === 'number') {
43 return value > 0 ? Math.floor(value) : 0;
44 }
45 if (typeof value === 'string') {
46 const parsed = parseInt(value, 10);
47 return isNaN(parsed) || parsed <= 0 ? 0 : parsed;
48 }
49 return 0;
50}
51
52function normalizeImageAssetOptions(options: ImageAssetOptions): ImageAssetOptions {
53 const normalized = options ? { ...options } : ({} as ImageAssetOptions);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected