View hyper-lit.md

The history of hyperHTML followed by lit-html

While many remember the epic hyperHTML: A Virtual DOM Alternative post I've published the 5th of March 2017, the first official implementation of the library was working as hyperHTML.bind(node) function for tagged literals the day before, and it's been in my experiments folder already for a little while.

The hilarious reaction from the skeptical community

At first glance people couldn't believe performance of the DBMonster demo shown in that article,

View JSON.js
if(JSON.stringify('\u2028').length<4)JSON.stringify=function(s,r,f){return function() {return s.apply(null,arguments).replace(r,f)}}(JSON.stringify,/\u2028|\u2029/g,function(c){return'\u2028'==c?'\\u2028':'\\u2029'});
View irc.js
#!/usr/bin/env node
require('fs').readFile(process.argv[2], (err, data) => {
if (err) return;
const content = data.toString().trim();
const re = /^\[(.+?)\]\s+<(.+?)>\s(.*)$/gm;
const chat = [];
let current = {};
while (match = re.exec(content)) {
if (match[2] !== current.name) {
View ama.md

[12:58] @icebox

ANNOUNCE: in two minutes "Wed, Feb 14th, at 13.00 CET (GMT+1) a 1 hour #angularjs (Freenode) AMA (Ask Me Anything) with me about hyperHTML, standards, transpilers, bundlers, esm modules, and the meaning of keyed VS non keyed JS benchmarks + your questions. See you there" - https://twitter.com/WebReflection/status/961352362962059264


[12:59] Pyrrhus666

welcome webreflection


View paint.js
var paint = function(rAF){ 'use strict';
return function paint(before) {
before();
return rAF(before), {
then: function (after) {
return rAF(rAF.bind(null, after)), this;
}
};
};
}(
View jsc
#!/usr/bin/env bash
if [ -f /System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc ]; then
/System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc "$@"
elif [ -f /usr/lib/jsc ]; then
/usr/lib/jsc "$@"
fi
View primitive.md

Two ways to do it, via Symbol

const Primitive = (() => {
  const secret = Symbol();
  const update = (obj, value) => {
    Object.defineProperty(obj, secret, {configurable: true, value});
  };

  function Primitive(value) {'use strict';
View clone.js
const clone = (() => {
/*! (c) Andrea Giammarchi - WTFPL */
const toString = {}.toString;
const flags = ['global', 'ignoreCase', 'multiline', 'sticky', 'unicode'];
const prime = obj => typeof obj === 'object' ? new obj.constructor(obj.valueOf()) : obj;
const through = obj => {
const descriptors = Object.getOwnPropertyDescriptors(obj);
Reflect.ownKeys(descriptors).forEach(key => {
const descriptor = descriptors[key];
if ('value' in descriptor) {
View caniuse
#!/usr/bin/env node
var browsers = [
'chrome 49',
'edge 15',
'firefox 51',
'opera 36'
].join(', ');
var caniuse = require('caniuse-api');
View fixEslintAllman.js
function fixEslintAllman(code) {
return code.replace(/^{/mg, function ($0, $1) {
var newLine = code.lastIndexOf('\n', $1 - 2);
var spaces = code.slice(newLine + 1, $1 - 1).match(/^(\s*)/)[1];
return spaces + '{';
});
}