Socket
Socket
Sign inDemoInstall

attach

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attach - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

34

lib/attach.js
/*!
* attach
* Copyright(c) 2012 RGBboy <me@rgbboy.com>
* Copyright(c) 2013 RGBboy <me@rgbboy.com>
* MIT Licensed

@@ -11,3 +11,3 @@ */

exports.version = '0.0.1';
exports.version = '0.0.2';

@@ -22,7 +22,2 @@ /**

// test that self has named routes
// test that has .all function
var children = [];
/**

@@ -45,31 +40,10 @@ * Attaches a routable component to itself;

if (children.indexOf(component) != -1) {
if (component.parent) {
throw new Error('Component already attached');
};
var origLookupRoute = self.lookupRoute,
origComponentLookupRoute = component.lookupRoute;
self.lookupRoute = function (lookupRouteName) {
var re = /^(.*?)\.(.*?)$/g,
test = re.exec(lookupRouteName);
if (test && test[1] === routeName) {
return component.lookupRoute(test[2]);
} else {
return origLookupRoute(lookupRouteName);
}
};
children.push(component);
component.lookupRoute = function (lookupRouteName, route) {
var route = self.lookupRoute(routeName) + origComponentLookupRoute(lookupRouteName, route);
route = route.replace(/\/{2,}/g, '/'); // remove double //
route = route.replace(/(.+)\/+$/g, '$1'); // remove trailing slash
return route;
};
self.all(self.lookupRoute(routeName) + '*', component.handler);
// emit attached event
component.parent = self;
component.emit('attached', self);

@@ -76,0 +50,0 @@

2

package.json
{
"name": "attach",
"version": "0.0.1",
"version": "0.0.2",
"description": "Add attach functionality to a routable object",

@@ -5,0 +5,0 @@ "keywords": ["router", "attach", "child", "parent"],

@@ -38,1 +38,26 @@ # Attach

* Write tests
## License
(The MIT License)
Copyright (c) 2013 RGBboy &lt;me@rgbboy.com&gt;
Permission 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:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE 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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc