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/utils/trim.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/utils/trim.ts')
-rw-r--r-- | src/parser/utils/trim.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/parser/utils/trim.ts b/src/parser/utils/trim.ts new file mode 100644 index 000000000..406a8c97f --- /dev/null +++ b/src/parser/utils/trim.ts @@ -0,0 +1,15 @@ +import { whitespace } from './patterns.js'; + +export function trim_start(str: string) { + let i = 0; + while (whitespace.test(str[i])) i += 1; + + return str.slice(i); +} + +export function trim_end(str: string) { + let i = str.length; + while (whitespace.test(str[i - 1])) i -= 1; + + return str.slice(0, i); +} |