Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
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.
cjs-model
extends Emitter interface.
npm install cjs-model
Add the constructor to the scope:
var Model = require('cjs-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
DEVELOP
which activates additional consistency checks and protection logic not available in release mode.
If you have any problem or suggestion please open an issue here. Pull requests are welcomed with respect to the JavaScript Code Style.
cjs-model
is released under the MIT 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.
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.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.