Skip to content

Instantly share code, notes, and snippets.

@robertcoopercode
robertcoopercode / .hyper.js
Last active June 20, 2023 19:49
Hyper Configuration
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Choose either "stable" for receiving highly polished,
// or "canary" for less polished but more frequent updates
updateChannel: 'stable',
@rluvaton
rluvaton / pouchdb-benchmark.js
Created February 7, 2019 16:10 — forked from perliedman/pouchdb-benchmark.js
PouchDB Benchmark
var dbName = 'http://localhost:5984/couch-test',
nDocs = 10000,
batchSize = 1000,
scrapFactor = 0,
docs = [],
testQuery = 'entries/sumTime',
destroyDb = false,
_log = console.log,
db;
@jperasmus
jperasmus / pipe.js
Last active June 27, 2019 09:52
"pipe" function that handles both sync and async functions
const pipe = (…functions) => input => functions.reduce((chain, func) => chain.then(func), Promise.resolve(input));
// Functions fn1, fn2, fn3 can be standard synchronous functions or return a Promise
pipe(fn1, fn2, fn3)(input).then(result => console.log(`Do with the ${result} as you please`))
@jperasmus
jperasmus / compose.js
Last active June 30, 2022 07:48
"compose" function that handles both sync and async functions
// Async compose
const compose = (…functions) => input => functions.reduceRight((chain, func) => chain.then(func), Promise.resolve(input));
// Functions fn1, fn2, fn3 can be standard synchronous functions or return a Promise
compose(fn3, fn2, fn1)(input).then(result => console.log(`Do with the ${result} as you please`))
@fokusferit
fokusferit / enzyme_render_diffs.md
Last active June 4, 2024 21:56
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@azproduction
azproduction / scrollIntoView.js
Created December 23, 2014 09:38
scrollIntoView.js
/*!
* Copyright 2014 jQuery Foundation and other contributors
* Released under the MIT license.
*/
/**
* Better Element.scrollIntoView() implementation
*
* @see https://github.com/jquery/jquery-ui/blob/master/ui/menu.js#L409-L425
*
@samwize
samwize / mocha-guide-to-testing.js
Created February 8, 2014 05:53
Explain Mocha's testing framework - describe(), it() and before()/etc hooks
// # Mocha Guide to Testing
// Objective is to explain describe(), it(), and before()/etc hooks
// 1. `describe()` is merely for grouping, which you can nest as deep
// 2. `it()` is a test case
// 3. `before()`, `beforeEach()`, `after()`, `afterEach()` are hooks to run
// before/after first/each it() or describe().
//
// Which means, `before()` is run before first it()/describe()