File tree 1 file changed +14
-13
lines changed
1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change 1
1
import { getInitialStatus , getIdleStatus , getStatusProps , statusTypes } from "./status"
2
2
3
3
// This exists to make sure we don't hold any references to user-provided functions
4
- class NeverSettle extends Promise {
5
- constructor ( ) {
6
- super ( ( ) => { } , ( ) => { } )
7
- /* istanbul ignore next */
8
- if ( Object . setPrototypeOf ) {
9
- // Not available in IE 10, but can be polyfilled
10
- Object . setPrototypeOf ( this , NeverSettle . prototype )
11
- }
12
- }
4
+ // The way NeverSettle extends from Promise is complicated, but can't be done differently because Babel doesn't support
5
+ // extending built-in classes. See https://babeljs.io/docs/en/caveats/#classes
6
+ function NeverSettle ( ) { }
7
+ /* istanbul ignore next */
8
+ if ( Object . setPrototypeOf ) {
9
+ Object . setPrototypeOf ( NeverSettle , Promise )
10
+ } else {
11
+ NeverSettle . __proto__ = Promise
12
+ }
13
+ NeverSettle . prototype = Object . assign ( Object . create ( Promise . prototype ) , {
13
14
finally ( ) {
14
15
return this
15
- }
16
+ } ,
16
17
catch ( ) {
17
18
return this
18
- }
19
+ } ,
19
20
then ( ) {
20
21
return this
21
- }
22
- }
22
+ } ,
23
+ } )
23
24
24
25
export const neverSettle = new NeverSettle ( )
25
26
You can’t perform that action at this time.
0 commit comments