Skip to content

MiscUtils

Wyatt Greenway edited this page Dec 13, 2022 · 1 revision

namespace MiscUtils

import var { Utils: { MiscUtils } } = require('mythix-orm');

MiscUtils utilities provide some miscellaneous utility functions for assisting with some common operations.

function collect(
    iterator: async * iterator,
): Promise<Array<any>>
📜

When provided an async iterator, collect all results from the iterator until the iterator is exhausted.

Arguments:

  • iterator: async * iterator

    The async generator iterator to collect items from.

Return value: Promise<Array<any>>

Return the collected results as an array.


function valueToDateTime(
    value: number | string | Date | DateTime,
    format?: string,
): DateTime
📜

Take a timestamp, a string, a Date instance, or a Luxon DateTime instance and convert the input to a Luxon DateTime instance.

Arguments:

  • value: number | string | Date | DateTime

    The value to use to create a new Luxon DateTime instance. If this is a number or bigint, then it will be assumed this is a timestamp, and the provided format will be ignored. If this is a string, the provided format will be used to parse it into a DateTime instance. If this is a Date instance, then it will be converted to a Luxon DateTime instance. A Luxon DateTime instance will simply be returned.

  • format?: string

    The Luxon DateTime format used to parse the date/time if the provided value is a string. This is only required if the format is something that Luxon doesn't natively understand (i.e. an ISO format).

Return value: DateTime

The newly created Luxon DateTime instance. If a Luxon DateTime instance was provided as the value argument, then it will simply be returned.


Clone this wiki locally