Source: main.js

/*
 * weekstart
 * https://github.com/gamtiq/weekstart
 */

/**
 * Library to get first day of week.
 * 
 * Uses data from {@link module:langRegionMap langRegionMap.js} and
 * {@link module:regionDayMap regionDayMap.js}.
 * 
 * @module main
 */

import * as api from './api';
import langRegionMap from './langRegionMap';
import regionDayMap from './regionDayMap';

/**
 * Return first day of week for country/region code.
 *
 * Based on data from:
 * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)
 * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html)
 *
 * @example
 * getWeekStartByRegion('PNG');   // 1
 * getWeekStartByRegion('qa');   // 6
 * getWeekStartByRegion(462);   // 5
 *
 * @param {number | string} regionCode
 *      ISO 3166 Alpha-2, Alpha-3 or numeric code.
 * @return {number}
 *      Code of first day of week for the given country/region code:
 *      0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
 * @alias module:main.getWeekStartByRegion
 * @see module:api.getWeekStartByRegion
 */
export function getWeekStartByRegion(regionCode) {
    return api.getWeekStartByRegion(regionCode, regionDayMap);
}

/**
 * Return first day of week for locale identifier.
 *
 * Based on data from:
 * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html)
 * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html)
 * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)
 * - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers)
 *
 * @example
 * getWeekStartByLocale('no');   // 1
 * getWeekStartByLocale('Pa_Guru');   // 0
 * getWeekStartByLocale('fr-DZ');   // 6
 *
 * @param {string} locale
 *      Locale identifier.
 * @return {number}
 *      Code of first day of week for the given locale identifier:
 *      0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
 * @alias module:main.getWeekStartByLocale
 * @see module:api.getWeekStartByLocale
 */
export function getWeekStartByLocale(locale) {
    return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap);
}