This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Parses json keys to camel or snake case | |
* Use lodash to convert strings to camelCase or snake-case | |
* | |
* @param {Object} json | |
* @param {Boolean} camel | |
*/ | |
function parseJsonKeys(json = {}, camel = true) { | |
if (typeof json === 'object') { | |
const arr = Object.entries(json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Implementation Example | |
struct LightMachine: StateMachine { | |
typealias States = LightStates | |
typealias Events = LightEvents | |
typealias Context = (Int) | |
enum LightStates { | |
case green | |
case yellow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let nums = [1, 2, 5, 13, 25, 50, 75, 100] | |
let names = ["Angel", "Bianca", "Carlos", "Gustavo", "Maria", "Samuel", "Victor"] | |
struct Date { | |
let year: Int | |
let month: Int | |
let day: Int | |
} |