Skip to content

Instantly share code, notes, and snippets.

(function(n,t,r,u,e,c,o){return t=String.fromCharCode,r=function(n,u){return u=c.length,n.replace(/./g,function(n){return c.indexOf(n).toString(u)}).replace(r.n,function(n){return t(parseInt(n,u))})},u=function(n,e){return e=function(n,t){return t=[],r.f(n)[r.a]("")[r.i](function(n,u,e){return!(1&u)&&t[r.j](e[u][r.b](0)*r.d+e[u+1][r.b](0))}),t}(n),function(n){return n[r.a]("")[r.h](function(n){return n[r.b](0)})}(r("⁢‬‬‬‫‫‫⁢⁡‫‫‫⁢‬‫‫‫⁢‫‫‫‫‫‫‫⁢‬‬‬⁢‬‬‬‫‫‫‫‫‫‫⁢‫‫‫‬⁢‬‬‬‫‫‫⁤‬⁢‬‬‬‫‫‫‬‫‫‫‫‫⁡‫‫‫⁡‫‫‫‫⁢‬‬‬⁢‬‬‬⁢‬‬‬⁢‬‬‬‫‫‫⁢‬‬‬‫‫‫⁡‫‫‫⁢⁢‬‬‬⁢‬‬‬‫‫‫‫⁢⁢‬‬‬⁢‬‬‬‫‫‫⁡⁢‫‫‫⁢‬‬‬‫‫‫‫⁢‬‬‬‫‫‫‫‫‫⁣‫‫‫‫‬⁢‬‬‬‫‫‫‫⁤‫‫‫‫‫‬⁢‬‬‬‫‫‫⁡⁢‬‬‬‫‫‫‬⁢‬‬‬‫‫‫"))[r.c]()[r.i](function(n,t){return t=n,e=function(n,t){return 1&(n[r.k](function(n,t){return t>n?n:t},0)^n[r.k](function(n,t){return n>t?n:t},0)^t)&&n[r.c](),n}(e,n)[r.h](function(u){return t=((u^n)-t+r.e)%r.e})}),r.g(e,t),u},r.t=n,e=r.constructor,c="‫‬⁡⁢⁣⁤",r.n=/.{2}/g,o=e("e",r("⁤⁢‬⁤‬⁡⁣‫⁡⁢⁤⁢⁡⁤‬⁡⁢‬⁤⁢⁣⁤⁤⁤⁡⁢⁤⁢⁢⁤‬⁡
((d, s = d.createElement('style')) => (s.textContent = '.contenu {left: unset}') && d.body.appendChild(s))(document)
const Async = async function(){}.constructor
const AsyncGenerator = async function*(){}.constructor
const Generator = function(){}.constructor
const isAsync = fn => fn instanceof Async
const isAsyncGenerator = fn => fn instanceof AsyncGenerator
const isGenerator = fn => fn instanceof Generator
@Lcfvs
Lcfvs / emitter.js
Created March 14, 2021 11:17
A simple event emitter, without any lib dedicated to.
import * as etched from 'https://unpkg.com/@etchedjs/etched@latest/etched.min.js'
const emitter = etched.model({
set event (value) {
console.log('event `event` emitted on `emitter` with value', value)
}
})
const emitter2 = etched.model(emitter, {
set event (value) {
@Lcfvs
Lcfvs / complex-etched-type-demo.md
Last active May 18, 2021 01:48
Extend the etched types

How to run this script?

Into a terminal: npx https://gist.github.com/Lcfvs/4b1523653bfe54605b82113170299f61

@Lcfvs
Lcfvs / controller.js
Last active July 8, 2021 09:50
abort controller generator
function* controller (end) {
while (end !== (yield)) {}
}
const end = Symbol()
const it = controller(end)
console.log(it.next()) // { value: undefined, done: false }
console.log(it.next(end)) // { value: undefined, done: true } -> aborted
@Lcfvs
Lcfvs / controller.js
Last active May 25, 2021 11:02
abort controller with progress
function* controller (end) {
let progress = 0
while (1) {
const value = yield progress
if (value === end) {
break
}
@Lcfvs
Lcfvs / fileToURI.js
Created June 11, 2021 22:40
fileToURI.js
const fileToURI = async file => new Promise((onload, onerror) =>
Object.assign(new FileReader(), { onload, onerror })
.readAsDataURL(file))
@Lcfvs
Lcfvs / example.js
Last active June 16, 2021 17:31
a simple fetcher, based on actions
import { resolve, text } from './fetcher.js'
const fetchText = event => resolve(event, [
fetch,
text,
data => console.log({ data })
])
document.querySelector('form')
.addEventListener('submit', fetchText)
@Lcfvs
Lcfvs / example.js
Created June 17, 2021 00:59
typed fetcher
import * as fetcher from './text-fetcher.js'
const fetchText = event => fetcher.resolver.resolve(event)
document.querySelector('form')
.addEventListener('submit', fetchText)
document.querySelector('a')
.addEventListener('click', fetchText)