Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Capped Collections for BackboneJS
branch: master
Failed to load latest commit information.
lib First commit
test First commit
.gitignore First commit
.npmignore First commit
.travis.yml First commit
LICENSE-MIT First commit Update
grunt.js First commit
index.js First commit
package.json Format

Backbone Capped Collections Build Status Gittip

Capped Collections for BackboneJS

Getting Started

Install the module with: npm install backbone-cappedcollection


<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: ""}, // Will be removed
  {name: "Bringr",  url: ""},
  {name: "Redsmin", url: ""},
], {
  // {optional} Capped Collection size (default. 5)
  // {optional} From where should it start to remove elements, "first" or "last" (default. first)

myColl.length; // == 2

myColl.add({name: "Github", url: ""});
myColl.add({name: "NodeJS", url: ""});

myColl.length; // == 2

myColl.toJSON(); // [{"name":"Github","url":""},{"name":"NodeJS","url":""}]

// Other Backbone methods (.add, .reset, ...) should work as expected as well.

Server-side (NodeJS)

var Backbone = require('backbone');
// Wrap it
Backbone = require('backbone-cappedcollection')(Backbone);

// [... same as the client-side code above ...]


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


Donate Bitcoins


Copyright (c) 2013 Francois-Guillaume Ribreau Licensed under the MIT license.

Something went wrong with that request. Please try again.