Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "index"

Index

Type aliases

InSyncDate

InSyncDate: object

Defines time elapsed since Epoch, with up to microsecond precision.

Type declaration

  • day: number

    day of month

  • hours: number

    hour of day (0-23)

  • microseconds: number

    microseconds of millisecond (0, 999)

  • milliseconds: number

    milliseconds of second (0, 999)

  • minutes: number

    minutes of hour (0-59)

  • month: number

    month of year

  • offsetHours: number

    offset hours, negative or positive

  • offsetMinutes: number

    offset minutes, negative or positive

  • seconds: number

    seconds of minute (0-59)

  • year: number

    year

Variables

Const DATE_EXPRESSION

DATE_EXPRESSION: RegExp = /^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})\.?([0-9]{0,3})([0-9]{0,})?(Z|[-+]{1}[0-9]{2}:[0-9]{2})/

Regular expression used to validate input string for parseInSyncDate.

Const MEDIATIME_EXP

MEDIATIME_EXP: RegExp = /^([0-9]{2}):([0-5]{1}[0-9]{1}):([0-5]{1}[0-9]{1})(\.([0-9]{1,}))?$/

Regular expression used to test if a string is a media string.

Const padStart

padStart: function = R.curry((len: number, char: string, s: string): string =>s.padStart(len, char))

Pads a string to specified length using given character.

param

length to pad the string to.

param

character to use for padding.

param

string to pad.

Type declaration

    • <T>(...args: Cast<T, Gaps<Parameters<F>>>): GapsOf<T, Parameters<F>> extends infer G ? Cast<G, readonly any[]>["length"] extends infer L ? L extends 0 ? Return<F> : L extends 1 ? (...args: Cast<G, readonly any[]>) => Return<F> : Curry<(...args: Cast<G, readonly any[]>) => Return<F>> : never : never
    • Type parameters

      • T: Tuple

      Parameters

      • Rest ...args: Cast<T, Gaps<Parameters<F>>>

      Returns GapsOf<T, Parameters<F>> extends infer G ? Cast<G, readonly any[]>["length"] extends infer L ? L extends 0 ? Return<F> : L extends 1 ? (...args: Cast<G, readonly any[]>) => Return<F> : Curry<(...args: Cast<G, readonly any[]>) => Return<F>> : never : never

Const substr

substr: function = R.curry((start: number, end: number, s: string): string =>s.substr(start, end))

Type declaration

    • <T>(...args: Cast<T, Gaps<Parameters<F>>>): GapsOf<T, Parameters<F>> extends infer G ? Cast<G, readonly any[]>["length"] extends infer L ? L extends 0 ? Return<F> : L extends 1 ? (...args: Cast<G, readonly any[]>) => Return<F> : Curry<(...args: Cast<G, readonly any[]>) => Return<F>> : never : never
    • Type parameters

      • T: Tuple

      Parameters

      • Rest ...args: Cast<T, Gaps<Parameters<F>>>

      Returns GapsOf<T, Parameters<F>> extends infer G ? Cast<G, readonly any[]>["length"] extends infer L ? L extends 0 ? Return<F> : L extends 1 ? (...args: Cast<G, readonly any[]>) => Return<F> : Curry<(...args: Cast<G, readonly any[]>) => Return<F>> : never : never

Const timeUnit

timeUnit: function = R.curry((digits: number, input: number): string =>R.compose(padStart(digits, "0"), R.toString)(input))

Formats a number to a string of given digits, padded with leading 0's (example: timeUnit(3, 1) => "001")

param

number of digits for the unit.

param

input to format.

returns

Formatted time unit.

Type declaration

    • <T>(...args: Cast<T, Gaps<Parameters<F>>>): GapsOf<T, Parameters<F>> extends infer G ? Cast<G, readonly any[]>["length"] extends infer L ? L extends 0 ? Return<F> : L extends 1 ? (...args: Cast<G, readonly any[]>) => Return<F> : Curry<(...args: Cast<G, readonly any[]>) => Return<F>> : never : never
    • Type parameters

      • T: Tuple

      Parameters

      • Rest ...args: Cast<T, Gaps<Parameters<F>>>

      Returns GapsOf<T, Parameters<F>> extends infer G ? Cast<G, readonly any[]>["length"] extends infer L ? L extends 0 ? Return<F> : L extends 1 ? (...args: Cast<G, readonly any[]>) => Return<F> : Curry<(...args: Cast<G, readonly any[]>) => Return<F>> : never : never

Const toIntegerOr

toIntegerOr: function = R.curry((defaultVal: number, i: unknown): number => {if (typeof i === "string") {return parseInt(i, 10);}if (typeof i === "number") {return Math.floor(i);}return defaultVal;})

Type declaration

    • <T>(...args: Cast<T, Gaps<Parameters<F>>>): GapsOf<T, Parameters<F>> extends infer G ? Cast<G, readonly any[]>["length"] extends infer L ? L extends 0 ? Return<F> : L extends 1 ? (...args: Cast<G, readonly any[]>) => Return<F> : Curry<(...args: Cast<G, readonly any[]>) => Return<F>> : never : never
    • Type parameters

      • T: Tuple

      Parameters

      • Rest ...args: Cast<T, Gaps<Parameters<F>>>

      Returns GapsOf<T, Parameters<F>> extends infer G ? Cast<G, readonly any[]>["length"] extends infer L ? L extends 0 ? Return<F> : L extends 1 ? (...args: Cast<G, readonly any[]>) => Return<F> : Curry<(...args: Cast<G, readonly any[]>) => Return<F>> : never : never

Functions

createInSyncDate

  • Takes an optional partial InsyncDate object and returns an InSyncDate. If no argument is given, will return current time as InSyncDate (up to millisecond precision).

    Parameters

    Returns InSyncDate

createInSyncDateObj

  • Takes a partial InSyncDate and merges it with [[DATE_OBJ_DEFAULTS|default values]].

    Parameters

    Returns InSyncDate

createInSyncNowDate

Const formatDay

  • formatDay(__namedParameters: object): string
  • Formats a numeral date value (0-*) from a givenInSyncDate to a string like "01", "02", etc.

    Parameters

    • __namedParameters: object
      • day: number

    Returns string

Const formatHours

  • formatHours(__namedParameters: object): string
  • Formats a numeral hour notation (0-23) from a given InSyncDate to a string like "00", "01", etc.

    Parameters

    • __namedParameters: object
      • hours: number

    Returns string

Const formatMinutes

  • formatMinutes(__namedParameters: object): string
  • Formats a numeral minutes notation (0-59) from a given InSyncDate to a string like "00", "01", etc.

    Parameters

    • __namedParameters: object
      • minutes: number

    Returns string

Const formatMonth

  • formatMonth(__namedParameters: object): string
  • Formats a numeral month value (0-11) from a given InSyncDate to a string like "01", "02", etc.

    Parameters

    • __namedParameters: object
      • month: number

    Returns string

Const formatOffset

  • formatOffset(__namedParameters: object): string
  • Formats offset of a given InSyncDate into an ISO8601 offset string like "+01:00", "-01:00", "Z", etc.

    Parameters

    • __namedParameters: object
      • hours: number
      • minutes: number

    Returns string

Const formatSecondFraction

  • Formats a numeral notation of milliseconds and microseconds from a given [[InSybncDate]] into a string like ".000001", ".123", etc. It will attempt to remove trailing zeroes. So for example .123000 will be truncated to .123.

    Parameters

    Returns string

Const formatSeconds

  • formatSeconds(__namedParameters: object): string
  • Formats a numeral seconds notation (0-59) from a given InSyncDate to a string like "00", "01", etc.

    Parameters

    • __namedParameters: object
      • seconds: number

    Returns string

fromDate

  • Takes a date and returns an InSyncDate from it.

    Parameters

    • date: Date

    Returns InSyncDate

fromMediaTime

  • Takes a media time and returns an InSyncDate. Note that this will have year, month and day set to 0

    throws

    If input string is not valid.

    input

    The string to parse.

    Parameters

    • input: string

    Returns InSyncDate

fromMicro

  • Takes a timestamp in microseconds and returns an InSyncDate.

    Parameters

    • micro: number

      microseconds elapsed since Epoch.

    Returns InSyncDate

isMediaTime

  • isMediaTime(input: string): boolean
  • Takes a string, and returns true if it is a media time like "01:12.44.123". Otherwise returns false;

    Parameters

    • input: string

      String to test.

    Returns boolean

parseInSyncDate

  • Parses a date string into an InSyncDate.

    throws

    If input string is not valid.

    Parameters

    • dateStr: string

    Returns InSyncDate

parseOffset

  • parseOffset(input: string): Pick<InSyncDate, "offsetHours" | "offsetMinutes">
  • Parses a string like "+01:00" to the offsetHours and offsetMinutes of InSyncDate.

    Parameters

    • input: string

      Offset string like "+01:00" or "-01:00"

    Returns Pick<InSyncDate, "offsetHours" | "offsetMinutes">

toDate

  • Takes an InSyncDate and creates a Date out of it (loses microsecond precision).

    Parameters

    Returns Date

toISO8601

  • Takes a (partial) InSyncDate and returns an ISO8601 string like "2019-10-11T11:55:38.511186Z"

    Parameters

    • input: Partial<InSyncDate>

      The (partial) InSyncDate to convert to an ISO8601 string.

    Returns string

Const toInt

  • toInt(i: string): number
  • Parses a string to an integer, functional equivalent of parseInt(x, 10

    Parameters

    • i: string

    Returns number

toMediaTime

  • Takes a (partial) InSyncDate and returns a media time like "01:12:44.124". Note that this only displays the hours, minutes, seconds, milliseconds of a date, the rest is not visible.

    Parameters

    Returns string

toMicro

  • Takes an InSyncDate and returns a microsecond timestamp from it (microseconds since Epoch).

    Parameters

    Returns number

Generated using TypeDoc