Skip to content

Commit 3e96f34

Browse files
committed
feat: add execution time info
1 parent 351c8da commit 3e96f34

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@egoistdeveloper/twcss-to-sass",
3-
"version": "2.1.16",
3+
"version": "2.1.17",
44
"description": "HTML template to SASS converter for TailwindCSS",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

src/interfaces/converter-result.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export interface IConverterResult {
22
sass: string | null
33
html: string | null
4+
executionTime: string
45
}

src/twcss-to-sass.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,13 @@ export function convertToSass(
678678
): null | IConverterResult {
679679
styles = []
680680

681+
let startTime = 0,
682+
endTime = 0
683+
684+
if (typeof performance !== 'undefined') {
685+
startTime = performance.now()
686+
}
687+
681688
if (html && html.length) {
682689
if (options) {
683690
_defaultOptions = {
@@ -719,15 +726,25 @@ export function convertToSass(
719726
_defaultOptions.formatterOptions
720727
)
721728

729+
if (typeof performance !== 'undefined') {
730+
endTime = performance.now()
731+
}
732+
722733
return {
723734
sass: Utils.fixFomatterApplyIssue(formattedSassResult),
724735
html: formattedHtmlResult,
736+
executionTime: (endTime - startTime).toFixed(2) + ' ms',
725737
}
726738
}
727739

740+
if (typeof performance !== 'undefined') {
741+
endTime = performance.now()
742+
}
743+
728744
return {
729745
sass: sassTreeResult,
730746
html: htmlTreeResult,
747+
executionTime: (endTime - startTime).toFixed(2) + ' ms',
731748
}
732749
}
733750
}

0 commit comments

Comments
 (0)