diff options
author | 2021-03-25 00:00:22 -0700 | |
---|---|---|
committer | 2021-03-25 00:00:22 -0700 | |
commit | 30cccdf7154b6470e876464da9e412af10894dd5 (patch) | |
tree | 73ed40b30af23ba3e5b94070e478f3e2ca1670c0 /src/parser/parse/utils/bracket.ts | |
parent | a72ab10c623022860691d6a095b74dea70cc6f69 (diff) | |
download | astro-30cccdf7154b6470e876464da9e412af10894dd5.tar.gz astro-30cccdf7154b6470e876464da9e412af10894dd5.tar.zst astro-30cccdf7154b6470e876464da9e412af10894dd5.zip |
add component state, top-level await support (#26)
Diffstat (limited to 'src/parser/parse/utils/bracket.ts')
-rw-r--r-- | src/parser/parse/utils/bracket.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/parser/parse/utils/bracket.ts b/src/parser/parse/utils/bracket.ts new file mode 100644 index 000000000..7e885ad78 --- /dev/null +++ b/src/parser/parse/utils/bracket.ts @@ -0,0 +1,27 @@ +// @ts-nocheck + +const SQUARE_BRACKET_OPEN = '['.charCodeAt(0); +const SQUARE_BRACKET_CLOSE = ']'.charCodeAt(0); +const CURLY_BRACKET_OPEN = '{'.charCodeAt(0); +const CURLY_BRACKET_CLOSE = '}'.charCodeAt(0); + +export function is_bracket_open(code) { + return code === SQUARE_BRACKET_OPEN || code === CURLY_BRACKET_OPEN; +} + +export function is_bracket_close(code) { + return code === SQUARE_BRACKET_CLOSE || code === CURLY_BRACKET_CLOSE; +} + +export function is_bracket_pair(open, close) { + return (open === SQUARE_BRACKET_OPEN && close === SQUARE_BRACKET_CLOSE) || (open === CURLY_BRACKET_OPEN && close === CURLY_BRACKET_CLOSE); +} + +export function get_bracket_close(open) { + if (open === SQUARE_BRACKET_OPEN) { + return SQUARE_BRACKET_CLOSE; + } + if (open === CURLY_BRACKET_OPEN) { + return CURLY_BRACKET_CLOSE; + } +} |