@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
export class SyncPath { | |
constructor(rootRef, path) { | |
this._rootRef = rootRef; | |
this.user = this._rootRef.getAuth(); | |
this._userDataRef = this._rootRef.child(path).child(this.user.uid); | |
this.data = {}; | |
this._userDataRef.on('value', (snap) => this.data = snap.val() || {}); | |
} | |
keys() { | |
return Object.keys(this.data); |
@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
/** | |
* WHY? - BECAUSE EXCEPTIONS/TRY/CATCH IS A GLOBAL HORRIBLE MESS :-( | |
* Check out error handling in golang: https://blog.golang.org/error-handling-and-go | |
*/ | |
/** | |
* Wrap an "unsafe" promise | |
*/ | |
function safePromise(promise) { | |
return promise |
var Firebase = require("./firebase-node.js"); | |
function Queue(ref) { | |
this._ref = ref; | |
} | |
Queue.prototype.pop = function(cb) { | |
this._ref.startAt().limit(1).once("child_added", this._pop.bind(this, cb)); | |
} |
#!/bin/bash | |
# TODO: skip tiny files (so small they couldn't be photos) | |
# TODO: make sure sym links and other file system oddities are handled | |
# | |
# Constants | |
# | |
CHAR_COUNT=12 | |
BLOCK_COUNT=6 | |
SKIP_SIZE=3 # Every new block is sampled by skipping this amount of blocks to the next position |
function composeLeft(...funcs) { | |
return function(input) { | |
return funcs.reduce((result, func) => { | |
return func(result); | |
}, input); | |
} | |
} | |
function composeRight(...funcs) { | |
return function(input) { |
'use strict'; | |
const { createStore, applyMiddleware } = require('./redux'); | |
const { addActionTakersToStore, addLoggingToStore } = require('./middleware'); | |
const { EventEmitter } = require('events'); | |
const { | |
isPromise, | |
isFunction, | |
isObject, |
'use strict'; | |
/** | |
* Dependencies | |
*/ | |
const expect = require('expect'); | |
/** | |
* Factory for creating an effects handling "runtime" | |
* that stores a retrievable effects log |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="root"></div> | |
<script id="jsbin-javascript"> |
One | Many | |
---|---|---|
Synchronous | T/Try[T] | Iterable[T] |
Asynchronous | Future[T] | Observable[T] |