Usage:
import kv from 'kv'
const {
SOME,
CONSTANTS,
FOR_INTERNAL_USE,
} = kv(Symbol)
const findOBR = v => { | |
while(v.length || !(v.tag.onbeforeremove || v.attrs && v.attrs.onbeforeremove)) | |
v = v.instance || v.children || v[0] | |
return v | |
} | |
const persist = v => { | |
const target = findOBR(v.instance || v.children) |
export default (component, previous = undefined) => ({ | |
...component, | |
onbeforeupdate: (a, b) => ( | |
component.onbeforeupdate | |
&& | |
component.onbeforeupdate(a, b) !== false | |
&& | |
previous = b | |
), |
import m from 'mithril' | |
const find = predicate => generator => { | |
for(const item of generator) | |
if(predicate(item)) | |
return item | |
} | |
const horizontalElementQuery = function * (root = document){ | |
const backlog = [] |
const pave = (container, target, path = []) => ( | |
container === target | |
? | |
path | |
: | |
Array.isArray(container) | |
? | |
container.filter((a, i) => pave(a, target, [...path, i])).pop() | |
: | |
container.instance |
export default function O(a){ | |
return ( | |
arguments.length == 1 | |
? | |
typeof a != 'function' | |
? | |
new O(a => O(b, a)) | |
: | |
this instanceof O | |
? |
const login = { | |
view : ({state}) => | |
m('form#login', { | |
onsubmit: e => { | |
e.preventDefault() | |
console.log( | |
state.email.dom.value, | |
state.pass.dom.value, | |
) |
export const censored = $ => | |
$ == undefined || $ === false ? '' : $ | |
export const censor = ({ censored, strings, expressions }) => | |
strings.reduce((a, c, i, [], b = expressions[i - 1]) => | |
a + censored(b) ? '' : b + c | |
) | |
export default (strings, ...expressions) => | |
Array.isArray(strings) |
Usage:
import kv from 'kv'
const {
SOME,
CONSTANTS,
FOR_INTERNAL_USE,
} = kv(Symbol)
import on from 'on.js'
async function royalAirForce(){
await on(requestAnimationFrame)
renderX()
await on(requestAnimationFrame)
// You can't proxy function application onto objects :/ | |
import {O} from 'patchinko' | |
const Patchem = def => | |
O({}, def, [{}, 'oninit', 'onbeforeupdate'].reduce((patch, key) => | |
O(patch, { | |
[key](node){ | |
O(node, { | |
state : new Proxy(v.state, { |