1.0.14 • Published 6 years ago

requirelive v1.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

requireLive

requires a file and keeps the file and object updated

example

const requireLive = require('requireLive')

// 'new' event is triggerd whenever a new name is added
requireLive.events.on('new', (name, object) => {
  console.log(name, object)
})

// 'update' event is triggerd whenever an object is updated
requireLive.events.on('update', (name, object) => {
  console.log(name, object)
})

// require an existing file
const example1 = requireLive('./example1.json')
const example2 = requireLive('./example2.json', {
  interval: 1000,
  persistent: true,
  name: 'example2',
  paths: module.paths
})

// example1.json will be updated to include the changes
example1.example = 'true'

// terminal will show current content of example2.json
requireLive.events.on('example2' + 'Update', (object) => {
  process.stdout.write('\x1B[2J\x1B[0f') // clear terminal
  console.log(example2) // example2 is the same as object
})

links

https://github.com/iseriousnoob/requireLive

https://www.npmjs.com/package/requirelive

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago