Skip to content

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

Notifications You must be signed in to change notification settings

xiaomingTang/tang-base-node-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published