JSFiddle - React, Tailwind, and code Playground

by kassiomaia

JavaScript

var Cache = (function() {
	return function(context) {
  	var map = new WeakMap()
    
    return new Proxy(this, {
    	set(target, property, value) {
      	var props = map.get(context)
        if (!props) {
        	props = new Map()
        }
        
        props.set(property, value)
        
        map.set(context, props)
        
        return true
      },
      get(target, property) {
      	var props = map.get(context)
        if (!props) {
        	return undefined
        }
        
        return props.get(property)
      }
    })
	}
}())

function Document() {
	
}

const ns = new Cache(Document)
ns.arguments = 10