diff --git a/README.md b/README.md index c2c876b..494c192 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ You can do `import { ... } from '@intlify/utils'` the above utilities - `tryPathLocale` - `tryQueryLocale` -The about utilies functions accpet Web APIs such as [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) that is supported by JS environments (such as Deno, Bun, and Browser) +The about utilities functions accept Web APIs such as [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) that is supported by JS environments (such as Deno, Bun, and Browser) #### Specialized environments @@ -161,7 +161,7 @@ If you will use Node.js and H3, You can do `import { ... } from '@intlify/utils/ The namespace `{ENV}` is one of the following: -- `node`: accpet `IncomingMessage` and `Outgoing` by Node.js [http](https://nodejs.org/api/http.html) module +- `node`: accept `IncomingMessage` and `Outgoing` by Node.js [http](https://nodejs.org/api/http.html) module - `h3`: accept `H3Event` by HTTP framework [h3](https://github.com/unjs/h3) - `hono`: accept `Context` by edge-side web framework [hono](https://github.com/honojs/hono) diff --git a/deno/README.md b/deno/README.md index c2c876b..494c192 100644 --- a/deno/README.md +++ b/deno/README.md @@ -153,7 +153,7 @@ You can do `import { ... } from '@intlify/utils'` the above utilities - `tryPathLocale` - `tryQueryLocale` -The about utilies functions accpet Web APIs such as [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) that is supported by JS environments (such as Deno, Bun, and Browser) +The about utilities functions accept Web APIs such as [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) that is supported by JS environments (such as Deno, Bun, and Browser) #### Specialized environments @@ -161,7 +161,7 @@ If you will use Node.js and H3, You can do `import { ... } from '@intlify/utils/ The namespace `{ENV}` is one of the following: -- `node`: accpet `IncomingMessage` and `Outgoing` by Node.js [http](https://nodejs.org/api/http.html) module +- `node`: accept `IncomingMessage` and `Outgoing` by Node.js [http](https://nodejs.org/api/http.html) module - `h3`: accept `H3Event` by HTTP framework [h3](https://github.com/unjs/h3) - `hono`: accept `Context` by edge-side web framework [hono](https://github.com/honojs/hono) diff --git a/deno/locale.ts b/deno/locale.ts index e7ff923..d223dad 100644 --- a/deno/locale.ts +++ b/deno/locale.ts @@ -258,7 +258,7 @@ export type ParseScriptSubtag< > = Result /** - * paser unicode script subtag (EBNF: = alpha{4};) + * parse unicode script subtag (EBNF: = alpha{4};) * https://unicode.org/reports/tr35/#unicode_script_subtag */ // TODO: Check if the script subtag is in CLDR diff --git a/deno/shared.ts b/deno/shared.ts index 9eaed34..49501bd 100644 --- a/deno/shared.ts +++ b/deno/shared.ts @@ -64,7 +64,7 @@ export function parseAcceptLanguage(value: string): string[] { } /** - * nomralize the language name + * normalize the language name * * @description * This function normalizes the locale name defined in {@link https://www.gnu.org/software/gettext/manual/gettext.html#Locale-Names | gettext(libc) style} to {@link https://datatracker.ietf.org/doc/html/rfc4646#section-2.1 | BCP 47 language tag} @@ -72,7 +72,7 @@ export function parseAcceptLanguage(value: string): string[] { * @example * ```ts * const oldLangName = 'en_US' - * const langTag = nomralizeLanguageName(oldLangName) + * const langTag = normalizeLanguageName(oldLangName) * conosle.log(langTag) // en-US * ``` * @@ -131,7 +131,7 @@ export let pathLanguageParser: PathLanguageParser = /* #__PURE__*/ createPathInd /** * register the path language parser * - * @description register a parser to be used in the `getPathLanugage` utility function + * @description register a parser to be used in the `getPathLanguage` utility function * * @param {PathLanguageParser} parser the path language parser */ diff --git a/deno/web.ts b/deno/web.ts index f74bea1..98ea9cf 100644 --- a/deno/web.ts +++ b/deno/web.ts @@ -54,7 +54,7 @@ export function getHeaderLanguages( /** * get language from header * - * @description parse header string, default `accept-language`. if you use `accept-language`, this function retuns the **first language tag** of `accept-language` header. + * @description parse header string, default `accept-language`. if you use `accept-language`, this function returns the **first language tag** of `accept-language` header. * * @example * example for Web API request on Deno: diff --git a/playground/browser/browser.test.mjs b/playground/browser/browser.test.mjs index 93cfb8c..19cc263 100644 --- a/playground/browser/browser.test.mjs +++ b/playground/browser/browser.test.mjs @@ -3,6 +3,7 @@ import test from 'node:test' import { createServer } from 'node:http' import playwright from 'playwright' import handler from 'serve-handler' +import process from 'node:process' const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) diff --git a/playground/browser/index.html b/playground/browser/index.html index eddd6cd..d0d81b4 100644 --- a/playground/browser/index.html +++ b/playground/browser/index.html @@ -1,4 +1,4 @@ - + diff --git a/playground/node/index.ts b/playground/node/index.ts index f1aff6f..3de6a89 100644 --- a/playground/node/index.ts +++ b/playground/node/index.ts @@ -1,5 +1,6 @@ import { createServer } from 'node:http' import { getHeaderLanguages } from '@intlify/utils/node' +import process from 'node:process' const server = createServer((req, res) => { const languages = getHeaderLanguages(req) diff --git a/playground/node/node.test.mjs b/playground/node/node.test.mjs index 0413e4b..5164759 100644 --- a/playground/node/node.test.mjs +++ b/playground/node/node.test.mjs @@ -2,6 +2,7 @@ import assert from 'node:assert' import test from 'node:test' import { spawn } from 'node:child_process' import { fetch } from 'ofetch' +import process from 'node:process' const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) diff --git a/scripts/bump-deno.ts b/scripts/bump-deno.ts index 8f04c25..7c6a03a 100644 --- a/scripts/bump-deno.ts +++ b/scripts/bump-deno.ts @@ -5,6 +5,7 @@ import semver from 'semver' import { readPackageJSON } from 'pkg-types' import type { ParseError } from 'jsonc-parser' +import process from 'node:process' async function main() { const npmPath = resolve(process.cwd(), 'package.json') diff --git a/scripts/bump-edge.ts b/scripts/bump-edge.ts index 369e04e..dd0021f 100644 --- a/scripts/bump-edge.ts +++ b/scripts/bump-edge.ts @@ -1,6 +1,7 @@ import { execSync } from 'node:child_process' import { promises as fs } from 'node:fs' import { resolve } from 'node:path' +import process from 'node:process' async function main() { const commit = execSync('git rev-parse --short HEAD').toString('utf-8').trim() diff --git a/scripts/deno.ts b/scripts/deno.ts index 91f4866..9a4da0a 100644 --- a/scripts/deno.ts +++ b/scripts/deno.ts @@ -3,6 +3,7 @@ import { resolve } from 'node:path' import { fileURLToPath } from 'node:url' import { isExists } from './utils.ts' import { readPackageJSON } from 'pkg-types' +import process from 'node:process' const __dirname = fileURLToPath(new URL('.', import.meta.url)) @@ -26,7 +27,7 @@ async function main() { throw new Error(`not found ${destPath}`) } - console.log('copy some source files to denoland hosting directries 🦕 ...') + console.log('copy some source files to denoland hosting directories 🦕 ...') // copy docs for (const p of ['README.md', 'LICENSE']) { diff --git a/scripts/playwright-version.ts b/scripts/playwright-version.ts index 8cf767f..56f043e 100644 --- a/scripts/playwright-version.ts +++ b/scripts/playwright-version.ts @@ -2,6 +2,7 @@ import { resolve } from 'node:path' import { fileURLToPath } from 'node:url' import { readPackageJSON } from 'pkg-types' import { isExists } from './utils.ts' +import process from 'node:process' const __dirname = fileURLToPath(new URL('.', import.meta.url)) diff --git a/scripts/replaceDeps.ts b/scripts/replaceDeps.ts index 9442d1e..e2828a8 100644 --- a/scripts/replaceDeps.ts +++ b/scripts/replaceDeps.ts @@ -3,6 +3,7 @@ import { resolve } from 'node:path' import { fileURLToPath } from 'node:url' import { readPackageJSON, writePackageJSON } from 'pkg-types' import { isExists } from './utils.ts' +import process from 'node:process' const __dirname = fileURLToPath(new URL('.', import.meta.url)) diff --git a/src/h3.ts b/src/h3.ts index 2a1eb41..2c0531d 100644 --- a/src/h3.ts +++ b/src/h3.ts @@ -54,7 +54,7 @@ export function getHeaderLanguages(event: H3Event, { /** * get language from header * - * @description parse header string, default `accept-language`. if you use `accept-language`, this function retuns the **first language tag** of `accept-language` header. + * @description parse header string, default `accept-language`. if you use `accept-language`, this function returns the **first language tag** of `accept-language` header. * * @example * example for h3: diff --git a/src/hono.ts b/src/hono.ts index 82ac1a6..5cd9eb0 100644 --- a/src/hono.ts +++ b/src/hono.ts @@ -55,7 +55,7 @@ export function getHeaderLanguages(context: Context, { /** * get language from header * - * @description parse header string, default `accept-language`. if you use `accept-language`, this function retuns the **first language tag** of `accept-language` header. + * @description parse header string, default `accept-language`. if you use `accept-language`, this function returns the **first language tag** of `accept-language` header. * * @example * example for Hone: diff --git a/src/locale.test-d.ts b/src/locale.test-d.ts index 440340c..3513935 100644 --- a/src/locale.test-d.ts +++ b/src/locale.test-d.ts @@ -286,7 +286,7 @@ test('ParseVariantsSubtag', () => { >() }) -test('ParseUnicodeLangugageId', () => { +test('ParseUnicodeLanguageId', () => { /** * Success cases */ @@ -312,7 +312,7 @@ test('ParseUnicodeLangugageId', () => { ] >() - /** Erros */ + /** Errors */ expectTypeOf>().toMatchTypeOf< [ { lang: never; script: never; region: never; variants: [] }, diff --git a/src/locale.ts b/src/locale.ts index e7ff923..d223dad 100644 --- a/src/locale.ts +++ b/src/locale.ts @@ -258,7 +258,7 @@ export type ParseScriptSubtag< > = Result /** - * paser unicode script subtag (EBNF: = alpha{4};) + * parse unicode script subtag (EBNF: = alpha{4};) * https://unicode.org/reports/tr35/#unicode_script_subtag */ // TODO: Check if the script subtag is in CLDR diff --git a/src/node.test.ts b/src/node.test.ts index 9bc87d2..3044e51 100644 --- a/src/node.test.ts +++ b/src/node.test.ts @@ -15,7 +15,7 @@ import { tryPathLocale, tryQueryLocale, } from './node.ts' -import { createServer, IncomingMessage, OutgoingMessage } from 'node:http' +import { createServer, type IncomingMessage, type OutgoingMessage } from 'node:http' import { DEFAULT_COOKIE_NAME, DEFAULT_LANG_TAG } from './constants.ts' describe('getHeaderLanguages', () => { diff --git a/src/node.ts b/src/node.ts index 901850c..99b082b 100644 --- a/src/node.ts +++ b/src/node.ts @@ -1,4 +1,4 @@ -import { IncomingMessage, OutgoingMessage } from 'node:http' +import type { IncomingMessage, OutgoingMessage } from 'node:http' import { parse, serialize } from 'cookie-es' import { getExistCookies, @@ -14,6 +14,7 @@ import { ACCEPT_LANGUAGE_HEADER, DEFAULT_COOKIE_NAME, DEFAULT_LANG_TAG } from '. import { normalizeLanguageName, pathLanguageParser } from './shared.ts' import type { CookieOptions, HeaderOptions, PathOptions, QueryOptions } from './http.ts' +import process from 'node:process' /** * get languages from header @@ -55,7 +56,7 @@ export function getHeaderLanguages( /** * get language from header * - * @description parse header string, default `accept-language`. if you use `accept-language`, this function retuns the **first language tag** of `accept-language` header. + * @description parse header string, default `accept-language`. if you use `accept-language`, this function returns the **first language tag** of `accept-language` header. * * @example * example for Node.js request: @@ -577,7 +578,7 @@ let navigatorLanguage = '' * @description * You can get the language tag from system environment variables. * - * @returns {string} {@link https://datatracker.ietf.org/doc/html/rfc4646#section-2.1 | BCP 47 language tag}, if you can't get the language tag, return a enmpty string. + * @returns {string} {@link https://datatracker.ietf.org/doc/html/rfc4646#section-2.1 | BCP 47 language tag}, if you can't get the language tag, return a empty string. */ function getNavigatorLanguage(): string { return navigatorLanguage || diff --git a/src/shared.ts b/src/shared.ts index 9eaed34..49501bd 100644 --- a/src/shared.ts +++ b/src/shared.ts @@ -64,7 +64,7 @@ export function parseAcceptLanguage(value: string): string[] { } /** - * nomralize the language name + * normalize the language name * * @description * This function normalizes the locale name defined in {@link https://www.gnu.org/software/gettext/manual/gettext.html#Locale-Names | gettext(libc) style} to {@link https://datatracker.ietf.org/doc/html/rfc4646#section-2.1 | BCP 47 language tag} @@ -72,7 +72,7 @@ export function parseAcceptLanguage(value: string): string[] { * @example * ```ts * const oldLangName = 'en_US' - * const langTag = nomralizeLanguageName(oldLangName) + * const langTag = normalizeLanguageName(oldLangName) * conosle.log(langTag) // en-US * ``` * @@ -131,7 +131,7 @@ export let pathLanguageParser: PathLanguageParser = /* #__PURE__*/ createPathInd /** * register the path language parser * - * @description register a parser to be used in the `getPathLanugage` utility function + * @description register a parser to be used in the `getPathLanguage` utility function * * @param {PathLanguageParser} parser the path language parser */ diff --git a/src/web.ts b/src/web.ts index 4291fe0..585ce78 100644 --- a/src/web.ts +++ b/src/web.ts @@ -54,7 +54,7 @@ export function getHeaderLanguages( /** * get language from header * - * @description parse header string, default `accept-language`. if you use `accept-language`, this function retuns the **first language tag** of `accept-language` header. + * @description parse header string, default `accept-language`. if you use `accept-language`, this function returns the **first language tag** of `accept-language` header. * * @example * example for Web API request on Deno: