Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Exert is a very simple library that allows to create watchables. Watchables are subscribable classes in which you can control publish timings.
It works by taking advantage of ES next decorators.
npm install exert
You will also want to setup your project to support class and object decorators. See: https://babeljs.io/docs/plugins/transform-decorators/
Create a watchable class.
import { watchable, change, changeAsync } from 'exert';
@watchable()
class MyWatchable {
constructor() {
this.firstName = 'Scott';
}
// @change decorator will automatically notify all subscriptions after
// changes are made. Works with synchronous methods.
@change setName(firstName) {
this.firstName = firstName;
}
// @changeAync will pass the "done" function as the last argument.
// Use with async methods such as calling a backend REST call.
@changeAsync setNameAsync(firstName, done) {
window.setTimeout(()=> {
this.firstName = firstName;
done();
}, 1000);
}
}
In the above, we use @change and @changeAsync decorators to publish out to subscribers. Generally any changes to public properties should be changed via a method decorated with @change or @changeAsync so that subscribers are correctly called.
Now that we have setup our class, we are ready to instantiate it and start subscribing/watching the class.
let myWatchable = new MyWatchable();
let onUpdate = (current, prev)=> {
console.log('name was:' + prev.firstName);
console.log('name is now:' + current.firstName);
// Do whatever you want.
// Typically, you may want to update/render the view.
}
// Subscribe to the stream updates. This will fire the next time a change is
// made.
myWatchable.watch(onUpdate);
// Subscribe and immidiately calls onUpdate.
myWatchable.watchNow(onUpdate);
// Make a change.
myWatchable.setName('John'); // You should see onUpdate called.
// Unsubscribe.
myWatchable.unwatch(onUpdate);
// Subscribe Once
myWatchable.watchOnce(onUpdate);
// Make async change
myWatchable.setNameAsync('Michael'); // You should see onUpdate called again.
npm install
yarn build
or npm run build
- General lib files.yarn dev
or npm run dev
- Produce dev version of lib and watch files.yarn test
or npm run test
- Run testsyarn test:watch
or npm run test:watch
- Run tests and watch.To publish:
npm publish
FAQs
A small library to create watchable/observable classes with decorators
The npm package exert receives a total of 2 weekly downloads. As such, exert popularity was classified as not popular.
We found that exert 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.