Skip to content

Instantly share code, notes, and snippets.

View Piliponful's full-sized avatar
💭
I'm doing nothing on github

piliponful Piliponful

💭
I'm doing nothing on github
View GitHub Profile
export default initialState => {
const stateEntriesNames = Object.keys(initialState)
const reducer = (state, action) => stateEntriesNames.includes(action.type) ? ({ ...new Map(state).set(action.type, action.payload) }) : initialState
const setters = stateEntriesNames.reduce((acc, next) => ({ ...acc, [next]: payload => ({ type: next, payload }) }), {})
return { reducer, setters }
}
@Piliponful
Piliponful / dijkstra.js
Created October 21, 2017 14:30 — forked from hiroshi-maybe/dijkstra.js
Implementation of `Dijkstra's algorithm` in JavaScript
var graph1 = {
vertex: ["1","2","3"],
edge: [,
/* vertex1, vertex2, weight */
["1", "2", 4],
["1", "3", 7],
["2", "3", 1]
]
},
graph2 = {