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.
Represents domain-specific data or information that an application will be working with. A typical example is a user account (e.g name, avatar, e-mail) or a music track (e.g title, year, album). Holds information, but don’t handle behaviour and don’t format information or influence how data appears.
npm install stb-model
Add the constructor to the scope:
var Model = require('stb-model');
Create an empty instance:
var model = new Model();
Create an instance with some data:
var model = new Model({
attr1: value1,
attr2: value2,
});
Clear all data:
model.clear();
emits
clear
event in case some data is present
Clear and set new model data:
model.init({
attr3: value3,
attr4: value4,
});
can emit
clear
andinit
events
Check an attribute existence:
if ( model.has('attr3') ) {
...
}
Get a model attribute value by name:
var value = model.get('attr1');
Update or create a model attribute:
var operationStatus = model.set('attr5', 'value5');
emits
change
event withprev
field in data in case of update operation
Delete the given attribute by name:
var operationStatus = model.unset('attr5');
emits
change
event
It is highly advisable to access a model data directly in case no events are required.
So instead of
var value = model.get('attr1');
model.set('attr5', 'value5');
to avoid performance penalty it's better to use
var value = model.data.attr1;
model.data.attr5 = 'value5';
There is a global var
DEBUG
which activates additional consistency checks and protection logic not available in release mode.
In debug mode the constructor is exposed to the global namespace as window.Model
.
If you have any problem or suggestion please open an issue here. Pull requests are welcomed with respect to the JavaScript Code Style.
stb-model
is released under the GPL-3.0 License.
FAQs
Basic model implementation.
The npm package cjs-model receives a total of 1 weekly downloads. As such, cjs-model popularity was classified as not popular.
We found that cjs-model 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.