@archoleat/validate-font-file-name 1.0.1 → 1.0.4
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/index.d.ts +21 -0
- package/index.js +1 -0
- package/package.json +1 -1
package/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The asynchronous function `validateFontFileName` validates
|
|
3
|
+
* if a given font file name matches a specific pattern.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} file - The `file` parameter in the `validateFontFileName`
|
|
6
|
+
* function is a string that represents the file name of a font file that
|
|
7
|
+
* you want to validate.
|
|
8
|
+
*
|
|
9
|
+
* @param {RegExp | string} regex - The `regex` parameter in the
|
|
10
|
+
* `validateFontFileName` function is used to provide a custom regular
|
|
11
|
+
* expression pattern for validating the font file name. If a custom
|
|
12
|
+
* regex pattern is not provided, the function uses a default pattern
|
|
13
|
+
* to validate the font file name.
|
|
14
|
+
*
|
|
15
|
+
* @returns The function `validateFontFileName` is returning a boolean value.
|
|
16
|
+
* It returns `true` if the file name matches the specified pattern,
|
|
17
|
+
* and `false` if it does not match.
|
|
18
|
+
*/
|
|
19
|
+
declare const validateFontFileName: (file: string, regex?: RegExp | string) => Promise<boolean>;
|
|
20
|
+
|
|
21
|
+
export { validateFontFileName as default };
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parse as N}from"node:path";import f from"chalk";const _=async(e,t="")=>{const o="[A-Z][a-z]",n=`^${o}+(${o}+)?`,E=["Thin","Hairline","ExtraLight","UltraLight","Light","Regular","Medium","SemiBold","DemiBold","Bold","ExtraBold","UltraBold","Black","Heavy","ExtraBlack","UltraBlack"].join("|"),c=["otf","ttf","woff","woff2"].join("|"),l=`(${n})`,r=`(${E})`,s=`(${c})$`,i=new RegExp(`${l}-${r}\\.${s}`),a=N(e).base,T=typeof t=="string"&&t!==""?new RegExp(t):t||i;return T.test(a)?!0:(console.error(f.red.bold(`'${a}' doesn't match with '${T}'.`)),!1)};export{_ as default};
|