https://github.com/zce/ooh-node
Ooh node~
https://github.com/zce/ooh-node
Last synced: 6 months ago
JSON representation
Ooh node~
- Host: GitHub
- URL: https://github.com/zce/ooh-node
- Owner: zce
- License: mit
- Created: 2016-12-08T12:29:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-11T04:00:06.000Z (over 4 years ago)
- Last Synced: 2025-08-09T12:45:30.525Z (7 months ago)
- Language: JavaScript
- Size: 78.1 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ooh-node
Ooh node~
> No callback in node
## Console Patchs
- `console.read()`
- `console.readline()`
- `console.write()`
- `console.writeline()`
- `console.clear()`
- `console.colors`
## Requirement
node >=7.6.0
## Installation
```shell
$ yarn global add ooh-node
# or npm
$ npm i ooh-node -g
```
## Usage
```javascript
// example.js
module.exports = async function (args) {
while (true) {
console.clear()
console.write(console.colors.gray('Input your age: '))
const res = await console.readline()
console.log(res)
if (res === 'q' || res === 'quit' || res === 'exit') {
console.writeline(console.colors.green('Bye bye!'))
break
}
const age = parseInt(res)
if (age) {
if (age < 18) {
console.writeline(console.colors.blue('You are just too young!'))
} else {
console.writeline(console.colors.bgYellow('Ooooooooook!'))
}
} else {
console.writeline(console.colors.red('Input is invalidated.'))
}
console.write(console.colors.gray('Press any key to continue.'))
await console.read()
}
}
```
```shell
$ ooh-node example.js
```