Skip to content

Commit

Permalink
chore(upload-client): do not use buffer for browser-like bundles to p…
Browse files Browse the repository at this point in the history
…revent polyfilling by cdn (#484)
  • Loading branch information
nd0ut authored May 1, 2023
1 parent 8b05ff0 commit 2e6ea7c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/upload-client/src/tools/isBuffer.browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isBuffer = (data: unknown): data is Buffer => false
2 changes: 2 additions & 0 deletions packages/upload-client/src/tools/isBuffer.node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const isBuffer = (data: unknown): data is Buffer =>
data instanceof Buffer
1 change: 1 addition & 0 deletions packages/upload-client/src/tools/isBuffer.react-native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isBuffer = (data: unknown): data is Buffer => false
9 changes: 4 additions & 5 deletions packages/upload-client/src/tools/isFileData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { SupportedFileInput, ReactNativeAsset } from '../types'
import { ReactNativeAsset, SupportedFileInput } from '../types'
import { isBuffer } from './isBuffer.node'

export { isBuffer }

export const isBlob = (data: unknown): data is Blob => {
return typeof Blob !== 'undefined' && data instanceof Blob
Expand All @@ -8,10 +11,6 @@ export const isFile = (data: unknown): data is File => {
return typeof File !== 'undefined' && data instanceof File
}

export const isBuffer = (data: unknown): data is Buffer => {
return typeof Buffer !== 'undefined' && data instanceof Buffer
}

export const isReactNativeAsset = (data: unknown): data is ReactNativeAsset => {
return (
!!data &&
Expand Down

0 comments on commit 2e6ea7c

Please sign in to comment.