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

ducktors / storagebus / 21387139548

27 Jan 2026 06:33AM UTC coverage: 96.681%. Remained the same
21387139548

Pull #477

github

web-flow
Merge 2351d7b0f into 347cd867c
Pull Request #477: chore(actions): bump github/codeql-action from 4.31.11 to 4.32.0

356 of 387 branches covered (91.99%)

Branch coverage included in aggregate %.

547 of 547 relevant lines covered (100.0%)

41.31 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'
5!
2

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

5✔
8
export type StorageOptions = AbstractStorageOptions
5✔
9

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

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

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

37✔
21
    this.bucket.set(_key, await this.toBuffer(fileReadable))
10✔
22
    return _key
13✔
23
  }
22✔
24

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

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

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

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

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

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

6✔
61
    return _destKey
6✔
62
  }
6✔
63
}
12✔
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