Skip to content

Commit

Permalink
Fix JSDoc placements
Browse files Browse the repository at this point in the history
  • Loading branch information
queicherius committed Aug 23, 2021
1 parent 78e337e commit 8912b14
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/compact/compact.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
type Falsy = undefined | null | false | 0 | ''

/**
* ### compact(array)
*
Expand All @@ -9,8 +11,6 @@
* ```
*/

type Falsy = undefined | null | false | 0 | ''

export function compact<T>(array: Array<T | Falsy>): Array<T> {
return array.filter(Boolean) as Array<T>
}
2 changes: 0 additions & 2 deletions src/escapeRegExp/escapeRegExp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* ```
*/

// The implementation of this function is taken from MDN:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
export function escapeRegExp(string: string): string {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
}
6 changes: 3 additions & 3 deletions src/get/get.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/no-explicit-any */

const REPLACE_EMPTY_REGEX = /]|^\[/g
const REPLACE_DOT_REGEX = /\.?\[/g

/**
* ### get(object, path, defaultValue?)
*
Expand All @@ -25,9 +28,6 @@
* ```
*/

const REPLACE_EMPTY_REGEX = /]|^\[/g
const REPLACE_DOT_REGEX = /\.?\[/g

export function get(
object: object | null | undefined,
path: string | Array<string | number>,
Expand Down
20 changes: 10 additions & 10 deletions src/memoize/memoize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { TAnyFunction } from '../typeHelpers'

interface MemoizeOptions {
strategy?: MemoizeStrategy
serializer?: MemoizeSerializer
ttl?: number
}

type MemoizeStrategy = 'monadic' | 'variadic'

type MemoizeSerializer = (data: unknown) => string

/**
* ### memoize(func, options?)
*
Expand All @@ -21,16 +31,6 @@ import { TAnyFunction } from '../typeHelpers'
* </details>
*/

interface MemoizeOptions {
strategy?: MemoizeStrategy
serializer?: MemoizeSerializer
ttl?: number
}

type MemoizeStrategy = 'monadic' | 'variadic'

type MemoizeSerializer = (data: unknown) => string

export function memoize<TThis, TReturn, TFunc extends TAnyFunction<TReturn>>(
this: TThis,
func: TFunc,
Expand Down
4 changes: 2 additions & 2 deletions src/omit/omit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable @typescript-eslint/ban-types */

type Omit<T, K> = Pick<T, Exclude<keyof T, K>>

/**
* ### omit(object, keys)
*
Expand All @@ -12,8 +14,6 @@
* ```
*/

type Omit<T, K> = Pick<T, Exclude<keyof T, K>>

export function omit<T extends object, K extends keyof T>(object: T, keys: Array<K>): Omit<T, K> {
const objectKeys = Object.keys(object) as Array<keyof T>

Expand Down
4 changes: 2 additions & 2 deletions src/promisePool/promisePool.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
type PromiseFunction<T> = () => Promise<T>

/**
* ### promisePool(promiseFunctions, limit)
*
Expand All @@ -14,8 +16,6 @@
* ```
*/

type PromiseFunction<T> = () => Promise<T>

export async function promisePool<T>(
promiseFunctions: Array<PromiseFunction<T>>,
limit: number
Expand Down
4 changes: 2 additions & 2 deletions src/randomString/randomString.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'

/**
* ### randomString(length)
*
Expand All @@ -9,8 +11,6 @@
* ```
*/

const CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'

export function randomString(length: number): string {
let string = ''

Expand Down
14 changes: 7 additions & 7 deletions src/toMap/toMap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/* eslint-disable @typescript-eslint/ban-types */

// Return all keys of an object that have value types we can use as a map key
type MappableKeys<T> = NonNullable<
{
[K in keyof T]: T[K] extends string | number | undefined ? K : never
}[keyof T]
>

/**
* ### toMap(array, key, target?)
*
Expand Down Expand Up @@ -33,13 +40,6 @@
* ```
*/

// Return all keys of an object that have value types we can use as a map key
type MappableKeys<T> = NonNullable<
{
[K in keyof T]: T[K] extends string | number | undefined ? K : never
}[keyof T]
>

export function toMap<Element extends object, Key extends MappableKeys<Element>>(
array: Array<Element>,
key: Key
Expand Down

0 comments on commit 8912b14

Please sign in to comment.