This file contains hidden or 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
| // source: https://seanbarry.dev/posts/switch-true-pattern | |
| switch (true) { | |
| case !isDefined(user): | |
| throw new Error("User must be defined."); | |
| case !isString(user.firstName): | |
| throw new Error("User's first name must be a string"); | |
| case !isValidEmail(user.email): | |
| throw new Error("User's email address must be a valid email address"); | |
| case !isValidPhoneNumber(user.number): |
This file contains hidden or 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
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions |
This file contains hidden or 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
| const EventMachine = Machine({ | |
| id: "eventState", | |
| initial: "INITIAL", | |
| states: { | |
| INITIAL: { | |
| on: { | |
| CreateLive: "PRE_LIVE", | |
| CreateVOD: "PRE_VOD", | |
| CreateRemix: "REMIX_GENERATING", | |
| CreateArchiver: "ARCHIVER_PUBLIC", |
This file contains hidden or 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 regex; | |
| /* matching a specific string */ | |
| regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello" | |
| regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO" | |
| regex = /hello/g; // looks for multiple occurrences of string between the forward slashes... | |
| /* wildcards */ | |
| regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo" | |
| regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo" |
This file contains hidden or 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
| #!/bin/bash | |
| # Description: bump version only if the previous master version was the same (not manually modified) | |
| # Requirements: The local package.json must have an upper property "url" setted with the git url of the project | |
| git config --global user.email "[email protected]" && git config --global user.name "vuplay" && git config --global push.default simple | |
| git fetch | |
| git checkout HEAD~1 | |
| PREVIOUS_PACKAGE_VERSION=$(cat package.json \ |