@animaapp/framework-helpers
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -39,6 +39,22 @@ "use strict"; | ||
} | ||
if (typeof newValue !== 'string' && typeof newValue !== 'number') { | ||
throw new Error(`Unexpected value in design tokens json file for key = ${key} expecting string got: ${JSON.stringify(newValue)}, new formats will come soon`); | ||
if (newValue == null) { | ||
throw new Error(`Unexpected value in design tokens json file for key = ${key} expecting value`); | ||
} | ||
antdTokens[key] = newValue; | ||
; | ||
if (typeof newValue === 'number' || typeof newValue === 'boolean') { | ||
antdTokens[key] = newValue; | ||
} | ||
else if (typeof newValue === 'object') { | ||
const newString = flattenToString(newValue); | ||
antdTokens[key] = newString; | ||
} | ||
else { | ||
const value = parseFloat(newValue); | ||
if (isNaN(value)) { | ||
antdTokens[key] = newValue; | ||
} | ||
else { | ||
antdTokens[key] = value; | ||
} | ||
} | ||
} | ||
@@ -55,1 +71,21 @@ else { | ||
}; | ||
function flattenToString(input) { | ||
function flatten(obj) { | ||
return Object.values(obj) | ||
.map((value) => { | ||
if (Array.isArray(value)) { | ||
return flattenToString(value); | ||
} | ||
else { | ||
return value.toString(); | ||
} | ||
}) | ||
.join(' '); | ||
} | ||
if (Array.isArray(input)) { | ||
return input.map((item) => flatten(item)).join(', '); | ||
} | ||
else { | ||
return flatten(input); | ||
} | ||
} |
{ | ||
"name": "@animaapp/framework-helpers", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17126
279