Skip to content

Instantly share code, notes, and snippets.

View petrikero's full-sized avatar

Petri Kero petrikero

  • Metaplay
  • Helsinki, Finland
View GitHub Profile
@petrikero
petrikero / simpleModule.js
Created February 20, 2018 15:47
Simple redux module implementation
// Simple module system.
// \todo [petri] write documentation
const mapObject = (obj, mapper) => {
const result = {};
for (const key in obj) {
let [mkey, value] = mapper(key, obj[key]);
result[mkey] = value;
}
return result;
@petrikero
petrikero / auth.js
Last active February 20, 2018 15:49
Simple redux modules
import { createModule } from './simpleModule';
// Standard initialState
const initialState = {
isAuthenticating: false,
userId: null,
authError: null
};
// These construct action creators as well as the module's reducer.
defmodule Benchmark do
def measure(function) do
elapsed = function
|> :timer.tc
|> elem(0)
|> Kernel./(1_000_000)
IO.puts "Elapsed = #{elapsed}s"
end
end