From eb6ac9cbb1ea06c3da1a0f87979a7fb7acd9a214 Mon Sep 17 00:00:00 2001 From: Matt Keas Date: Tue, 3 Jan 2017 11:36:03 -0600 Subject: [PATCH 1/2] 0.0.34 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 036fe0d..ca6ee85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clan-fp", - "version": "0.0.33", + "version": "0.0.34", "description": "A set of opinionated, functional utilities that work particularly well when used together", "scripts": { "prestart": "rimraf .fusebox build", From 980edb10667dbb49ba47f9ff323d6275075a42ae Mon Sep 17 00:00:00 2001 From: Matt Keas Date: Tue, 3 Jan 2017 11:47:46 -0600 Subject: [PATCH 2/2] ok... --- build/index.js | 106 --------------------------------------------- build/index.js.map | 2 +- fuse.js | 2 +- 3 files changed, 2 insertions(+), 108 deletions(-) diff --git a/build/index.js b/build/index.js index e8d1357..f4421c5 100644 --- a/build/index.js +++ b/build/index.js @@ -1590,112 +1590,6 @@ var concatter = exports.concatter = function concatter(thing, value) { }; }); }); -FuseBox.pkg("process", {}, function(___scope___){ -___scope___.file("index.js", function(exports, require, module, __filename, __dirname){ - -// From https://github.com/defunctzombie/node-process/blob/master/browser.js -// shim for using process in browser -if (FuseBox.isServer) { - module.exports = global.process; -} else { - var productionEnv = false; //require('@system-env').production; - - var process = module.exports = {}; - var queue = []; - var draining = false; - var currentQueue; - var queueIndex = -1; - - function cleanUpNextTick() { - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } - } - - function drainQueue() { - if (draining) { - return; - } - var timeout = setTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while (len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - clearTimeout(timeout); - } - - process.nextTick = function(fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - setTimeout(drainQueue, 0); - } - }; - - // v8 likes predictible objects - function Item(fun, array) { - this.fun = fun; - this.array = array; - } - Item.prototype.run = function() { - this.fun.apply(null, this.array); - }; - process.title = 'browser'; - process.browser = true; - process.env = { - NODE_ENV: productionEnv ? 'production' : 'development' - }; - process.argv = []; - process.version = ''; // empty string to avoid regexp issues - process.versions = {}; - - function noop() {} - - process.on = noop; - process.addListener = noop; - process.once = noop; - process.off = noop; - process.removeListener = noop; - process.removeAllListeners = noop; - process.emit = noop; - - process.binding = function(name) { - throw new Error('process.binding is not supported'); - }; - - process.cwd = function() { return '/' }; - process.chdir = function(dir) { - throw new Error('process.chdir is not supported'); - }; - process.umask = function() { return 0; }; - -} -}); -return ___scope___.entry = "index.js"; -}); FuseBox.expose([{"alias":"clan-fp","pkg":"default"}]); FuseBox.import("clan-fp/index.js"); diff --git a/build/index.js.map b/build/index.js.map index e13229f..aa63145 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["index.js","batch.js","vdom.js","mixin.js","model.js","observable.js","hamt.js","worker.js","fp.js","packages/process@0.0.0"],"names":["hamt","worker","fp","hash","v","_v","JSON","stringify","i","len","length","c","charCodeAt","module","exports","Object","assign","batch","vdom","mixin","model","obs","inflight","url","options","method","key","toLowerCase","f","compress","Promise","res","rej","then","d","catch","e","undefined","data","console","error","rAF","document","requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","setTimeout","cb","class_id_regex","tagName_regex","parseSelector","test","tagreg","exec","s","tag","slice","reg","create","substr","className","trim","id","debounce","func","wait","immediate","timeout","args","later","callNow","clearTimeout","m","selector","children","attrs","Array","Function","unshift","shouldUpdate","unload","config","__hash","stripEvents","a","name","applyEvents","events","el","strip_existing","removeEvents","flatten","arr","push","EVENTS","split","map","x","mnt","mount","fn","render","applyUpdates","update","stylify","style","setAttrs","attr","innerHTML","value","setAttribute","_id","_className","createTag","parent","parentElement","__vdom","t","createTextNode","insertBefore","removeEl","appendChild","shouldExchange","tagName","_shouldUpdate","createElement","removeChild","insertAt","next_sib","resolve","_el","vdom_children","el_children","childNodes","qs","querySelector","resolver","states","promises","done","_await","_promises","finish","ms","isDone","total","all","props","keys","forEach","getState","gs","view","state","r","instance","container","queries","wrapper_view","reservedAttrs","toHTML","_vdom","html","_class","_attrs","inner","indexOf","str","filter","join","classes","_mixin","proto","prototype","p","getOwnPropertyNames","oldFn","apply","call","arguments","is","type","isValid","String","Number","Boolean","check","types","required","reduce","_type","MODEL","init","logic","pipe","whenValid","ArrayOf","M","subscribers","val","o","take","n","values","delete","takeWhile","acc","maybe","success","stop","ts","Date","now","from","union","fs","hamming","popcount","root","sum","comp","b","HMAP_SIZE","MAX_DEPTH","vec","h","range","shallowClone","y","cloneNode","node","numChildren","set","newroot","bits","cp","cn","rh","j","__r","__n","vecr","vecn","_r","get","first","unset","_n","item","toList","toOrderedList","toJSON","toJson","pop","shift","k","supports","q","window","supportsWorkers","supportsBlobs","supportsURLs","supportsBuilders","code","B","U","W","blob","append","getBlob","encodeURIComponent","createObjectURL","Worker","farm","workers","fill","current","iter","onerror","w","onmessage","postMessage","log","process","nextTick","g","cof","fns","cob","reverse","pf","curry","bind","mapping","mapper","reducer","result","filtering","predicate","concatter","thing","concat"],"mappings":";;;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;IAAYA;;AACZ;;IAAYC;;AACZ;;IAAYC;;;;;;AAEL,IAAMC,sBAAO,cAACC,CAAD,EAA4B;AAAA,QAAzBC,EAAyB,uEAAtBC,KAAKC,SAAL,CAAeH,CAAf,CAAsB;;AAC5C,QAAID,OAAO,CAAX;AACA,SAAK,IAAIK,IAAI,CAAR,EAAWC,MAAMJ,GAAGK,MAAzB,EAAiCF,IAAIC,GAArC,EAA0C,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MADhD;AAAA;AADJ;AAAA;AADqB;AAAA,CAAlB;;AAKA,IAAMG,gCAAY,SAAZA,SAAY,CAACC,KAAD,EAAQ/L,KAAR;AAAA,WACrB+L,MAAMC,MAAN,CAAa,CAAChM,KAAD,CAAb,CADqB;AAAA,CAAlB;;;AC5CP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"","sourcesContent":["import batch from './batch'\nimport vdom from './vdom'\nimport mixin from './mixin'\nimport model from './model'\nimport obs from './observable'\nimport * as hamt from './hamt'\nimport * as worker from './worker'\nimport * as fp from './fp'\n\nexport const hash = (v,_v=JSON.stringify(v)) => {\n let hash = 0\n for (let i = 0, len = _v.length; i < len; ++i) {\n const c = _v.charCodeAt(i)\n hash = (((hash << 5) - hash) + c) | 0\n }\n return hash\n}\n\nmodule.exports = Object.assign({}, fp, {\n\tbatch\n\t, vdom\n\t, mixin\n\t, model\n\t, obs\n\t, hamt\n\t, worker\n})\n","\n// batched requests\n// The `fetch()` module batches in-flight requests, so if at any point in time, anywhere in my front-end or\n// back-end application I have a calls occur to `fetch('http://api.github.com/users/matthiasak')` while another\n// to that URL is \"in-flight\", the Promise returned by both of those calls will be resolved by a single network request.\n\n// f :: (url -> options) -> Promise\nconst batch = f => {\n let inflight = {}\n\n return (url, options={}) => {\n let {method} = options,\n key = `${url}:${JSON.stringify(options)}`\n\n if((method || '').toLowerCase() === 'post')\n return f(url, Object.assign({}, options, {compress: false}))\n\n return inflight[key] ||\n (inflight[key] =\n new Promise((res,rej) => {\n f(url, Object.assign({}, options, {compress: false}))\n .then(d => res(d))\n .catch(e => rej(e))\n })\n .then(data => {\n inflight = Object.assign({}, inflight, {[key]: undefined})\n return data\n })\n .catch(e =>\n console.error(e, url)))\n }\n}\n\nexport default batch","const rAF =\n typeof document !== 'undefined' &&\n (requestAnimationFrame ||\n webkitRequestAnimationFrame ||\n mozRequestAnimationFrame) ||\n (cb => setTimeout(cb, 16.6))\n\n// Virtual DOMs\nconst vdom = () => {\n const class_id_regex = () => {\n return /[#\\.][^#\\.]+/ig\n },\n tagName_regex = () => {\n return /^([^\\.#]+)\\b/i\n }\n\n const parseSelector = s => {\n let test = null,\n tagreg = tagName_regex().exec(s),\n tag = tagreg && tagreg.slice(1)[0],\n reg = class_id_regex(),\n vdom = Object.create(null)\n\n if(tag) s = s.substr(tag.length)\n vdom.className = ''\n vdom.tag = tag || 'div'\n\n while((test = reg.exec(s)) !== null){\n test = test[0]\n if(test[0] === '.')\n vdom.className = (vdom.className+' '+test.substr(1)).trim()\n else if(test[0] === '#')\n vdom.id = test.substr(1)\n }\n return vdom\n }\n\n const debounce = (func, wait, immediate, timeout) =>\n (...args) => {\n let later = () => {\n timeout = null\n !immediate && func(...args)\n }\n var callNow = immediate && !timeout\n clearTimeout(timeout)\n timeout = setTimeout(later, wait || 0)\n callNow && func(...args)\n }\n\n const hash = (v,_v=JSON.stringify(v)) => {\n let hash = 0\n for (let i = 0, len = _v.length; i < len; ++i) {\n const c = _v.charCodeAt(i)\n hash = (((hash << 5) - hash) + c) | 0\n }\n return hash\n }\n\n const m = (selector, attrs=Object.create(null), ...children) => {\n if(attrs.tag || !(typeof attrs === 'object') || attrs instanceof Array || attrs instanceof Function){\n if(attrs instanceof Array) children.unshift(...attrs)\n else children.unshift(attrs)\n attrs = Object.create(null)\n }\n let vdom = parseSelector(selector)\n if(children.length)\n vdom.children = children\n vdom.attrs = attrs\n vdom.shouldUpdate = attrs.shouldUpdate\n vdom.unload = attrs.unload\n vdom.config = attrs.config\n vdom.__hash = hash(vdom)\n delete attrs.unload\n delete attrs.shouldUpdate\n delete attrs.config\n return vdom\n }\n\n // creatign html, strip events from DOM element... for now just deleting\n const stripEvents = ({attrs}) => {\n let a = Object.create(null)\n\n if(attrs){\n for(var name in attrs){\n if(name[0]==='o'&&name[1]==='n') {\n a[name] = attrs[name]\n delete attrs[name]\n }\n }\n }\n\n return a\n }\n\n const applyEvents = (events, el, strip_existing=true) => {\n strip_existing && removeEvents(el)\n for(var name in events){\n el[name] = events[name]\n }\n }\n\n const flatten = (arr, a=[]) => {\n for(var i=0,len=arr.length; i 'on'+x)\n\n const removeEvents = el => {\n // strip away event handlers on el, if it exists\n if(!el) return;\n for(var i in EVENTS){\n el[i] = null\n }\n }\n\n let mnt\n\n const mount = (fn, el) => {\n mnt = [el, fn]\n render(fn, el)\n }\n\n const render = debounce((fn, el) => rAF(_ => {\n applyUpdates(fn, el.children[0], el)\n }))\n\n const update = () => {\n if(!mnt) return\n let [el, fn] = mnt\n render(fn, el)\n }\n\n const stylify = style => {\n let s = ''\n for(var i in style){\n s+=`${i}:${style[i]};`\n }\n return s\n }\n\n const setAttrs = ({attrs, id, className, __hash},el) => {\n \tel.className = ''\n \tel.style = ''\n\n if(attrs){\n for(var attr in attrs){\n if(attr === 'style') {\n el.style = stylify(attrs[attr])\n } else if(attr === 'innerHTML'){\n rAF(() => el.innerHTML = attrs[attr])\n } else if(attr === 'value'){\n rAF(() => el.value = attrs[attr])\n } else {\n el.setAttribute(attr, attrs[attr])\n }\n }\n }\n let _id = attrs.id || id\n if(_id) el.id = _id\n let _className = ((attrs.className || '') + ' ' + (className || '')).trim()\n if(_className) el.className = _className\n el.__hash = __hash\n }\n\n // recycle or create a new el\n const createTag = (vdom=Object.create(null), el, parent=el&&el.parentElement) => {\n let __vdom = vdom\n // make text nodes from primitive types\n if(typeof vdom !== 'object'){\n let t = document.createTextNode(vdom)\n if(el){\n parent.insertBefore(t,el)\n removeEl(el)\n } else {\n parent.appendChild(t)\n }\n return t\n }\n\n // else make an HTMLElement from \"tag\" types\n let {tag, attrs, id, className, unload, shouldUpdate, config, __hash} = vdom,\n shouldExchange = !el || !el.tagName || (tag && el.tagName.toLowerCase() !== tag.toLowerCase()),\n _shouldUpdate = !(shouldUpdate instanceof Function) || shouldUpdate(el)\n\n if(!attrs) return\n if(el && (!_shouldUpdate || ((!vdom instanceof Function) && el.__hash === __hash))) {\n return\n }\n\n if(shouldExchange){\n let t = document.createElement(tag)\n el ? (parent.insertBefore(t, el), removeEl(el)) : parent.appendChild(t)\n el = t\n }\n\n setAttrs(vdom, el)\n if(el.unload instanceof Function) {\n rAF(el.unload)\n }\n if(unload instanceof Function) {\n el.unload = unload\n }\n applyEvents(stripEvents(vdom), el)\n config && rAF(_ => config(el))\n return el\n }\n\n // find parent element, and remove the input element\n const removeEl = el => {\n if(!el) return\n el.parentElement.removeChild(el)\n removeEvents(el)\n // removed for now, added unload logic to the immediate draw()s\n if(el.unload instanceof Function)\n el.unload()\n }\n\n const insertAt = (el, parent, i) => {\n if(parent.children.length > i) {\n let next_sib = parent.children[i]\n parent.insertBefore(el, next_sib)\n } else {\n parent.appendChild(el)\n }\n }\n\n const applyUpdates = (vdom, el, parent=el&&el.parentElement) => {\n let v = vdom\n // if vdom is a function, execute it until it isn't\n while(vdom instanceof Function)\n vdom = vdom()\n\n if(!vdom) return\n\n if(vdom.resolve instanceof Function){\n let i = parent.children.length\n return vdom.resolve().then(v => {\n if(!el) {\n let x = createTag(v, null, parent)\n insertAt(x, parent, i)\n applyUpdates(v, x, parent)\n } else {\n applyUpdates(v, el, parent)\n }\n })\n }\n\n // create/edit el under parent\n let _el = vdom instanceof Array ? parent : createTag(vdom, el, parent)\n\n if(!_el) return\n\n if(vdom instanceof Array || vdom.children){\n let vdom_children = flatten(vdom instanceof Array ? vdom : vdom.children),\n el_children = vdom instanceof Array ? parent.childNodes : _el.childNodes\n\n while(el_children.length > vdom_children.length){\n removeEl(el_children[el_children.length-1])\n }\n\n for(let i=0; i 0){\n removeEl(_el.childNodes[_el.childNodes.length-1])\n }\n }\n }\n\n const qs = (s='body', el=document) => el.querySelector(s)\n\n const resolver = (states = {}) => {\n let promises = [],\n done = false\n\n const _await = (_promises = []) => {\n promises = [...promises, ..._promises]\n return finish()\n }\n\n const wait = (ms=0) => new Promise(res => setTimeout(res, ms))\n\n const isDone = () => done\n\n const finish = () => {\n const total = promises.length\n return wait().then(_ => Promise.all(promises)).then(values => {\n if(promises.length > total){\n return finish()\n }\n done = true\n return states\n })\n }\n\n const resolve = (props) => {\n const keys = Object.keys(props)\n if (!keys.length)\n return Promise.resolve(true)\n\n let f = []\n keys.forEach(name => {\n let x = props[name]\n\n while(x instanceof Function)\n x = x()\n\n if(x && x.then instanceof Function)\n f.push(x.then(d => states[name] = d))\n })\n\n return _await(f)\n }\n\n const getState = () => states\n\n return { finish, resolve, getState, promises, isDone }\n }\n\n const gs = (view, state) => {\n let r = view(state)\n while(r instanceof Function)\n r = view(instance.getState())\n return r\n }\n\n const container = (view, queries={}, instance=resolver()) => {\n let wrapper_view = state =>\n instance.isDone() ? view(state) : m('span')\n\n return () => {\n let r = gs(wrapper_view, instance.getState())\n instance.resolve(queries)\n\n if(r instanceof Array) {\n let d = instance.finish().then(_ =>\n gs(wrapper_view, instance.getState()))\n\n return r.map((x,i) => {\n x.resolve = _ => d.then(vdom => vdom[i])\n return x\n })\n }\n\n r.resolve = _ => instance.finish().then(_ =>\n gs(wrapper_view, instance.getState()))\n\n return r\n }\n }\n\n const reservedAttrs = ['className','id']\n\n const toHTML = _vdom => {\n while(_vdom instanceof Function) _vdom = _vdom()\n if(_vdom instanceof Array) return new Promise(r => r(html(..._vdom)))\n if(!_vdom) return new Promise(r => r(''))\n if(typeof _vdom !== 'object') return new Promise(r => r(_vdom))\n return (_vdom.resolve ? _vdom.resolve() : Promise.resolve()).then(vdom => {\n if(!vdom) vdom = _vdom\n\n if(vdom instanceof Array) return new Promise(r => r(html(...vdom)))\n\n const {tag, id, className, attrs, children, instance} = vdom,\n _id = (id || (attrs && attrs.id)) ? ` id=\"${(id || (attrs && attrs.id) || '')}\"` : '',\n _class = (className || (attrs && attrs.className)) ? ` class=\"${((className||'') + ' ' + (attrs.className||'')).trim()}\"` : ''\n\n const events = stripEvents(vdom)\n let _attrs = '',\n inner = ''\n for(var i in (attrs || Object.create(null))){\n if(i === 'style'){\n _attrs += ` style=\"${stylify(attrs[i])}\"`\n } else if(i === 'innerHTML') {\n inner = attrs[i]\n } else if(reservedAttrs.indexOf(i) === -1){\n _attrs += ` ${i}=\"${attrs[i]}\"`\n }\n }\n\n if(!inner && children)\n return html(...children).then(str =>\n `<${tag}${_id}${_class}${_attrs}>${str}`)\n\n if('br,input,img'.split(',').filter(x => x===tag).length === 0)\n return new Promise(r => r(`<${tag}${_id}${_class}${_attrs}>${inner}`))\n\n return new Promise(r => r(`<${tag}${_id}${_class}${_attrs} />`))\n })\n }\n\n const html = (...v) => Promise.all(v.map(toHTML)).then(x => x.filter(x => !!x).join(''))\n\n return {container, html, qs, update, mount, m, debounce}\n}\n\nmodule.exports = vdom()\n\n/*\nusage:\n\nlet component = () =>\n new Array(20).fill(true).map(x =>\n m('div', {onMouseOver: e => log(e.target.innerHTML)}, range(1,100)))\n\nclient-side\n-----\nmount(component, qs())\n\nclient-side constant re-rendering\n-----\nconst run = () => {\n setTimeout(run, 20)\n update()\n}\nrun()\n*/\n\n/* CONTAINER / HTML USAGE (Server-side rendering)\n\nconst name = _ => new Promise(res => setTimeout(_ => res('matt'), 1500))\n\nlet x = container(data => [\n m('div.test.row', {className:'hola', 'data-name':data.name, style:{border:'1px solid black'}}),\n m('div', data.name),\n ],\n {name}\n)\n\nhtml(x).then(x => log(x)).catch(e => log(e+''))\n*/\n","\nconst mixin = (...classes) => {\n class _mixin {}\n\n let proto = _mixin.prototype\n\n classes.map(({prototype:p}) => {\n Object.getOwnPropertyNames(p).map(key => {\n let oldFn = proto[key] || ($ => {})\n proto[key] = function() {\n oldFn.apply(null, [].slice.call(arguments))\n return p[key].apply(null, [].slice.call(arguments))\n }\n })\n })\n\n return _mixin\n}\n\nmodule.exports = mixin","// Validate JS objects for their \"shape\"\nconst model = {\n is(type, value) {\n if(type && type.isValid instanceof Function){\n return type.isValid(value)\n } else if((type === String && ((value instanceof String) || typeof value === 'string'))\n || (type === Number && ((value instanceof Number) || typeof value === 'number'))\n || (type === Boolean && ((value instanceof Boolean) || typeof value === 'boolean'))\n || (type === Function && ((value instanceof Function) || typeof value === 'function'))\n || (type === Object && ((value instanceof Object) || typeof value === 'object'))\n || (type === undefined)\n ){\n return true\n }\n\n return false\n },\n check(types, required, data) {\n Object.keys(types).forEach(key => {\n let t = types[key],\n value = data[key]\n\n if(required[key] || value !== undefined){\n if(!(t instanceof Array)) t = [t]\n\n let i = t.reduce((a,_type) => a || MODEL.is(_type, value), false)\n if(!i) {\n throw `{${key}: ${JSON.stringify(value)}} is not one of ${t.map(x => `\\n - ${x}`)}`\n }\n }\n })\n\n return true\n },\n init(...args) {\n let types, required, logic\n args.map(x => {\n if(x instanceof Function && !logic){ logic = x }\n else if(typeof x === 'object') {\n if(!types){ types = x }\n else if(!required){ required = x }\n }\n })\n\n const isValid = (data) => {\n const pipe = logic ? [check, logic] : [check]\n return pipe.reduce((a,v) => a && v(types||{},required||{},data), true)\n }\n\n const whenValid = (data) => new Promise((res,rej) => isValid(data) && res(data))\n\n return {isValid, whenValid}\n },\n ArrayOf(M) {\n return MODEL.init((t,r,data) => {\n if(!(data instanceof Array)) throw `${data} not an Array`\n data.map(x => {\n if(!MODEL.is(M, x))\n throw `${x} is not a model instance`\n })\n return true\n })\n }\n}\n\nexport default model\n\n/**\nUse it\n\n// create a Name model with required first/last,\n// but optional middle\nlet Name = MODEL.init({\n first: String,\n middle: String,\n last: String\n}, {first:true, last:true})\n\n// create a Tags model with extra checks\nlet Tags = MODEL.init((types,required,data) => {\n if(!(data instanceof Array)) throw `${data} not an Array`\n data.map(x => {\n if(!is(String, x))\n throw `[${data}] contains non-String`\n })\n return true\n})\n\n// create a Price model that just has a business logic fn\nlet Price = MODEL.init((t,r,d) => {\n return (d instanceof Number || typeof d === 'number') && d !== 0\n})\n\n// create an Activity model with a required type and name,\n// all others optional\nlet Activity = MODEL.init({\n type: [String, Function, Number],\n latlng: Array,\n title: String,\n tags: Tags,\n name: Name,\n price: Price\n}, {name:true, price: true})\n\n// create a new Activity instance, throwing errors if there are\n// any invalid fields.\nlet a = {\n tags: ['1','2'],\n type: 1,\n name: {first:'matt',last:'keas'},\n price: 100.43,\n url: 'http://www.google.com'\n}\nActivity.whenValid(a).then(log).catch(e => log(e+''))\n**/\n","// async-supporting-observables\nconst obs = (state) => {\n let subscribers = []\n\n const fn = (val) => {\n if(val !== undefined){\n state = val\n for(let i = 0, len = subscribers.length; i {\n const o = obs()\n subscribers.push(val => o(f(val)))\n return o\n }\n\n fn.filter = f => {\n const o = obs()\n subscribers.push(val => f(val) && o(val))\n return o\n }\n\n fn.then = f => {\n subscribers.push(val => f(val))\n return fn\n }\n\n fn.take = (n) => {\n const values = [],\n \to = obs()\n\n const cb = val => {\n if(values.length < n)\n values.push(val)\n\n if(values.length === n) {\n subscribers.delete(cb)\n return o(values)\n }\n }\n\n subscribers.push(cb)\n\n return o\n }\n\n fn.takeWhile = f => {\n const values = [],\n \to = obs()\n\n const cb = val => {\n if(!f(val)) {\n subscribers = subscribers.filter(x => x !== cb)\n return o(values)\n }\n\n\t\t\tvalues.push(val)\n }\n\n subscribers.push(cb)\n\n return o\n }\n\n fn.reduce = (f,acc) => {\n const o = obs()\n\n subscribers.push(val => {\n acc = f(acc,val)\n o(acc)\n })\n\n return o\n }\n\n fn.maybe = f => {\n const success = obs(),\n error = obs(),\n cb = val =>\n \t\tf(val)\n\t\t\t\t .then(d => success(d))\n .catch(e => error(e))\n\n subscribers.push(cb)\n\n return [ success, error ]\n }\n\n fn.stop = () => subscribers = []\n\n fn.debounce = ms => {\n const o = obs()\n let ts = +new Date\n subscribers.push(val => {\n const now = +new Date\n if(now - ts >= ms){\n ts = +new Date\n o(val)\n }\n })\n return o\n }\n\n return fn\n}\n\nobs.from = f => {\n const o = obs()\n f(x => o(x))\n return o\n}\n\nobs.union = (...fs) => {\n const o = obs()\n fs.map(f => f.then(o))\n return o\n}\n\nexport default obs","// compute the hamming weight\nexport const hamming = x => {\n x -= ((x >> 1) & 0x55555555)\n x = (x & 0x33333333) + ((x >> 2) & 0x33333333)\n x = (x + (x >> 4)) & 0x0f0f0f0f\n x += (x >> 8)\n x += (x >> 16)\n return (x & 0x7f)\n}\n\nexport const popcount = root => {\n if(root.key)\n return 1\n\n let c = root.children\n if(c) {\n var sum = 0\n for(var i in c) sum += popcount(c[i])\n return sum\n }\n}\n\n// hash fn\nexport const hash = (v='') => {\n v = JSON.stringify(v)\n var hash = 5381\n for (let i = 0; i < v.length; i++)\n hash = ((hash << 5) + hash) + v.charCodeAt(i)\n return hash\n}\n\n// compare two hashes\nexport const comp = (a,b) => hash(a) === hash(b)\n\n// get a bit vector\nexport const HMAP_SIZE = 8\nexport const MAX_DEPTH = 32 / HMAP_SIZE - 1\nexport const vec = (h=0, i=0, range=HMAP_SIZE) => (h >>> (range*i)) & ((1 << range) - 1)\n\nexport const shallowClone = x => {\n let y = Object.create(null)\n for(let i in x)\n y[i] = x[i]\n return y\n}\n\nexport const cloneNode = x => {\n let y = node()\n if(!x) return y\n\n if(x.children) {\n y.children = shallowClone(x.children)\n } else if(x.key !== undefined) {\n y.key = x.key\n y.val = x.val\n y.hash = x.hash\n }\n\n return y\n}\n\nexport const numChildren = x => {\n let c = 0\n for(var i in x) ++c\n return c\n}\n\nexport const set = (root, key, val) => {\n if((root.key === undefined) && !root.children) return node(key, val)\n\n const newroot = cloneNode(root), h = hash(key)\n\n // walk the tree\n for(var i = 3, r = root, n = newroot; i >= 0; --i){\n let bits = vec(h, i)\n\n if(r.key !== undefined){\n // if we have a collision\n if(r.key === key || i === 0) {\n // if keys match or is leaf, just overwrite n's val\n n.val = val\n } else if(i !== 0) {\n // else if r is not at max depth and keys don't match\n // add levels to both trees, new tree must be able\n // to access old data\n\n // 0. create makeshift value node for r\n // and new value node for n\n let cp = node(r.key, r.val, r.hash)\n let cn = node(key, val, h)\n let rh = r.hash\n\n // 1. delete value props from nodes\n delete r.key\n delete r.val\n delete r.hash\n delete n.key\n delete n.val\n delete n.hash\n\n // 2. create layers until bit-vectors don't collide\n for(let j = i, __r = r, __n = n; j >= 0; j--){\n let vecr = vec(rh, j),\n vecn = vec(h, j)\n\n // create new layer for c and r\n let c = __r.children = Object.create(null)\n let d = __n.children = shallowClone(c)\n\n if(vecr !== vecn) {\n c[vecr] = cp\n d[vecr] = cp\n d[vecn] = cn\n break\n } else {\n __r = c[vecr] = node()\n __n = d[vecn] = cloneNode(__r)\n }\n }\n }\n break\n } else if(r.children) {\n let _r = r.children[bits]\n if(!_r) {\n n = n.children[bits] = node(key, val)\n break\n } else {\n r = _r\n n = n.children[bits] = cloneNode(r)\n }\n }\n }\n\n return newroot\n}\n\nexport const get = (root, key) => {\n if(root.key === key) return root.val\n const h = hash(key)\n for(let i = 3, r = root; i >= 0; --i){\n if(!r.children) return undefined\n r = r.children[vec(h, i)]\n if(!r) return undefined\n if(r.key !== undefined) return r.val\n }\n\n return undefined\n}\n\nexport const first = root => {\n let c = root.children\n for(let i in c) return c[i]\n}\n\nexport const unset = (root, key) => {\n const n = cloneNode(root),\n h = hash(key)\n\n for(var i = 3, _n = n, p = n; i >= -1; --i) {\n if(_n.key) {\n delete _n.key\n delete _n.val\n delete _n.hash\n return n\n\n// let c = numChildren(p)\n\n// if(c === 1) {\n// // if only child, delete child and parent?\n// delete p.children\n// } else if(c===2){\n// // if 2 children, promote sibling as parent value nod\n// delete p.children[bits]\n// let sibling = first(p)\n// delete p.children\n// if(sibling.children){\n// p.children = sibling.children\n// } else if(p.key) {\n// p.val = sibling.val\n// p.hash = sibling.hash\n// p.key = sibling.key\n// }\n// } else {\n// // if more than 2 children, just delete the one\n// delete p.children[bits]\n// }\n// return n\n }\n\n const bits = vec(h, i)\n _n = _n && _n.children && _n.children[bits]\n if(!_n) return n\n p = _n\n }\n return n\n}\n\nexport const node = (key,val,h= key !== undefined && hash(key)) => {\n /*\n potential props of a tree node\n - key - hashkey\n - val - value\n - children - { ... } -> points to other nodes (List children)\n */\n\n let item = Object.create(null)\n if(key !== undefined){\n item.key = key\n item.hash = h\n item.val = val\n }\n return item\n}\n\nexport const map = (root, fn) => {\n if(root.key !== undefined)\n return node(root.key, fn(root.val, root.key), root.hash)\n\n let d = cloneNode(root),\n c = d.children\n\n if(c) {\n for(var i in c){\n c[i] = map(c[i], fn)\n }\n }\n\n return d\n}\n\nexport const filter = (root, fn) => {\n if(root.key !== undefined)\n return fn(root.val, root.key) ? root : undefined\n\n let d = cloneNode(root),\n c = d.children\n\n if(c) {\n for(var i in c){\n if(!filter(c[i], fn))\n delete c[i]\n }\n }\n\n return d\n}\n\nexport const reduce = (root, fn, acc) => {\n if(root.key !== undefined)\n return fn(acc, root.val, root.key)\n\n let c = root.children\n if(c) {\n for(var i in c)\n acc = reduce(c[i], fn, acc)\n\n return acc\n }\n}\n\nexport const toList = (root, r=[]) => {\n if(root.key !== undefined) r.push(root.val)\n\n let c = root.children\n if(c) {\n for(var i in c) {\n toList(c[i], r)\n }\n }\n\n return r\n}\n\nexport const toOrderedList = (root, r=[]) => {\n let i = 0,\n n\n\n do {\n n = get(root, i++)\n n !== undefined && r.push(n)\n } while(n)\n\n return r\n}\n\nexport const toJSON = (root, r={}) => {\n if(root.key !== undefined)\n r[root.key] = root.val\n\n let c = root.children\n if(c) {\n for(var i in c) {\n toJson(c[i], r)\n }\n }\n\n return r\n}\n\nexport const push = (root, val) => set(root, popcount(root), val)\n\nexport const pop = root => unset(root, popcount(root)-1)\n\nexport const shift = root => reduce(\n unset(root, 0),\n (acc,v,k) => set(acc, k-1, v),\n node())\n\nexport const unshift = (root, val) =>\n set(\n reduce(\n root,\n (acc,v,k) => set(acc, k+1, v),\n node()),\n 0,\n val)\n\nexport const hamt = node\n\n// console.clear()\n// const l = (...args) => console.log(...args)\n// const j = (...a) => console.log(JSON.stringify(a))\n\n// let x = hamt()\n// let s = 20\n\n// Array(s).fill(1).map((v,i) => {\n// x = set(x, i, i)\n// })\n\n// l(toList(x))\n// l(toJson(x))\n\n// x = map(x, x => log(x*x) || x*x)\n// l(get(x, 19))\n\n// l(x)\n// l(reduce(x, (acc, x) => acc+x, 0))\n\n// x = unset(x, 1)\n// Array(s).fill(1).map((_,i) => {\n// if(!get(x, i)) l(i)\n// // l(get(x, i))\n// })","const supports = (...q) => () =>\n q.reduce((acc,s) =>\n acc\n || (window[s] !== undefined)\n && /[native code]/.test(window[s]+'')\n && window[s]\n , false)\n\nconst supportsWorkers = supports('Worker')\n\nconst supportsBlobs = supports('Blob')\n\nconst supportsURLs = supports('URL', 'webkitURL')\n\nconst supportsBuilders = supports('BlobBuilder', 'WebKitBlobBuilder', 'MozBlobBuilder')\n\n/*\nworker:: [X] -> Worker where X : Function | String\n\nthe last X provided in the arguments will be setup as the handler for self.onmessage()\n*/\nexport const worker = (...code) => {\n if(!supportsWorkers()) throw 'WebWorkers not supported'\n\n code[code.length-1] = `self.onmessage=${code[code.length-1]}`\n\n const B = supportsBlobs()\n , U = supportsBuilders()\n , W = supportsURLs()\n\n let blob\n\n if(supportsBlobs()) {\n blob =\n new B(code.map(c => c+''),\n {type: 'application/javascript'})\n\n } else if(U){\n blob = new U\n code.map(c => blob.append(c+''))\n blob = blob.getBlob()\n } else {\n blob = `data:application/javascript,`\n +`${encodeURIComponent(\n code.reduce((acc,c) => acc+c, '')\n )}`\n }\n\n let url = W.createObjectURL(blob)\n return new Worker(url)\n}\n\nexport const farm = (n, ...code) => {\n let workers = Array(n).fill(1).map(x => worker(...code))\n , current = 0\n , iter = () => {\n let _n = current\n ++current >= n && (current = 0)\n return current\n }\n , pipe\n , onerror\n\n workers.map(w => {\n w.onmessage = e => pipe instanceof Function && pipe(e.data)\n w.onerror = e => onerror instanceof Function && onerror(e)\n })\n\n const exec = (...args) => {\n let w = workers[iter()]\n w && w.postMessage(args)\n }\n\n exec.pipe = fn => {\n pipe = fn\n return exec\n }\n exec.error = fn => {\n onerror = fn\n return exec\n }\n return exec\n}\n","export const log = (...a) => console.log(...a)\n\n// rAF\nexport const rAF =\n typeof document !== 'undefined' &&\n (requestAnimationFrame ||\n webkitRequestAnimationFrame ||\n mozRequestAnimationFrame) ||\n process && process.nextTick ||\n (cb => setTimeout(cb, 16.6))\n\n// composition\n// c :: (T -> U) -> (U -> V) -> (T -> V)\nexport const c = (f,g) => x => f(g(x))\n\n// cof :: [(an -> bn)] -> a0 -> bn\n// compose forward\nexport const cof = (...fns) => fns.reduce((acc,fn) => c(acc, fn))\n\n// cob :: [(an -> bn)] -> b0 -> an\n// compose backwards\nexport const cob = (...fns) => cof(...fns.reverse())\n\n// functional utilities\n// pointfree\nexport const pf = fn => (...args) => x => fn.apply(x, args)\n\n// curry\n// curry :: (T -> U) -> [args] -> ( -> U)\nexport const curry = (fn, ...args) =>\n\tfn.bind(undefined, ...args)\n\n\n// Transducers\nexport const mapping = (mapper) => // mapper: x -> y\n (reducer) => // reducer: (state, value) -> new state\n (result, value) =>\n reducer(result, mapper(value))\n\nexport const filtering = (predicate) => // predicate: x -> true/false\n (reducer) => // reducer: (state, value) -> new state\n (result, value) =>\n predicate(value) ? reducer(result, value) : result\n\nexport const concatter = (thing, value) =>\n thing.concat([value])\n",null]} \ No newline at end of file +{"version":3,"sources":["index.js","batch.js","vdom.js","mixin.js","model.js","observable.js","hamt.js","worker.js","fp.js"],"names":["hamt","worker","fp","hash","v","_v","JSON","stringify","i","len","length","c","charCodeAt","module","exports","Object","assign","batch","vdom","mixin","model","obs","inflight","url","options","method","key","toLowerCase","f","compress","Promise","res","rej","then","d","catch","e","undefined","data","console","error","rAF","document","requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","setTimeout","cb","class_id_regex","tagName_regex","parseSelector","test","tagreg","exec","s","tag","slice","reg","create","substr","className","trim","id","debounce","func","wait","immediate","timeout","args","later","callNow","clearTimeout","m","selector","children","attrs","Array","Function","unshift","shouldUpdate","unload","config","__hash","stripEvents","a","name","applyEvents","events","el","strip_existing","removeEvents","flatten","arr","push","EVENTS","split","map","x","mnt","mount","fn","render","applyUpdates","update","stylify","style","setAttrs","attr","innerHTML","value","setAttribute","_id","_className","createTag","parent","parentElement","__vdom","t","createTextNode","insertBefore","removeEl","appendChild","shouldExchange","tagName","_shouldUpdate","createElement","removeChild","insertAt","next_sib","resolve","_el","vdom_children","el_children","childNodes","qs","querySelector","resolver","states","promises","done","_await","_promises","finish","ms","isDone","total","all","props","keys","forEach","getState","gs","view","state","r","instance","container","queries","wrapper_view","reservedAttrs","toHTML","_vdom","html","_class","_attrs","inner","indexOf","str","filter","join","classes","_mixin","proto","prototype","p","getOwnPropertyNames","oldFn","apply","call","arguments","is","type","isValid","String","Number","Boolean","check","types","required","reduce","_type","MODEL","init","logic","pipe","whenValid","ArrayOf","M","subscribers","val","o","take","n","values","delete","takeWhile","acc","maybe","success","stop","ts","Date","now","from","union","fs","hamming","popcount","root","sum","comp","b","HMAP_SIZE","MAX_DEPTH","vec","h","range","shallowClone","y","cloneNode","node","numChildren","set","newroot","bits","cp","cn","rh","j","__r","__n","vecr","vecn","_r","get","first","unset","_n","item","toList","toOrderedList","toJSON","toJson","pop","shift","k","supports","q","window","supportsWorkers","supportsBlobs","supportsURLs","supportsBuilders","code","B","U","W","blob","append","getBlob","encodeURIComponent","createObjectURL","Worker","farm","workers","fill","current","iter","onerror","w","onmessage","postMessage","log","process","nextTick","g","cof","fns","cob","reverse","pf","curry","bind","mapping","mapper","reducer","result","filtering","predicate","concatter","thing","concat"],"mappings":";;;;;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3L,KAAT;AAAA,2BACI0L,QAAQC,MAAR,EAAgBF,OAAOzL,KAAP,CAAhB,CADJ;AAAA;AADJ;AAAA;AADmB;AAAA,CAAhB;;AAKA,IAAM4L,gCAAY,SAAZA,SAAY,CAACC,SAAD;AAAA,WAAe;AACpC,kBAACH,OAAD;AAAA,mBAAa;AACT,0BAACC,MAAD,EAAS3L,KAAT;AAAA,2BACI6L,UAAU7L,KAAV,IAAmB0L,QAAQC,MAAR,EAAgB3L,KAAhB,CAAnB,GAA4C2L,MADhD;AAAA;AADJ;AAAA;AADqB;AAAA,CAAlB;;AAKA,IAAMG,gCAAY,SAAZA,SAAY,CAACC,KAAD,EAAQ/L,KAAR;AAAA,WACrB+L,MAAMC,MAAN,CAAa,CAAChM,KAAD,CAAb,CADqB;AAAA,CAAlB","file":"","sourcesContent":["import batch from './batch'\nimport vdom from './vdom'\nimport mixin from './mixin'\nimport model from './model'\nimport obs from './observable'\nimport * as hamt from './hamt'\nimport * as worker from './worker'\nimport * as fp from './fp'\n\nexport const hash = (v,_v=JSON.stringify(v)) => {\n let hash = 0\n for (let i = 0, len = _v.length; i < len; ++i) {\n const c = _v.charCodeAt(i)\n hash = (((hash << 5) - hash) + c) | 0\n }\n return hash\n}\n\nmodule.exports = Object.assign({}, fp, {\n\tbatch\n\t, vdom\n\t, mixin\n\t, model\n\t, obs\n\t, hamt\n\t, worker\n})\n","\n// batched requests\n// The `fetch()` module batches in-flight requests, so if at any point in time, anywhere in my front-end or\n// back-end application I have a calls occur to `fetch('http://api.github.com/users/matthiasak')` while another\n// to that URL is \"in-flight\", the Promise returned by both of those calls will be resolved by a single network request.\n\n// f :: (url -> options) -> Promise\nconst batch = f => {\n let inflight = {}\n\n return (url, options={}) => {\n let {method} = options,\n key = `${url}:${JSON.stringify(options)}`\n\n if((method || '').toLowerCase() === 'post')\n return f(url, Object.assign({}, options, {compress: false}))\n\n return inflight[key] ||\n (inflight[key] =\n new Promise((res,rej) => {\n f(url, Object.assign({}, options, {compress: false}))\n .then(d => res(d))\n .catch(e => rej(e))\n })\n .then(data => {\n inflight = Object.assign({}, inflight, {[key]: undefined})\n return data\n })\n .catch(e =>\n console.error(e, url)))\n }\n}\n\nexport default batch","const rAF =\n typeof document !== 'undefined' &&\n (requestAnimationFrame ||\n webkitRequestAnimationFrame ||\n mozRequestAnimationFrame) ||\n (cb => setTimeout(cb, 16.6))\n\n// Virtual DOMs\nconst vdom = () => {\n const class_id_regex = () => {\n return /[#\\.][^#\\.]+/ig\n },\n tagName_regex = () => {\n return /^([^\\.#]+)\\b/i\n }\n\n const parseSelector = s => {\n let test = null,\n tagreg = tagName_regex().exec(s),\n tag = tagreg && tagreg.slice(1)[0],\n reg = class_id_regex(),\n vdom = Object.create(null)\n\n if(tag) s = s.substr(tag.length)\n vdom.className = ''\n vdom.tag = tag || 'div'\n\n while((test = reg.exec(s)) !== null){\n test = test[0]\n if(test[0] === '.')\n vdom.className = (vdom.className+' '+test.substr(1)).trim()\n else if(test[0] === '#')\n vdom.id = test.substr(1)\n }\n return vdom\n }\n\n const debounce = (func, wait, immediate, timeout) =>\n (...args) => {\n let later = () => {\n timeout = null\n !immediate && func(...args)\n }\n var callNow = immediate && !timeout\n clearTimeout(timeout)\n timeout = setTimeout(later, wait || 0)\n callNow && func(...args)\n }\n\n const hash = (v,_v=JSON.stringify(v)) => {\n let hash = 0\n for (let i = 0, len = _v.length; i < len; ++i) {\n const c = _v.charCodeAt(i)\n hash = (((hash << 5) - hash) + c) | 0\n }\n return hash\n }\n\n const m = (selector, attrs=Object.create(null), ...children) => {\n if(attrs.tag || !(typeof attrs === 'object') || attrs instanceof Array || attrs instanceof Function){\n if(attrs instanceof Array) children.unshift(...attrs)\n else children.unshift(attrs)\n attrs = Object.create(null)\n }\n let vdom = parseSelector(selector)\n if(children.length)\n vdom.children = children\n vdom.attrs = attrs\n vdom.shouldUpdate = attrs.shouldUpdate\n vdom.unload = attrs.unload\n vdom.config = attrs.config\n vdom.__hash = hash(vdom)\n delete attrs.unload\n delete attrs.shouldUpdate\n delete attrs.config\n return vdom\n }\n\n // creatign html, strip events from DOM element... for now just deleting\n const stripEvents = ({attrs}) => {\n let a = Object.create(null)\n\n if(attrs){\n for(var name in attrs){\n if(name[0]==='o'&&name[1]==='n') {\n a[name] = attrs[name]\n delete attrs[name]\n }\n }\n }\n\n return a\n }\n\n const applyEvents = (events, el, strip_existing=true) => {\n strip_existing && removeEvents(el)\n for(var name in events){\n el[name] = events[name]\n }\n }\n\n const flatten = (arr, a=[]) => {\n for(var i=0,len=arr.length; i 'on'+x)\n\n const removeEvents = el => {\n // strip away event handlers on el, if it exists\n if(!el) return;\n for(var i in EVENTS){\n el[i] = null\n }\n }\n\n let mnt\n\n const mount = (fn, el) => {\n mnt = [el, fn]\n render(fn, el)\n }\n\n const render = debounce((fn, el) => rAF(_ => {\n applyUpdates(fn, el.children[0], el)\n }))\n\n const update = () => {\n if(!mnt) return\n let [el, fn] = mnt\n render(fn, el)\n }\n\n const stylify = style => {\n let s = ''\n for(var i in style){\n s+=`${i}:${style[i]};`\n }\n return s\n }\n\n const setAttrs = ({attrs, id, className, __hash},el) => {\n \tel.className = ''\n \tel.style = ''\n\n if(attrs){\n for(var attr in attrs){\n if(attr === 'style') {\n el.style = stylify(attrs[attr])\n } else if(attr === 'innerHTML'){\n rAF(() => el.innerHTML = attrs[attr])\n } else if(attr === 'value'){\n rAF(() => el.value = attrs[attr])\n } else {\n el.setAttribute(attr, attrs[attr])\n }\n }\n }\n let _id = attrs.id || id\n if(_id) el.id = _id\n let _className = ((attrs.className || '') + ' ' + (className || '')).trim()\n if(_className) el.className = _className\n el.__hash = __hash\n }\n\n // recycle or create a new el\n const createTag = (vdom=Object.create(null), el, parent=el&&el.parentElement) => {\n let __vdom = vdom\n // make text nodes from primitive types\n if(typeof vdom !== 'object'){\n let t = document.createTextNode(vdom)\n if(el){\n parent.insertBefore(t,el)\n removeEl(el)\n } else {\n parent.appendChild(t)\n }\n return t\n }\n\n // else make an HTMLElement from \"tag\" types\n let {tag, attrs, id, className, unload, shouldUpdate, config, __hash} = vdom,\n shouldExchange = !el || !el.tagName || (tag && el.tagName.toLowerCase() !== tag.toLowerCase()),\n _shouldUpdate = !(shouldUpdate instanceof Function) || shouldUpdate(el)\n\n if(!attrs) return\n if(el && (!_shouldUpdate || ((!vdom instanceof Function) && el.__hash === __hash))) {\n return\n }\n\n if(shouldExchange){\n let t = document.createElement(tag)\n el ? (parent.insertBefore(t, el), removeEl(el)) : parent.appendChild(t)\n el = t\n }\n\n setAttrs(vdom, el)\n if(el.unload instanceof Function) {\n rAF(el.unload)\n }\n if(unload instanceof Function) {\n el.unload = unload\n }\n applyEvents(stripEvents(vdom), el)\n config && rAF(_ => config(el))\n return el\n }\n\n // find parent element, and remove the input element\n const removeEl = el => {\n if(!el) return\n el.parentElement.removeChild(el)\n removeEvents(el)\n // removed for now, added unload logic to the immediate draw()s\n if(el.unload instanceof Function)\n el.unload()\n }\n\n const insertAt = (el, parent, i) => {\n if(parent.children.length > i) {\n let next_sib = parent.children[i]\n parent.insertBefore(el, next_sib)\n } else {\n parent.appendChild(el)\n }\n }\n\n const applyUpdates = (vdom, el, parent=el&&el.parentElement) => {\n let v = vdom\n // if vdom is a function, execute it until it isn't\n while(vdom instanceof Function)\n vdom = vdom()\n\n if(!vdom) return\n\n if(vdom.resolve instanceof Function){\n let i = parent.children.length\n return vdom.resolve().then(v => {\n if(!el) {\n let x = createTag(v, null, parent)\n insertAt(x, parent, i)\n applyUpdates(v, x, parent)\n } else {\n applyUpdates(v, el, parent)\n }\n })\n }\n\n // create/edit el under parent\n let _el = vdom instanceof Array ? parent : createTag(vdom, el, parent)\n\n if(!_el) return\n\n if(vdom instanceof Array || vdom.children){\n let vdom_children = flatten(vdom instanceof Array ? vdom : vdom.children),\n el_children = vdom instanceof Array ? parent.childNodes : _el.childNodes\n\n while(el_children.length > vdom_children.length){\n removeEl(el_children[el_children.length-1])\n }\n\n for(let i=0; i 0){\n removeEl(_el.childNodes[_el.childNodes.length-1])\n }\n }\n }\n\n const qs = (s='body', el=document) => el.querySelector(s)\n\n const resolver = (states = {}) => {\n let promises = [],\n done = false\n\n const _await = (_promises = []) => {\n promises = [...promises, ..._promises]\n return finish()\n }\n\n const wait = (ms=0) => new Promise(res => setTimeout(res, ms))\n\n const isDone = () => done\n\n const finish = () => {\n const total = promises.length\n return wait().then(_ => Promise.all(promises)).then(values => {\n if(promises.length > total){\n return finish()\n }\n done = true\n return states\n })\n }\n\n const resolve = (props) => {\n const keys = Object.keys(props)\n if (!keys.length)\n return Promise.resolve(true)\n\n let f = []\n keys.forEach(name => {\n let x = props[name]\n\n while(x instanceof Function)\n x = x()\n\n if(x && x.then instanceof Function)\n f.push(x.then(d => states[name] = d))\n })\n\n return _await(f)\n }\n\n const getState = () => states\n\n return { finish, resolve, getState, promises, isDone }\n }\n\n const gs = (view, state) => {\n let r = view(state)\n while(r instanceof Function)\n r = view(instance.getState())\n return r\n }\n\n const container = (view, queries={}, instance=resolver()) => {\n let wrapper_view = state =>\n instance.isDone() ? view(state) : m('span')\n\n return () => {\n let r = gs(wrapper_view, instance.getState())\n instance.resolve(queries)\n\n if(r instanceof Array) {\n let d = instance.finish().then(_ =>\n gs(wrapper_view, instance.getState()))\n\n return r.map((x,i) => {\n x.resolve = _ => d.then(vdom => vdom[i])\n return x\n })\n }\n\n r.resolve = _ => instance.finish().then(_ =>\n gs(wrapper_view, instance.getState()))\n\n return r\n }\n }\n\n const reservedAttrs = ['className','id']\n\n const toHTML = _vdom => {\n while(_vdom instanceof Function) _vdom = _vdom()\n if(_vdom instanceof Array) return new Promise(r => r(html(..._vdom)))\n if(!_vdom) return new Promise(r => r(''))\n if(typeof _vdom !== 'object') return new Promise(r => r(_vdom))\n return (_vdom.resolve ? _vdom.resolve() : Promise.resolve()).then(vdom => {\n if(!vdom) vdom = _vdom\n\n if(vdom instanceof Array) return new Promise(r => r(html(...vdom)))\n\n const {tag, id, className, attrs, children, instance} = vdom,\n _id = (id || (attrs && attrs.id)) ? ` id=\"${(id || (attrs && attrs.id) || '')}\"` : '',\n _class = (className || (attrs && attrs.className)) ? ` class=\"${((className||'') + ' ' + (attrs.className||'')).trim()}\"` : ''\n\n const events = stripEvents(vdom)\n let _attrs = '',\n inner = ''\n for(var i in (attrs || Object.create(null))){\n if(i === 'style'){\n _attrs += ` style=\"${stylify(attrs[i])}\"`\n } else if(i === 'innerHTML') {\n inner = attrs[i]\n } else if(reservedAttrs.indexOf(i) === -1){\n _attrs += ` ${i}=\"${attrs[i]}\"`\n }\n }\n\n if(!inner && children)\n return html(...children).then(str =>\n `<${tag}${_id}${_class}${_attrs}>${str}`)\n\n if('br,input,img'.split(',').filter(x => x===tag).length === 0)\n return new Promise(r => r(`<${tag}${_id}${_class}${_attrs}>${inner}`))\n\n return new Promise(r => r(`<${tag}${_id}${_class}${_attrs} />`))\n })\n }\n\n const html = (...v) => Promise.all(v.map(toHTML)).then(x => x.filter(x => !!x).join(''))\n\n return {container, html, qs, update, mount, m, debounce}\n}\n\nmodule.exports = vdom()\n\n/*\nusage:\n\nlet component = () =>\n new Array(20).fill(true).map(x =>\n m('div', {onMouseOver: e => log(e.target.innerHTML)}, range(1,100)))\n\nclient-side\n-----\nmount(component, qs())\n\nclient-side constant re-rendering\n-----\nconst run = () => {\n setTimeout(run, 20)\n update()\n}\nrun()\n*/\n\n/* CONTAINER / HTML USAGE (Server-side rendering)\n\nconst name = _ => new Promise(res => setTimeout(_ => res('matt'), 1500))\n\nlet x = container(data => [\n m('div.test.row', {className:'hola', 'data-name':data.name, style:{border:'1px solid black'}}),\n m('div', data.name),\n ],\n {name}\n)\n\nhtml(x).then(x => log(x)).catch(e => log(e+''))\n*/\n","\nconst mixin = (...classes) => {\n class _mixin {}\n\n let proto = _mixin.prototype\n\n classes.map(({prototype:p}) => {\n Object.getOwnPropertyNames(p).map(key => {\n let oldFn = proto[key] || ($ => {})\n proto[key] = function() {\n oldFn.apply(null, [].slice.call(arguments))\n return p[key].apply(null, [].slice.call(arguments))\n }\n })\n })\n\n return _mixin\n}\n\nmodule.exports = mixin","// Validate JS objects for their \"shape\"\nconst model = {\n is(type, value) {\n if(type && type.isValid instanceof Function){\n return type.isValid(value)\n } else if((type === String && ((value instanceof String) || typeof value === 'string'))\n || (type === Number && ((value instanceof Number) || typeof value === 'number'))\n || (type === Boolean && ((value instanceof Boolean) || typeof value === 'boolean'))\n || (type === Function && ((value instanceof Function) || typeof value === 'function'))\n || (type === Object && ((value instanceof Object) || typeof value === 'object'))\n || (type === undefined)\n ){\n return true\n }\n\n return false\n },\n check(types, required, data) {\n Object.keys(types).forEach(key => {\n let t = types[key],\n value = data[key]\n\n if(required[key] || value !== undefined){\n if(!(t instanceof Array)) t = [t]\n\n let i = t.reduce((a,_type) => a || MODEL.is(_type, value), false)\n if(!i) {\n throw `{${key}: ${JSON.stringify(value)}} is not one of ${t.map(x => `\\n - ${x}`)}`\n }\n }\n })\n\n return true\n },\n init(...args) {\n let types, required, logic\n args.map(x => {\n if(x instanceof Function && !logic){ logic = x }\n else if(typeof x === 'object') {\n if(!types){ types = x }\n else if(!required){ required = x }\n }\n })\n\n const isValid = (data) => {\n const pipe = logic ? [check, logic] : [check]\n return pipe.reduce((a,v) => a && v(types||{},required||{},data), true)\n }\n\n const whenValid = (data) => new Promise((res,rej) => isValid(data) && res(data))\n\n return {isValid, whenValid}\n },\n ArrayOf(M) {\n return MODEL.init((t,r,data) => {\n if(!(data instanceof Array)) throw `${data} not an Array`\n data.map(x => {\n if(!MODEL.is(M, x))\n throw `${x} is not a model instance`\n })\n return true\n })\n }\n}\n\nexport default model\n\n/**\nUse it\n\n// create a Name model with required first/last,\n// but optional middle\nlet Name = MODEL.init({\n first: String,\n middle: String,\n last: String\n}, {first:true, last:true})\n\n// create a Tags model with extra checks\nlet Tags = MODEL.init((types,required,data) => {\n if(!(data instanceof Array)) throw `${data} not an Array`\n data.map(x => {\n if(!is(String, x))\n throw `[${data}] contains non-String`\n })\n return true\n})\n\n// create a Price model that just has a business logic fn\nlet Price = MODEL.init((t,r,d) => {\n return (d instanceof Number || typeof d === 'number') && d !== 0\n})\n\n// create an Activity model with a required type and name,\n// all others optional\nlet Activity = MODEL.init({\n type: [String, Function, Number],\n latlng: Array,\n title: String,\n tags: Tags,\n name: Name,\n price: Price\n}, {name:true, price: true})\n\n// create a new Activity instance, throwing errors if there are\n// any invalid fields.\nlet a = {\n tags: ['1','2'],\n type: 1,\n name: {first:'matt',last:'keas'},\n price: 100.43,\n url: 'http://www.google.com'\n}\nActivity.whenValid(a).then(log).catch(e => log(e+''))\n**/\n","// async-supporting-observables\nconst obs = (state) => {\n let subscribers = []\n\n const fn = (val) => {\n if(val !== undefined){\n state = val\n for(let i = 0, len = subscribers.length; i {\n const o = obs()\n subscribers.push(val => o(f(val)))\n return o\n }\n\n fn.filter = f => {\n const o = obs()\n subscribers.push(val => f(val) && o(val))\n return o\n }\n\n fn.then = f => {\n subscribers.push(val => f(val))\n return fn\n }\n\n fn.take = (n) => {\n const values = [],\n \to = obs()\n\n const cb = val => {\n if(values.length < n)\n values.push(val)\n\n if(values.length === n) {\n subscribers.delete(cb)\n return o(values)\n }\n }\n\n subscribers.push(cb)\n\n return o\n }\n\n fn.takeWhile = f => {\n const values = [],\n \to = obs()\n\n const cb = val => {\n if(!f(val)) {\n subscribers = subscribers.filter(x => x !== cb)\n return o(values)\n }\n\n\t\t\tvalues.push(val)\n }\n\n subscribers.push(cb)\n\n return o\n }\n\n fn.reduce = (f,acc) => {\n const o = obs()\n\n subscribers.push(val => {\n acc = f(acc,val)\n o(acc)\n })\n\n return o\n }\n\n fn.maybe = f => {\n const success = obs(),\n error = obs(),\n cb = val =>\n \t\tf(val)\n\t\t\t\t .then(d => success(d))\n .catch(e => error(e))\n\n subscribers.push(cb)\n\n return [ success, error ]\n }\n\n fn.stop = () => subscribers = []\n\n fn.debounce = ms => {\n const o = obs()\n let ts = +new Date\n subscribers.push(val => {\n const now = +new Date\n if(now - ts >= ms){\n ts = +new Date\n o(val)\n }\n })\n return o\n }\n\n return fn\n}\n\nobs.from = f => {\n const o = obs()\n f(x => o(x))\n return o\n}\n\nobs.union = (...fs) => {\n const o = obs()\n fs.map(f => f.then(o))\n return o\n}\n\nexport default obs","// compute the hamming weight\nexport const hamming = x => {\n x -= ((x >> 1) & 0x55555555)\n x = (x & 0x33333333) + ((x >> 2) & 0x33333333)\n x = (x + (x >> 4)) & 0x0f0f0f0f\n x += (x >> 8)\n x += (x >> 16)\n return (x & 0x7f)\n}\n\nexport const popcount = root => {\n if(root.key)\n return 1\n\n let c = root.children\n if(c) {\n var sum = 0\n for(var i in c) sum += popcount(c[i])\n return sum\n }\n}\n\n// hash fn\nexport const hash = (v='') => {\n v = JSON.stringify(v)\n var hash = 5381\n for (let i = 0; i < v.length; i++)\n hash = ((hash << 5) + hash) + v.charCodeAt(i)\n return hash\n}\n\n// compare two hashes\nexport const comp = (a,b) => hash(a) === hash(b)\n\n// get a bit vector\nexport const HMAP_SIZE = 8\nexport const MAX_DEPTH = 32 / HMAP_SIZE - 1\nexport const vec = (h=0, i=0, range=HMAP_SIZE) => (h >>> (range*i)) & ((1 << range) - 1)\n\nexport const shallowClone = x => {\n let y = Object.create(null)\n for(let i in x)\n y[i] = x[i]\n return y\n}\n\nexport const cloneNode = x => {\n let y = node()\n if(!x) return y\n\n if(x.children) {\n y.children = shallowClone(x.children)\n } else if(x.key !== undefined) {\n y.key = x.key\n y.val = x.val\n y.hash = x.hash\n }\n\n return y\n}\n\nexport const numChildren = x => {\n let c = 0\n for(var i in x) ++c\n return c\n}\n\nexport const set = (root, key, val) => {\n if((root.key === undefined) && !root.children) return node(key, val)\n\n const newroot = cloneNode(root), h = hash(key)\n\n // walk the tree\n for(var i = 3, r = root, n = newroot; i >= 0; --i){\n let bits = vec(h, i)\n\n if(r.key !== undefined){\n // if we have a collision\n if(r.key === key || i === 0) {\n // if keys match or is leaf, just overwrite n's val\n n.val = val\n } else if(i !== 0) {\n // else if r is not at max depth and keys don't match\n // add levels to both trees, new tree must be able\n // to access old data\n\n // 0. create makeshift value node for r\n // and new value node for n\n let cp = node(r.key, r.val, r.hash)\n let cn = node(key, val, h)\n let rh = r.hash\n\n // 1. delete value props from nodes\n delete r.key\n delete r.val\n delete r.hash\n delete n.key\n delete n.val\n delete n.hash\n\n // 2. create layers until bit-vectors don't collide\n for(let j = i, __r = r, __n = n; j >= 0; j--){\n let vecr = vec(rh, j),\n vecn = vec(h, j)\n\n // create new layer for c and r\n let c = __r.children = Object.create(null)\n let d = __n.children = shallowClone(c)\n\n if(vecr !== vecn) {\n c[vecr] = cp\n d[vecr] = cp\n d[vecn] = cn\n break\n } else {\n __r = c[vecr] = node()\n __n = d[vecn] = cloneNode(__r)\n }\n }\n }\n break\n } else if(r.children) {\n let _r = r.children[bits]\n if(!_r) {\n n = n.children[bits] = node(key, val)\n break\n } else {\n r = _r\n n = n.children[bits] = cloneNode(r)\n }\n }\n }\n\n return newroot\n}\n\nexport const get = (root, key) => {\n if(root.key === key) return root.val\n const h = hash(key)\n for(let i = 3, r = root; i >= 0; --i){\n if(!r.children) return undefined\n r = r.children[vec(h, i)]\n if(!r) return undefined\n if(r.key !== undefined) return r.val\n }\n\n return undefined\n}\n\nexport const first = root => {\n let c = root.children\n for(let i in c) return c[i]\n}\n\nexport const unset = (root, key) => {\n const n = cloneNode(root),\n h = hash(key)\n\n for(var i = 3, _n = n, p = n; i >= -1; --i) {\n if(_n.key) {\n delete _n.key\n delete _n.val\n delete _n.hash\n return n\n\n// let c = numChildren(p)\n\n// if(c === 1) {\n// // if only child, delete child and parent?\n// delete p.children\n// } else if(c===2){\n// // if 2 children, promote sibling as parent value nod\n// delete p.children[bits]\n// let sibling = first(p)\n// delete p.children\n// if(sibling.children){\n// p.children = sibling.children\n// } else if(p.key) {\n// p.val = sibling.val\n// p.hash = sibling.hash\n// p.key = sibling.key\n// }\n// } else {\n// // if more than 2 children, just delete the one\n// delete p.children[bits]\n// }\n// return n\n }\n\n const bits = vec(h, i)\n _n = _n && _n.children && _n.children[bits]\n if(!_n) return n\n p = _n\n }\n return n\n}\n\nexport const node = (key,val,h= key !== undefined && hash(key)) => {\n /*\n potential props of a tree node\n - key - hashkey\n - val - value\n - children - { ... } -> points to other nodes (List children)\n */\n\n let item = Object.create(null)\n if(key !== undefined){\n item.key = key\n item.hash = h\n item.val = val\n }\n return item\n}\n\nexport const map = (root, fn) => {\n if(root.key !== undefined)\n return node(root.key, fn(root.val, root.key), root.hash)\n\n let d = cloneNode(root),\n c = d.children\n\n if(c) {\n for(var i in c){\n c[i] = map(c[i], fn)\n }\n }\n\n return d\n}\n\nexport const filter = (root, fn) => {\n if(root.key !== undefined)\n return fn(root.val, root.key) ? root : undefined\n\n let d = cloneNode(root),\n c = d.children\n\n if(c) {\n for(var i in c){\n if(!filter(c[i], fn))\n delete c[i]\n }\n }\n\n return d\n}\n\nexport const reduce = (root, fn, acc) => {\n if(root.key !== undefined)\n return fn(acc, root.val, root.key)\n\n let c = root.children\n if(c) {\n for(var i in c)\n acc = reduce(c[i], fn, acc)\n\n return acc\n }\n}\n\nexport const toList = (root, r=[]) => {\n if(root.key !== undefined) r.push(root.val)\n\n let c = root.children\n if(c) {\n for(var i in c) {\n toList(c[i], r)\n }\n }\n\n return r\n}\n\nexport const toOrderedList = (root, r=[]) => {\n let i = 0,\n n\n\n do {\n n = get(root, i++)\n n !== undefined && r.push(n)\n } while(n)\n\n return r\n}\n\nexport const toJSON = (root, r={}) => {\n if(root.key !== undefined)\n r[root.key] = root.val\n\n let c = root.children\n if(c) {\n for(var i in c) {\n toJson(c[i], r)\n }\n }\n\n return r\n}\n\nexport const push = (root, val) => set(root, popcount(root), val)\n\nexport const pop = root => unset(root, popcount(root)-1)\n\nexport const shift = root => reduce(\n unset(root, 0),\n (acc,v,k) => set(acc, k-1, v),\n node())\n\nexport const unshift = (root, val) =>\n set(\n reduce(\n root,\n (acc,v,k) => set(acc, k+1, v),\n node()),\n 0,\n val)\n\nexport const hamt = node\n\n// console.clear()\n// const l = (...args) => console.log(...args)\n// const j = (...a) => console.log(JSON.stringify(a))\n\n// let x = hamt()\n// let s = 20\n\n// Array(s).fill(1).map((v,i) => {\n// x = set(x, i, i)\n// })\n\n// l(toList(x))\n// l(toJson(x))\n\n// x = map(x, x => log(x*x) || x*x)\n// l(get(x, 19))\n\n// l(x)\n// l(reduce(x, (acc, x) => acc+x, 0))\n\n// x = unset(x, 1)\n// Array(s).fill(1).map((_,i) => {\n// if(!get(x, i)) l(i)\n// // l(get(x, i))\n// })","const supports = (...q) => () =>\n q.reduce((acc,s) =>\n acc\n || (window[s] !== undefined)\n && /[native code]/.test(window[s]+'')\n && window[s]\n , false)\n\nconst supportsWorkers = supports('Worker')\n\nconst supportsBlobs = supports('Blob')\n\nconst supportsURLs = supports('URL', 'webkitURL')\n\nconst supportsBuilders = supports('BlobBuilder', 'WebKitBlobBuilder', 'MozBlobBuilder')\n\n/*\nworker:: [X] -> Worker where X : Function | String\n\nthe last X provided in the arguments will be setup as the handler for self.onmessage()\n*/\nexport const worker = (...code) => {\n if(!supportsWorkers()) throw 'WebWorkers not supported'\n\n code[code.length-1] = `self.onmessage=${code[code.length-1]}`\n\n const B = supportsBlobs()\n , U = supportsBuilders()\n , W = supportsURLs()\n\n let blob\n\n if(supportsBlobs()) {\n blob =\n new B(code.map(c => c+''),\n {type: 'application/javascript'})\n\n } else if(U){\n blob = new U\n code.map(c => blob.append(c+''))\n blob = blob.getBlob()\n } else {\n blob = `data:application/javascript,`\n +`${encodeURIComponent(\n code.reduce((acc,c) => acc+c, '')\n )}`\n }\n\n let url = W.createObjectURL(blob)\n return new Worker(url)\n}\n\nexport const farm = (n, ...code) => {\n let workers = Array(n).fill(1).map(x => worker(...code))\n , current = 0\n , iter = () => {\n let _n = current\n ++current >= n && (current = 0)\n return current\n }\n , pipe\n , onerror\n\n workers.map(w => {\n w.onmessage = e => pipe instanceof Function && pipe(e.data)\n w.onerror = e => onerror instanceof Function && onerror(e)\n })\n\n const exec = (...args) => {\n let w = workers[iter()]\n w && w.postMessage(args)\n }\n\n exec.pipe = fn => {\n pipe = fn\n return exec\n }\n exec.error = fn => {\n onerror = fn\n return exec\n }\n return exec\n}\n","export const log = (...a) => console.log(...a)\n\n// rAF\nexport const rAF =\n typeof document !== 'undefined' &&\n (requestAnimationFrame ||\n webkitRequestAnimationFrame ||\n mozRequestAnimationFrame) ||\n process && process.nextTick ||\n (cb => setTimeout(cb, 16.6))\n\n// composition\n// c :: (T -> U) -> (U -> V) -> (T -> V)\nexport const c = (f,g) => x => f(g(x))\n\n// cof :: [(an -> bn)] -> a0 -> bn\n// compose forward\nexport const cof = (...fns) => fns.reduce((acc,fn) => c(acc, fn))\n\n// cob :: [(an -> bn)] -> b0 -> an\n// compose backwards\nexport const cob = (...fns) => cof(...fns.reverse())\n\n// functional utilities\n// pointfree\nexport const pf = fn => (...args) => x => fn.apply(x, args)\n\n// curry\n// curry :: (T -> U) -> [args] -> ( -> U)\nexport const curry = (fn, ...args) =>\n\tfn.bind(undefined, ...args)\n\n\n// Transducers\nexport const mapping = (mapper) => // mapper: x -> y\n (reducer) => // reducer: (state, value) -> new state\n (result, value) =>\n reducer(result, mapper(value))\n\nexport const filtering = (predicate) => // predicate: x -> true/false\n (reducer) => // reducer: (state, value) -> new state\n (result, value) =>\n predicate(value) ? reducer(result, value) : result\n\nexport const concatter = (thing, value) =>\n thing.concat([value])\n"]} \ No newline at end of file diff --git a/fuse.js b/fuse.js index 4fc937f..e855046 100644 --- a/fuse.js +++ b/fuse.js @@ -12,7 +12,7 @@ let c = { , outFile: "./build/index.js.map" } , outFile: "./build/index.js" - , inFile: "> index.js [src/**/*.js]" + , inFile: "> index.js [index.js]" , plugins: (browser) => [ f.BabelPlugin({