hyperapplicable
Advanced tools
Comparing version 0.5.3 to 0.6.0
@@ -27,3 +27,3 @@ import { ClassProp, MaybeVNode, VNode, Action, CustomPayloads, Dispatch, Effect, Unsubscribe, Dispatchable } from 'hyperapp'; | ||
declare const unite: <S, P = any>(transform: Transform<S, any>, stateForm: StateFormat<S, any>, payload?: P | undefined) => StateFormat<S, any>; | ||
declare const unite: <S, P = any>(stateForm: StateFormat<S, any>, transformation: Transform<S, any> | [Transform<S, any>, P]) => StateFormat<S, any>; | ||
@@ -30,0 +30,0 @@ declare const contentView: <S>(view: Content<S> | VistaView<S>) => (state: S) => MaybeVNode<S>[]; |
import { h, text } from "hyperapp"; | ||
const box = (classProp, contents) => h("div", { class: classProp }, contents); | ||
const unite = (transform, stateForm, payload) => { | ||
const unite = (stateForm, transformation) => { | ||
let transform, payload; | ||
if (Array.isArray(transformation)) { | ||
transform = transformation[0]; | ||
payload = transformation[1]; | ||
} else { | ||
transform = transformation; | ||
} | ||
if (!Array.isArray(stateForm)) { | ||
@@ -15,3 +22,3 @@ return transform(stateForm, payload); | ||
}; | ||
const handleWith = (handlers) => (state, event) => handlers.reduce((stateForm, transform) => unite(transform, stateForm, event), state); | ||
const handleWith = (handlers) => (state, event) => handlers.reduce((stateForm, transform) => unite(stateForm, [transform, event]), state); | ||
const isAction = (x) => typeof x === "function" || Array.isArray(x) && x.length > 0; | ||
@@ -18,0 +25,0 @@ const runNext = (dispatch, x) => { |
@@ -1,1 +0,1 @@ | ||
(function(e,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("hyperapp")):typeof define=="function"&&define.amd?define(["exports","hyperapp"],o):(e=typeof globalThis!="undefined"?globalThis:e||self,o(e.hyperapplicable={},e.Hyperapp))})(this,function(e,o){"use strict";const d=(t,n)=>o.h("div",{class:t},n),f=(t,n,i)=>{if(!Array.isArray(n))return t(n,i);const[r,...c]=n,u=t(r,i);if(!Array.isArray(u))return[u,...c];const[m,...S]=u;return[m,...c,...S]},l=t=>(n,i)=>t.reduce((r,c)=>f(c,r,i),n),A=t=>typeof t=="function"||Array.isArray(t)&&t.length>0,h=(t,n)=>{window.requestAnimationFrame(()=>t(n))},p=t=>[h,t],b=(t,n)=>typeof n=="function"?"function":n,V=t=>n=>o.h("pre",{},o.text(`${t}: ${JSON.stringify(n[t],b,2)}`)),s=t=>n=>{if(typeof t=="function"){const i=t(n);return Array.isArray(i)?i:[i]}return typeof t=="number"||typeof t=="string"?[o.text(t)]:[t]},g=t=>t==null||typeof t=="boolean"||typeof t=="function"||typeof t=="number"||typeof t=="string"||y(t),y=t=>typeof t=="object"&&t!=null&&"node"in t,a=t=>n=>Array.isArray(t)?t.reduce((i,r)=>[...i,...Array.isArray(r)?a(r)(n):s(r)(n)],[]):s(t)(n);e.box=d,e.contentView=s,e.handleWith=l,e.isAction=A,e.isVNode=y,e.isVista=g,e.next=p,e.readout=V,e.unite=f,e.vista=a,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
(function(n,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("hyperapp")):typeof define=="function"&&define.amd?define(["exports","hyperapp"],r):(n=typeof globalThis!="undefined"?globalThis:n||self,r(n.hyperapplicable={},n.Hyperapp))})(this,function(n,r){"use strict";const l=(e,t)=>r.h("div",{class:e},t),f=(e,t)=>{let i,o;if(Array.isArray(t)?(i=t[0],o=t[1]):i=t,!Array.isArray(e))return i(e,o);const[s,...d]=e,u=i(s,o);if(!Array.isArray(u))return[u,...d];const[m,...N]=u;return[m,...d,...N]},A=e=>(t,i)=>e.reduce((o,s)=>f(o,[s,i]),t),p=e=>typeof e=="function"||Array.isArray(e)&&e.length>0,h=(e,t)=>{window.requestAnimationFrame(()=>e(t))},b=e=>[h,e],V=(e,t)=>typeof t=="function"?"function":t,g=e=>t=>r.h("pre",{},r.text(`${e}: ${JSON.stringify(t[e],V,2)}`)),c=e=>t=>{if(typeof e=="function"){const i=e(t);return Array.isArray(i)?i:[i]}return typeof e=="number"||typeof e=="string"?[r.text(e)]:[e]},S=e=>e==null||typeof e=="boolean"||typeof e=="function"||typeof e=="number"||typeof e=="string"||y(e),y=e=>typeof e=="object"&&e!=null&&"node"in e,a=e=>t=>Array.isArray(e)?e.reduce((i,o)=>[...i,...Array.isArray(o)?a(o)(t):c(o)(t)],[]):c(e)(t);n.box=l,n.contentView=c,n.handleWith=A,n.isAction=p,n.isVNode=y,n.isVista=S,n.next=b,n.readout=g,n.unite=f,n.vista=a,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
{ | ||
"name": "hyperapplicable", | ||
"version": "0.5.3", | ||
"version": "0.6.0", | ||
"description": "A utility library for Hyperapp.", | ||
@@ -50,14 +50,14 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/jest": "^27.5.0", | ||
"@typescript-eslint/eslint-plugin": "^5.22.0", | ||
"@typescript-eslint/parser": "^5.22.0", | ||
"eslint": "^8.14.0", | ||
"@types/jest": "^27.5.1", | ||
"@typescript-eslint/eslint-plugin": "^5.23.0", | ||
"@typescript-eslint/parser": "^5.23.0", | ||
"eslint": "^8.15.0", | ||
"fast-check": "^2.25.0", | ||
"jest": "^28.0.3", | ||
"rollup": "^2.72.0", | ||
"jest": "^28.1.0", | ||
"rollup": "^2.73.0", | ||
"terser": "^5.13.1", | ||
"ts-jest": "^28.0.1", | ||
"ts-jest": "^28.0.2", | ||
"tsup": "^5.12.7", | ||
"typescript": "^4.6.4", | ||
"vite": "^2.9.8" | ||
"vite": "^2.9.9" | ||
}, | ||
@@ -64,0 +64,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8641
74