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

ducktors / storagebus / 23181647159

17 Mar 2026 06:33AM UTC coverage: 97.059%. Remained the same
23181647159

Pull #499

github

web-flow
Merge 174428cc7 into 1936bd766
Pull Request #499: chore(actions): bump github/codeql-action from 4.32.6 to 4.33.0

443 of 473 branches covered (93.66%)

Branch coverage included in aggregate %.

547 of 547 relevant lines covered (100.0%)

69.1 hits per line

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

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

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

6✔
8
export type StorageOptions = AbstractStorageOptions
6✔
9

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

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

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

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

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

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

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

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

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

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

8✔
61
    return _destKey
8✔
62
  }
8✔
63
}
20✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc