@freakycoder/react-native-helpers
Advanced tools
| export declare const openAppInPlayStore: (appPackageName: string) => void; | ||
| export declare const openAppInAppStore: (appStoreId: string) => void; | ||
| export declare const openExternalApp: (appPackageName: string, appStoreId: string) => void; |
| import { Linking, Platform } from "react-native"; | ||
| export const openAppInPlayStore = (appPackageName) => { | ||
| const url = `market://details?id=${appPackageName}`; | ||
| Linking.canOpenURL(url) | ||
| .then((supported) => { | ||
| if (!supported) { | ||
| return console.log("Cannot handle URL: " + url); | ||
| } | ||
| else { | ||
| return Linking.openURL(url); | ||
| } | ||
| }) | ||
| .catch((err) => console.error("An error occurred", err)); | ||
| }; | ||
| export const openAppInAppStore = (appStoreId) => { | ||
| const url = `https://apps.apple.com/app/id${appStoreId}`; | ||
| Linking.canOpenURL(url) | ||
| .then((supported) => { | ||
| if (!supported) { | ||
| return console.log("Cannot handle URL: " + url); | ||
| } | ||
| else { | ||
| return Linking.openURL(url); | ||
| } | ||
| }) | ||
| .catch((err) => console.error("An error occurred", err)); | ||
| }; | ||
| export const openExternalApp = (appPackageName, appStoreId) => { | ||
| if (Platform.OS === "ios") { | ||
| openAppInAppStore(appStoreId); | ||
| } | ||
| else if (Platform.OS === "android") { | ||
| openAppInPlayStore(appPackageName); | ||
| } | ||
| }; | ||
| //# sourceMappingURL=linking.js.map |
| {"version":3,"file":"linking.js","sourceRoot":"","sources":["../../../lib/utils/linking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,cAAsB,EAAE,EAAE;IAC3D,MAAM,GAAG,GAAG,uBAAuB,cAAc,EAAE,CAAC;IACpD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;SACpB,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;QAClB,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,GAAG,CAAC,CAAC;SACjD;aAAM;YACL,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SAC7B;IACH,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,UAAkB,EAAE,EAAE;IACtD,MAAM,GAAG,GAAG,gCAAgC,UAAU,EAAE,CAAC;IACzD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;SACpB,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;QAClB,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,GAAG,CAAC,CAAC;SACjD;aAAM;YACL,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SAC7B;IACH,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,cAAsB,EAAE,UAAkB,EAAE,EAAE;IAC5E,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,iBAAiB,CAAC,UAAU,CAAC,CAAC;KAC/B;SAAM,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QACpC,kBAAkB,CAAC,cAAc,CAAC,CAAC;KACpC;AACH,CAAC,CAAC"} |
| import { Linking, Platform } from "react-native"; | ||
| export const openAppInPlayStore = (appPackageName: string) => { | ||
| const url = `market://details?id=${appPackageName}`; | ||
| Linking.canOpenURL(url) | ||
| .then((supported) => { | ||
| if (!supported) { | ||
| return console.log("Cannot handle URL: " + url); | ||
| } else { | ||
| return Linking.openURL(url); | ||
| } | ||
| }) | ||
| .catch((err) => console.error("An error occurred", err)); | ||
| }; | ||
| export const openAppInAppStore = (appStoreId: string) => { | ||
| const url = `https://apps.apple.com/app/id${appStoreId}`; | ||
| Linking.canOpenURL(url) | ||
| .then((supported) => { | ||
| if (!supported) { | ||
| return console.log("Cannot handle URL: " + url); | ||
| } else { | ||
| return Linking.openURL(url); | ||
| } | ||
| }) | ||
| .catch((err) => console.error("An error occurred", err)); | ||
| }; | ||
| export const openExternalApp = (appPackageName: string, appStoreId: string) => { | ||
| if (Platform.OS === "ios") { | ||
| openAppInAppStore(appStoreId); | ||
| } else if (Platform.OS === "android") { | ||
| openAppInPlayStore(appPackageName); | ||
| } | ||
| }; |
| import { isIOS, isAndroid, ScreenMin, ScreenMax, vh, vw, vmin, vmax, ScreenWidth, ScreenHeight, ScreenScale, ScreenFontScale, WindowWidth, WindowHeight, WindowScale, WindowFontScale, PlatformVersion, getDeviceLanguage } from "./helpers/device/DeviceInfo"; | ||
| import { getStatusBarHeight, hasNotch, hasNotchOnly, hasDynamicIsland } from "./helpers/notch/Notch"; | ||
| import normalizeText from "./helpers/normalize/normalizeText"; | ||
| import { openExternalApp, openAppInAppStore, openAppInPlayStore } from "./utils"; | ||
| import { numberFormat } from "./helpers/text/Text"; | ||
| export { vh, vw, vmin, vmax, ScreenMin, ScreenMax, isIOS, isAndroid, ScreenWidth, ScreenHeight, ScreenScale, ScreenFontScale, WindowWidth, WindowHeight, WindowScale, WindowFontScale, PlatformVersion, getDeviceLanguage, getStatusBarHeight, hasNotch, hasNotchOnly, hasDynamicIsland, numberFormat, normalizeText, }; | ||
| export { vh, vw, vmin, vmax, ScreenMin, ScreenMax, isIOS, isAndroid, ScreenWidth, ScreenHeight, ScreenScale, ScreenFontScale, WindowWidth, WindowHeight, WindowScale, WindowFontScale, PlatformVersion, getDeviceLanguage, getStatusBarHeight, hasNotch, hasNotchOnly, hasDynamicIsland, numberFormat, normalizeText, openExternalApp, openAppInAppStore, openAppInPlayStore, }; |
| import { isIOS, isAndroid, ScreenMin, ScreenMax, vh, vw, vmin, vmax, ScreenWidth, ScreenHeight, ScreenScale, ScreenFontScale, WindowWidth, WindowHeight, WindowScale, WindowFontScale, PlatformVersion, getDeviceLanguage, } from "./helpers/device/DeviceInfo"; | ||
| import { getStatusBarHeight, hasNotch, hasNotchOnly, hasDynamicIsland, } from "./helpers/notch/Notch"; | ||
| import normalizeText from "./helpers/normalize/normalizeText"; | ||
| import { openExternalApp, openAppInAppStore, openAppInPlayStore, } from "./utils"; | ||
| import { numberFormat } from "./helpers/text/Text"; | ||
| export { vh, vw, vmin, vmax, ScreenMin, ScreenMax, isIOS, isAndroid, ScreenWidth, ScreenHeight, ScreenScale, ScreenFontScale, WindowWidth, WindowHeight, WindowScale, WindowFontScale, PlatformVersion, getDeviceLanguage, getStatusBarHeight, hasNotch, hasNotchOnly, hasDynamicIsland, numberFormat, normalizeText, }; | ||
| export { vh, vw, vmin, vmax, ScreenMin, ScreenMax, isIOS, isAndroid, ScreenWidth, ScreenHeight, ScreenScale, ScreenFontScale, WindowWidth, WindowHeight, WindowScale, WindowFontScale, PlatformVersion, getDeviceLanguage, getStatusBarHeight, hasNotch, hasNotchOnly, hasDynamicIsland, numberFormat, normalizeText, openExternalApp, openAppInAppStore, openAppInPlayStore, }; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,EAAE,EACF,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,aAAa,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EACL,EAAE,EACF,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,SAAS,EACT,KAAK,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,GACd,CAAC"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,EAAE,EACF,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,aAAa,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EACL,EAAE,EACF,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,SAAS,EACT,KAAK,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,CAAC"} |
@@ -1,47 +0,2 @@ | ||
| export declare const capitalizeFirstLetter: (str: string) => string; | ||
| export declare const capitalizeAllStartingWords: (str: string, lower?: boolean) => string; | ||
| export declare const capitalize: (str: string) => string; | ||
| export declare const generateRandomNumber: (min: number, max: number) => number; | ||
| export declare const diffArrays: (arr1: any[], arr2: any[]) => any[]; | ||
| export declare const diffArraysWithId: (arr1: any[], arr2: any[]) => any[]; | ||
| export declare const diffDates: (date: number, date2: number) => number; | ||
| export declare const isBlankString: (str: string) => boolean; | ||
| export declare const randomBoolean: () => boolean; | ||
| export declare const coinflip: () => boolean; | ||
| export declare const isEven: (val: number) => boolean; | ||
| export declare const removeAllDuplicateValuesInArray: (arr: any[]) => any[]; | ||
| export declare const isArray: (arr: any[]) => boolean; | ||
| export declare const generateRandomString: () => string; | ||
| export declare const mergeArrays: (a: any[], b: any[]) => any[]; | ||
| export declare const mergeArraysAndRemoveDuplicates: (a: any[], b: any[]) => any[]; | ||
| export declare const getTrueType: (obj: any) => string; | ||
| export declare const isNotEmptyArray: (arr: any[]) => boolean; | ||
| export declare const safelyParseJson: (string?: string | null) => any; | ||
| export declare const isEmptyObj: (obj: any) => boolean; | ||
| export declare const shuffleArray: (arr: any[]) => any[]; | ||
| export declare const convertSnakeToCamelCase: (str: string) => string; | ||
| export declare const getRandomHexColor: () => string; | ||
| export declare const convertRGBToHexColor: (r: number, g: number, b: number) => string; | ||
| export declare const getMinMaxOfArray: (arr: any[]) => number[]; | ||
| export declare const sleep: (delay: number) => Promise<void>; | ||
| /** | ||
| * Create an object from the pairs of key and value | ||
| * @param arr | ||
| * @returns | ||
| */ | ||
| export declare const toObj: (arr: any[]) => { | ||
| [k: string]: any; | ||
| }; | ||
| /** | ||
| * Get union of arrays | ||
| * @param arr | ||
| * @returns | ||
| */ | ||
| export declare const getUnion: (...arr: any[]) => any[]; | ||
| /** | ||
| * Partition an array based on the criteria/condition | ||
| * @param arr | ||
| * @param criteria | ||
| * @returns | ||
| */ | ||
| export declare const partition: (arr: any[], criteria: any) => any; | ||
| import { openExternalApp, openAppInAppStore, openAppInPlayStore } from "./linking"; | ||
| export { openExternalApp, openAppInAppStore, openAppInPlayStore }; |
@@ -1,70 +0,3 @@ | ||
| export const capitalizeFirstLetter = (str) => str && str.length ? str.charAt(0).toUpperCase() + str.slice(1) : str; | ||
| export const capitalizeAllStartingWords = (str, lower = false) => (lower ? str.toLowerCase() : str).replace(/(?:^|\s|[''({])+\S/g, (match) => match.toUpperCase()); | ||
| export const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1); | ||
| export const generateRandomNumber = (min, max) => Math.floor(Math.random() * (max - min + 1) + min); | ||
| export const diffArrays = (arr1, arr2) => arr1 && | ||
| arr2 && | ||
| arr1.filter((obj1) => !arr2.find((obj2) => obj1.id === obj2.id && obj2.isChecked)); | ||
| export const diffArraysWithId = (arr1, arr2) => arr1 && | ||
| arr2 && | ||
| arr1.filter((obj1) => !arr2.find((obj2) => obj1.id === obj2.id && obj2.id)); | ||
| export const diffDates = (date, date2) => Math.floor(Math.abs(date - date2) / 86400000); | ||
| export const isBlankString = (str) => !str || str.length === 0 || /^\s*$/.test(str); | ||
| export const randomBoolean = () => Math.random() >= 0.5; | ||
| export const coinflip = () => Math.random() >= 0.5; | ||
| export const isEven = (val) => val % 2 === 0; | ||
| export const removeAllDuplicateValuesInArray = (arr) => [ | ||
| ...new Set(arr), | ||
| ]; | ||
| export const isArray = (arr) => Array.isArray(arr); | ||
| export const generateRandomString = () => Math.random().toString(36).slice(2); | ||
| export const mergeArrays = (a, b) => [...a, ...b]; | ||
| export const mergeArraysAndRemoveDuplicates = (a, b) => [ | ||
| ...new Set([...a, ...b]), | ||
| ]; | ||
| export const getTrueType = (obj) => Object.prototype.toString.call(obj).slice(8, -1).toLocaleLowerCase(); | ||
| export const isNotEmptyArray = (arr) => Array.isArray(arr) && arr.length > 0; | ||
| export const safelyParseJson = (string) => { | ||
| try { | ||
| return JSON.parse(string); | ||
| } | ||
| catch { | ||
| return string; | ||
| } | ||
| }; | ||
| export const isEmptyObj = (obj) => Reflect.ownKeys(obj).length === 0 && obj.constructor === Object; | ||
| export const shuffleArray = (arr) => arr.sort(() => 0.5 - Math.random()); | ||
| export const convertSnakeToCamelCase = (str) => { | ||
| return str.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace("-", "").replace("_", "")); | ||
| }; | ||
| export const getRandomHexColor = () => `#${Math.floor(Math.random() * 0xffffff) | ||
| .toString(16) | ||
| .padEnd(6, "0")}`; | ||
| export const convertRGBToHexColor = (r, g, b) => "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); | ||
| export const getMinMaxOfArray = (arr) => [ | ||
| Math.min(...arr), | ||
| Math.max(...arr), | ||
| ]; | ||
| export const sleep = (delay) => { | ||
| return new Promise((resolve) => setTimeout(resolve, delay)); | ||
| }; | ||
| /** | ||
| * Create an object from the pairs of key and value | ||
| * @param arr | ||
| * @returns | ||
| */ | ||
| export const toObj = (arr) => Object.fromEntries(arr); | ||
| /** | ||
| * Get union of arrays | ||
| * @param arr | ||
| * @returns | ||
| */ | ||
| export const getUnion = (...arr) => [...new Set(arr.flat())]; | ||
| /** | ||
| * Partition an array based on the criteria/condition | ||
| * @param arr | ||
| * @param criteria | ||
| * @returns | ||
| */ | ||
| export const partition = (arr, criteria) => arr.reduce((acc, i) => (acc[criteria(i) ? 0 : 1].push(i), acc), [[], []]); | ||
| import { openExternalApp, openAppInAppStore, openAppInPlayStore, } from "./linking"; | ||
| export { openExternalApp, openAppInAppStore, openAppInPlayStore }; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/utils/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAE,EAAE,CACnD,GAAG,IAAI,GAAG,C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,GAAG,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAU,EAAE,QAAa,EAAE,EAAE,CACrD,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC"} |
+9
-0
@@ -30,2 +30,8 @@ import { | ||
| import { | ||
| openExternalApp, | ||
| openAppInAppStore, | ||
| openAppInPlayStore, | ||
| } from "./utils"; | ||
| import { numberFormat } from "./helpers/text/Text"; | ||
@@ -58,2 +64,5 @@ | ||
| normalizeText, | ||
| openExternalApp, | ||
| openAppInAppStore, | ||
| openAppInPlayStore, | ||
| }; |
+6
-117
@@ -1,118 +0,7 @@ | ||
| export const capitalizeFirstLetter = (str: string) => | ||
| str && str.length ? str.charAt(0).toUpperCase() + str.slice(1) : str; | ||
| import { | ||
| openExternalApp, | ||
| openAppInAppStore, | ||
| openAppInPlayStore, | ||
| } from "./linking"; | ||
| export const capitalizeAllStartingWords = ( | ||
| str: string, | ||
| lower: boolean = false, | ||
| ) => | ||
| (lower ? str.toLowerCase() : str).replace(/(?:^|\s|[''({])+\S/g, (match) => | ||
| match.toUpperCase(), | ||
| ); | ||
| export const capitalize = (str: string) => | ||
| str.charAt(0).toUpperCase() + str.slice(1); | ||
| export const generateRandomNumber = (min: number, max: number) => | ||
| Math.floor(Math.random() * (max - min + 1) + min); | ||
| export const diffArrays = (arr1: any[], arr2: any[]): any[] => | ||
| arr1 && | ||
| arr2 && | ||
| arr1.filter( | ||
| (obj1) => !arr2.find((obj2) => obj1.id === obj2.id && obj2.isChecked), | ||
| ); | ||
| export const diffArraysWithId = (arr1: any[], arr2: any[]): any[] => | ||
| arr1 && | ||
| arr2 && | ||
| arr1.filter((obj1) => !arr2.find((obj2) => obj1.id === obj2.id && obj2.id)); | ||
| export const diffDates = (date: number, date2: number) => | ||
| Math.floor(Math.abs(date - date2) / 86400000); | ||
| export const isBlankString = (str: string) => | ||
| !str || str.length === 0 || /^\s*$/.test(str); | ||
| export const randomBoolean = () => Math.random() >= 0.5; | ||
| export const coinflip = () => Math.random() >= 0.5; | ||
| export const isEven = (val: number) => val % 2 === 0; | ||
| export const removeAllDuplicateValuesInArray = (arr: any[]) => [ | ||
| ...new Set(arr), | ||
| ]; | ||
| export const isArray = (arr: any[]) => Array.isArray(arr); | ||
| export const generateRandomString = () => Math.random().toString(36).slice(2); | ||
| export const mergeArrays = (a: any[], b: any[]) => [...a, ...b]; | ||
| export const mergeArraysAndRemoveDuplicates = (a: any[], b: any[]) => [ | ||
| ...new Set([...a, ...b]), | ||
| ]; | ||
| export const getTrueType = (obj: any) => | ||
| Object.prototype.toString.call(obj).slice(8, -1).toLocaleLowerCase(); | ||
| export const isNotEmptyArray = (arr: any[]) => | ||
| Array.isArray(arr) && arr.length > 0; | ||
| export const safelyParseJson = (string?: string | null) => { | ||
| try { | ||
| return JSON.parse(string as string); | ||
| } catch { | ||
| return string; | ||
| } | ||
| }; | ||
| export const isEmptyObj = (obj: any) => | ||
| Reflect.ownKeys(obj).length === 0 && obj.constructor === Object; | ||
| export const shuffleArray = (arr: any[]) => arr.sort(() => 0.5 - Math.random()); | ||
| export const convertSnakeToCamelCase = (str: string) => { | ||
| return str.replace(/([-_][a-z])/g, (group) => | ||
| group.toUpperCase().replace("-", "").replace("_", ""), | ||
| ); | ||
| }; | ||
| export const getRandomHexColor = () => | ||
| `#${Math.floor(Math.random() * 0xffffff) | ||
| .toString(16) | ||
| .padEnd(6, "0")}`; | ||
| export const convertRGBToHexColor = (r: number, g: number, b: number) => | ||
| "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); | ||
| export const getMinMaxOfArray = (arr: any[]) => [ | ||
| Math.min(...arr), | ||
| Math.max(...arr), | ||
| ]; | ||
| export const sleep = (delay: number): Promise<void> => { | ||
| return new Promise((resolve) => setTimeout(resolve, delay)); | ||
| }; | ||
| /** | ||
| * Create an object from the pairs of key and value | ||
| * @param arr | ||
| * @returns | ||
| */ | ||
| export const toObj = (arr: any[]) => Object.fromEntries(arr); | ||
| /** | ||
| * Get union of arrays | ||
| * @param arr | ||
| * @returns | ||
| */ | ||
| export const getUnion = (...arr) => [...new Set(arr.flat())]; | ||
| /** | ||
| * Partition an array based on the criteria/condition | ||
| * @param arr | ||
| * @param criteria | ||
| * @returns | ||
| */ | ||
| export const partition = (arr: any[], criteria: any) => | ||
| arr.reduce((acc, i) => (acc[criteria(i) ? 0 : 1].push(i), acc), [[], []]); | ||
| export { openExternalApp, openAppInAppStore, openAppInPlayStore }; |
+4
-4
| { | ||
| "name": "@freakycoder/react-native-helpers", | ||
| "version": "2.2.2", | ||
| "version": "2.3.0", | ||
| "description": "All helpers in one; iPhone series support, dimensions helper, hasNotch helper, normalize text helper and text helpers for React Native with very easy use", | ||
@@ -34,3 +34,3 @@ "keywords": [ | ||
| "devDependencies": { | ||
| "@commitlint/cli": "^17.6.6", | ||
| "@commitlint/cli": "^18.2.0", | ||
| "@commitlint/config-conventional": "^17.6.6", | ||
@@ -43,3 +43,3 @@ "@types/react": "^18.2.15", | ||
| "husky": "^8.0.0", | ||
| "lint-staged": "^14.0.0", | ||
| "lint-staged": "^15.0.1", | ||
| "npm-post-install": "0.0.2", | ||
@@ -49,3 +49,3 @@ "prettier": "^3.0.0", | ||
| "react-native-typescript-transformer": "^1.2.13", | ||
| "semantic-release": "^21.0.7", | ||
| "semantic-release": "^22.0.5", | ||
| "typescript": "^5.1.6" | ||
@@ -52,0 +52,0 @@ }, |
+9
-0
@@ -137,2 +137,11 @@ <img alt="React Native Helpers" src="assets/logo.png" width="1050"/> | ||
| ## Utils Props | ||
| | Property | Type | Description | | ||
| |--------------------|:------------------------------------:|--------------------------------------------------------| | ||
| | openAppInPlayStore | function(appPackageName) | opens the app on android or Google Play | | ||
| | openAppInAppStore | function(appStoreId) | opens the app on ios or App Store | | ||
| | openExternalApp | function(appPackageName, appStoreId) | opens the app on ios or android - handles the platform | | ||
| ## Normalize Text Props | ||
@@ -139,0 +148,0 @@ |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
52
8.33%175
5.42%109374
-6.34%690
-14.5%2
100%