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
// Match everything inside balancing groups ['<' and '>'] (Variables) and ['{' and '}'] (Macros) | |
// ex: <This is A Variable> and {This is a macro} | |
// http://goo.gl/Rjo6Ih | |
public static string PatternBuilder(char open, char close) | |
{ | |
return $"(((?<open>{open})[^{open}]*)+([^{open}]*(?<close-open>{close}))+).*?(?(open)(?!))"; | |
} | |
public static string caretPattern => PatternBuilder('<', '>'); |
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 defaults = { file: null }; | |
function foo(options) { | |
// Merging defaults and options objects in ES6 | |
options = [ defaults, options ].reduce(Object.assign, {}); | |
} | |
foo({ file: "happy.md" }); |
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
function* delays() { | |
let a = yield delay(800, "Hello, I'm an"); | |
console.log(a); | |
let b = yield delay(400, "async coroutine!"); | |
console.log(b); | |
} | |
const coroutine = nextValue => iterator => { | |
const { done, value } = iterator.next(nextValue); |