Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
js-list-container
Advanced tools
Readme
#List Container
An evented array list container that augments the standard javascript array without altering the array prototype. Events fire when the array changes or when a contained value or model changes.
A simple wrapper/container for array lists that provides a base class to extend without modifying the javascript Array prototype.
npm install js-list-container --save
Simple use without extension...
const ListContainer = require('js-list-container');
const options = {
list:require('./list.json'),
lastRefresh:new Date()
};
const container = new ListContainer( options );
container.size() === options.list.length;
container.forEach(item => {
console.log( item );
});
Simple extension use case...
const MyCollection = function(options) {
const container = this;
ListContainer.extend( this, options );
this.getItem = function(index) {
var list = container.getList();
return list[ index ];
};
};
const collection = new MyCollection( opts );
collection.push( { id:1, created:new Date() } );
collection.push( { id:2, created:new Date() } );
collection.size() === 2;
let item = collection.getItem( 1 );
item.id === 2;
Evented Example
const dash = require('lodash');
const ListContainer = require('js-list-container');
const options = {
list:require('./list.json'),
lastRefresh:new Date()
};
const container = new ListContainer( options );
container.onListChange(function() {
console.log( 'list changed: ', container.lastChangeDate );
});
container.onDataChange(function(oldValue, newValue) {
console.log( 'data changed: ', container.lastChangeDate );
});
// copy of one of the contained models
let originalModel = container.getList()[ 3 ],
changeModel = dash.clone( original );
changeModel.title = 'My New Title';
// do the change will file a data change event and return true
container.updateModel( originalModel, changeModel ) === true;
// this will fire a list change event
let popped = container.pop();
// this will also fire a list change event
container.clear();
// this will not fire a data change event
container.updateModel( originalModel, changeModel ) === false;
All objects are tested using gulp and mocha. You can run tests by doing this:
make test
// or
make watch
// or
make test
// or
npm test
FAQs
An evented array list container that augments the standard javascript array without altering the array prototype. Events fire when the list changes or when a contained model is updated.
The npm package js-list-container receives a total of 3 weekly downloads. As such, js-list-container popularity was classified as not popular.
We found that js-list-container 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.