Skip to content

Instantly share code, notes, and snippets.

@Hypercubed
Hypercubed / index.js
Created February 6, 2016 10:27
requirebin sketch
var typed = require("typed-function");
typed.addType({
name: 'zero',
test: function (x) { return x === 0; }
});
typed.addType({
name: 'one',
test: function (x) { return x === 1; }
@Hypercubed
Hypercubed / index.js
Created February 6, 2016 10:27
requirebin sketch
var typed = require("typed-function");
typed.addType({
name: 'zero',
test: function (x) { return x === 0; }
});
typed.addType({
name: 'one',
test: function (x) { return x === 1; }
@Hypercubed
Hypercubed / index.js
Last active February 6, 2016 10:30
requirebin sketch
var typed = require("typed-function");
typed.addType({
name: 'zero',
test: function (x) { return x === 0; }
});
typed.addType({
name: 'one',
test: function (x) { return x === 1; }
@Hypercubed
Hypercubed / index.js
Created February 23, 2016 02:43
requirebin sketch
var Tokenizer = require('tokenizer');
var t = new Tokenizer();
t.on('token', function(token, type) {
console.log(token);
});
t.on('end', function() {
console.log(arguments);
});
{
"presets": [ "es2015-rollup" ]
}
const dict = require('dictionary-js');
const words = Object.keys(dict);
const xwords = xx => words.filter(x => x[0] === xx);
const kwords = xwords('K')
const iwords = xwords('I')
function randomWord (list) {
return list[Math.floor(Math.random() * list.length)];
};
@Hypercubed
Hypercubed / flatten.js
Created April 21, 2016 11:09 — forked from thetutlage/flatten.js
Flatten an array in Javascript without recursion
'use strict'
var Benchmark = require('benchmark')
var suite = new Benchmark.Suite;
var list = [1, 2, 3, [[4]], [[[5]]], [6], [[7]]]
function flattenRecursive (list) {
var flatList = []
list.forEach(function (item) {
@Hypercubed
Hypercubed / chrome-v50.md
Last active May 17, 2016 07:19
EventsSpeedTests emit objects

Chrome 50.0.2661.102 on OS X 10.11.2

emit objects

EventEmitter ................................... 184,353 op/s
EventEmitter2 .................................. 1,366,034 op/s
EventEmitter3 .................................. 4,718,065 op/s
RXJS ........................................... 1,388,534 op/s
ReactiveProperty ............................... 5,766,001 op/s

JS-Signals ..................................... 175,555 op/s

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="https://d3js.org/d3-dispatch.v0.4.min.js"></script>
<script>
var dispatch = d3_dispatch.dispatch('foo');
dispatch.on('foo', handle);
@Hypercubed
Hypercubed / .gitignore
Last active June 3, 2016 00:29
chuhai async
node_modules