{"_id":"Backbone.Subset","_rev":"11-a9b87c310a8e6107888c9eac002d92a9","name":"Backbone.Subset","description":"Provides a collection-like constructor that allows you create a collection that is subset from a parent one","dist-tags":{"latest":"0.1.1"},"versions":{"0.0.1":{"name":"Backbone.Subset","description":"Provides a collection-like constructor that allows you create a collection that is subset from a parent one","version":"0.0.1","author":{"name":"Pau ramon","email":"masylum@gmail.com"},"repository":{"type":"git","url":"git://github.com/masylum/Backbone.Subset.git"},"devDependencies":{"backbone":"*","underscore":"*","mocha":"*"},"main":"./backbone.subset","_npmUser":{"name":"masylum","email":"masylum@gmail.com"},"_id":"Backbone.Subset@0.0.1","dependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"3ce5e4322483e2c94a7f790ec22bc6c480f1fe61","tarball":"https://registry.npmjs.org/Backbone.Subset/-/Backbone.Subset-0.0.1.tgz","integrity":"sha512-Pczk+68eEMggLsnGGO7obCaLY0XO6ypg032yYcNcKMfeCTLAaqN3pzvKinwuFvSEsu0v+T545wond7cRJpVS2Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDXEWOxPn9Z0HOy1UjkPMoeORNfRBFo7ykm5QbmeC0L+AiBUArDAogevr3xdnB87DmEIQFqKogkpHNxDBB0zFy2pJA=="}]},"maintainers":[{"name":"masylum","email":"masylum@gmail.com"}]},"0.0.2":{"name":"Backbone.Subset","description":"Provides a collection-like constructor that allows you create a collection that is subset from a parent one","version":"0.0.2","author":{"name":"Pau ramon","email":"masylum@gmail.com"},"repository":{"type":"git","url":"git://github.com/masylum/Backbone.Subset.git"},"devDependencies":{"backbone":"*","underscore":"*","mocha":"*"},"main":"./backbone.subset","_npmUser":{"name":"masylum","email":"masylum@gmail.com"},"_id":"Backbone.Subset@0.0.2","dependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"2ae967849dc68f476630eda7f397a19aa213d1ad","tarball":"https://registry.npmjs.org/Backbone.Subset/-/Backbone.Subset-0.0.2.tgz","integrity":"sha512-8slYnawLm3fMjMIIi1lfDjB2Hd+N118q08odlfeSbiW/AEbAaL8sp/NxOJ3s+IvsMoq1hhrD0d5+74b+Y1ptPQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBkUb/wZY2+zbEwCnR72gPnlkmy3E5ynS4Uc3vqN+5DjAiBxHBBfapXHIyv49j6Aevq8+qceqd5C/S2RT58agauDPQ=="}]},"maintainers":[{"name":"masylum","email":"masylum@gmail.com"}]},"0.0.3":{"name":"Backbone.Subset","description":"Provides a collection-like constructor that allows you create a collection that is subset from a parent one","version":"0.0.3","author":{"name":"Pau ramon","email":"masylum@gmail.com"},"contributors":[{"name":"Saimon Moore","email":"saimon@saimonmoore.net"},{"name":"Philip Roberts","email":"phil@latentflip.com"}],"repository":{"type":"git","url":"git://github.com/masylum/Backbone.Subset.git"},"devDependencies":{"backbone":"0.5.3","underscore":"*","mocha":"*"},"main":"./backbone.subset","_npmUser":{"name":"masylum","email":"masylum@gmail.com"},"_id":"Backbone.Subset@0.0.3","dependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.0-3","_nodeVersion":"v0.6.9","_defaultsLoaded":true,"dist":{"shasum":"08d348e043b58d6ef11d4f5533f6a45403aee4ff","tarball":"https://registry.npmjs.org/Backbone.Subset/-/Backbone.Subset-0.0.3.tgz","integrity":"sha512-WFYUpG0PrI4HYeZ47dym2GIL0JvkzDnkUL2Odfyh97jovG76WzpSKkbcPjlMdt4kkdACogACYoKZx5BqIBh13w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDWO2B5g0qpYEaOMG3qeIW9FupY9zfIaTg63sQcMhX/XgIhALnZT8HKI1xvePdugUYhnctHwQVPJ85/rjunqRIxYUhy"}]},"maintainers":[{"name":"masylum","email":"masylum@gmail.com"}]},"0.1.1":{"name":"Backbone.Subset","description":"Provides a collection-like constructor that allows you create a collection that is subset from a parent one","version":"0.1.1","author":{"name":"Pau ramon","email":"masylum@gmail.com"},"contributors":[{"name":"Saimon Moore","email":"saimon@saimonmoore.net"},{"name":"Philip Roberts","email":"phil@latentflip.com"},{"name":"Steven Lindberg","email":"stevenjohnlindberg@gmail.com"}],"repository":{"type":"git","url":"git://github.com/masylum/Backbone.Subset.git"},"devDependencies":{"backbone":"0.5.3","underscore":"1.3.3","mocha":"*"},"main":"./backbone.subset","readme":"# Backbone.Subset\n\nA subset collection that contains pointers to models from a parent collection.\n\n## Use case?\n\nHaving a collection that represents only a subset of your models.\n\nFor instance having a *Archived tasks*, you want to be sure that adding, deleting\nor changing a *Task* will update that subset collection according to a given `sieve`\n\n## How does it work?\n\nThe API is almost the same as `Backbone.Collection`.\n\n  * You must implement a `parent` function that returns the collection the subset belongs or pass a `parent` option.\n  * You must implement a `sieve` function that will be used to filter the parent collection.\n  * You can pass the option `{noproxy: true}` if you don't want the event to bubble from the parent to the subset\n  (not recommended since it can leave your collections in a weird state).\n\n``` javascript\nModels.Task = Backbone.Model.extend({\n  initialize: function () {\n    this.collection = tasks;\n  }\n, isArchived: function () {\n    return this.get('archived');\n  }\n});\n\nCollections.Tasks = Backbone.Collection.extend({model: Models.Task});\nCollections.ArchivedTasks = Backbone.Subset.extend({\n  parent: function () {\n    return tasks;\n  }\n, sieve: function (task) {\n    return task.isArchived();\n  }\n});\n\ntasks = new Collections.Tasks();\narchivedTasks = new Collections.ArchivedTasks();\n\ntasks.reset([{archived: true}, {archived: false}]);\n\nassert.equal(tasks.length, 2);\nassert.equal(archivedTasks.length, 1);\n```\n\n## Live Updating of subsets\n\nSubsets can be optionally updated live. That is, if a models attributes\nchange such that affect it's membership of a subset, that update will\nhappen automatically.\n\nBy default live updating is disabled. Continuing the above example:\n\n```\ntasks.reset([{archived: true}, {archived: false}]);\narchivedTasks.liveupdate_keys = 'all'\n\nassert.equal(tasks.length, 2);\nassert.equal(archivedTasks.length, 1);\n\ntasks.first().set({archived: false});\nassert.equal(tasks.length, 2);\nassert.equal(archivedTasks.length, 0);\n```\n\n### Controlling live updating\n\nLive updating is controlled by a subset's `liveupdate\\_keys` attribute.\n\n* To prevent live updating of a subset, set it's `liveupdate\\_keys` attribute\nto be 'none' (this is the default).\n* To enable live updating when any model key changes, set\n  `liveupdate\\_keys = 'all'`.\n* To limit which model keys trigger a live update, set `liveupdate\\_keys`\nto be an array of attributes: `liveupdate\\_keys = ['archived']`.\n\n### Exclusive subsets\n\nThere are subsets that are exclusive and can operate more efficiently since they don't have to\nbubble to their siblings. To mark a subset as exclusive just implement the `exclusiveSubset`\nfunction to return `true` or `false`.\n\n## Tests\n\nYou must have node installed in order to run the tests.\n\n```\nnpm install\nmake\n```\n\n## Benchmarks\n\nYou must have node installed in order to run the benchmarks.\n\n```\nnpm install\nmake benchmark\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2010-2012 Pau Ramon <masylum@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"Backbone.Subset@0.1.1","dist":{"shasum":"a2449f6ed2d5eb816fa723e51574c3b7e615ec49","tarball":"https://registry.npmjs.org/Backbone.Subset/-/Backbone.Subset-0.1.1.tgz","integrity":"sha512-9C9+xojnlq0a2x6fx+K61jfJ//fgfhLoJXE9lIVLxewTCigWOc4dzD1bcN2rX/UhIs9plPOyRNvm9Qnl/6CyzA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7q/bVQ3iTEoGUQfFZFu8TKRRhTWyaCIIS/JBoiHsqSwIgPc9koEcOESTwvltZtNErY+NFK39hiTIrfpWh9WFK0Us="}]},"maintainers":[{"name":"masylum","email":"masylum@gmail.com"}]}},"readme":"# Backbone.Subset\n\nA subset collection that contains pointers to models from a parent collection.\n\n## Use case?\n\nHaving a collection that represents only a subset of your models.\n\nFor instance having a *Archived tasks*, you want to be sure that adding, deleting\nor changing a *Task* will update that subset collection according to a given `sieve`\n\n## How does it work?\n\nThe API is almost the same as `Backbone.Collection`.\n\n  * You must implement a `parent` function that returns the collection the subset belongs.\n  * You must implement a `sieve` function that will be used to filter the parent collection.\n  * You can pass the option `{noparent: true}` on doing an `add` or a `remove` if you don't want this action to bubble to the parent collection.\n\n``` javascript\nModels.Task = Backbone.Model.extend({\n  initialize: function () {\n    this.collection = tasks;\n  }\n, isArchived: function () {\n    return this.get('archived');\n  }\n});\n\nCollections.Tasks = Backbone.Collection.extend({model: Models.Task});\nCollections.ArchivedTasks = Backbone.Subset.extend({\n  parent: function () {\n    return tasks;\n  }\n, sieve: function (task) {\n    return task.isArchived();\n  }\n});\n\ntasks = new Collections.Tasks();\narchivedTasks = new Collections.ArchivedTasks();\n\ntasks.reset([{archived: true}, {archived: false}]);\n\nassert.equal(task.length, 2);\nassert.equal(archivedTasks.length, 1);\n```\n\n## Tests\n\nYou must have node installed in order to run the tests.\n\n```\nnpm install\nmake\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2010-2011 Pau Ramon <masylum@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","maintainers":[{"name":"masylum","email":"masylum@gmail.com"}],"time":{"modified":"2022-06-13T02:13:07.489Z","created":"2011-11-25T11:49:36.001Z","0.0.1":"2011-11-25T11:49:38.225Z","0.0.2":"2011-11-25T11:52:50.320Z","0.0.3":"2012-02-16T10:20:38.856Z","0.1.1":"2012-09-28T17:19:56.736Z"},"author":{"name":"Pau ramon","email":"masylum@gmail.com"},"repository":{"type":"git","url":"git://github.com/masylum/Backbone.Subset.git"}}