0.1.3 • Published 4 years ago

ewajs v0.1.3

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

ewajs

NPM version

ewajs means 二娃 in Chinese, who is one young hero with great eyesight(qianli yan) and hearing(shunfeng er).

Get Started

Install by

npm i -S ewajs

Javascript Apis

Watch

You can watch change of fs target position(whether its existence when you start watching) with those signals:

  • EV_FILE_ADDED: watched file added, it didn't exist before.
  • EV_FILE_MODIFIED: watched file modifed, it existed before.
  • EV_FILE_REMOVED: watched file removed, it existed before.
  • EV_DIR_ADDED: watched directory removed, it existed before.
  • EV_DIR_REMOVED: watched directory removed, it existed before.
  • EV_SYMLINK_ADDED: watched symbolic link removed, it didn't exist before.
  • EV_SYMLINK_REMOVED: watched symbolic link removed, it existed before.
import { watch, SIGNALS } from 'ewajs'

// start watching one file, detecting its change(added, removed, modefied)
const qianliyan = watch('/path/to/file')

// subscribe when it's added
qianliyan.on(SIGNALS.EV_FILE_ADDED, () => {
    // deal
})

// stop watch
qianliyan.stop()

you can also watch one directory

// start watching one file, detecting its change(added, removed, modefied)
const qianliyan = watch('/path/to/dir')

qianliyan.on(SIGNALS.EV_DIR_ADDED, () => {
    // deal
})