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

ducktors / storagebus / 21741228135

06 Feb 2026 06:33AM UTC coverage: 96.681%. Remained the same
21741228135

Pull #480

github

web-flow
Merge 6925a87c8 into b94a37f84
Pull Request #480: chore(actions): bump github/codeql-action from 4.32.1 to 4.32.2

356 of 387 branches covered (91.99%)

Branch coverage included in aggregate %.

547 of 547 relevant lines covered (100.0%)

75.88 hits per line

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

96.33
/packages/memory/src/memory.ts
1
import { Readable } from 'node:stream'
8!
2

8✔
3
import {
8✔
4
  Storage as AbstractStorage,
8✔
5
  type AbstractStorageOptions,
8✔
6
} from '@ducktors/storagebus-abstract'
8✔
7

8✔
8
export type StorageOptions = AbstractStorageOptions
8✔
9

8✔
10
export class Storage extends AbstractStorage {
8✔
11
  protected bucket: Map<string, Buffer>
20✔
12

32✔
13
  constructor(opts: StorageOptions) {
20✔
14
    super({ debug: opts?.debug, logger: opts?.logger })
20✔
15
    this.bucket = new Map()
40✔
16
  }
40✔
17

40✔
18
  async write(key: string, fileReadable: Readable): Promise<string> {
40!
19
    const _key = this.sanitize(key)
18✔
20

54✔
21
    this.bucket.set(_key, await this.toBuffer(fileReadable))
18✔
22
    return _key
22✔
23
  }
40✔
24

42✔
25
  async exists(key: string): Promise<boolean> {
24✔
26
    const _key = this.sanitize(key)
30✔
27
    return this.bucket.has(_key)
26✔
28
  }
26✔
29

20✔
30
  async read(key: string): Promise<Readable> {
20✔
31
    const _key = this.sanitize(key)
14✔
32
    if (!(await this.exists(_key))) {
10✔
33
      throw new Error(`Missing ${_key} from Storagebus Memory`)
12✔
34
    }
12✔
35

12✔
36
    // biome-ignore lint/style/noNonNullAssertion: TBD
12!
37
    return Readable.from(this.bucket.get(_key)!)
12✔
38
  }
26✔
39

36✔
40
  async remove(key: string): Promise<void> {
36✔
41
    const _key = this.sanitize(key)
22✔
42
    this.bucket.delete(_key)
22✔
43
  }
22✔
44

32✔
45
  async copy(key: string, destKey: string): Promise<string> {
32✔
46
    const _key = this.sanitize(key)
20✔
47
    const file = this.bucket.has(_key)
20✔
48
    if (!file) {
20!
49
      throw new Error(`Missing ${_key} from Storagebus Memory`)
18✔
50
    }
24✔
51
    const _destKey = this.sanitize(destKey)
22✔
52
    // biome-ignore lint/style/noNonNullAssertion: TBD
12✔
53
    this.bucket.set(_destKey, this.bucket.get(_key)!)
10✔
54
    return _destKey
10✔
55
  }
10✔
56

20✔
57
  async move(key: string, destKey: string): Promise<string> {
32✔
58
    const _destKey = await this.copy(key, destKey)
20✔
59
    await this.remove(key)
10✔
60

10✔
61
    return _destKey
10✔
62
  }
10✔
63
}
22✔
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

© 2026 Coveralls, Inc