I have a class called SocketPolyfill that looks roughly like this:
import { EventEmitter } from 'events'
export class SocketPolyfill extends EventEmitter {
// methods here
}| declare module '@apollo/client/core' { | |
| export interface DefaultContext { | |
| accessToken: string | |
| } | |
| } | |
| export {} |
| import { createFsFromVolume, Volume } from 'memfs' | |
| const fs = createFsFromVolume(new Volume()) | |
| const compiler = webpack({ | |
| entry: 'file.js', | |
| output: { filename: 'main.js' } | |
| }) | |
| // Compile the file to memory. | |
| compiler.outputFileSystem = fs |
| // Determine a body of the given Response. | |
| // In case of a Response that has no body (i.e. 204 response), | |
| // return `null`. | |
| function getResponseBody(res: Response) { | |
| res.body // ReadableStream, locked | |
| await res.text() // always "" for a response with no body | |
| } | |
| // Empty string cannot be used as a response body | |
| // for the responses that have no body (i.e. 204 response). |
| // Source: https://medium.com/@minaluke/typescript-compose-function-b7512a7cc012 | |
| type ArityOneFn = (arg: any) => any | |
| type PickLastInTuple<T extends any[]> = T extends [ | |
| ...rest: infer U, | |
| argn: infer L | |
| ] | |
| ? L | |
| : never | |
| type FirstFnParameterType<T extends any[]> = Parameters<PickLastInTuple<T>>[any] | |
| type LastFnParameterType<T extends any[]> = ReturnType<T[0]> |
| declare module '*.gql' { | |
| import { DocumentNode } from 'graphql' | |
| const vaule: DocumentNode | |
| export default value | |
| } |
I have a class called SocketPolyfill that looks roughly like this:
import { EventEmitter } from 'events'
export class SocketPolyfill extends EventEmitter {
// methods here
}This document describes a flow of a request issued by different modules/libraries in NodeJS environment.
[](https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ3JhcGggVERcbiAgd2luZG93LmZldGNoIC0tPiBYTUxIdHRwUmVxdWVzdFxuICBYTUxIdHRwUmVxdWVzdCAtLT4gcmVxdWVzdChyZXF1ZXN0LCAzcmQgcGFydHkpXG4gIHJlcXVlc3QgLS0-IHByb3RvY29se1Byb3RvY29sfVxuICBwcm90b2NvbCAtLSBodHRwcyAtLT4gaHR0cHMucmVxdWVzdFxuICBwcm90b2NvbCAtLSBodHRwIC0tPiBodHRwLnJlcXVlc3RcblxuICBodHRwcy5yZXF1Z
| import { createGlobalStyle, css } from 'styled-components' | |
| const GlobalStyle = createGlobalStyle` | |
| html { | |
| /* Maps all colors from the `theme` to CSS variables: */ | |
| ${({ theme }) => Object.entries(theme.colors).map(([name, value]) => css` | |
| --${camelCaseToKebabCase(name)}: ${value}; | |
| `)} | |
| } | |
| ` |
| if (__IE__) { | |
| const ieSpecificShim = require('ie-shim') | |
| ieSpecificShim(...) | |
| } | |