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
35 lines
854 B
Plaintext
35 lines
854 B
Plaintext
processItems = (items) ->
|
|
items
|
|
.filter (item) -> item.active
|
|
.map (item) ->
|
|
id: item.id
|
|
name: item.name.toUpperCase()
|
|
value: item.value * 2
|
|
|
|
validateInput = (value) ->
|
|
return Error "Input cannot be empty" if not value
|
|
return Error "Input too long" if value.length > 255
|
|
return Ok value
|
|
|
|
fetchData = (url, options = {}) ->
|
|
defaults =
|
|
timeout: 30000
|
|
retries: 3
|
|
contentType: 'application/json'
|
|
config = Object.assign {}, defaults, options
|
|
fetch url, config
|
|
|
|
retryOnFailure = (maxAttempts, fn) ->
|
|
attempt = 0
|
|
loop
|
|
try
|
|
return fn()
|
|
catch err
|
|
attempt++
|
|
throw err if attempt >= maxAttempts
|
|
|
|
# File-specific: format products list
|
|
formatProducts = (products) ->
|
|
processItems products |> (items) ->
|
|
items.map (p) -> "#{p.id}: #{p.name} ($#{p.value})"
|