An exploration of the different render methods available in react-enzyme.
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 EventEmitter = require('events'); | |
const myEmitter = new EventEmitter(); | |
function handler1() { | |
console.log('first handler'); | |
myEmitter.removeListener('event', handler2); | |
} | |
function handler2() { |
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 add(val = 0, ...args) { | |
let sum = args.reduce((prev, curr) => { | |
return prev + curr; | |
}, val); | |
let ret = add.bind(this, sum); | |
ret.value = () => sum; | |
ret.add = ret; | |
return ret; | |
} |
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
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | |
exports.default = Loadable; |
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
<!doctype html> | |
<html class="no-js" lang=""> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="x-ua-compatible" content="ie=edge"> | |
<title></title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | |
<style> | |
* { |
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 --max-old-space-size=100 --expose-gc index.js | |
const prettyBytes = require('pretty-bytes'); | |
const forceGC = () => { | |
if (global.gc) { | |
global.gc(); | |
} else { | |
console.warn('No GC hook! Start your program as `node --expose-gc file.js`.'); | |
} |
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 express = require('express'); | |
console.log(process.version); | |
const app = express(); | |
app.get('/hello', (req, res) => { | |
console.log('HANDLING REQUEST'); | |
res.setHeader('content-type', 'application/json'); | |
res.flushHeaders(); // `flushHeaders` to prevent http client from retrying and therefore invoking this handler multiple times. |
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 closest = (values: number[], val: number) => { | |
if (!values.length) { | |
throw new VError( | |
{ info: { values, val } }, | |
'Expected values to contain at least one value' | |
); | |
} | |
return values.reduce( | |
(acc, currVal) => | |
Math.abs(acc.delta) > Math.abs(currVal - val) |