hyperapplicable
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -5,3 +5,3 @@ import { Action, MaybeVNode, CustomPayloads, Dispatch, Effect, Unsubscribe, ClassProp, VNode, Dispatchable } from 'hyperapp'; | ||
declare type Content<S> = number | string | MaybeVNode<S>; | ||
declare type ContentViews<S> = readonly (Content<S> | View<S>)[]; | ||
declare type Contents<S> = Content<S> | View<S> | (Content<S> | View<S>)[]; | ||
declare type CustomProps<T, S, P> = CustomPayloads<S, P> & T; | ||
@@ -20,5 +20,6 @@ declare type Effecter<S, P> = (dispatch: Dispatch<S>, payload: P) => void | Promise<void>; | ||
declare const contentNode: <S>(x: Content<S>) => MaybeVNode<S>; | ||
declare const contentView: <S>(view: Content<S> | View<S>) => (state: S) => MaybeVNode<S>; | ||
declare const isContent: <S>(x: unknown) => x is Content<S>; | ||
declare const isVNode: <S>(x: unknown) => x is VNode<S>; | ||
declare const vista: <S>(xs: readonly (Content<S> | View<S>)[]) => (state: S) => MaybeVNode<S>[]; | ||
declare const vista: <S>(views: Contents<S>) => (state: S) => MaybeVNode<S>[]; | ||
@@ -35,2 +36,2 @@ declare const handleWith: <S>(handlers: readonly Transform<S, Event>[]) => (state: StateFormat<S, any>, event: Event) => StateFormat<S, any>; | ||
export { ActionWithPayload, Content, ContentViews, CustomProps, Effecter, Reaction, StateFormat, StateWithEffects, Subscriber, Transform, View, ViewComponent, box, contentNode, handleWith, isAction, isContent, isVNode, next, readout, unite, vista }; | ||
export { ActionWithPayload, Content, Contents, CustomProps, Effecter, Reaction, StateFormat, StateWithEffects, Subscriber, Transform, View, ViewComponent, box, contentNode, contentView, handleWith, isAction, isContent, isVNode, next, readout, unite, vista }; |
import { text, h } from "hyperapp"; | ||
const contentNode = (x) => typeof x === "number" || typeof x === "string" ? text(x) : x; | ||
const contentView = (view) => (state) => typeof view === "function" ? view(state) : contentNode(view); | ||
const isContent = (x) => typeof x === "number" || typeof x === "string" || x == null || typeof x === "boolean" || isVNode(x); | ||
const isVNode = (x) => x != null && typeof x === "object" && "node" in x; | ||
const vista = (xs) => (state) => xs.map((x) => typeof x === "function" ? x(state) : contentNode(x)); | ||
const vista = (views) => (state) => Array.isArray(views) ? views.map((view) => contentView(view)(state)) : [contentView(views)(state)]; | ||
const box = (classProp, content) => h("div", { class: classProp }, contentNode(content)); | ||
@@ -27,2 +28,2 @@ const unite = (transform, stateForm, payload) => { | ||
const readout = (prop) => (obj) => h("pre", {}, text(`${prop}: ${JSON.stringify(obj[prop], readoutReplacer, 2)}`)); | ||
export { box, contentNode, handleWith, isAction, isContent, isVNode, next, readout, unite, vista }; | ||
export { box, contentNode, contentView, handleWith, isAction, isContent, isVNode, next, readout, unite, vista }; |
@@ -1,1 +0,1 @@ | ||
(function(t,i){typeof exports=="object"&&typeof module!="undefined"?i(exports,require("hyperapp")):typeof define=="function"&&define.amd?define(["exports","hyperapp"],i):(t=typeof globalThis!="undefined"?globalThis:t||self,i(t.hyperapplicable={},t.Hyperapp))})(this,function(t,i){"use strict";const s=e=>typeof e=="number"||typeof e=="string"?i.text(e):e,y=e=>typeof e=="number"||typeof e=="string"||e==null||typeof e=="boolean"||r(e),r=e=>e!=null&&typeof e=="object"&&"node"in e,a=e=>n=>e.map(o=>typeof o=="function"?o(n):s(o)),l=(e,n)=>i.h("div",{class:e},s(n)),d=(e,n,o)=>{if(!Array.isArray(n))return e(n,o);const[f,...c]=n,u=e(f,o);if(!Array.isArray(u))return[u,...c];const[g,...S]=u;return[g,...c,...S]},h=e=>(n,o)=>e.reduce((f,c)=>d(c,f,o),n),p=e=>typeof e=="function"||Array.isArray(e)&&e.length>0,b=(e,n)=>{window.requestAnimationFrame(()=>e(n))},A=e=>[b,e],m=(e,n)=>typeof n=="function"?"function":n,N=e=>n=>i.h("pre",{},i.text(`${e}: ${JSON.stringify(n[e],m,2)}`));t.box=l,t.contentNode=s,t.handleWith=h,t.isAction=p,t.isContent=y,t.isVNode=r,t.next=A,t.readout=N,t.unite=d,t.vista=a,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
(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 f=n=>typeof n=="number"||typeof n=="string"?o.text(n):n,s=n=>t=>typeof n=="function"?n(t):f(n),a=n=>typeof n=="number"||typeof n=="string"||n==null||typeof n=="boolean"||d(n),d=n=>n!=null&&typeof n=="object"&&"node"in n,l=n=>t=>Array.isArray(n)?n.map(i=>s(i)(t)):[s(n)(t)],A=(n,t)=>o.h("div",{class:n},f(t)),y=(n,t,i)=>{if(!Array.isArray(t))return n(t,i);const[u,...c]=t,r=n(u,i);if(!Array.isArray(r))return[r,...c];const[S,...V]=r;return[S,...c,...V]},h=n=>(t,i)=>n.reduce((u,c)=>y(c,u,i),t),b=n=>typeof n=="function"||Array.isArray(n)&&n.length>0,p=(n,t)=>{window.requestAnimationFrame(()=>n(t))},m=n=>[p,n],N=(n,t)=>typeof t=="function"?"function":t,g=n=>t=>o.h("pre",{},o.text(`${n}: ${JSON.stringify(t[n],N,2)}`));e.box=A,e.contentNode=f,e.contentView=s,e.handleWith=h,e.isAction=b,e.isContent=a,e.isVNode=d,e.next=m,e.readout=g,e.unite=y,e.vista=l,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
{ | ||
"name": "hyperapplicable", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "A utility library for Hyperapp.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
8186
58