generated from iamogbz/node-js-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(wip): polyfill symbol observable and typing
- Loading branch information
Showing
22 changed files
with
2,731 additions
and
1,424 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
Large diffs are not rendered by default.
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
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
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,3 @@ | ||
export function isFunction<F>(maybeFunction: F | unknown): maybeFunction is F { | ||
return typeof maybeFunction === "function"; | ||
} |
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,7 @@ | ||
function polyfillSymbol(name: string): void { | ||
if (!Symbol[name]) { | ||
Object.defineProperty(Symbol, name, { value: Symbol(name) }); | ||
} | ||
} | ||
|
||
polyfillSymbol("observable"); |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`createContext has unimplemented observable symbol 1`] = ` | ||
exports[`createContext has expected default context value 1`] = ` | ||
Object { | ||
"dispatch": [Function], | ||
"enhancer": undefined, | ||
"getState": [Function], | ||
"reducer": [Function], | ||
"state": Object {}, | ||
Symbol(@@observable): [Function], | ||
"subscribe": [Function], | ||
} | ||
`; |
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
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,61 @@ | ||
// github.com/tc39/proposal-observable | ||
interface SymbolConstructor { | ||
readonly observable: symbol; | ||
readonly [key: string]: symbol; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
interface Observable { | ||
// Subscribes to the sequence with an observer | ||
subscribe: SubscriberFunction; | ||
|
||
// Subscribes to the sequence with callbacks | ||
subscribe: SubscriberFunctions; | ||
|
||
// Returns itself | ||
[Symbol.observable]?(): Observable; | ||
|
||
// Converts items to an Observable | ||
static of?(...items): Observable; | ||
|
||
// Converts an observable or iterable to an Observable | ||
static from?(observable): Observable; | ||
} | ||
|
||
type SubscriberFunction = ( | ||
observer: SubscriptionObserver, | ||
) => UnsubscriberFunction | Subscription; | ||
|
||
type SubscriberFunctions = ( | ||
onNext: OnNextFunction, | ||
onError?: OnErrorFunction, | ||
onComplete?: OnCompleteFunction, | ||
) => Subscription; | ||
|
||
interface Subscription { | ||
// Cancels the subscription | ||
unsubscribe: UnsubscriberFunction; | ||
|
||
// A boolean value indicating whether the subscription is closed | ||
closed: boolean; | ||
} | ||
|
||
type OnNextFunction = (value) => void; | ||
type OnErrorFunction = (errorValue) => void; | ||
type OnCompleteFunction = () => void; | ||
|
||
interface SubscriptionObserver { | ||
// Sends the next value in the sequence | ||
next: OnNextFunction; | ||
|
||
// Sends the sequence error | ||
error: OnErrorFunction; | ||
|
||
// Sends the completion notification | ||
complete: OnCompleteFunction; | ||
|
||
// A boolean value indicating whether the subscription is closed | ||
closed: boolean; | ||
} | ||
|
||
type UnsubscriberFunction = () => void; |
Oops, something went wrong.