@almighty-shogun/utils 1.4.3 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -21
- package/dist/containsRoutePrefix.js +1 -1
- package/dist/formatCurrency.d.ts.map +1 -1
- package/dist/formatCurrency.js +3 -1
- package/dist/formatDate.d.ts +1 -1
- package/dist/formatDate.d.ts.map +1 -1
- package/dist/formatDate.js +5 -1
- package/dist/formatDateTime.d.ts +1 -1
- package/dist/formatDateTime.d.ts.map +1 -1
- package/dist/formatDateTime.js +8 -2
- package/dist/formatFullDate.d.ts.map +1 -1
- package/dist/formatFullDate.js +5 -1
- package/dist/formatHour.d.ts +1 -1
- package/dist/formatHour.d.ts.map +1 -1
- package/dist/formatHour.js +6 -2
- package/dist/formatMonth.d.ts +1 -1
- package/dist/formatMonth.d.ts.map +1 -1
- package/dist/formatMonth.js +5 -1
- package/dist/formatNumber.d.ts.map +1 -1
- package/dist/formatNumber.js +3 -1
- package/dist/formatPercentage.d.ts.map +1 -1
- package/dist/formatPercentage.js +3 -1
- package/dist/formatTime.d.ts +1 -1
- package/dist/formatTime.d.ts.map +1 -1
- package/dist/formatTime.js +6 -2
- package/dist/formatWeekday.d.ts +1 -1
- package/dist/formatWeekday.d.ts.map +1 -1
- package/dist/formatWeekday.js +5 -1
- package/dist/hasCurrentRoute.js +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/internal/getCorrectDateTime.d.ts +3 -0
- package/dist/internal/getCorrectDateTime.d.ts.map +1 -0
- package/dist/internal/getCorrectDateTime.js +4 -0
- package/dist/internal/getCorrectLocale.d.ts +2 -0
- package/dist/internal/getCorrectLocale.d.ts.map +1 -0
- package/dist/internal/getCorrectLocale.js +3 -0
- package/dist/internal/getCurrentRouteName.d.ts.map +1 -0
- package/dist/isBeforeNow.d.ts +3 -0
- package/dist/isBeforeNow.d.ts.map +1 -0
- package/dist/isBeforeNow.js +6 -0
- package/dist/isCurrentRoute.js +1 -1
- package/package.json +2 -3
- package/src/containsRoutePrefix.ts +1 -1
- package/src/formatCurrency.ts +5 -1
- package/src/formatDate.ts +7 -2
- package/src/formatDateTime.ts +10 -3
- package/src/formatFullDate.ts +6 -1
- package/src/formatHour.ts +7 -2
- package/src/formatMonth.ts +7 -2
- package/src/formatNumber.ts +5 -1
- package/src/formatPercentage.ts +5 -1
- package/src/formatTime.ts +7 -2
- package/src/formatWeekday.ts +7 -2
- package/src/hasCurrentRoute.ts +1 -1
- package/src/index.ts +2 -4
- package/src/internal/getCorrectDateTime.ts +5 -0
- package/src/internal/getCorrectLocale.ts +3 -0
- package/src/isBeforeNow.ts +8 -0
- package/src/isCurrentRoute.ts +1 -1
- package/dist/axiosHttpLog.d.ts +0 -8
- package/dist/axiosHttpLog.d.ts.map +0 -1
- package/dist/axiosHttpLog.js +0 -4
- package/dist/axiosInstancesRegister.d.ts +0 -19
- package/dist/axiosInstancesRegister.d.ts.map +0 -1
- package/dist/axiosInstancesRegister.js +0 -20
- package/dist/getCurrentRouteName.d.ts.map +0 -1
- package/src/axiosHttpLog.ts +0 -11
- package/src/axiosInstancesRegister.ts +0 -41
- /package/dist/{getCurrentRouteName.d.ts → internal/getCurrentRouteName.d.ts} +0 -0
- /package/dist/{getCurrentRouteName.js → internal/getCurrentRouteName.js} +0 -0
- /package/src/{getCurrentRouteName.ts → internal/getCurrentRouteName.ts} +0 -0
package/README.md
CHANGED
|
@@ -5,27 +5,6 @@ A small package that contains common utilities used in all my projects.
|
|
|
5
5
|
## 📃 Prerequisites
|
|
6
6
|
- **[Node.js](https://nodejs.org/en/)**: >= v23.11.1
|
|
7
7
|
|
|
8
|
-
## 💻 Installation
|
|
9
|
-
|
|
10
|
-
### Step 1
|
|
11
|
-
Install the package using your package manager of choice.
|
|
12
|
-
```shell
|
|
13
|
-
bun add @almighty-shogun/utils
|
|
14
|
-
yarn add @almighty-shogun/utils
|
|
15
|
-
npm install @almighty-shogun/utils
|
|
16
|
-
pnpm install @almighty-shogun/utils
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Step 2
|
|
20
|
-
Import a utility function from the package and use it.
|
|
21
|
-
```ts
|
|
22
|
-
import { getWeather } from '@almighty-shogun/utils'
|
|
23
|
-
|
|
24
|
-
const weatherData = await getWeather(52.374, 4.8897);
|
|
25
|
-
|
|
26
|
-
console.log(`Current weather in Amsterdam: ${weatherData.current.temperature.current} °C`);
|
|
27
|
-
```
|
|
28
|
-
|
|
29
8
|
## 📦 Building
|
|
30
9
|
- Use the command `bun install` in the root directory to install the required dependencies.
|
|
31
10
|
- Run `bun --cwd packages/utils build` to build the package.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatCurrency.d.ts","sourceRoot":"","sources":["../src/formatCurrency.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatCurrency.d.ts","sourceRoot":"","sources":["../src/formatCurrency.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAUlF"}
|
package/dist/formatCurrency.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
1
2
|
export default function (value, currency, locale) {
|
|
2
|
-
|
|
3
|
+
const localization = getCorrectLocale(locale);
|
|
4
|
+
return new Intl.NumberFormat(localization, {
|
|
3
5
|
style: "currency",
|
|
4
6
|
currency: currency ?? "EUR",
|
|
5
7
|
currencyDisplay: "symbol",
|
package/dist/formatDate.d.ts
CHANGED
package/dist/formatDate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../src/formatDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../src/formatDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAS5E"}
|
package/dist/formatDate.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
1
3
|
export default function (date, locale) {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
year: "numeric",
|
|
4
8
|
month: "long",
|
|
5
9
|
day: "numeric"
|
package/dist/formatDateTime.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatDateTime.d.ts","sourceRoot":"","sources":["../src/formatDateTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatDateTime.d.ts","sourceRoot":"","sources":["../src/formatDateTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAW5E"}
|
package/dist/formatDateTime.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
1
3
|
export default function (date, locale) {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
day: "numeric",
|
|
4
8
|
weekday: "long",
|
|
5
|
-
month: "long"
|
|
9
|
+
month: "long",
|
|
10
|
+
hour: "2-digit",
|
|
11
|
+
minute: "2-digit"
|
|
6
12
|
});
|
|
7
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatFullDate.d.ts","sourceRoot":"","sources":["../src/formatFullDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatFullDate.d.ts","sourceRoot":"","sources":["../src/formatFullDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAShE"}
|
package/dist/formatFullDate.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
1
3
|
export default function (date, locale) {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
day: "numeric",
|
|
4
8
|
weekday: "long",
|
|
5
9
|
month: "long"
|
package/dist/formatHour.d.ts
CHANGED
package/dist/formatHour.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatHour.d.ts","sourceRoot":"","sources":["../src/formatHour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatHour.d.ts","sourceRoot":"","sources":["../src/formatHour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAO5E"}
|
package/dist/formatHour.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
3
|
+
export default function (date, locale) {
|
|
4
|
+
const dateTime = getCorrectDateTime(date);
|
|
5
|
+
const localization = getCorrectLocale(locale);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
hour: "2-digit"
|
|
4
8
|
});
|
|
5
9
|
}
|
package/dist/formatMonth.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatMonth.d.ts","sourceRoot":"","sources":["../src/formatMonth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatMonth.d.ts","sourceRoot":"","sources":["../src/formatMonth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,GAAE,OAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOpG"}
|
package/dist/formatMonth.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
1
3
|
export default function (date, isLong = true, locale) {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
month: isLong ? "long" : "short",
|
|
4
8
|
});
|
|
5
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatNumber.d.ts","sourceRoot":"","sources":["../src/formatNumber.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatNumber.d.ts","sourceRoot":"","sources":["../src/formatNumber.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOrF"}
|
package/dist/formatNumber.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
1
2
|
export default function (value, decimals = 2, locale) {
|
|
2
|
-
|
|
3
|
+
const localization = getCorrectLocale(locale);
|
|
4
|
+
return new Intl.NumberFormat(localization, {
|
|
3
5
|
maximumFractionDigits: decimals,
|
|
4
6
|
minimumFractionDigits: decimals
|
|
5
7
|
}).format(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatPercentage.d.ts","sourceRoot":"","sources":["../src/formatPercentage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatPercentage.d.ts","sourceRoot":"","sources":["../src/formatPercentage.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ/D"}
|
package/dist/formatPercentage.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
1
2
|
export default function (value, locale) {
|
|
2
|
-
|
|
3
|
+
const localization = getCorrectLocale(locale);
|
|
4
|
+
return new Intl.NumberFormat(localization, {
|
|
3
5
|
style: "percent",
|
|
4
6
|
maximumFractionDigits: 1,
|
|
5
7
|
minimumFractionDigits: 0
|
package/dist/formatTime.d.ts
CHANGED
package/dist/formatTime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatTime.d.ts","sourceRoot":"","sources":["../src/formatTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatTime.d.ts","sourceRoot":"","sources":["../src/formatTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ5E"}
|
package/dist/formatTime.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
3
|
+
export default function (date, locale) {
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
hour: "2-digit",
|
|
4
8
|
minute: "2-digit"
|
|
5
9
|
});
|
package/dist/formatWeekday.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatWeekday.d.ts","sourceRoot":"","sources":["../src/formatWeekday.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"formatWeekday.d.ts","sourceRoot":"","sources":["../src/formatWeekday.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,GAAE,OAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOpG"}
|
package/dist/formatWeekday.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale';
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime';
|
|
1
3
|
export default function (date, isLong = true, locale) {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
3
7
|
weekday: isLong ? "long" : "short",
|
|
4
8
|
});
|
|
5
9
|
}
|
package/dist/hasCurrentRoute.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export type { Weather, WeatherItem } from './internal/weather';
|
|
2
2
|
export { getCountry, getCountries } from './internal/localization';
|
|
3
|
-
export { default as axiosHttpLog } from './axiosHttpLog';
|
|
4
|
-
export { default as axiosInstancesRegister } from './axiosInstancesRegister';
|
|
5
3
|
export { default as containsRoutePrefix } from './containsRoutePrefix';
|
|
6
4
|
export { default as disableZoom } from './disableZoom';
|
|
7
5
|
export { default as formatCelsius } from './formatCelsius';
|
|
@@ -18,9 +16,9 @@ export { default as formatNumber } from './formatNumber';
|
|
|
18
16
|
export { default as formatPercentage } from './formatPercentage';
|
|
19
17
|
export { default as formatTime } from './formatTime';
|
|
20
18
|
export { default as formatWeekday } from './formatWeekday';
|
|
21
|
-
export { default as getCurrentRouteName } from './getCurrentRouteName';
|
|
22
19
|
export { default as getWeather } from './getWeather';
|
|
23
20
|
export { default as hasCurrentRoute } from './hasCurrentRoute';
|
|
24
|
-
export { default as
|
|
21
|
+
export { default as isBeforeNow } from './isBeforeNow';
|
|
25
22
|
export { default as isCurrentRoute } from './isCurrentRoute';
|
|
23
|
+
export { default as scrollToTop } from './scrollToTop';
|
|
26
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAElE,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAElE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { getCountry, getCountries } from './internal/localization';
|
|
2
|
-
export { default as axiosHttpLog } from './axiosHttpLog';
|
|
3
|
-
export { default as axiosInstancesRegister } from './axiosInstancesRegister';
|
|
4
2
|
export { default as containsRoutePrefix } from './containsRoutePrefix';
|
|
5
3
|
export { default as disableZoom } from './disableZoom';
|
|
6
4
|
export { default as formatCelsius } from './formatCelsius';
|
|
@@ -17,8 +15,8 @@ export { default as formatNumber } from './formatNumber';
|
|
|
17
15
|
export { default as formatPercentage } from './formatPercentage';
|
|
18
16
|
export { default as formatTime } from './formatTime';
|
|
19
17
|
export { default as formatWeekday } from './formatWeekday';
|
|
20
|
-
export { default as getCurrentRouteName } from './getCurrentRouteName';
|
|
21
18
|
export { default as getWeather } from './getWeather';
|
|
22
19
|
export { default as hasCurrentRoute } from './hasCurrentRoute';
|
|
23
|
-
export { default as
|
|
20
|
+
export { default as isBeforeNow } from './isBeforeNow';
|
|
24
21
|
export { default as isCurrentRoute } from './isCurrentRoute';
|
|
22
|
+
export { default as scrollToTop } from './scrollToTop';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCorrectDateTime.d.ts","sourceRoot":"","sources":["../../src/internal/getCorrectDateTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,GAAG,QAAQ,CAE7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCorrectLocale.d.ts","sourceRoot":"","sources":["../../src/internal/getCorrectLocale.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrentRouteName.d.ts","sourceRoot":"","sources":["../../src/internal/getCurrentRouteName.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,cAAc,MAAM,CAIjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isBeforeNow.d.ts","sourceRoot":"","sources":["../src/isBeforeNow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,GAAG,OAAO,CAI5D"}
|
package/dist/isCurrentRoute.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almighty-shogun/utils",
|
|
3
3
|
"description": "A small package that contains common utilities used in all my projects.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -37,8 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@types/luxon": "^3.7.1",
|
|
40
|
-
"axios": "^1.13.2",
|
|
41
40
|
"luxon": "^3.7.2",
|
|
42
|
-
"vue-router": "^4.6.
|
|
41
|
+
"vue-router": "^4.6.4"
|
|
43
42
|
}
|
|
44
43
|
}
|
package/src/formatCurrency.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
2
|
+
|
|
1
3
|
export default function (value: number, currency?: string, locale?: string): string {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
|
|
6
|
+
return new Intl.NumberFormat(localization, {
|
|
3
7
|
style: "currency",
|
|
4
8
|
currency: currency ?? "EUR",
|
|
5
9
|
currencyDisplay: "symbol",
|
package/src/formatDate.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime, locale?: string): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, locale?: string): string {
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
year: "numeric",
|
|
6
11
|
month: "long",
|
|
7
12
|
day: "numeric"
|
package/src/formatDateTime.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime, locale?: string): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, locale?: string): string {
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
day: "numeric",
|
|
6
11
|
weekday: "long",
|
|
7
|
-
month: "long"
|
|
12
|
+
month: "long",
|
|
13
|
+
hour: "2-digit",
|
|
14
|
+
minute: "2-digit"
|
|
8
15
|
});
|
|
9
16
|
}
|
package/src/formatFullDate.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
5
|
export default function (date: DateTime, locale?: string): string {
|
|
4
|
-
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
day: "numeric",
|
|
6
11
|
weekday: "long",
|
|
7
12
|
month: "long"
|
package/src/formatHour.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, locale?: string): string {
|
|
6
|
+
const dateTime = getCorrectDateTime(date);
|
|
7
|
+
const localization = getCorrectLocale(locale);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
hour: "2-digit"
|
|
6
11
|
});
|
|
7
12
|
}
|
package/src/formatMonth.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime, isLong: boolean = true, locale?: string): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, isLong: boolean = true, locale?: string): string {
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
month: isLong ? "long" : "short",
|
|
6
11
|
});
|
|
7
12
|
}
|
package/src/formatNumber.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
2
|
+
|
|
1
3
|
export default function (value: number, decimals: number = 2, locale?: string): string {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
|
|
6
|
+
return new Intl.NumberFormat(localization, {
|
|
3
7
|
maximumFractionDigits: decimals,
|
|
4
8
|
minimumFractionDigits: decimals
|
|
5
9
|
}).format(value);
|
package/src/formatPercentage.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
2
|
+
|
|
1
3
|
export default function (value: number, locale?: string): string {
|
|
2
|
-
|
|
4
|
+
const localization = getCorrectLocale(locale);
|
|
5
|
+
|
|
6
|
+
return new Intl.NumberFormat(localization, {
|
|
3
7
|
style: "percent",
|
|
4
8
|
maximumFractionDigits: 1,
|
|
5
9
|
minimumFractionDigits: 0
|
package/src/formatTime.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, locale?: string): string {
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
hour: "2-digit",
|
|
6
11
|
minute: "2-digit"
|
|
7
12
|
});
|
package/src/formatWeekday.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectLocale from './internal/getCorrectLocale'
|
|
3
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
2
4
|
|
|
3
|
-
export default function (date: DateTime, isLong: boolean = true, locale?: string): string {
|
|
4
|
-
|
|
5
|
+
export default function (date: DateTime|string|null, isLong: boolean = true, locale?: string): string {
|
|
6
|
+
const localization = getCorrectLocale(locale);
|
|
7
|
+
const dateTime = getCorrectDateTime(date);
|
|
8
|
+
|
|
9
|
+
return dateTime.setLocale(localization).toLocaleString({
|
|
5
10
|
weekday: isLong ? "long" : "short",
|
|
6
11
|
});
|
|
7
12
|
}
|
package/src/hasCurrentRoute.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export type { Weather, WeatherItem } from './internal/weather'
|
|
2
2
|
export { getCountry, getCountries } from './internal/localization'
|
|
3
3
|
|
|
4
|
-
export { default as axiosHttpLog } from './axiosHttpLog'
|
|
5
|
-
export { default as axiosInstancesRegister } from './axiosInstancesRegister'
|
|
6
4
|
export { default as containsRoutePrefix } from './containsRoutePrefix'
|
|
7
5
|
export { default as disableZoom } from './disableZoom'
|
|
8
6
|
export { default as formatCelsius } from './formatCelsius'
|
|
@@ -19,8 +17,8 @@ export { default as formatNumber } from './formatNumber'
|
|
|
19
17
|
export { default as formatPercentage } from './formatPercentage'
|
|
20
18
|
export { default as formatTime } from './formatTime'
|
|
21
19
|
export { default as formatWeekday } from './formatWeekday'
|
|
22
|
-
export { default as getCurrentRouteName } from './getCurrentRouteName'
|
|
23
20
|
export { default as getWeather } from './getWeather'
|
|
24
21
|
export { default as hasCurrentRoute } from './hasCurrentRoute'
|
|
25
|
-
export { default as
|
|
22
|
+
export { default as isBeforeNow } from './isBeforeNow'
|
|
26
23
|
export { default as isCurrentRoute } from './isCurrentRoute'
|
|
24
|
+
export { default as scrollToTop } from './scrollToTop'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DateTime } from 'luxon'
|
|
2
|
+
import getCorrectDateTime from './internal/getCorrectDateTime'
|
|
3
|
+
|
|
4
|
+
export default function (date: DateTime|string|null): boolean {
|
|
5
|
+
const dateTime = getCorrectDateTime(date);
|
|
6
|
+
|
|
7
|
+
return dateTime.toMillis() < DateTime.now().toMillis();
|
|
8
|
+
}
|
package/src/isCurrentRoute.ts
CHANGED
package/dist/axiosHttpLog.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axiosHttpLog.d.ts","sourceRoot":"","sources":["../src/axiosHttpLog.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAIjF"}
|
package/dist/axiosHttpLog.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { InternalAxiosRequestConfig, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
-
type RegisterInstance<Name extends string = string> = {
|
|
3
|
-
name: Name;
|
|
4
|
-
url: string;
|
|
5
|
-
responseInterceptors?: [
|
|
6
|
-
(response: any) => any,
|
|
7
|
-
(error: any) => any
|
|
8
|
-
];
|
|
9
|
-
requestInterceptors?: [
|
|
10
|
-
(config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig,
|
|
11
|
-
(error: any) => any
|
|
12
|
-
];
|
|
13
|
-
config?: AxiosRequestConfig;
|
|
14
|
-
};
|
|
15
|
-
export default function <const T extends readonly RegisterInstance[]>(instances: T): {
|
|
16
|
-
[K in T[number]['name']]: AxiosInstance;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=axiosInstancesRegister.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axiosInstancesRegister.d.ts","sourceRoot":"","sources":["../src/axiosInstancesRegister.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAE1F,KAAK,gBAAgB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI;IAClD,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,CAAC,EAAE;QACnB,CAAC,QAAQ,EAAE,GAAG,KAAK,GAAG;QACtB,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG;KACtB,CAAC;IACF,mBAAmB,CAAC,EAAE;QAClB,CAAC,MAAM,EAAE,0BAA0B,KAAK,0BAA0B;QAClE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG;KACtB,CAAC;IACF,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC/B,CAAA;AAED,MAAM,CAAC,OAAO,WAAU,KAAK,CAAC,CAAC,SAAS,SAAS,gBAAgB,EAAE,EAAE,SAAS,EAAE,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,aAAa;CAAE,CAuB9H"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
export default function (instances) {
|
|
3
|
-
const instancesMap = {};
|
|
4
|
-
instances.forEach(instance => {
|
|
5
|
-
const axiosInstance = axios.create({
|
|
6
|
-
baseURL: instance.url,
|
|
7
|
-
...instance.config
|
|
8
|
-
});
|
|
9
|
-
if (instance.responseInterceptors) {
|
|
10
|
-
const [onSuccess, onError] = instance.responseInterceptors;
|
|
11
|
-
axiosInstance.interceptors.response.use(onSuccess, onError);
|
|
12
|
-
}
|
|
13
|
-
if (instance.requestInterceptors) {
|
|
14
|
-
const [onSuccess, onError] = instance.requestInterceptors;
|
|
15
|
-
axiosInstance.interceptors.request.use(onSuccess, onError);
|
|
16
|
-
}
|
|
17
|
-
instancesMap[instance.name] = axiosInstance;
|
|
18
|
-
});
|
|
19
|
-
return instancesMap;
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getCurrentRouteName.d.ts","sourceRoot":"","sources":["../src/getCurrentRouteName.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,cAAc,MAAM,CAIjC"}
|
package/src/axiosHttpLog.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type AxiosData = {
|
|
2
|
-
status: number;
|
|
3
|
-
url: string;
|
|
4
|
-
message: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default function (name: string, data: AxiosData, isRejected: boolean): void {
|
|
8
|
-
const logMethod = isRejected ? console.error : console.info;
|
|
9
|
-
|
|
10
|
-
logMethod(`${name}: [HTTP ${data.status}] ${data.url} ${data.message}`);
|
|
11
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
import type { InternalAxiosRequestConfig, AxiosInstance, AxiosRequestConfig } from 'axios'
|
|
3
|
-
|
|
4
|
-
type RegisterInstance<Name extends string = string> = {
|
|
5
|
-
name: Name;
|
|
6
|
-
url: string;
|
|
7
|
-
responseInterceptors?: [
|
|
8
|
-
(response: any) => any,
|
|
9
|
-
(error: any) => any
|
|
10
|
-
];
|
|
11
|
-
requestInterceptors?: [
|
|
12
|
-
(config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig,
|
|
13
|
-
(error: any) => any
|
|
14
|
-
];
|
|
15
|
-
config?: AxiosRequestConfig;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default function<const T extends readonly RegisterInstance[]>(instances: T): { [K in T[number]['name']]: AxiosInstance } {
|
|
19
|
-
const instancesMap = {} as { [K in T[number]['name']]: AxiosInstance };
|
|
20
|
-
|
|
21
|
-
instances.forEach(instance => {
|
|
22
|
-
const axiosInstance = axios.create({
|
|
23
|
-
baseURL: instance.url,
|
|
24
|
-
...instance.config
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
if (instance.responseInterceptors) {
|
|
28
|
-
const [onSuccess, onError] = instance.responseInterceptors;
|
|
29
|
-
axiosInstance.interceptors.response.use(onSuccess, onError);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (instance.requestInterceptors) {
|
|
33
|
-
const [onSuccess, onError] = instance.requestInterceptors;
|
|
34
|
-
axiosInstance.interceptors.request.use(onSuccess, onError);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
instancesMap[instance.name as T[number]['name']] = axiosInstance;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return instancesMap;
|
|
41
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|