Skip to content

Commit

Permalink
fix decoder setting error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kent-williams committed Feb 3, 2025
1 parent ac494f7 commit 98c4cd1
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/utils/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@ iconv.encodings = encodings

console.log(Object.getOwnPropertyDescriptor(global, 'TextDecoder'))

Check warning on line 12 in src/utils/polyfill.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

if (global.TextDecoder) {
try {
delete global.TextDecoder // Attempt to remove the existing TextDecoder
} catch (error) {
console.warn('Failed to delete existing TextDecoder:', error)
}
}

global.TextEncoder = TextEncoder
global.TextDecoder = TextDecoder
if (typeof global.TextDecoder === 'undefined') {
global.TextEncoder = TextEncoder
global.TextDecoder = TextDecoder

// Force override global.TextDecoder
Object.defineProperty(global, 'TextDecoder', {
value: global.TextDecoder,
writable: false,
configurable: false,
enumerable: true,
})
// Define global.TextDecoder
Object.defineProperty(global, 'TextDecoder', {
value: global.TextDecoder,
writable: false,
configurable: false,
enumerable: true,
})
} else {
console.warn(

Check warning on line 26 in src/utils/polyfill.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
'TextDecoder is already defined and not configurable. Skipping override.',
)
}

0 comments on commit 98c4cd1

Please sign in to comment.