From e72a12922f672380301b712c9af5d3cae82cce9c Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 22 Mar 2023 14:50:34 +0100 Subject: [PATCH] Refactor some types --- lib/index.js | 8 ++++---- lib/parse.js | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/index.js b/lib/index.js index f0fdb15..f6e831d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -61,7 +61,7 @@ * > To solve this, you could for example use an npm script called `dependencies` * > (which runs everytime `node_modules` is changed) which copies * > `vscode-oniguruma/release/onig.wasm` to the place you want to host it. - * @returns {URL|Promise} + * @returns {URL | Promise} * URL object to a WASM binary. */ @@ -111,7 +111,7 @@ export async function createStarryNight(grammars, options) { * @param {string} flag * Grammar name (such as `'markdown'` or `'pandoc'`) or grammar extension * (such as `'.md'` or `'.rmd'`). - * @returns {string|undefined} + * @returns {string | undefined} * Grammar scope (such as `'source.gfm'`). */ function flagToScope(flag) { @@ -183,7 +183,7 @@ export async function createStarryNight(grammars, options) { /** * @param {Array} grammars - * @param {Options} [options] + * @param {Options | undefined} [options] */ async function createRegistry(grammars, options) { for (const grammar of grammars) { @@ -223,7 +223,7 @@ export async function createStarryNight(grammars, options) { * Idea: as this seems to be a singleton, would it help if we call it once and * keep the promise? * - * @param {Options} [options] + * @param {Options | undefined} [options] */ async function createOniguruma(options) { const wasmBin = await getOniguruma(options) diff --git a/lib/parse.js b/lib/parse.js index 644c11d..2091d8b 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -55,7 +55,7 @@ export function parse(value, grammar, colors) { const bg = (metadata & BACKGROUND_MASK) >>> BACKGROUND_OFFSET const fs = (metadata & FONT_STYLE_MASK) >>> FONT_STYLE_OFFSET - /** @type {Root|Element} */ + /** @type {Root | Element} */ let scope = tree scope = delveIfClassName(scope, fontStyleToClass(fs)) scope = delveIfClassName(scope, colorToClass(colors[bg])) @@ -77,9 +77,9 @@ export function parse(value, grammar, colors) { } /** - * @param {Root|Element} scope - * @param {string|undefined} className - * @returns {Root|Element} + * @param {Root | Element} scope + * @param {string | undefined} className + * @returns {Root | Element} */ function delveIfClassName(scope, className) { if (!className) return scope @@ -106,7 +106,7 @@ function delveIfClassName(scope, className) { } /** - * @param {Root|Element} scope + * @param {Root | Element} scope * @param {string} value */ function appendText(scope, value) { @@ -124,7 +124,7 @@ function appendText(scope, value) { * Note: there’s only one grandparent. * We could encode more grandparents in `fontStyle` if needed. * @param {number} fontStyle - * @returns {string|undefined} + * @returns {string | undefined} */ function fontStyleToClass(fontStyle) { return fontStyle ? grandparents[0] : undefined @@ -132,7 +132,7 @@ function fontStyleToClass(fontStyle) { /** * @param {string} color - * @returns {string|undefined} + * @returns {string | undefined} */ function colorToClass(color) { if (color === transparent) return undefined