Skip to content

Node.js text processing and format converting utility

License

Notifications You must be signed in to change notification settings

movapages/bkrs-convertor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bkrs-convertor (Mova Club project)

BKRS Info dsl-to-csv file converter.

Usage

Please, check example sub-folder script for a use-case. The script itself is capable of converting UTF16LE dsl/markdown file of freely distributable with bkrs.info dictionary. First, it's converting the source file encoding, and, second, it saves CSV file free from the markdown in the long run.

The package itself is intended for use in Electron applications by Mova Project.

Module API

ES6 Node Module Notes
  • The ES6 module syntax support in Node.js starts with Node v.14, the version used here - 14.9.

  • It's mandatory to adjust one's package.json by adding "type":"module", plus, start using *.mjs extensions for all NPM libraries.

  • Some configuration scripts, like f.i. jest.config.mjs in this library, may require explicit module designation.

API Details
Class Method(s) Description
FileEncoding static getFileEncoding(fileName: string): <encoding: string> checks a text file (fileName - path to file), and returns encoding
ToUTF8 static convertToUTF8(srcFileName: string, targetFileName: string, fromEncoding: string): <Promise.resolve(targetFileName: string)> accepts a file to convert (path), output file (path) and source file encoding; output encoding is UTF8
OneLine getFile(srcFile: string): <string[]> reads (sync) in a file (path) and returns array of dictionary nests - 1 nest = 3 lines
procSet(set: string[]): <Promise.resolve(set[])> accepts an array of lines (nests) and returns a set of processed lines
promiseReady(file: string): <Promise.all(set[])> accepts a file (path) and returns an array of arrays of strings: processed UTF8 dictionary file
FileSize static getLineNumberFromFile(fileName: string): <STDOUT> accepts a file (path) and returns a number of lines in that text file

Testing

The present Jest capabilites don't cover full-fledged testing of ES6 Node.js modules, however, jest-esm-transformer module makes it possible.

It means usingimport {...} from "..." syntax is possible in Jest tests.

About

Node.js text processing and format converting utility

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published