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
// node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = void 0; | |
function _helperPluginUtils() { |
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
type Listener<T extends Array<unknown>> = (...args: T) => void; | |
export class EventEmitter< | |
E extends Record<string, Array<unknown>> = Record<never, []> | |
> { | |
private listenerMap: { [K in keyof E]?: Set<Listener<E[K]>> } = {}; | |
on<K extends keyof E>(key: K, listener: Listener<E[K]>) { | |
return this.addListener(key, listener); | |
} |
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
{ | |
"jest": { | |
"preset": "jest-expo", | |
"transform": { | |
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js", | |
"^.+\\.tsx?$": "ts-jest" | |
}, | |
"testMatch": [ | |
"**/__tests__/**/*.ts?(x)", | |
"**/?(*.)+(spec|test).ts?(x)" |
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
// @flow | |
import fs from 'fs'; | |
import {join} from 'path'; | |
async function main() { | |
let filePath = join(__dirname, '../assets/image.jpg'); | |
// The first one uses Promise-based readable stream. | |
await getFileSizeOne(filePath); | |
// The second one uses "for await" async iterator approach. | |
await getFileSizeTwo(filePath); |
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
// @flow | |
/* global fetch */ | |
/* eslint-disable babel/no-await-in-loop */ | |
type JSONData = null | string | number | boolean | {[key: string]: JSONData} | Array<JSONData>; | |
function handleResponseJSON(response: Response): Promise<JSONData> { | |
return response.json(); | |
} |
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
import React from 'react'; | |
import './App.css'; | |
class App extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
error: null, | |
data: null, | |
}; |
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
const http = require('http'); | |
let server = http.createServer(); | |
server.on('request', (request, response) => { | |
let {method, url, headers} = request; | |
console.log(`Received ${method} request for "${url}".`); | |
for (let headerName of Object.keys(headers)) { | |
let headerValue = headers[headerName]; |
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
// ES5 | |
var getBound = Function.prototype.apply.bind(Function.prototype.bind) | |
function createDate() { | |
for (var i = 0, length = arguments.length, args = new Array(length + 1); i < length; i++) { | |
args[i + 1] = arguments[i]; | |
} | |
var BoundDate = getBound(Date, args); | |
return new BoundDate(); |
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
import RichTextEditor from 'react-rte'; | |
import React from 'react'; | |
class StatefulRichTextEditor { | |
constructor() { | |
this.state = { | |
value: RichTextEditor.createEmptyValue(), | |
}; | |
} |
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
function MyArray() { | |
var array = []; | |
if (arguments.length) { | |
array.push.apply(array, arguments); | |
} | |
// note: use `Object.setPrototypeOf` instead of __proto__ to be truly standards-compliant | |
array.__proto__ = MyArray.prototype; | |
return array; | |
} |