Skip to content

Commit

Permalink
🐛 Rename functions toUpper -> upperCase, toLower -> lowerCase
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Apr 17, 2021
1 parent 16d2ece commit f978c42
Show file tree
Hide file tree
Showing 26 changed files with 85 additions and 84 deletions.
4 changes: 2 additions & 2 deletions src/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { add as _add } from 'arithmetic4'
/**
* Adds first argument and second argument.
*
* @public
*
* @param a - The first input number
* @param b - The second input number
* @returns The result of `a + b`
Expand All @@ -28,5 +26,7 @@ import { add as _add } from 'arithmetic4'
* const plus2(2)
* plus2(-3) // -1
* ```
*
* @public
*/
export const add = _add
4 changes: 2 additions & 2 deletions src/divide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { divide as _divide } from 'arithmetic4'
/**
* Divide input two arguments.
*
* @public
*
* @param a - The first input number
* @param b - The second input number
* @returns The result of `a / b`
Expand All @@ -30,5 +28,7 @@ import { divide as _divide } from 'arithmetic4'
* const half = divide(2)
* half(20) // 10
* ```
*
* @public
*/
export const divide = _divide
4 changes: 2 additions & 2 deletions src/endsWith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ type endsWith<T extends string | undefined = undefined> = StringWith<
/**
* Checks if a string ends with the provided substring.
*
* @public
*
* @param val - search string
* @param target - target string
* @returns The result of `target.endsWith(val)`
Expand All @@ -28,6 +26,8 @@ type endsWith<T extends string | undefined = undefined> = StringWith<
* const endsWithTs = endsWith('ts')
* endsWithTs('index.ts') // true
* ```
*
* @public
*/
const endsWith = <T extends string, U extends string | undefined = undefined>(
val: T,
Expand Down
4 changes: 2 additions & 2 deletions src/first.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ type First<T extends string | unknown[]> = IsString<T> extends true
/**
* Returns the first element of the given list or string.
*
* @public
*
* @param val - string or any array object
* @returns The first element of the `val`
*
Expand All @@ -28,6 +26,8 @@ type First<T extends string | unknown[]> = IsString<T> extends true
* first([]) // undefined
* first(['one', 2, 3, 4]) // 'one'
* ```
*
* @public
*/
const first = <T extends string | unknown[]>(val: T): First<T> => {
if (Array.isArray(val)) {
Expand Down
4 changes: 2 additions & 2 deletions src/isBigint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { BIGINT } from '@/constants'
/**
* Bigint or not
*
* @public
*
* @typeParam T - any value
*/
type IsBigint<T extends unknown> = T extends bigint ? true : false
Expand All @@ -22,6 +20,8 @@ type IsBigint<T extends unknown> = T extends bigint ? true : false
* isBigint(1n) // true
* isBigint(1000) // false
* ```
*
* @public
*/
const isBigint = (val: unknown): val is bigint => typeof val === BIGINT

Expand Down
8 changes: 4 additions & 4 deletions src/isBoolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { BOOLEAN } from '@/constants'
/**
* Boolean or not
*
* @public
*
* @typeParam T - any value
*
* @public
*/
type IsBoolean<T extends unknown> = T extends boolean ? true : false

/**
* Whatever argument is type of boolean or not.
*
* @public
*
* @param val - input any value
* @returns The result of `typeof val === 'boolean'`
*
Expand All @@ -22,6 +20,8 @@ type IsBoolean<T extends unknown> = T extends boolean ? true : false
* isBoolean(true) // true
* isBoolean('hello') // false
* ```
*
* @public
*/
const isBoolean = (val: unknown): val is boolean => typeof val === BOOLEAN

Expand Down
8 changes: 4 additions & 4 deletions src/isFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import type { AnyFn } from '@/types'
/**
* Function or not
*
* @public
*
* @typeParam T - any value
*
* @public
*/
type IsFunction<T extends unknown> = T extends AnyFn ? true : false

/**
* Whatever argument is type of function or not.
*
* @public
*
* @param val - input any value
* @returns The result of `typeof val === 'function'`
*
Expand All @@ -23,6 +21,8 @@ type IsFunction<T extends unknown> = T extends AnyFn ? true : false
* isFunction(function) // true
* isFunction('hello') // false
* ```
*
* @public
*/
const isFunction = (val: unknown): val is AnyFn => typeof val === FUNCTION

Expand Down
9 changes: 5 additions & 4 deletions src/isNill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { IsUndefined, isUndefined } from '@/isUndefined'
/**
* Undefiled or null, or not
*
* @public
*
* @typeParam T - any value
*
* @public
*/
type IsNill<T extends unknown> = IsUndefined<T> extends true
? true
Expand All @@ -17,8 +17,6 @@ type IsNill<T extends unknown> = IsUndefined<T> extends true
/**
* Whatever argument is type of undefined or null.
*
* @public
*
* @param val - input any value
* @returns The result of type of `val` is undefined or null
*
Expand All @@ -27,6 +25,9 @@ type IsNill<T extends unknown> = IsUndefined<T> extends true
* isNumber(0) // true
* isNumber('hello') // false
* ```
*
* @public
*
*/
const isNill = (val: unknown): val is null | undefined =>
isUndefined(val) || isNull(val)
Expand Down
8 changes: 4 additions & 4 deletions src/isNull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { NULL } from '@/constants'
/**
* Null or not
*
* @public
*
* @typeParam T - any value
*
* @public
*/
type IsNull<T extends unknown> = T extends null ? true : false

/**
* Whatever argument is type of null or not.
*
* @public
*
* @param val - input any value
* @returns The result of `val === null`
*
Expand All @@ -22,6 +20,8 @@ type IsNull<T extends unknown> = T extends null ? true : false
* isNull(null) // true
* isNull(undefined) // false
* ```
*
* @public
*/
const isNull = (val: unknown): val is null => val === NULL

Expand Down
8 changes: 4 additions & 4 deletions src/isNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { NUMBER } from '@/constants'
/**
* Number or not
*
* @public
*
* @typeParam T - any value
*
* @public
*/
type IsNumber<T extends unknown> = T extends number ? true : false

/**
* Whatever argument is type of number or not.
*
* @public
*
* @param val - input any value
* @returns The result of `typeof val === 'number'`
*
Expand All @@ -22,6 +20,8 @@ type IsNumber<T extends unknown> = T extends number ? true : false
* isNumber(0) // true
* isNumber('hello') // false
* ```
*
* @public
*/
const isNumber = (val: unknown): val is number => typeof val === NUMBER

Expand Down
8 changes: 4 additions & 4 deletions src/isObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { IsPrimitive, isPrimitive } from '@/isPrimitive'
/**
* Object or not
*
* @public
*
* @typeParam T - any value
*
* @public
*/
type IsObject<T extends unknown> = IsPrimitive<T> extends true ? false : true

/**
* Whatever argument is type of object or not.
*
* @public
*
* @param val - input any value
* @returns The result of object or not
*
Expand All @@ -38,6 +36,8 @@ type IsObject<T extends unknown> = IsPrimitive<T> extends true ? false : true
* isObject([]) // true
* isObject('hello') // false
* ```
*
* @public
*/
const isObject = <T extends unknown>(val: T): val is T =>
!isPrimitive(val) as IsObject<T>
Expand Down
8 changes: 4 additions & 4 deletions src/isPrimitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { Primitive } from '@/types'
/**
* Primitive or not
*
* @public
*
* @typeParam T - any value
*
* @public
*/
type IsPrimitive<T extends unknown> = IsBigint<T> extends true
? true
Expand All @@ -30,8 +30,6 @@ type IsPrimitive<T extends unknown> = IsBigint<T> extends true
/**
* Whatever argument is primitive or not.
*
* @public
*
* @param val - input any value
* @returns The result of primitive or not
*
Expand All @@ -50,6 +48,8 @@ type IsPrimitive<T extends unknown> = IsBigint<T> extends true
* isPrimitive(true) // true
* isPrimitive([]) // false
* ```
*
* @public
*/
const isPrimitive = (val: unknown): val is Primitive =>
[isNill, isBoolean, isNumber, isString, isBigint, isSymbol].some((is) =>
Expand Down
8 changes: 4 additions & 4 deletions src/isString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { STRING } from '@/constants'
/**
* String or not
*
* @public
*
* @typeParam T - any value
*
* @public
*/
type IsString<T extends unknown> = T extends string ? true : false

/**
* Whatever argument is type of string or not.
*
* @public
*
* @param val - input any value
* @returns The result of `typeof val === 'string'`
*
Expand All @@ -22,6 +20,8 @@ type IsString<T extends unknown> = T extends string ? true : false
* isString('hello world') // true
* isString(1000) // false
* ```
*
* @public
*/
const isString = (val: unknown): val is string => typeof val === STRING

Expand Down
8 changes: 4 additions & 4 deletions src/isSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { SYMBOL } from '@/constants'
/**
* Symbol or not
*
* @public
*
* @typeParam T - any value
*
* @public
*/
type IsSymbol<T extends unknown> = T extends symbol ? true : false

/**
* Whatever argument is type of symbol or not.
*
* @public
*
* @param val - input any value
* @returns The result of `typeof val === 'symbol'`
*
Expand All @@ -22,6 +20,8 @@ type IsSymbol<T extends unknown> = T extends symbol ? true : false
* isSymbol(Symbol('hello')) // true
* isSymbol('hello') // false
* ```
*
* @public
*/
const isSymbol = (val: unknown): val is symbol => typeof val === SYMBOL

Expand Down
8 changes: 4 additions & 4 deletions src/isUndefined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { UNDEFINED } from '@/constants'
/**
* Undefined or not
*
* @public
*
* @typeParam T - any value
*
* @public
*/
type IsUndefined<T extends unknown> = T extends undefined ? true : false

/**
* Whatever argument is type of undefined or not.
*
* @public
*
* @param val - input any value
* @returns The result of `typeof val === 'undefined'`
*
Expand All @@ -22,6 +20,8 @@ type IsUndefined<T extends unknown> = T extends undefined ? true : false
* isUndefined(undefined) // true
* isUndefined('hello') // false
* ```
*
* @public
*/
const isUndefined = (val: unknown): val is undefined => typeof val === UNDEFINED

Expand Down
4 changes: 2 additions & 2 deletions src/last.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ type Last<T extends string | unknown[]> = IsString<T> extends true
/**
* Returns the last element of the given list or string.
*
* @public
*
* @param val - string or any array object
* @returns The last element of the `val`
*
Expand All @@ -28,6 +26,8 @@ type Last<T extends string | unknown[]> = IsString<T> extends true
* last([]) // undefined
* last(['one', 2, 3, 4]) // 4
* ```
*
* @public
*/
const last = <T extends string | unknown[]>(val: T): Last<T> => {
if (Array.isArray(val)) {
Expand Down

0 comments on commit f978c42

Please sign in to comment.