1.0.14 • Published 7 years ago

requirelive v1.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
7 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

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago