This is the MemStore implementaion as used in Replicache 12.1
This depends on files not included in this gist but these should be pretty self describing.
import type {Immutable} from './immutable.js'; | |
type Todo = { | |
id: string; | |
done: boolean; | |
order: string; | |
text: string; | |
}; | |
type ImmutableTodo = Immutable<Todo>; |
node --version # v17.9.0
npm --version # 8.5.5
npm install
npm run test
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); | |
setRep(r); |
<!DOCTYPE html> | |
<script src="url.js"></script> | |
<script> | |
var url = new URL('http://www.example.com/a/b/c.html?p=q&r=s&p&p=t#hash'); | |
for (var key in url) { | |
console.log(key, url[key]); | |
} |
When called, the register method must run these steps:
ENVIRONMENT
, the unit of related similar-origin browsing contextsDOCUMENT
, the context object of the methodNAME
, the custom element name of the element being registeredFUNCTION
, the custom element constructor function, optional<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="../polymer/polymer.js"></script> | |
</head> | |
<body> | |
<template id="host-template"> | |
<div>host shadowRoot</div> | |
<content></content> | |
</template> |
// XXX should be standard (and named clone, after Java?) | |
Object.prototype.copy = function () { | |
let o = {} | |
for (let i in this) | |
o[i] = this[i] | |
return o | |
} | |
// Containment testing for arrays and strings that should be coherent with their iterator. | |
Array.prototype.contains = String.prototype.contains = function (e) { |
traceur --out out.js parser.js | |
# Traceur does not strip dead code. Use Uglify2. | |
uglifyjs src/runtime/runtime.js out.js -cm -o out.min.js |
// Create is defined in the latest ES6 spec. Foo[create]() is used to create the instance | |
// when you do "new Foo". This instance is then passed to Foo.call(instance, <args>) | |
import {create} from '@reflect'; | |
Element[create] = function() { | |
return documemt.createElementNS(this.prototype.namespaceURI, this.prototype.localName) | |
}; |