Preview generator: generating a preview by layer number

This commit is contained in:
He4eT 2021-08-27 17:59:49 +05:00
commit a5d894b84a
3 changed files with 31 additions and 10 deletions

View file

@ -5,26 +5,28 @@
const fs = require('fs')
const {buildRow} = require('./parts/rows')
const {buildRow, layerRange} = require('./parts/rows')
const {cleanKeys, printLegends} = require('./parts/keys')
const keymapToKLERawData = fileContent =>
const keymapToKLERawData = (fileContent, layerIndex) =>
fileContent
.split('\n')
.map(row => row.split(','))
.filter(keys => keys.length > 1)
.slice(...layerRange(layerIndex))
.map(cleanKeys)
.map(printLegends)
.map(buildRow)
.map(JSON.stringify)
// .slice(0, 8)
// .slice(8, 16)
// .slice(16)
.join(',\n')
/* */
const keymapFilePath = process.argv[2]
const layerIndex = Number(process.argv[3])
const fileContent = fs.readFileSync(keymapFilePath, 'utf8')
const rawData = keymapToKLERawData(fileContent)
const rawData = keymapToKLERawData(fileContent, layerIndex)
console.log(rawData)