mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Improved utils by removing old imports and fixing comments
This commit is contained in:
26
src/utils.ts
26
src/utils.ts
@@ -1,13 +1,8 @@
|
|||||||
import { EOL } from "os";
|
|
||||||
import type * as Schemas from "./schemas";
|
|
||||||
import { sep } from "path";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if an rgb value is compliant with CSS-like syntax
|
* Checks if an rgb value is compliant with CSS-like syntax
|
||||||
*
|
*
|
||||||
* @function isValidRGB
|
* @params value - string to analyze
|
||||||
* @params {String} value - string to analyze
|
* @returns true if valid rgb, false otherwise
|
||||||
* @returns {Boolean} True if valid rgb, false otherwise
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function isValidRGB(value?: string): boolean {
|
export function isValidRGB(value?: string): boolean {
|
||||||
@@ -26,6 +21,12 @@ export function isValidRGB(value?: string): boolean {
|
|||||||
return rgb.slice(1, 4).every((v) => Math.abs(Number(v)) <= 255);
|
return rgb.slice(1, 4).every((v) => Math.abs(Number(v)) <= 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acts as a wrapper for converting date to W3C string
|
||||||
|
* @param date
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
|
||||||
export function processDate(date: Date): string | null {
|
export function processDate(date: Date): string | null {
|
||||||
if (!(date instanceof Date)) {
|
if (!(date instanceof Date)) {
|
||||||
throw "Invalid date";
|
throw "Invalid date";
|
||||||
@@ -50,10 +51,6 @@ export function processDate(date: Date): string | null {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function dateToW3CString(date: Date) {
|
function dateToW3CString(date: Date) {
|
||||||
if (!(date instanceof Date)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// if it is NaN, it is "Invalid Date"
|
// if it is NaN, it is "Invalid Date"
|
||||||
if (isNaN(Number(date))) {
|
if (isNaN(Number(date))) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -90,11 +87,10 @@ function padMeTwo(original: string | number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a filter to arg0 to remove hidden files names (starting with dot)
|
* Removes hidden files from a list (those starting with dot)
|
||||||
*
|
*
|
||||||
* @function removeHidden
|
* @params from - list of file names
|
||||||
* @params {String[]} from - list of file names
|
* @return
|
||||||
* @return {String[]}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function removeHidden(from: Array<string>): Array<string> {
|
export function removeHidden(from: Array<string>): Array<string> {
|
||||||
|
|||||||
Reference in New Issue
Block a user