Skip to content

Watch changes to object properties, using Proxy and __proto__ modifications

Notifications You must be signed in to change notification settings

saviski/ski-spy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple observer that allow watching for property value changes of existing objects

import { spy } from '@ski/spy'

let originalObject = { a: 1, b: 2 }

let events = spy(originalObject)
logChanges(events)

originalObject.a = 3
originalObject.b = 5
originalObject.c = 1

async function logChanges(stream) {
  for await (const [key, value] of stream) console.log('property', key, 'changed', value)
}

will log

  • property a changed 3
  • property b changed 5
  • property c changed 1

About

Watch changes to object properties, using Proxy and __proto__ modifications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published