Skip to content

Instantly share code, notes, and snippets.

export default {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
@matthewp
matthewp / fixture.js
Created September 10, 2019 19:28
Fixtures and schema merging
let RelativeDate = {
[Symbol.for("can.new")](value) {
if( date === "yesterday" ) {
return new Date()- 1000*24
}
return date;
},
[Symbol.for("can.isMember")](value) {
return value instanceof Date;
}
@matthewp
matthewp / machine.js
Created September 7, 2019 20:22
FSM backup
function valueEnumerable(value) {
return { enumerable: true, value };
}
function valueEnumerableWritable(value) {
return { enumerable: true, writable: true, value };
}
let truthy = () => true;
let empty = () => ({});
@matthewp
matthewp / machine.js
Created September 7, 2019 20:22
FSM backup
function valueEnumerable(value) {
return { enumerable: true, value };
}
function valueEnumerableWritable(value) {
return { enumerable: true, writable: true, value };
}
let truthy = () => true;
let empty = () => ({});
@matthewp
matthewp / helpers.js
Last active September 2, 2019 23:59
Filters for eleventy.
eleventyConfig.addFilter('bareUrl', url => {
return url.substr(1);
});
eleventyConfig.addFilter('baseUrl', url => {
let rel = path.relative(path.dirname(url), '/') || '.';
return rel + '/';
});
@matthewp
matthewp / lit-haunted-element.js
Last active October 17, 2021 15:52
Haunted State Integration
import { LitElement } from 'lit-element';
import { State } from 'haunted';
export default class LitHauntedElement extends LitElement {
constructor() {
super();
this.hauntedState = new State(() => this.requestUpdate(), this);
}
@matthewp
matthewp / constants.js
Last active July 20, 2022 19:55
FSM DSL
export const HOLE = 'hole';
export const ASSIGN = 'assign';
@matthewp
matthewp / .gitignore
Created July 12, 2019 15:17
haunted example
node_modules/
build/
@matthewp
matthewp / notes.md
Last active July 12, 2019 11:41
Haunted 4.5.0

👻 Haunted 4.5.0 is out 🎉. This is a pretty big release as it introduces some nice new features:

haunted/core

the new haunted/core entry point is ideal for those who are using a templating library other than lit-html, for example lighterhtml. This has been one of the most requested features for Haunted for a long time. Although Haunted has always worked with hyperHTML, lighterhtml, and others, it always included lit-html even if it was unused.

I didn't like the idea of not including support for a templating library out-of-the-box and forcing configuration on everything, so Haunted still works the easy way with lit-html. The new haunted/core is for people who want a little more control. The haunted export is a function that wires together a render function and produces the component function, createContext, and a few other things. Here's a simple example:

import haunted, { useState } from 'haunted/core';
@matthewp
matthewp / explainer.md
Last active July 3, 2019 20:59
huntry types

In the past CanJS typed objects such as CanMap, DefineMap, and DefineList would always eagerly convert objects into observables. For example when you do:

let map = new DefineMap({a: {b: 'c'}});

Then map.a is also a DefineMap, and is therefore observable.

This changes with DefineObject, DefineArray and anything else that uses their mixins, like StacheDefineElement. These objects do not convert inner values. So: