Skip to content

Commit

Permalink
refactor: move CharSets to core module
Browse files Browse the repository at this point in the history
  • Loading branch information
fityannugroho committed Nov 18, 2023
1 parent 6ef4a27 commit 6c7c882
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 8 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
export type CharSet = Record<string, string[] | undefined>;

/**
* The list of built-in charset names.
*/
export const CharSets = {
LATIN: 'latin',
LATIN_1: 'latin-1',
} as const;

export class ValidationError extends Error {
constructor(message: string) {
super(message);
Expand Down
13 changes: 3 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import coreWisely, {
CharSet,
CharSets,
Options as CoreOptions,
ValidationError,
mergeCharSets as coreMergeCharSets,
isCharSetValid,
isPhraseValid,
} from './core.js';

/**
* The name of built-in charsets.
*/
export const CharSets = {
LATIN: 'latin',
LATIN_1: 'latin-1',
} as const;

export type CharSetNames = typeof CharSets[keyof typeof CharSets];
type CharSetNames = typeof CharSets[keyof typeof CharSets];

const dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -75,5 +68,5 @@ export default function wisely(options: Options): string {

// Export from core
export {
CharSet, ValidationError, isCharSetValid, isPhraseValid,
CharSet, CharSets, ValidationError, isCharSetValid, isPhraseValid,
};

0 comments on commit 6c7c882

Please sign in to comment.