mirror of
https://github.com/kucherenko/jscpd.git
synced 2026-09-19 08:11:03 +08:00
64e471e2b0
Adds 92 new tests (178 → 270 total) with zero source-file modifications: - packages/finder: 13 new test files covering all reporters, subscribers, validators, hooks, utils, options, cloneFound, getFilesToDetect, and InFilesDetector; shared buildClone() factory helper - apps/jscpd: 3 new test files (options-unit, print, store) plus extensions to formats, modes, and options integration tests - vitest.config.ts added to both packages to restrict coverage.include to src/** only, eliminating bin/ and prism.js noise - Fixes 3 tokenizer bugs (trailing space in format lookup, tokenization edge cases) uncovered by the new format fixture suite - Adds fixture files for 40+ language formats to support formats.test.ts
37 lines
1.1 KiB
VB.net
37 lines
1.1 KiB
VB.net
Public Module DataUtils
|
|
|
|
Public Function ValidateInput(ByVal value As String) As Boolean
|
|
If String.IsNullOrWhiteSpace(value) Then
|
|
Return False
|
|
End If
|
|
If value.Length > 255 Then
|
|
Return False
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Public Function ParseIntSafe(ByVal s As String) As Integer?
|
|
Dim result As Integer
|
|
If Integer.TryParse(s, result) Then
|
|
Return result
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
Public Function FilterActive(Of T)(ByVal items As IEnumerable(Of T),
|
|
ByVal predicate As Func(Of T, Boolean)) As IEnumerable(Of T)
|
|
Return items.Where(predicate)
|
|
End Function
|
|
|
|
Public Function MapItems(Of T, U)(ByVal items As IEnumerable(Of T),
|
|
ByVal transform As Func(Of T, U)) As IEnumerable(Of U)
|
|
Return items.Select(transform)
|
|
End Function
|
|
|
|
' File-specific: sum values
|
|
Public Function SumValues(ByVal items As IEnumerable(Of Integer)) As Integer
|
|
Return items.Sum()
|
|
End Function
|
|
|
|
End Module
|