tang-base-node-utils

1.3.0 • Public • Published

tang-base-node-utils

一个让文件+目录的读写更简单的语法糖
& 一个让交互更简单的语法糖

const newFile = new Base("nonexistent-file").createAsFile()

newFile.write("what ever").moveTo("nonexistent-path")

newFile.handleLineByLine((str, i, close) => {
  console.log(`${i} -> ${str}`)
  if (i >= 5) {
    close()  // quit?
  }
})

async function func() {
  const inputStr = question("not non string to be accepted.", defaultValIfNeeded)
  const inputNum = questionNumber("quit until valid number.", defaultValIfNeeded)
  const specialInput = questionUntil("quit until valid string", (inputStr) => {
    return /^a (young|naive|simple) guy$/.test(inputStr)
  })
}

func()

Readme

Keywords

Package Sidebar

Install

npm i tang-base-node-utils

Weekly Downloads

3

Version

1.3.0

License

MIT

Unpacked Size

52.5 kB

Total Files

15

Last publish

Collaborators

  • xiaomingtang