
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@insertish/mutable
Advanced tools
The use-case of this library is for when you need to monitor mutations for a set of objects.
You may be wondering if something like Redux would do the job, probably, but it gets a bit messy when you also want to persist all the data, i.e. you're serializing and writing huge amounts of data for every small little change.
The solution is to wrap every object internally and catch any mutations on the objects.
import { MutableMap } from '@insertish/mutable';
type User = {
_id: string
username: string
online: boolean
flag: number
}
class Users extends MutableMap<User> {
updateUsername(id: string, username: string) {
// we would call an API here to verify we can do this
// and then use Reflect to set the correct field
this.map[id].username = username;
}
}
let map = new Users();
map.on('create', item => console.log('Created user', item));
map.on('delete', id => console.log('Deleted user with id', id));
map.on('mutation', (user: User, property: string) => console.log('User', user._id, 'has had property', property, 'changed!'));
map.create({ _id: '123', username: 'aaa', online: true, flag: 0 });
let user = map.get('123');
map.updateUsername('123', 'bbb');
map.updateUsername('123', 'bbb'); // Internally, we use lodash.isEqual to prevent multiple events firing.
console.log(JSON.stringify(user)); // Since it's a normal object, we can just serialize it if we want.
map.set({ _id: '456', username: 'bbb', online: false, flag: 0 });
map.set({ _id: '456', username: 'bbb', online: false, flag: 8 });
map.patch('456', { online: true });
map.patch('123', { flag: 1 });
map.delete('456');
To use with IDB, simply pass a ZangoDB collection in. (reliance on this library isn't necessary, but I am already using it elsewhere in the project this is going to be used in, feel free to PR to use just IDB)
import { Db } from '@insertish/zangodb';
let db = new Db('state', 1, [ 'users' ]);
let map = new MutableMap<T>(db.collection('users'));
// After constructing, always reload state first.
map.restore(); // -> Promise<void>
// All changes are automatically saved to IDB.
FAQs
Mutable object utilities.
The npm package @insertish/mutable receives a total of 1 weekly downloads. As such, @insertish/mutable popularity was classified as not popular.
We found that @insertish/mutable 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 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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.