diff --git a/package.json b/package.json index c23a97f..75b994e 100644 --- a/package.json +++ b/package.json @@ -36,4 +36,4 @@ "npmextra.json", "readme.md" ] -} +} \ No newline at end of file diff --git a/readme.md b/readme.md index 819c763..a130a13 100644 --- a/readme.md +++ b/readme.md @@ -19,7 +19,7 @@ TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartrouter)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartrouter)](https://lossless.cloud) +PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartrouter)](https://lossless.cloud) BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartrouter)](https://lossless.cloud) Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud) diff --git a/ts/index.ts b/ts/index.ts index a9a0561..442e164 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,6 +1,6 @@ import * as plugins from './smartrouter.plugins'; -const routeLog = (message) => { +const routeLog = message => { console.log(`%c[Router]%c ${message}`, 'color: rgb(255, 105, 100);', 'color: inherit'); }; @@ -13,13 +13,16 @@ export interface IRouterOptions { */ export class SmartRouter { public options: IRouterOptions = { - debug: false, + debug: false }; /** * the routes we are handling */ - public routes: Array<{ matchFunction: plugins.pathToRegExp.MatchFunction; handler: (matchArg: plugins.pathToRegExp.Match) => Promise }> = []; + public routes: Array<{ + matchFunction: plugins.pathToRegExp.MatchFunction; + handler: (matchArg: plugins.pathToRegExp.Match) => Promise; + }> = []; /** * Creates an instance of Router. @@ -28,11 +31,11 @@ export class SmartRouter { // lets set the router options this.options = { ...this.options, - ...optionsArg, + ...optionsArg }; // lets subscribe to route changes - window.addEventListener('popstate', (popStateEventArg) => { + window.addEventListener('popstate', popStateEventArg => { popStateEventArg.preventDefault(); this._handleRouteState(); }); @@ -59,10 +62,9 @@ export class SmartRouter { * @param {function} handlerArg */ public on(routeArg: string, handlerArg: () => Promise) { - this.routes.push({ matchFunction: plugins.pathToRegExp.match(routeArg), - handler: handlerArg, + handler: handlerArg }); } diff --git a/ts/smartrouter.plugins.ts b/ts/smartrouter.plugins.ts index b8db00c..7ae6f56 100644 --- a/ts/smartrouter.plugins.ts +++ b/ts/smartrouter.plugins.ts @@ -1,5 +1,3 @@ import * as pathToRegExp from 'path-to-regexp'; -export { - pathToRegExp -}; \ No newline at end of file +export { pathToRegExp };