Skip to content

Instantly share code, notes, and snippets.

arv /
Last active Apr 11, 2022
fractional-indexing and Jest
node --version # v17.9.0
npm --version # 8.5.5
npm install
npm run test
View use-replicache.ts
import { useEffect, useState } from "react";
import { MutatorDefs, Replicache, ReplicacheOptions } from "replicache";
export function useReplicache<MD extends MutatorDefs>(
opts: ReplicacheOptions<MD>
): Replicache<MD> | null {
const [rep, setRep] = useState<Replicache<MD> | null>(null);
useEffect(() => {
const r = new Replicache(opts);
View arrow-super.js
'use strict';
class Base {
constructor(x) {
this.x = x;
let f;
class D1 extends Base {
constructor() {
View .js
createPropertyAccessor: function(name, ignoreWrites) {
var proto = this.prototype;
var privateName = name + '_';
var privateObservable = name + 'Observable_';
Object.defineProperty(proto, name, {
get: function() {
var observable = this[privateObservable];
if (observable)
arv / test.js
Created Feb 20, 2015
Map -0 bug
View test.js
var assert = {
equal: function(x, y) {
if (x === y) return;
throw new Error();
isTrue: function(x) {
if (x) return;
throw new Error();
arv / gist:d9082aea49e47657bc21
Last active Aug 29, 2015
Custom Elements with @@create
View gist:d9082aea49e47657bc21

At the July TC39 meeting we decided to explore removing @@create in favor of a model where super() in a [[Construct]] call creates the instance object. To correctly know how to create the instance and set the prototype a [[Construct]] call gets an implicit receiver which is the constructor function new was called with.

class Base {
  constructor() {
    var object = Object.create(new*.prototype);  // new binding needs new syntax...
                                                 // bikeshed...
    myWeakMap.set(object, myHiddenData);
    return object;
arv / 0_reuse_code.js
Created Jul 16, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
arv /
Last active Aug 29, 2015
Unscopables spec update

13.10.4 Runtime Semantics: Evaluation

WithStatement : with ( Expression ) Statement

  1. Let val be the result of evaluating Expression.
  2. Let obj be ToObject(GetValue(val)).
  3. ReturnIfAbrupt(obj).
  4. Let oldEnv be the running execution context’s LexicalEnvironment.
  5. Let newEnv be NewObjectEnvironment(obj, oldEnv).
arv /
Last active Aug 29, 2015
@@new and @@create
class B {
  constructor(x) {
    this.x = x;
  static [Symbol.create]() {
    var o = super();
    weakMap.set(o, 123456789);  // Dom wrapper foo
    return o;
View designer.html
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">