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

Function convertString

packages/core/utils/common.ts:34–52  ·  view source on GitHub ↗
(value: any)

Source from the content-addressed store, hash-verified

32}
33
34export function convertString(value: any): any {
35 let result;
36
37 if (!types.isString(value) || value.trim() === '') {
38 result = value;
39 } else {
40 // Try to convert value to number.
41 const valueAsNumber = +value;
42 if (!isNaN(valueAsNumber)) {
43 result = valueAsNumber;
44 } else if (value && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
45 result = value.toLowerCase() === 'true' ? true : false;
46 } else {
47 result = value;
48 }
49 }
50
51 return result;
52}
53
54export function getModuleName(path: string): string {
55 const moduleName = path.replace('./', '');

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected