]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: improve tsdoc
authorEduardo San Martin Morote <posva13@gmail.com>
Sun, 22 Mar 2020 18:19:37 +0000 (19:19 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Sun, 22 Mar 2020 18:19:37 +0000 (19:19 +0100)
src/history/common.ts
src/index.ts
src/matcher/index.ts
src/matcher/path-parser-ranker.ts
src/router.ts
src/types/index.ts
src/utils/query.ts

index 41efecb1b7f07e8802db6f406b88941bd4bd82e5..a59b9dd7f8298c0b62a49507f93f5dc354d93975 100644 (file)
@@ -90,7 +90,7 @@ export interface RouterHistory {
 /**
  * Transforms an URI into a normalized history location
  * @param parseQuery
- * @param location URI to normalize
+ * @param location URI to normalize
  * @returns a normalized history location
  */
 export function parseURL(
@@ -148,8 +148,8 @@ export function stringifyURL(
 
 /**
  * Strips off the base from the beginning of a location.pathname
- * @param pathname location.pathname
- * @param base base to strip off
+ * @param pathname location.pathname
+ * @param base base to strip off
  */
 export function stripBase(pathname: string, base: string): string {
   if (!base || pathname.indexOf(base) !== 0) return pathname
index 567d35d53d30c1010e12e18ed0b2d4f20636dd0f..8dbeb57e020087438e3718cd5e81961e160f19eb 100644 (file)
@@ -4,6 +4,8 @@ import createWebHashHistory from './history/hash'
 import { inject } from 'vue'
 import { routerKey, routeLocationKey } from './utils/injectionSymbols'
 
+export { RouterHistory } from './history/common'
+
 export {
   RouteLocationNormalized,
   RouteLocationOptions,
index 9a1888ffc59e2f231670139f256eb80298b37d51..1f4e9d6548122c3591b5d350b8fdb71187b48beb 100644 (file)
@@ -173,8 +173,8 @@ export function createRouterMatcher(
 
   /**
    * Resolves a location. Gives access to the route record that corresponds to the actual path as well as filling the corresponding params objects
-   * @param location MatcherLocation to resolve to a url
-   * @param currentLocation MatcherLocationNormalized of the current location
+   * @param location MatcherLocation to resolve to a url
+   * @param currentLocation MatcherLocationNormalized of the current location
    */
   function resolve(
     location: Readonly<MatcherLocation>,
index 3ff0e324e8ee7ba6abd7dad073303834294053d4..bd65ed112dfc43aa813d9f58058fa50116cce5ab 100644 (file)
@@ -28,14 +28,14 @@ export interface PathParser {
    * Parses a url and returns the matched params or nul if it doesn't match. An
    * optional param that isn't preset will be an empty string. A repeatable
    * param will be an array if there is at least one value.
-   * @param path url to parse
+   * @param path url to parse
    * @returns a Params object, empty if there are no params. `null` if there is
    * no match
    */
   parse(path: string): PathParams | null
   /**
    * Creates a string version of the url
-   * @param params object of params
+   * @param params object of params
    * @returns a url
    */
   stringify(params: PathParams): string
@@ -93,8 +93,8 @@ const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g
 /**
  * Creates a path parser from an array of Segments (a segment is an array of Tokens)
  *
- * @param segments array of segments returned by tokenizePath
- * @param extraOptions optional options for the regexp
+ * @param segments array of segments returned by tokenizePath
+ * @param extraOptions optional options for the regexp
  * @returns a PathParser
  */
 export function tokensToParser(
@@ -253,8 +253,8 @@ export function tokensToParser(
 /**
  * Compares an array of numbers as used in PathParser.score and returns a
  * number. This function can be used to `sort` an array
- * @param a first array of numbers
- * @param b second array of numbers
+ * @param a first array of numbers
+ * @param b second array of numbers
  * @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
  * should be sorted first
  */
@@ -285,8 +285,8 @@ function compareScoreArray(a: number[], b: number[]): number {
 
 /**
  * Compare function that can be used with `sort` to sort an array of PathParser
- * @param a first PathParser
- * @param b second PathParser
+ * @param a first PathParser
+ * @param b second PathParser
  * @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
  */
 export function comparePathParserScore(a: PathParser, b: PathParser): number {
index bdb819b6b55beb75c75d169e7fa87d92172e62c5..119285e02e56421d9c3425f028518d489163a670 100644 (file)
@@ -451,8 +451,8 @@ export function createRouter({
 
   /**
    * Trigger errorHandlers added via onError and throws the error as well
-   * @param error error to throw
-   * @param shouldThrow defaults to true. Pass false to not throw the error
+   * @param error error to throw
+   * @param shouldThrow defaults to true. Pass false to not throw the error
    */
   function triggerError(error: any, shouldThrow: boolean = true): void {
     markAsReady(error)
@@ -479,7 +479,7 @@ export function createRouter({
   /**
    * Mark the router as ready, resolving the promised returned by isReady(). Can
    * only be called once, otherwise does nothing.
-   * @param err optional error
+   * @param err optional error
    */
   function markAsReady(err?: any): void {
     if (ready) return
index 93f502c0a23bf67ede00549198468a3e326ba79f..12c3f5954e56ce465f4389cdfdf2f69f7b4b6944 100644 (file)
@@ -108,18 +108,18 @@ export interface RouteComponentInterface {
   /**
    * Guard called when the router is navigating away from the current route
    * that is rendering this component.
-   * @param to RouteLocation we are navigating to
-   * @param from RouteLocation we are navigating from
-   * @param next function to validate, cancel or modify (by redirectering) the navigation
+   * @param to RouteLocation we are navigating to
+   * @param from RouteLocation we are navigating from
+   * @param next function to validate, cancel or modify (by redirectering) the navigation
    */
   beforeRouteLeave?: NavigationGuard
   /**
    * Guard called whenever the route that renders this component has changed but
    * it is reused for the new route. This allows you to guard for changes in params,
    * the query or the hash.
-   * @param to RouteLocation we are navigating to
-   * @param from RouteLocation we are navigating from
-   * @param next function to validate, cancel or modify (by redirectering) the navigation
+   * @param to RouteLocation we are navigating to
+   * @param from RouteLocation we are navigating from
+   * @param next function to validate, cancel or modify (by redirectering) the navigation
    */
   beforeRouteUpdate?: NavigationGuard
 }
index 7ef1bc3f9b9a8fd42fbafc9888d4b1c88ea3d575..4d1ff4d6fb493842e1769d2ac575ce17677e5d02 100644 (file)
@@ -14,7 +14,7 @@ export type LocationQueryRaw = Record<
 /**
  * Transform a queryString into a query object. Accept both, a version with the leading `?` and without
  * Should work as URLSearchParams
- * @param search
+ * @param search - search string to parse
  * @returns a query object
  */
 export function parseQuery(search: string): LocationQuery {
@@ -48,7 +48,7 @@ export function parseQuery(search: string): LocationQuery {
 
 /**
  * Stringify an object query. Works like URLSearchParams. Doesn't prepend a `?`
- * @param query
+ * @param query - query object to stringify
  */
 export function stringifyQuery(query: LocationQueryRaw): string {
   let search = ''
@@ -80,7 +80,7 @@ export function stringifyQuery(query: LocationQueryRaw): string {
  * Transforms a RawQuery intoe a NormalizedQuery by casting numbers into
  * strings, removing keys with an undefined value and replacing undefined with
  * null in arrays
- * @param query
+ * @param query - query object to normalize
  */
 export function normalizeQuery(
   query: LocationQueryRaw | undefined