Backbone Capped Collections
Capped Collections for BackboneJS
Getting Started
Install the module with: npm install backbone-cappedcollection
Client-side
<script type="text/javascript" src="underscore.js"></script>
<script type="text/javascript" src="backbone.js"></script>
<script type="text/javascript" src="lib/index.js"></script>
<script type="text/javascript">
var myColl = new Backbone.CappedCollection([
{name: "Twitter", url: "http://twitter.com/FGRibreau"},
{name: "Bringr", url: "http://brin.gr"},
{name: "Redsmin", url: "http://redsmin.com"},
], {
cap:2,
capRemove:'first'
});
myColl.length;
myColl.add({name: "Github", url: "http://github.com"});
myColl.add({name: "NodeJS", url: "http://nodejs.org/"});
myColl.length;
myColl.toJSON();
</script>
Server-side (NodeJS)
var Backbone = require('backbone');
Backbone = require('backbone-cappedcollection')(Backbone);
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Release History
v0.1.0 - First commit
License
Copyright (c) 2013 Francois-Guillaume Ribreau
Licensed under the MIT license.