Skip to content

Instantly share code, notes, and snippets.

View okwolf's full-sized avatar
🐺
Howling

Wolf okwolf

🐺
Howling
View GitHub Profile
export default actionStack => {
if (actionStack.length === 1 && actionStack[0][0] === "state") {
console.log(
"%cinitial state",
"color: #4CAF50; font-weight: bold;",
actionStack[0][1].nextState
);
} else {
const groupTitle = actionStack
.slice(1)

Keybase proof

I hereby claim:

  • I am okwolf on github.
  • I am okwolf (https://keybase.io/okwolf) on keybase.
  • I have a public key ASBeCmAcr9jCa6qAM5vXJYjQ6E94d_sf-PYFL-5YGvvxMAo

To claim this, I am signing this object:

const randomEffect = (props, dispatch) => {
const randomValue = Math.random() * (props.max - props.min) + props.min;
dispatch(props.action, randomValue)
};
export const Random = ({ action, min = 0, max = 1 }) => ({
props: {
action,
min,
max
import { h, app } from "hyperapp"
// higher-order app function for update powers
const withUpdateApp = nextApp => {
return (initialState, actionsTemplate, view, container) => {
let currentView = view
const enhancedActions = nextApp(
initialState,
{
...actionsTemplate,
<html>
<head>
<title>unpkg :: basic-react demo</title>
<meta charset="utf-8" />
</head>
<body>
<div id="app"></div>
(
[char[]]([char]33..[char]95) +
([char[]]([char]97..[char]126)) +
0..9 |
Sort { Get-Random }
)[0..63] -Join '' | Clip

Original was from Reduce Advanced of funfunfunction. It was a great example, but I thought it could use a bit more of the ES6 goodness like template literals, destructuring, and the spread operators.

Also the reduced form is a more "pure" functional implementation since it doesn't mutate the original object with evil functions like push, but instead returns new data every time. A JS Bin is available to run and play with the modified version.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title></title>
<style>
* {
margin: 0;