• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nicholaswmin / automap / 9855082686

09 Jul 2024 10:08AM UTC coverage: 92.515% (+0.03%) from 92.486%
9855082686

Pull #11

github

web-flow
Merge a3d5d9db2 into e6bd4a332
Pull Request #11: Benchmark

459 of 463 branches covered (99.14%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 1 file covered. (0.0%)

2013 of 2209 relevant lines covered (91.13%)

18.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.57
/src/utils.js
1
import crypto from 'node:crypto'
1✔
2
import ioredis from 'ioredis'
1✔
3

1✔
4
// Number
1✔
5

1✔
6
const round = num => Math.round((num + Number.EPSILON) * 100) / 100
1✔
7

1✔
8
// Randoms
1✔
9

1✔
10
const randomID = () => crypto.randomUUID().split('-').at(-1)
1✔
11
const randomNum = (min = -300, max = 600) =>
1✔
12
  round(Math.random() * (max - min) + min)
×
13

1✔
14
// Payload
1✔
15

1✔
16
const payloadKB = kb => {
1✔
17
  return JSON.stringify({
×
18
    ...JSON.parse(`["Path",{"applyMatrix":true,"data":{"guid":"${randomID()}"},"segments":[${`[${randomNum()}, ${randomNum()}]`}],"strokeColor":[0.6141276000612308,0.0073291996604683, 0.20695908748200353],"strokeWidth":2,"strokeCap":"round","strokeJoin":"round"}]`),
×
19
    segments: Array.from({
×
20
      length: 63 * kb
×
21
    }, (_, i) => [ randomNum(), randomNum() ])
×
22
  })
×
23
}
×
24

1✔
25
// size value converter
1✔
26

1✔
27
const toMB = bytes => round(bytes / 1000 / 1000)
1✔
28

1✔
29
// Size of
1✔
30

1✔
31
const sizeKB = item => round(sizeBytes(item) / 1000)
1✔
32
const sizeBytes = item => {
1✔
33
  if (typeof item === 'undefined' || !item)
×
34
    throw new Error('passed item is falsy')
×
35

×
36
  const str = typeof item === 'string' ? item : JSON.stringify(item)
×
37

×
38
  return round(new Blob([str]).size)
×
39
}
×
40

1✔
41
// Redis
1✔
42

1✔
43
const createRedis = () => ['development', undefined]
1✔
44
  .includes(process.env.NODE_ENV) ?
×
45
    new ioredis() :
×
46
    new ioredis({
×
47
      url: process.env.REDIS_URL,
×
48
      tlsOptions: { tls: { rejectUnauthorized: false } }
×
49
    })
×
50

1✔
51

1✔
52
const utils = {
1✔
53
  ioredis: createRedis,
1✔
54

1✔
55
  round,
1✔
56

1✔
57
  randomID,
1✔
58
  randomNum,
1✔
59

1✔
60
  payloadKB,
1✔
61

1✔
62
  toMB,
1✔
63

1✔
64
  sizeKB
1✔
65
}
1✔
66

1✔
67
export { utils }
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc