Skip to content

Instantly share code, notes, and snippets.

View Havunen's full-sized avatar

Sampo Kivistö Havunen

View GitHub Profile
@Havunen
Havunen / index.html
Created April 6, 2018 17:36 — forked from RubaXa/index.html
createElement vs. cloneElement (http://jsbench.github.io/#da24f870b75b08c68f70) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>createElement vs. cloneElement</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
'use strict'
var Benchmark = require('benchmark')
var suite = new Benchmark.Suite;
function createList() {
return [1, 2, 3, [[4]], [[[5]]], [6], [[7]]];
}
function flattenRecursive (list) {
@Havunen
Havunen / promise.js
Created March 12, 2017 16:36 — forked from Rich-Harris/promise.js
ES6 Promise polyfill
( function ( global ) {
'use strict';
var Promise, PENDING = {}, FULFILLED = {}, REJECTED = {};
if ( typeof global.Promise === 'function' ) {
Promise = global.Promise;
} else {
Promise = function ( callback ) {
( function ( global ) {
'use strict';
var Promise, PENDING = {}, FULFILLED = {}, REJECTED = {};
if ( typeof global.Promise === 'function' ) {
Promise = global.Promise;
} else {
Promise = function ( callback ) {