Skip to content

Instantly share code, notes, and snippets.

Shannon Moeller shannonmoeller

Block or report user

Report or block shannonmoeller

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View .editorconfig
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
View test.js
const tests = new Set();
const t = {
total: 0,
passed: 0,
failed: 0,
comment(message) {
console.log(`# ${message}`);
},
@shannonmoeller
shannonmoeller / container.js
Last active Sep 8, 2018
Dependency-injection container example using vanilla JS.
View container.js
let uid = 0;
class Foo {
constructor({ bar }, id) {
this.uid = uid++;
this.id = id;
this.bar = bar;
}
}
@shannonmoeller
shannonmoeller / store.md
Last active May 21, 2019
JavaScript stores for devs who like stores.
View store.md

Arbitrary Values

export function createStore(state) {
  const listeners = new Set();

  return {
    get() {
      return state;
    },
@shannonmoeller
shannonmoeller / multiline-regexp.js
Last active Oct 26, 2019
Multiline Regular Expressions using ES6 Template Strings
View multiline-regexp.js
/**
* 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;
@shannonmoeller
shannonmoeller / many-to-one-gulpfile.js
Last active Aug 29, 2015
Many data sources to one template
View many-to-one-gulpfile.js
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));
View mocket.js
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);
View sprinkle.js
var a = [
'a', 'aa', 'aaa', 'aaaa', 'aaaaa',
'b', 'bb', 'bbb', 'bbbb', 'bbbbb',
'c', 'cc', 'ccc', 'cccc', 'ccccc'
];
var b = [
'Z', 'ZZ', 'ZZZ'
];
You can’t perform that action at this time.