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

ducktors / storagebus / 13492066744

24 Feb 2025 06:24AM UTC coverage: 96.411%. Remained the same
13492066744

Pull #379

github

web-flow
Merge e709811f8 into 5ce2e2fdf
Pull Request #379: chore(actions): bump github/codeql-action from 3.28.9 to 3.28.10

260 of 290 branches covered (89.66%)

Branch coverage included in aggregate %.

546 of 546 relevant lines covered (100.0%)

62.1 hits per line

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

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

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

4✔
8
export type StorageOptions = AbstractStorageOptions
4✔
9

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

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

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

14✔
21
    this.bucket.set(_key, await this.toBuffer(fileReadable))
14✔
22
    return _key
14✔
23
  }
32✔
24

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

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

4✔
36
    // biome-ignore lint/style/noNonNullAssertion: <explanation>
4✔
37
    return Readable.from(this.bucket.get(_key)!)
4✔
38
  }
18✔
39

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

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

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

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