summaryrefslogtreecommitdiff
path: root/node_modules/express/lib/router/collection.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2012-09-24 16:22:07 -0400
committerJules Laplace <jules@okfoc.us>2012-09-24 16:22:07 -0400
commit686106d544ecc3b6ffd4db2b665d3bc879a58d8c (patch)
treea5b5e50237cef70e12f0745371896e96f5f6d578 /node_modules/express/lib/router/collection.js
ok
Diffstat (limited to 'node_modules/express/lib/router/collection.js')
-rw-r--r--node_modules/express/lib/router/collection.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/node_modules/express/lib/router/collection.js b/node_modules/express/lib/router/collection.js
new file mode 100644
index 0000000..991a9a2
--- /dev/null
+++ b/node_modules/express/lib/router/collection.js
@@ -0,0 +1,53 @@
+
+/*!
+ * Express - router - Collection
+ * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
+ * MIT Licensed
+ */
+
+/**
+ * Expose `Collection`.
+ */
+
+module.exports = Collection;
+
+/**
+ * Initialize a new route `Collection`
+ * with the given `router`.
+ *
+ * @param {Router} router
+ * @api private
+ */
+
+function Collection(router) {
+ Array.apply(this, arguments);
+ this.router = router;
+}
+
+/**
+ * Inherit from `Array.prototype`.
+ */
+
+Collection.prototype.__proto__ = Array.prototype;
+
+/**
+ * Remove the routes in this collection.
+ *
+ * @return {Collection} of routes removed
+ * @api public
+ */
+
+Collection.prototype.remove = function(){
+ var router = this.router
+ , len = this.length
+ , ret = new Collection(this.router);
+
+ for (var i = 0; i < len; ++i) {
+ if (router.remove(this[i])) {
+ ret.push(this[i]);
+ }
+ }
+
+ return ret;
+};
+