Files
standardnotes-app-web/packages/mobile/src/Lib/Utils.ts
Mo 566f6e1432 refactor: components cdn (#1110)
* refactor(wip): separate components files into zips and assets dir

* refactor(wip): use new components package and cdn in mobile

* chore: add components to metro config

* chore: bump snjs with new web assets path

* refactor: exclude package.json files recursively from being copied into components dist folder to avoid conflicts with react native duplicates
2022-06-15 16:00:23 -05:00

46 lines
1.1 KiB
TypeScript

import { TEnvironment } from '@Root/App'
import VersionInfo from 'react-native-version-info'
export const IsDev = VersionInfo.bundleIdentifier?.includes('dev')
export function isNullOrUndefined(value: unknown) {
return value === null || value === undefined
}
/**
* Returns a string with non-alphanumeric characters stripped out
*/
export function stripNonAlphanumeric(str: string) {
return str.replace(/\W/g, '')
}
export function isMatchCaseInsensitive(a: string, b: string) {
return a.toLowerCase() === b.toLowerCase()
}
/**
* Returns a Date object from a JSON stringified date
*/
export function dateFromJsonString(str: string) {
if (str) {
return new Date(JSON.parse(str))
}
return str
}
/**
* Returns a boolean representing whether two dates are on the same day
*/
export function isSameDay(dateA: Date, dateB: Date) {
return (
dateA.getFullYear() === dateB.getFullYear() &&
dateA.getMonth() === dateB.getMonth() &&
dateA.getDate() === dateB.getDate()
)
}
export function isUnfinishedFeaturesEnabled(env: TEnvironment): boolean {
return env === 'dev' || __DEV__
}