
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
object-observer
Advanced tools
Object observer utility provides simple means to (deeply) observe specified object/array changes; implemented via Proxy; changes delivered in a synchronous way
Observation of a changes performed on any arbitrary object (array being subtype of it, of course) is a MUST HAVE facility in JavaScript world (i'd say in any environment in general and in those providing GUI especially).
Native facility would be the best solution for this, since it may provide non-intrusive observation wihtout actual 'touch' of the original objects, but seems like spec is not yet mature enough for that.
Present library attempts to provide this functionality in a most clean (from consumption/API perspective) and performant way. Main aspects:
Support matrix is mainly dependent on 2 advanced language features: Proxy
and Reflect
. The broader their adoption - the broader the support matrix of ObjectObserver.
You have 2 ways to load the library: into a 'window' global scope, or a custom scope provided by you.
<script src="object-observer.js"></script>
<script>
var person = { name: 'Uriya', age: 8 },
observablePerson;
observablePerson = ObjectObserver.observableFrom(person);
</script>
var customNamespace = {},
person = { name: 'Nava', age: 6 },
observablePerson;
fetch('object-observer.js').then(function (response) {
if (response.status === 200) {
response.text().then(function (code) {
Function(code).call(customNamespace);
// the below code is an example of consumption, locate it in your app lifecycle/flow as appropriate
observablePerson = customNamespace.ObjectObserver.observableFrom(person);
});
}
});
ObjectObserver
observableFrom
- receives a non-null object and returns Observable
:
var person = { name: 'Aya', age: '1' },
observablePerson;
observablePerson = ObjectObserver.observableFrom(person);
...
Observable
observe
- receives a function, which will be added to the list of observers subscribed for a changes of this observable:
function personUIObserver(changes) {
changes.forEach(change => {
console.log(change.type);
console.log(change.path);
console.log(change.value);
console.log(change.oldValue);
});
}
...
observablePerson = ObjectObserver.observableFrom(person);
observablePerson.observe(personUIObserver);
Changes delivered always as an array. Changes MAY NOT be null. Changes MAY be an empty array. Each change is a defined, non-null object, having:
type
- on the following: 'insert', 'update', 'delete' (not yet implemented, reserved for the future use)path
- path to the changed property from the root of the observed graph (see examples below)value
- new value or undefined
if 'delete' change was observedoldValue
- old value or undefined
if 'insert' change was observedunobserve
- receives a function/s which previously was/were registered as an observer/s and removes it/them. If no arguments passed, all observers will be removed:
...
observablePerson.unobserve(personUIObserver);
...
observablePerson.unobserve();
...
TODO
FAQs
object-observer utility provides simple means to (deeply) observe specified object/array changes; implemented via native Proxy; changes delivered in a synchronous way
The npm package object-observer receives a total of 166 weekly downloads. As such, object-observer popularity was classified as not popular.
We found that object-observer 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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.