
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
Papillon is a smart change detection library.
The library is using the fact, that changes of data in the context of the browser cannot be provided more often than the refresh rate of the browser.
Instead of watching every change, the library creates a frozen states of objects between repaints and provides the difference between these states.
npm install papillon
import { Observer, State } from 'papillon';
NPM package contains UMD built version of the library in dist/ path.
State provides an singleton interface for storing state of object. Only last state and changes between this and the previous state are stored.
Singleton pattern ensures low memory usage and consistent states for objects that reference to themselves.
Module uses a state counter that increase only before next repaint. Checking state multiply times before counter is changed yields the same results.
let statestamp = State.now()
Returns the current value of the state counter.
let state = new State({ one: 'two' });
Params:
state.target - reference to object, which state is storedstate.lastCheck - value of state counter when target was checkedstate.lastChange - value of state counter when target has changedstate.changelog - list of changes between previous and current state{
one: { type: 'set', oldKey: 'five' },
two: { type: 'set', oldValue: 'some'},
three: { type: 'delete', oldValue: 'before removed'},
four: { type: 'modify', changelog: {...} }
}
set - Set reference or primitive value.delete - Deleted property.modify - Nested changes of Object property in changelog.oldValue - Property value from last state.oldKey - Property key from last state which value was moved to this property.
Paremeter is set only when new value of old property has changed. In another
words, it is set only for relocated properties, not copied.Checks if target object has changed from last state.
If it is true, method regenerates changelog.
This module connects changes of observed object properties with callback action.
Callback method is called with changelog state property.
Observed property is redefined as getter/setter. Getting or setting
that property will trigger request for state change detection
before next repaint.
let host = {test: 'one'};
let observer = new Observer(host, 'test', changelog => {
console.dir(changelog.test);
});
// Will trigger log in console before next repaint
host.test = 'two';
Params:
changelog object as argumentSchedule change detection with window.requestAnimationFrame.
This method is called when the observed property is set or get. You do not have to use this method directly. If your code changes object by other reference then observed property, you have to schedule checking manually.
Cancel scheduled checking request and revert observed properties to original definition. If your code do not requires object with original definition of observed properties you do not have to call this method.
After destroying Observer instance, accessing properties will not
trigger check() method.
Feel free to contribute project. Fork repository, clone and run:
npm install && npm run develop
Write some code, provide proper tests and pull request to this repository.
Papillon is released under the MIT License.
FAQs
Change detection library
We found that papillon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.