Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

more-router

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

more-router - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

lib/main.js

79

lib/router.js

@@ -7,3 +7,3 @@ "use strict";

var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };

@@ -22,7 +22,9 @@ var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };

this.root = new Node();
this.registered = new Map();
}
_createClass(Router, {
_prototypeProperties(Router, null, {
addPattern: {
value: function addPattern(path, value) {
this.registered.set(normalizePath(path), value);
var node = this.root;

@@ -58,4 +60,13 @@ var knownVariables = new Set();

node.value = value;
}
},
writable: true,
configurable: true
},
getPattern: {
value: function getPattern(path) {
return this.registered.get(normalizePath(path));
},
writable: true,
configurable: true
},
consume: {

@@ -85,3 +96,5 @@ value: function consume(stack) {

};
}
},
writable: true,
configurable: true
},

@@ -93,3 +106,5 @@ resolve: {

return this.consume(steps);
}
},
writable: true,
configurable: true
}

@@ -114,3 +129,3 @@ });

_createClass(Step, {
_prototypeProperties(Step, null, {
match: {

@@ -134,3 +149,5 @@ value: function match(s) {

};
}
},
writable: true,
configurable: true
},

@@ -140,3 +157,5 @@ hasVariables: {

return this.names.length > 0;
}
},
writable: true,
configurable: true
},

@@ -149,3 +168,5 @@ greaterThan: {

return !this.lesserThan(other);
}
},
writable: true,
configurable: true
},

@@ -164,3 +185,5 @@ lesserThan: {

return greaterThan(this.parts, other.parts);
}
},
writable: true,
configurable: true
}

@@ -183,3 +206,3 @@ });

_createClass(Node, {
_prototypeProperties(Node, null, {
add: {

@@ -191,3 +214,5 @@ value: function add(step) {

return this.addVariableNode(step);
}
},
writable: true,
configurable: true
},

@@ -203,3 +228,5 @@ addNameNode: {

return node;
}
},
writable: true,
configurable: true
},

@@ -224,3 +251,5 @@ addVariableNode: {

return result;
}
},
writable: true,
configurable: true
},

@@ -262,3 +291,5 @@ get: {

return { node: null, variables: {} };
}
},
writable: true,
configurable: true
}

@@ -270,3 +301,3 @@ });

var StepNode = (function (_Node) {
var StepNode = (function (Node) {
function StepNode(step) {

@@ -279,9 +310,11 @@ _classCallCheck(this, StepNode);

_inherits(StepNode, _Node);
_inherits(StepNode, Node);
_createClass(StepNode, {
_prototypeProperties(StepNode, null, {
match: {
value: function match(segment) {
return this.step.match(segment);
}
},
writable: true,
configurable: true
}

@@ -294,2 +327,6 @@ });

function parsePath(path) {
return normalizePath(path).split(PATH_SEPARATOR);
}
function normalizePath(path) {
if (path.startsWith("/")) {

@@ -301,4 +338,4 @@ path = path.slice(1);

}
return path.split(PATH_SEPARATOR);
}
return path;
};

@@ -305,0 +342,0 @@ function generalizeVariables(s) {

{
"name": "more-router",
"version": "0.1.0",
"version": "0.2.0",
"description": "Router library. Derived from Morepath.",
"main": "lib/router.js",
"main": "lib/main.js",
"scripts": {

@@ -7,0 +7,0 @@ "compile": "babel -d lib/ src/",

@@ -1,3 +0,3 @@

more-route
==========
more-router
===========

@@ -7,4 +7,4 @@ Introduction

more-route is a routing library. It can run both on the client
as well as on the server.
more-router is a routing library. It can run both on the client as
well as on the server.

@@ -19,2 +19,5 @@ Its possibly special qualities include:

* a publisher abstraction where you can express routes only respond to
particular requests, i.e. only GET requests.
Usage

@@ -24,5 +27,5 @@ -----

```javascript
var Router = require('more-router');
var moreRouter = require('more-router');
var router = new Router();
var router = new moreRouter.Router();

@@ -69,6 +72,11 @@ // second argument can be anything you like; here we use a string

Publisher
---------
To be documented.
Background
----------
more-route is derived from the routing code in the Morepath web
more-router is derived from the routing code in the Morepath web
framework written in Python.
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