diff --git a/README.md b/README.md index 22c4edf..729afa3 100755 --- a/README.md +++ b/README.md @@ -138,10 +138,16 @@ addEpisode(n) ``` Add an episode in position `n`, plucked randomly from the Pool, also ups the count for the programme. Returns the episode added. +```javascript +trimTo(n) +``` + +Removes all but the first `n` child episodes. + ```javascript removeAllItems() ``` -Removes all child episodes and sets the count of episodes to 0. +Removes all child episodes and sets the count of episodes to 0 (alias for `trimTo(0)`). ### Group diff --git a/lib/Fixture.js b/lib/Fixture.js index b79eb6e..7bb9802 100755 --- a/lib/Fixture.js +++ b/lib/Fixture.js @@ -26,7 +26,12 @@ function Fixture(name, data, elementPool, config, fixtureName) { /* Instance Methods */ Fixture.prototype.removeAllItems = function() { - this.elementsArray.splice(0,this.elementsArray.length); + this.trimTo(0); +}; + +Fixture.prototype.trimTo = function(length) { + var total = this.elementsArray.length; + this.elementsArray.splice(length, total-length); }; Fixture.prototype.getElement = function (num) {