-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compatibility with pre-ES2016 environments (like RN) via `Buffer.…
…subarray` polyfill (#733) * Fix the issue that cannot run in a pre-ES2016 environment. * bump @stellar/js-xdr to 3.1.1
- Loading branch information
Showing
4 changed files
with
18 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// See https://github.com/stellar/js-xdr/issues/117 | ||
import { Buffer } from 'buffer'; | ||
|
||
if (!(Buffer.alloc(1).subarray(0, 1) instanceof Buffer)) { | ||
Buffer.prototype.subarray = function subarray(start, end) { | ||
const result = Uint8Array.prototype.subarray.call(this, start, end); | ||
Object.setPrototypeOf(result, Buffer.prototype); | ||
return result; | ||
}; | ||
} | ||
|
||
export default Buffer; |
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