const fs = require('fs') const key = "SpecialRing.config" const values = [56, 100] const interval = [1, 100] const num = 45 const start = () => { const template = ` "S1": { "attr": [ { "value": S2, "type": 75 }, { "value": 10000, "type": 5 }, { "value": 428, "type": 76 }, { "value": 536, "type": 77 }, { "value": 55, "type": 21 }, { "value": 55, "type": 23 }, { "value": 55, "type": 25 }, { "value": 55, "type": 27 }, { "value": 5000, "type": 83 } ], "lv": S1, "cost": [ { "id": 2, "type": 2, "count": 300000 }, { "id": 4, "type": 4, "count": 500 }, { "id": 1018, "type": 0, "count": 1000 } ], "pos": 4 }` const getStr = (index) => { let str = template values.forEach((v, i) => { const reg = new RegExp(`S${i + 1}`, 'g') str = str.replace(reg, v + index * interval[i]) }) return str } const content = Array(num).fill(1).map((e,i)=>`${getStr(i)}`).join(',') fs.writeFileSync(`./dist/${key}.txt`, content) } start()