-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ts): splitting up the module functions to a cleaner public api
- Loading branch information
1 parent
eacf1d0
commit 3dae8e9
Showing
3 changed files
with
33 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { NativeModules, Platform } from 'react-native'; | ||
import type { Lz4Type } from './types'; | ||
|
||
const LINKING_ERROR = | ||
`The package 'react-native-lz4' doesn't seem to be linked. Make sure: \n\n` + | ||
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + | ||
'- You rebuilt the app after installing the package\n' + | ||
'- You are not using Expo Go\n'; | ||
|
||
// @ts-expect-error | ||
const isTurboModuleEnabled = global.__turboModuleProxy != null; | ||
|
||
const Lz4Module = isTurboModuleEnabled | ||
? require('./NativeLz4').default | ||
: NativeModules.Lz4; | ||
|
||
export const Lz4 = Lz4Module | ||
? Lz4Module | ||
: new Proxy( | ||
{}, | ||
{ | ||
get() { | ||
throw new Error(LINKING_ERROR); | ||
}, | ||
} | ||
); | ||
|
||
export const _global = global as unknown as Lz4Type; |