View debounce-example.js
const {observable, computed, action, extendObservable} = mobx;
const {observer} = mobxReact;
const {Component} = React;
let debounce = delay => (object, key, descriptor) => {
let getter = descriptor.get
let state = new WeakMap();
function initializeState(self) {
View cancel-via-race.js
function delay(n) { return new Promise(r => setTimeout(r, n)) }
function debounced(ms, action) {
let cancelPrevious;
let cancellation = () => new Promise((resolve, reject) => cancelPrevious = reject)
return function (...args) {
if (cancelPrevious != null) cancelPrevious()
return Promise.race([cancellation(), delay(ms)])
.then(() => action.apply(this, args))
View composable-type-guards.ts
type Checker<T> = (x: any) => x is T;
function tArray<T>(f: Checker<T>) {
return function (a:any): a is Array<T> {
if (!Array.isArray(a)) return false;
for (var k = 0; k < a.length; ++k)
if (!f(a[k])) return false;
return true;
export "$(grep -az '^DBUS_SESSION_BUS_ADDRESS=' /proc/`ps -e | grep 'i3$' | awk '{print $1}'`/environ)"
/bin/bash -c "$*"
exit 0

Why .mjs

Alternative 1

As far as I can tell from the latest update, the ability to import ES6 import from CommonJS modules is off the table. The main argument for this was to enable existing modules to upgrade to ES6 without causing any breakage to their CommonJS dependants.

This is a big deal. This means that CommonJS libraries that want to upgrade to ES6 modules will HAVE to bump semver-major version to

View translate-error.js
function translateError(msg) {
var newErr = new Error(msg); // placed here to get correct stack
return e => {
newErr.originalError = e;
throw newErr;
async function asyncTask() {
const user = await UserModel.findById(1).catch(translateError('No user found'))
View mobx-form-prototype.ts
type ValidationError = string | boolean | null;
function fNoError<T>(t:T):ValidationError { return null }
class FieldState<TField> {
private validator: (val:TField) => ValidationError = fNoError
@observable focused = false
@observable changed = false
@observable finisedEditing = false;
View typescript-2.1-json.ts
type Json = null | boolean | string | number | Array<{}> | {}
function tArray<T>(f:(t:any) => t is T) {
return function (a:any): a is Array<T> {
if (!Array.isArray(a)) return false;
for (var k = 0; k < a.length; ++k)
if (!f(a[k])) return false;
return true;
View 01-mobx-async-magic.ts
import {render} from 'react-dom'
import {observable, computed, action} from 'mobx'
import {observer} from 'mobx-react'
import * as React from 'react'
import {fromPromise, IPromiseBasedObservable} from 'mobx-utils'
import 'whatwg-fetch'
import {computedAsync, matchAsync} from './computed-async'
function delay<T>(n:number) {
View promise-variables.js
function getData() {
var respondent = Respondent.findById(respondentId)
var box = respondent.then(r => Box.findById(r.box_id))
var user = box.then(box => User.findById(box.owned_by))
return Promise.props({user, box, respondent})