Skip to content

Commit

Permalink
Support Export Index from Dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvNC committed Jul 24, 2024
1 parent 5221fa9 commit bb5c49e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
TagOption,
} from './types/yomitan/tagbank';
import path from 'path';
import { DictionaryIndex } from './builders/dictionaryIndex';

const INDEX_FILE_NAME = 'index.json';
const TERM_BANK_FILE_NAME = (bankNumber: number) =>
Expand Down Expand Up @@ -86,11 +87,20 @@ export class Dictionary {
* @param index - JSON object
* @returns
*/
async setIndex(index: DictionaryIndexType) {
async setIndex(
index: DictionaryIndexType,
directory: string = './',
fileName: string = 'index.json',
) {
if (!index.format) {
index.format = 3;
}
await this.saveJsonToZip(INDEX_FILE_NAME, index);

if (directory || fileName) {
const indexBuilder = new DictionaryIndex(index);
await indexBuilder.export(directory, fileName);
}
return this;
}

Expand Down

0 comments on commit bb5c49e

Please sign in to comment.