@dofiltra/helpers
Advanced tools
Comparing version 1.0.50 to 1.0.53
@@ -51,2 +51,8 @@ import type { TDodecoratorSettings, TResultError, TTrackMetadata } from '@dofiltra/types'; | ||
export declare const median: (arr: string[]) => number; | ||
export declare class MathHelper { | ||
static roundUp({ num, precision }: { | ||
num: number; | ||
precision: number; | ||
}): number; | ||
} | ||
export declare class TextHelper { | ||
@@ -93,2 +99,9 @@ static isHeadingTag: (tag: string) => boolean; | ||
}): string[]; | ||
static getShortcodes({ text }: { | ||
text: string; | ||
}): { | ||
shortcode: string; | ||
attributes: string; | ||
content: string; | ||
}[]; | ||
} | ||
@@ -257,7 +270,1 @@ export declare class SplitHelper { | ||
} | ||
export declare class MathHelper { | ||
static roundUp({ num, precision }: { | ||
num: number; | ||
precision: number; | ||
}): number; | ||
} |
@@ -106,2 +106,8 @@ /* tslint:disable:max-classes-per-file */ | ||
}; | ||
export class MathHelper { | ||
static roundUp({ num, precision }) { | ||
precision = Math.pow(10, precision); | ||
return Math.ceil(num * precision) / precision; | ||
} | ||
} | ||
//#endregion MATH | ||
@@ -229,2 +235,17 @@ //#region TEXT | ||
} | ||
static getShortcodes({ text }) { | ||
// Regex to match shortcodes | ||
const regex = /\[([a-zA-Z0-9_-]+)([^\]]*)\](?:([^[]*(?:\[(?!\/\1\])[^[]*\])*?)\[\/\1\])?/g; | ||
const shortcodes = []; | ||
let match; | ||
// Iterate over all matches | ||
while ((match = regex.exec(text)) !== null) { | ||
shortcodes.push({ | ||
shortcode: match[1], // Name of the shortcode | ||
attributes: match[2], // Attributes of the shortcode | ||
content: match[3] // Content inside the shortcode | ||
}); | ||
} | ||
return shortcodes; | ||
} | ||
} | ||
@@ -676,3 +697,5 @@ export class SplitHelper { | ||
currentLength -= microHtml.length; | ||
chunk += separator + microHtml; | ||
if (microHtml?.trim?.()) { | ||
chunk += separator + microHtml; | ||
} | ||
}); | ||
@@ -852,10 +875,2 @@ if (chunk) { | ||
//#endregion TIMELINE | ||
//#region MATH | ||
export class MathHelper { | ||
static roundUp({ num, precision }) { | ||
precision = Math.pow(10, precision); | ||
return Math.ceil(num * precision) / precision; | ||
} | ||
} | ||
//#endregion MATH | ||
//#region COMMON | ||
@@ -862,0 +877,0 @@ //#endregion COMMON |
{ | ||
"name": "@dofiltra/helpers", | ||
"version": "1.0.50", | ||
"version": "1.0.53", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111638
2126