-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make `lz4` module optional Signed-off-by: Levko Kravets <levko.ne@gmail.com> * Fix lint errors Signed-off-by: Levko Kravets <levko.ne@gmail.com> --------- Signed-off-by: Levko Kravets <levko.ne@gmail.com>
- Loading branch information
1 parent
38db1b0
commit 1fd9e1e
Showing
8 changed files
with
70 additions
and
18 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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import definedOrError from './definedOrError'; | ||
import buildUserAgentString from './buildUserAgentString'; | ||
import formatProgress, { ProgressUpdateTransformer } from './formatProgress'; | ||
import LZ4 from './lz4'; | ||
|
||
export { definedOrError, buildUserAgentString, formatProgress, ProgressUpdateTransformer }; | ||
export { definedOrError, buildUserAgentString, formatProgress, ProgressUpdateTransformer, LZ4 }; |
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,16 @@ | ||
import type LZ4Namespace from 'lz4'; | ||
|
||
type LZ4Module = typeof LZ4Namespace; | ||
|
||
function tryLoadLZ4Module(): LZ4Module | undefined { | ||
try { | ||
return require('lz4'); // eslint-disable-line global-require | ||
} catch (err) { | ||
const isModuleNotFoundError = err instanceof Error && 'code' in err && err.code === 'MODULE_NOT_FOUND'; | ||
if (!isModuleNotFoundError) { | ||
throw err; | ||
} | ||
} | ||
} | ||
|
||
export default tryLoadLZ4Module(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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