Skip to content

Instantly share code, notes, and snippets.

View shqld's full-sized avatar
🦭
shqld

shqld

🦭
shqld
View GitHub Profile
@shqld
shqld / workbox.d.ts
Last active December 23, 2018 03:18
Typings for workbox (most part is copied from @types/workbox-sw)
// Type definitions for workbox-sw 3.2
// Project: https://github.com/GoogleChrome/workbox
// Definitions by: Frederik Wessberg <https://github.com/wessberg>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
/**
* ===== BroadcastCacheUpdate =====
*/
@shqld
shqld / withDynamicAttributes.jsx
Last active August 28, 2018 01:14
Setting element attributes dynamically
/* withAttr.jsx */
import React from 'react'
const withAttr = (Component) => ({attrs, ...props}) => <Component {...attrs} {...props} />
export default withAttr
/* example.jsx */
import React from 'react'
@shqld
shqld / dict-symbol.js
Created December 13, 2017 13:18
Abstract dictionaries in ES2015 with immutability and method chaining
const repository = Symbol('repository')
class Dict {
constructor(props) {
if (typeof props !== 'object') {
throw new Error(
`Props must be an object, you passed ${typeof props} ${props}.`
)
}
Object.freeze(props)