@typeolymp/utils 0.1.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/package.json +19 -0
- package/src/enums/Color.ts +11 -0
- package/src/enums/Country.ts +4 -0
- package/src/enums/CourseTranslation.ts +4 -0
- package/src/enums/KeyboardLayout.ts +9 -0
- package/src/enums/Locale.ts +8 -0
- package/src/enums/Medal.ts +5 -0
- package/src/enums/Plan.ts +4 -0
- package/src/enums/TextTopic.ts +11 -0
- package/src/enums/index.ts +8 -0
- package/src/expressions/hasCapitalLetter.ts +5 -0
- package/src/expressions/hasNumber.ts +5 -0
- package/src/expressions/hasSpecialCharacter.ts +7 -0
- package/src/expressions/index.ts +6 -0
- package/src/expressions/isStrongPassword.ts +7 -0
- package/src/expressions/isValidEmail.ts +7 -0
- package/src/expressions/isValidUsername.ts +7 -0
- package/src/index.ts +3 -0
- package/src/parsers/getCountryByLocale.ts +10 -0
- package/src/parsers/getCourseTranslationByLocale.ts +15 -0
- package/src/parsers/getKeyboardLayoutByLocale.ts +15 -0
- package/src/parsers/getLanguageCodeByLocale.ts +3 -0
- package/src/parsers/getNativeLanguageByLocale.ts +15 -0
- package/src/parsers/index.ts +5 -0
- package/tsconfig.json +15 -0
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@typeolymp/utils",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"author": "TypeOlymp",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsc -p .",
|
|
7
|
+
"refresh": "rm -rf ./node_modules ./package-lock.json && npm install",
|
|
8
|
+
"prepublishOnly": "npm run build"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "restricted"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/node": "^18.16.0",
|
|
15
|
+
"ts-node": "^10.9.1",
|
|
16
|
+
"tslint": "^6.1.3",
|
|
17
|
+
"typescript": "^5.0.4"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const isValidEmail = (email: string): boolean => {
|
|
2
|
+
const regex = new RegExp(
|
|
3
|
+
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
4
|
+
);
|
|
5
|
+
|
|
6
|
+
return regex.test(email);
|
|
7
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Locale, CourseTranslation } from "../enums";
|
|
2
|
+
|
|
3
|
+
export const getCourseTranslationByLocale = (locale: Locale) => {
|
|
4
|
+
const courseTranslations: { [key in Locale]: CourseTranslation } = {
|
|
5
|
+
"nl-NL": CourseTranslation.NL_NL,
|
|
6
|
+
"nl-BE": CourseTranslation.NL_NL,
|
|
7
|
+
// "en-GB": KeyboardLayout.QWERTY_UK,
|
|
8
|
+
// "en-US": KeyboardLayout.QWERTY_US,
|
|
9
|
+
// "fr-BE": KeyboardLayout.AZERTY_FR,
|
|
10
|
+
// "fr-FR": KeyboardLayout.AZERTY_FR,
|
|
11
|
+
// "de-DE": KeyboardLayout.QWERTZ_DE,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return courseTranslations[locale];
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Locale, KeyboardLayout } from "../enums";
|
|
2
|
+
|
|
3
|
+
export const getKeyboardLayoutByLocale = (locale: Locale) => {
|
|
4
|
+
const keyboardLayouts: { [key in Locale]: KeyboardLayout } = {
|
|
5
|
+
"nl-NL": KeyboardLayout.QWERTY_NL,
|
|
6
|
+
"nl-BE": KeyboardLayout.AZERTY_BE,
|
|
7
|
+
// "en-GB": KeyboardLayout.QWERTY_UK,
|
|
8
|
+
// "en-US": KeyboardLayout.QWERTY_US,
|
|
9
|
+
// "fr-BE": KeyboardLayout.AZERTY_FR,
|
|
10
|
+
// "fr-FR": KeyboardLayout.AZERTY_FR,
|
|
11
|
+
// "de-DE": KeyboardLayout.QWERTZ_DE,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return keyboardLayouts[locale];
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Locale } from "../enums";
|
|
2
|
+
|
|
3
|
+
export const getNativeLanguageByLocale = (locale: Locale) => {
|
|
4
|
+
const nativeLanguages: { [key in Locale]: string } = {
|
|
5
|
+
"nl-NL": "Nederlands",
|
|
6
|
+
"nl-BE": "Nederlands (BE)",
|
|
7
|
+
// "en-GB": "English (UK)",
|
|
8
|
+
// "en-US": "English (US)",
|
|
9
|
+
// "fr-BE": "Français (BE)",
|
|
10
|
+
// "fr-FR": "Français",
|
|
11
|
+
// "de-DE": "Deutsch",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return nativeLanguages[locale];
|
|
15
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "src",
|
|
4
|
+
"sourceMap": true,
|
|
5
|
+
"target": "ES5",
|
|
6
|
+
"module": "CommonJS",
|
|
7
|
+
"lib": ["ES2019", "DOM"],
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"outDir": "build",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"types": ["node"],
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"resolveJsonModule": true
|
|
14
|
+
}
|
|
15
|
+
}
|