I am not sure how feasible this concept is, and I'll start just with the pattern it's useful for.
someRef.setup({
one: 'or more',
runtime: 'definition'
});In JS user-land, the amount of unnecessary duplicated objects is embarrassing.
| // https://medium.com/@bdc/web-components-the-react-way-8ed5b6f4f942 | |
| const store = (() => { | |
| let state; | |
| return todos => { | |
| if (todos) { | |
| state = todos; | |
| render("todo-list"); | |
| } | |
| return state; | |
| }; |
I am not sure how feasible this concept is, and I'll start just with the pattern it's useful for.
someRef.setup({
one: 'or more',
runtime: 'definition'
});In JS user-land, the amount of unnecessary duplicated objects is embarrassing.
| const Class = require('classtrophobic'); | |
| const List = Class({ | |
| extends: Array, | |
| static: {import:(o) => List.from(o)}, | |
| constructor(...args) { | |
| this.super().push(...args); | |
| }, | |
| push(...args) { | |
| this.super.push(...args); |
| const MyDiv = Class({ | |
| extends: HTMLElement, | |
| constructor(...args) { | |
| this.super(...args); | |
| this.addEventListener('click', console.log); | |
| }, | |
| connectedCallback() { | |
| this.textContent = 'Hello World'; | |
| } | |
| }); |
| class MyDiv extends HTMLElement { | |
| constructor(...args) { | |
| super(...args); | |
| this.addEventListener('click', console.log); | |
| } | |
| connectedCallback() { | |
| this.textContent = 'Hello World'; | |
| } | |
| } |
| class NoSpecies extends Array {} | |
| (new NoSpecies).slice() instanceof NoSpecies; | |
| // it should be true on native environment |
| class List extends Array { | |
| constructor(...args) { | |
| super().push(...args); | |
| } | |
| // chainable push | |
| push(...args) { | |
| super.push(...args); | |
| return this; | |
| } | |
| } |
| var Cancelable = (function ($Promise) { | |
| var setPrototypeOf = Object.setPrototypeOf || | |
| function (o, p) { o.__proto__ = p; }; | |
| function Promise(fn) { | |
| var | |
| cancel, | |
| promise = new $Promise(function (resolve, reject) { | |
| cancel = function (info) { |
Accordingly to this Writing efficient JavaScript post,
I wonder if the following utility could anyhow help to improve performance without removing entirely the ability to try/catch
const Try = (fn) => {
let e, attempt = {
catch: (fn) => {
if (e) fn(e);
return attempt;
},Most simple little Map (using native WeakMap) shim.
// ES3 compatible syntax example
var wm = typeof WeakMap === typeof wm ?
(function (m, a, p) {
var indexOf = m.indexOf || function (v) {
p = this.length;
while (p-- && this[p] !== v) {}
return p;