export function createStore(state) {
const listeners = new Set();
return {
get() {
return state;
},
This file contains hidden or 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 createCascade() { | |
const middleware = []; | |
async function run(ctx, next = () => {}) { | |
// Reverse list to .pop() instead of .shift() for performance | |
const handlers = [...middleware, next].reverse(); | |
async function runNext() { | |
if (handlers.length) { | |
const handler = handlers.pop(); |
This file contains hidden or 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
root = true | |
[*] | |
charset = utf-8 | |
end_of_line = lf | |
indent_size = 4 | |
indent_style = tab | |
insert_final_newline = true | |
trim_trailing_whitespace = true |
This file contains hidden or 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 tests = new Set(); | |
const t = { | |
total: 0, | |
passed: 0, | |
failed: 0, | |
comment(message) { | |
console.log(`# ${message}`); | |
}, |
This file contains hidden or 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
let uid = 0; | |
class Foo { | |
constructor({ bar }, id) { | |
this.uid = uid++; | |
this.id = id; | |
this.bar = bar; | |
} | |
} |
Github Issue: rollup/rollup#372
Example Input: https://gist.github.com/shannonmoeller/280dda1f47e222c1ee88e5613bd01897
Github Issue: rollup/rollup#372
Example Output: https://gist.github.com/shannonmoeller/280dda1f47e222c1ee88e5613bd01897
This file contains hidden or 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
/** | |
* Inspired by XRegExp via 2ality | |
* http://www.2ality.com/2012/12/template-strings-xregexp.html | |
* http://xregexp.com/ | |
*/ | |
import test from 'ava'; | |
export function rx(flags) { | |
const trailingComments = /\s+#.*$/gm; |
This file contains hidden or 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
var gulp = require('gulp'); | |
var hb = require('gulp-hb'); | |
var rename = require('gulp-rename'); | |
var through = require('through2'); | |
gulp.task('build', function () { | |
return gulp | |
.src('./data/**/*.json') | |
.pipe(through.obj(function(file, enc, cb) { | |
var data = JSON.parse(String(file.contents)); |
This file contains hidden or 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
var es = require('event-stream'), | |
reader = es.readArray([mockDataIn]), | |
writer = es.writeArray(function (err, mockDataOut){ | |
assert(mockDataOut); | |
}), | |
mockSocket = es.duplex(writer, reader); | |
mockSocket.pipe(...).pipe(mockSocket); |