Options
All
  • Public
  • Public/Protected
  • All
Menu

Module types

Index

Type aliases

ConvertDayNameOption

ConvertDayNameOption: { lang: DatetimeLang; type: DatetimeType }

Type declaration

ConvertMonthNameOption

ConvertMonthNameOption: { lang: DatetimeLang; type: DatetimeType }

Type declaration

Data

Data: string

Datetime

Datetime<T, L>: Record<L, DatetimeFormat<T>>

Type parameters

  • T

  • L: string = DatetimeLang

DatetimeFormat

DatetimeFormat<T>: Record<DatetimeType, T>

Type parameters

  • T

DatetimeKey

DatetimeKey: "day" | "month"

DatetimeLang

DatetimeLang: "en" | "th"

DatetimeTimezone

DatetimeTimezone: "UTC" | "local"

DatetimeType

DatetimeType: "short" | "long"

Day

Day: [string, string, string, string, string, string, string]

GetIndexOption

GetIndexOption: { key: DatetimeKey; lang: DatetimeLang; type: DatetimeType }

Type declaration

GetNameOption

GetNameOption: { key: DatetimeKey; lang: DatetimeLang; type: DatetimeType }

Type declaration

Json

Json<T>: Partial<Record<string, PossibleValue<T>>>

Type parameters

  • T = Value

JsonSortableData

JsonSortableData<T>: { data: T; index: number }

Type parameters

  • T

Type declaration

  • data: T
  • index: number

MaskOption

MaskOption: { back: number; enabled: boolean; front: number; mask: string }

Type declaration

  • back: number
  • enabled: boolean
  • front: number
  • mask: string

Month

Month: [string, string, string, string, string, string, string, string, string, string, string, string]

NestedJson

NestedJson<T>: Partial<Record<string, PossibleValues<PossibleValue<T>>>>

Type parameters

  • T = Value

NewDateOption

NewDateOption: { date?: undefined | number; hour?: undefined | number; millisecond?: undefined | number; minute?: undefined | number; month?: undefined | number; second?: undefined | number; year?: undefined | number }

Type declaration

  • Optional date?: undefined | number
  • Optional hour?: undefined | number
  • Optional millisecond?: undefined | number
  • Optional minute?: undefined | number
  • Optional month?: undefined | number
  • Optional second?: undefined | number
  • Optional year?: undefined | number

OptionalSortableJson

OptionalSortableJson: Partial<SortableJson>

PossibleValue

PossibleValue<T>: T | T[]

Type parameters

  • T = Value

PossibleValues

PossibleValues<T>: T | Record<string, T>

Type parameters

  • T = PossibleValue

SortableJson

SortableJson: {}

Type declaration

TimestampType

TimestampType: "second" | "millisecond"

Value

Value: any

YearType

YearType: "thai" | "global"

Variables

Const enDayLong

enDayLong: Day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

Const enDayShort

enDayShort: Day = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]

Const enMonthLong

enMonthLong: Month = ["January","February","March","April","May","June","July","August","September","October","November","December",]

Const enMonthShort

enMonthShort: Month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

Const filewhitelist

filewhitelist: "________________________________" = "________________________________"

Const internal

internal: "internal" = "internal"

Const thDayLong

thDayLong: Day = ["วันอาทิตย์", "วันจันทร์", "วันอังคาร", "วันพุธ", "วันพฤหัสบดี", "วันศุกร์", "วันเสาร์"]

Const thDayShort

thDayShort: Day = ["อาทิตย์", "จันทร์", "อังคาร", "พุธ", "พฤหัส", "ศุกร์", "เสาร์"]

Const thMonthLong

thMonthLong: Month = ["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม",]

Const thMonthShort

thMonthShort: Month = ["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.",]

Functions

Const check

  • check(...d: Data[]): boolean

Const cleanObject

Const convertDayName

Const convertMonthName

Const convertYear

  • convertYear(year: string, type?: YearType): number
  • convert year from type to global year number

    Thai year example:

    • 54 => 2011
    • 61 => 2018
    • 2544 => 2001
    • 2565 => 2022
    • 5 => 1962
    • 612 => 2037
    • Y65 => 2022

    Global year example

    • 12 => 2012
    • 25 => 2525
    • 2044 => 2044
    • 2001 => 2001
    • 5 => 2005
    • 612 => 2612
    • Y18 => 2018

    Parameters

    • year: string

      year string

    • Default value type: YearType = "thai"

      year type

    Returns number

Const deepMerge

  • deepMerge<T, U>(_jsonA?: Optional<T>, _jsonB?: Optional<U>, size?: number): T & U

Const equals

  • equals<T>(t1: T | T[], t2: T | T[]): boolean

Const equals

  • deepEquals object data with specify keys

    example

    equals({a: 1}, {a: 2}, ["a"]) - check only keys 'a' equals({a: 2, b: 3}, {a: 2, b: 3}) - check all keys ('a' and 'b') equals({a: {aa: 1, ab: 2}}, {a: {aa: 2, bb: 3, cc: 1}, ["a.ab"]}) - check only 'b' key inside a object

    Type parameters

    Parameters

    • o1: Optional<T>

      base object

    • o2: Optional<T>

      checking object with o1

    • Default value keys: string[] = []

      only specify key to check, empty means check all. The keys can cover nested object by . (see on example)

    Returns boolean

    true if two object is identical

Const flatmap

  • flatmap<T>(...arr: (T[] | T)[]): T[]

Const forceObject

  • forceObject<T>(obj: Optional<T>, def?: {}): T
  • this will convert input to T object

    Type parameters

    • T = unknown

    Parameters

    • obj: Optional<T>

      input any type

    • Default value def: {} = {}

      default value if input is not object

    Returns T

    always new object returned

Const getDateFromTimestamp

  • getDateFromTimestamp(timestamp: string | number): Date | undefined

Const getIndex

Const getName

Const getObject

  • getObject<R, T>(obj: T, key: string, all?: boolean): R | T | undefined
  • Type parameters

    Parameters

    • obj: T

      input object to query

    • key: string

      object query statment (format as a.b.c)

    • Default value all: boolean = false

      if enable this, getObject will return full object instead of undefined

    Returns R | T | undefined

Const isBoolean

Const isCI

  • isCI(): boolean

Const isDevelopment

  • isDevelopment(): boolean

Const isEmpty

  • return true when match following condition

    1. is undefined or null
    2. is empty string
    3. is empty object ({})
    4. is empty array ([])

    Type parameters

    • T = unknown

    Parameters

    Returns t is Null

Const isExist

Const isFalsy

Const isNotEmpty

  • isNotEmpty(str: Optional<string>): str is string

Const isNumber

  • isNumber(t: AnyOptional, ignoreSpecial?: boolean): t is number

Const isObject

  • isObject<T>(obj: Optional<T>): obj is T

Const isProduction

  • isProduction(): boolean

Const isStaging

  • isStaging(): boolean

Const isString

Const isTesting

  • isTesting(): boolean

Const isTruthy

Const mask

Const merge

  • merge<T>(base: Optional<Partial<T>>, ...obj: Optional<Partial<T>>[]): T | undefined

Const newDate

Const noExist

Const nonEmpty

Const padEnd

  • padEnd(str: string, length: number, fill?: string): string

Const padStart

  • padStart(str: string, size: number, fill?: string): string

Const read

  • read(name: string, def: string): string

Const setEnv

  • setEnv(name: string, value: string | undefined): string | undefined

Const setImmediate

  • setImmediate(fn: (error?: Error | null) => void): void
  • Parameters

    • fn: (error?: Error | null) => void
        • (error?: Error | null): void
        • Parameters

          • Optional error: Error | null

          Returns void

    Returns void

Const timestamp

  • timestamp(input: string | number | Date, type?: TimestampType): number

Const toArray

  • toArray<T>(t: T | T[]): T[]

Const toArray

Const toBoolean

  • toBoolean<T>(input: T): boolean | undefined

Const toNumber

  • toNumber<T>(input: T, converter?: (s: string) => number): number | undefined
  • Cast input to number, This supported by list below

    1. undefined | null => return undefined
    2. boolean => return 1 if true; otherwise, return 0
    3. string => return by converter function

    Type parameters

    • T: any = unknown

    Parameters

    • input: T

      input data on any type

    • Default value converter: (s: string) => number = parseFloat

      parseFloat or parseInt, applied only when input is string. (default is parseFloat())

        • (s: string): number
        • Parameters

          • s: string

          Returns number

    Returns number | undefined

Const toOptional

  • toOptional<T>(input: Optional<T>): T | undefined
  • remove null possiblity and return as undefined instead

    Type parameters

    • T: any = unknown

    Parameters

    • input: Optional<T>

      input as any type and undefined | null

    Returns T | undefined

    input if input is exist; otherwise, return undefined. This function will never return null

Const toString

  • toString<T>(input: T): string | undefined
  • Cast input to string. This supporting by listed below

    1. undefined | null => return undefined
    2. boolean | string => return as string
    3. number => return as fix digit not more than 6
    4. array => return as array syntax without space
    5. object => return by JSON.stringify()

    Type parameters

    • T: any = unknown

    Parameters

    • input: T

      input data on any type

    Returns string | undefined

Object literals

Const day

day: object

en

en: object

long

long: Day = enDayLong

short

short: Day = enDayShort

th

th: object

long

long: Day = thDayLong

short

short: Day = thDayShort

Const defaultMaskOption

defaultMaskOption: object

back

back: number = 15

enabled

enabled: true = true

front

front: number = 15

mask

mask: string = "*"

Const month

month: object

en

en: object

long

long: Month = enMonthLong

short

short: Month = enMonthShort

th

th: object

long

long: Month = thMonthLong

short

short: Month = thMonthShort

Generated using TypeDoc