Comparing version 0.2.0 to 0.3.0
@@ -6,2 +6,13 @@ | ||
## 0.3.0 | ||
### Features and Improvements | ||
* Move to [Yarn](https://yarnpkg.com/) for primary build steps. | ||
* Implementation of positional parameters in routes. | ||
## Bug Fixes | ||
* Fix incorrectly implemented module export in `main.js`. | ||
## 0.2.0 | ||
@@ -13,3 +24,2 @@ | ||
## 0.1.1 | ||
@@ -16,0 +26,0 @@ |
# Contributing | ||
A guide for contributing to this repository which extends the [README.md](README.md) file. | ||
## Contributors | ||
* [Daniel Tedman](https://danieltedman.com) | ||
## Dependencies | ||
* [Node (v6)](https://nodejs.org) | ||
* [NPM (v3)](https://www.npmjs.com) | ||
## Testing | ||
@@ -24,3 +13,3 @@ | ||
```bash | ||
npm run test:lint | ||
yarn test:lint | ||
``` | ||
@@ -33,3 +22,3 @@ | ||
```bash | ||
npm run test:unit | ||
yarn test:unit | ||
``` | ||
@@ -42,5 +31,5 @@ | ||
``` | ||
npm publish | ||
yarn publish | ||
``` | ||
See [npm-developers](https://docs.npmjs.com/misc/developers) for a comprehensive developer guide to NPM. | ||
See [Publishing a Package](https://yarnpkg.com/lang/en/docs/publishing-a-package/) for more information. |
@@ -0,0 +0,0 @@ |
{ | ||
"name": "estoolbox", | ||
"description": "A collection of libraries intended to augment the development of ES2015 targeted applications.", | ||
"version": "0.2.0", | ||
"description": "A collection of tools intended to augment the development of ES2015 targeted applications.", | ||
"version": "0.3.0", | ||
"main": "./src/js/main.js", | ||
@@ -36,4 +36,5 @@ "scripts": { | ||
"dependencies": { | ||
"jquery": "3.1.1" | ||
"jquery": "3.1.1", | ||
"path-to-regexp": "2.1.0" | ||
} | ||
} |
# [ESToolbox](https://dbtedman.github.io/estoolbox/) `v0.2.0` [![Build Status](https://travis-ci.org/dbtedman/estoolbox.svg?branch=master)](https://travis-ci.org/dbtedman/estoolbox) [![NPM Version](https://img.shields.io/npm/v/estoolbox.svg)](https://www.npmjs.com/package/estoolbox) | ||
# [ESToolbox](https://dbtedman.github.io/estoolbox/) | ||
A collection of libraries intended to augment the development of Modern JS (ES6+) targeted applications. | ||
[![Build Status](https://travis-ci.org/dbtedman/estoolbox.svg?branch=master)](https://travis-ci.org/dbtedman/estoolbox) [![NPM Version](https://img.shields.io/npm/v/estoolbox.svg)](https://www.npmjs.com/package/estoolbox) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE.md) | ||
## Is it open? | ||
A collection of tools intended to augment the development of [ES2015](https://en.wikipedia.org/wiki/ECMAScript#6th_Edition_-_ECMAScript_2015) targeted applications. | ||
Yes, it is released under the MIT License, See [LICENSE.md](LICENSE.md). | ||
## Where do I start? | ||
1\. Install the NPM module. | ||
1\. Install the package. | ||
```bash | ||
npm install --save-dev estoolbox | ||
# NPM | ||
npm install estoolbox --save-dev | ||
# Yarn | ||
yarn add estoolbox --dev | ||
``` | ||
@@ -55,12 +57,12 @@ | ||
}); | ||
Router.when("/person/:username", (route) => { | ||
const username = route.variables.username; | ||
// Show the person content for this user. | ||
}); | ||
``` | ||
--- | ||
## Want to learn more? | ||
Created [Down Under](https://en.wikipedia.org/wiki/Australia) by [Daniel Tedman](https://danieltedman.com). | ||
See our [CONTRIBUTING.md](CONTRIBUTING.md) guide for information regarding: | ||
* project contributors | ||
* dependencies | ||
* testing | ||
* releasing | ||
[![Australia](https://danieltedman.com/images/Australia.png)](https://en.wikipedia.org/wiki/Australia) |
@@ -0,0 +0,0 @@ import $ from "jquery"; |
@@ -8,3 +8,2 @@ // | ||
exports.Affix = Affix; | ||
exports.Router = Router; | ||
export {Affix, Router}; |
@@ -0,7 +1,12 @@ | ||
import pathToRegexp from "path-to-regexp"; | ||
export default class Route { | ||
constructor(pattern, callback) { | ||
this.patternKeys = []; | ||
/** | ||
* @type {String} | ||
* @type {RegExp} | ||
*/ | ||
this.pattern = pattern; | ||
this.pattern = pathToRegexp(pattern, this.patternKeys); | ||
@@ -12,3 +17,8 @@ /** | ||
this.callback = callback; | ||
/** | ||
* @type {{}} Positional variables parsed from matched pattern. | ||
*/ | ||
this.variables = {}; | ||
} | ||
} |
@@ -58,3 +58,4 @@ import Route from "./route"; | ||
found = true; | ||
route.callback(); | ||
this.parsePatternVariablesFromPath(route, path); | ||
route.callback(route); | ||
} | ||
@@ -66,11 +67,20 @@ } | ||
/** | ||
* @param {Route} route | ||
* @param {String} path | ||
*/ | ||
parsePatternVariablesFromPath(route, path) { | ||
route.patternKeys.forEach((key, index) => { | ||
route.variables[key.name] = route.pattern.exec(path)[(index + 1)]; | ||
}); | ||
} | ||
/** | ||
* Compare a pattern to a route. | ||
* | ||
* @param {String} path A URL hash path. | ||
* @param {String} pattern A URL route matching pattern. | ||
* @param {RegExp} pattern A URL route matching pattern. | ||
* @return {Boolean} True if pattern matches route, else false. | ||
*/ | ||
compare(path, pattern) { | ||
// TODO: Update sophistication of matching logic. | ||
return pattern == path; | ||
return pattern.exec(path) !== null; | ||
} | ||
@@ -77,0 +87,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12438
12
189
68
2
+ Addedpath-to-regexp@2.1.0
+ Addedpath-to-regexp@2.1.0(transitive)