Skip to content

Instantly share code, notes, and snippets.

View matthewstokeley's full-sized avatar
🎯
Focusing

Matthew Stokeley matthewstokeley

🎯
Focusing
View GitHub Profile
@matthewstokeley
matthewstokeley / fetch-wrapper.js
Last active April 6, 2020 17:54
a robust application lifecycle built around the fetch web api
// quick sketch
/**
* Contextual piping
* @todo create a method to mimic a piping operator
*/
const pipe = function() {
let res
for ( let i = 0; i < this.length; i++ ) {
@matthewstokeley
matthewstokeley / isolated-development.sh
Last active March 22, 2020 15:01
isolated-development
# Isolated Development Environment Installation
# Poor man's storybook for scripts, with glitch
# https://www.lucidchart.com/invitations/accept/d77e6095-bd82-41af-a9cf-a48e056f39ee
# tl;dr
# Problem:
# `return _cache( new Symbol( key ) )` should have been `return ( typeof key === 'Symbol' ) ? _cache( key ) : _cache( new Symbol( key ) )
@matthewstokeley
matthewstokeley / dom-sibling-query-sketch.js
Last active March 22, 2020 14:58
query dom siblings + sibling children w/o traversal with a function macro pattern
// an alternative to traversal
// https://github.com/matthewstokeley/dom-traversal
// @version 0.0.3
_.castArr = function(
list: NodeList
): Array {
return Array.prototype.splice.call( list )
}
/*> Click Handler Middleware */
// @version 0.0.3
// CHANGELOG
// 0.0.3 add type scaffolding
type Next = function():void {}
interface Target {
@matthewstokeley
matthewstokeley / on-one-off.ts
Last active March 16, 2020 18:39
an on-one-off robust api with the mixin pattern
// dom versus publisher subscribe naming conventions
const Handler = ( function() {
return {}
} )()
type eventName: String
type eventFn: Function
@matthewstokeley
matthewstokeley / tsconfig.json
Created February 9, 2020 15:21
sample typescript config boilerplate
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es6",
"jsx": "react"
}
}
// RDD-inspired replication with node
const createQueue (nodeServices) => {
const q = new Set()
for (var value of nodeServices) {
q.add(value)
}
return q;
}
@matthewstokeley
matthewstokeley / progressive-web-applications.md
Last active March 6, 2020 17:21
progressive web application

Progressive Web Applications

@todo

API's

  • Cache
  • ServiceWorkers
  • localStorage

This is one possible example of object-based prototypal inheritance, using hasOwnProperty to break the prototype chain.

    const _createElement = _proto => {
        let _el = Document.createElement()
        for (var prop of _proto) {
            if (Object.hasOwnProperty(prop)) {
                _el[prop] = _proto[prop]
 }