2.0.6 • Published 3 years ago

@tom-konda/wdtt-parser v2.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

これは何?

駅時刻表の作成ソフト WinDIATimetable で出力される、WDTT 形式のファイルを解析して JavaScript オブジェクトに変換できるパーサです。

対応ブラウザ

  • ES 2015+ に対応しているブラウザ

対応 Node.js バージョン

  • 最新の LTS

使用方法

WDTT 形式のファイルは Shift_JIS でエンコードされているため、 事前に UTF-8 に文字コードを変換するか、JavaScript のコード内で UTF-8 のテキストに変換する必要があります。

ブラウザ (ES Modules)

<!DOCTYPE html>
<html>
<head>
  <script type="module">
    import wdttParse from './wdtt-parser.js';

    fetch('./test.wtt')
    .then(
      (result) => {
        return result.arrayBuffer();
      }
    ).then(
      (buffer) => {
        // Convert from buffer to utf8 string.
        const sjisDecoder = new TextDecoder('shift_jis');
        const wdttText = sjisDecoder.decode(buffer);
        const wdtt = wdttParse(wdttText);
        console.log(wdtt);
      }
    );
  </script>
</head>
</html>

Node.js

const wdttParse = require('@tom-konda/wdtt-parser');
const iconvLite = require('iconv-lite');
const fs = require('fs');

const file = fs.readFileSync(`PATH_TO_WDTTFILE/test.wtt`);

// Convert from buffer to utf8 string.
const wdttText = iconvLite.decode(file, 'SHIFT_JIS');
const wdtt = wdttParse(wdttText);
console.log(wdtt);

ライセンス

ライセンスは MIT になります。

ビルドの仕方

  1. git clone https://github.com/tom-konda/wdtt_parser.git を実行し、レポジトリをクローンします
  2. cd wdtt_parser でカレントディレクトリを変更します
  3. npm install を実行します
  4. npm run build を実行します
2.0.6

3 years ago

2.0.5

4 years ago

2.0.5-1

4 years ago

2.0.5-0

5 years ago

2.0.4

5 years ago

2.0.3-0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago