if (isDate(value)) {
return value
}
- if (isString(value) || typeof value === 'number') {
+ if (typeof value === 'string' || typeof value === 'number') {
const valueToDate = new Date(value)
if (isNaN(valueToDate.getTime())) {
throw new Error(`Cannot convert to date: '${value}'`)
return Math.trunc(value)
}
let changedValue: number = value as number
- if (isString(value)) {
+ if (typeof value === 'string') {
changedValue = parseInt(value)
}
if (isNaN(changedValue)) {
return 0
}
let changedValue: number = value as number
- if (isString(value)) {
+ if (typeof value === 'string') {
changedValue = parseFloat(value)
}
if (isNaN(changedValue)) {
// Check the type
if (typeof value === 'boolean') {
return value
- } else if (isString(value) && (value.toLowerCase() === 'true' || value === '1')) {
+ } else if (typeof value === 'string' && (value.toLowerCase() === 'true' || value === '1')) {
result = true
} else if (typeof value === 'number' && value === 1) {
result = true
return env.VCAP_APPLICATION != null
}
-const isString = (value: unknown): value is string => {
- return typeof value === 'string'
-}
-
export const isNotEmptyString = (value: unknown): value is string => {
- return isString(value) && value.trim().length > 0
+ return typeof value === 'string' && value.trim().length > 0
}
export const isNotEmptyArray = (value: unknown): value is unknown[] => {