UNPKG

redux-tiles

Version:

Library to create and easily compose redux pieces together in less verbose manner

38 lines 1.09 kB
import { isArray, isString } from "./utils"; export function ensureArray(value) { return isString(value) ? [value] : value; } export function populateHash(hash, path, value) { if (isString(path)) { return populateHash(hash, [path], value); } if (path.length === 1) { hash[path[0]] = value; return hash; } var property = path[0]; if (!hash[property]) { hash[property] = {}; } return populateHash(hash[property], path.slice(1), value); } export function iterate(tiles) { return isArray(tiles) ? tiles : Object.keys(tiles).reduce(function (arr, key) { var values = tiles[key]; return arr.concat(values); }, []); } function capitalize(str, i) { if (i === 0) { return str; } return str[0].toUpperCase() + str.slice(1); } export function createType(_a) { var type = _a.type, path = _a.path; var list = ensureArray(type).concat(path == null ? [] : path.map(String)); return list.map(capitalize).join(""); } //# sourceMappingURL=helpers.js.map