-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replacing node-fetch with cross-fetch (#687)
* installing cross-fetch * implementing cross-fetch * Correcting web3 dependancy * importing types from cross-fetch * fixing dependancies * adding imports from cross/fetch/lib * changing .buffer() to .arrayBufer() * implementing timeout-signal * chaning require statements to import statements * fixing require/import issues * using default import for timeoutSignal * fixing linting issues * fixing dependancy issue * lint fix * fix timeout Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add abort controller compatible with browser and node Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro>
- Loading branch information
1 parent
c957e8e
commit 2a4510a
Showing
6 changed files
with
77 additions
and
38 deletions.
There are no files selected for viewing
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
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,17 @@ | ||
import AbortController from 'node-abort-controller' | ||
|
||
export default function timeoutSignal(timeout: number) { | ||
if (!Number.isInteger(timeout)) { | ||
throw new TypeError(`Expected an integer, got ${typeof timeout}`) | ||
} | ||
const signalMap = new WeakMap() | ||
const controller = new AbortController() | ||
|
||
const timeoutId = setTimeout(() => { | ||
controller.abort() | ||
}, timeout) | ||
|
||
signalMap.set(controller.signal, timeoutId) | ||
// any is needed due to some type incompatibility | ||
return controller.signal as any | ||
} |
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