Skip to content

Commit

Permalink
feat(package): allow custom dict data
Browse files Browse the repository at this point in the history
  • Loading branch information
DGCK81LNN committed Feb 5, 2024
1 parent bbec881 commit aa2c6a2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
3 changes: 3 additions & 0 deletions package/data/bundle.json.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { Data } from "../src/types"
declare const data: Data
export default data
4 changes: 3 additions & 1 deletion package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"author": "DGCK81LNN <triluolnn@163.com>",
"license": "MIT",
"files": [
"lib/**/*"
"lib/**/*",
"data/bundle.json",
"data/bundle.json.d.ts"
],
"main": "lib/index.js",
"repository": {
Expand Down
3 changes: 0 additions & 3 deletions package/src/data.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions package/src/data.js

This file was deleted.

11 changes: 6 additions & 5 deletions package/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { data } from "./data"
import data from "../data/bundle.json"
import {
HanziToAlphaTranscriber,
AlphaToHanziTranscriber,
} from "./base_transcribers"
import { chatToXdPUA, xdPUAToChat } from "./encoding"

export {
data,
HanziToAlphaTranscriber,
AlphaToHanziTranscriber,
chatToXdPUA,
Expand All @@ -15,14 +16,14 @@ export {
export * from "./types"

export class HanziToXdi8Transcriber extends HanziToAlphaTranscriber {
constructor() {
super(data)
constructor(dictData = data) {
super(dictData)
}
}

export class Xdi8ToHanziTranscriber extends AlphaToHanziTranscriber {
constructor() {
super(data)
constructor(dictData = data) {
super(dictData)
}

transcribe(
Expand Down

0 comments on commit aa2c6a2

Please sign in to comment.