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

ducktors / storagebus / 23181687145

17 Mar 2026 06:34AM UTC coverage: 97.059%. Remained the same
23181687145

push

github

web-flow
Merge pull request #498 from ducktors/dependabot/github_actions/step-security/harden-runner-2.16.0

chore(actions): bump step-security/harden-runner from 2.15.1 to 2.16.0

443 of 473 branches covered (93.66%)

Branch coverage included in aggregate %.

547 of 547 relevant lines covered (100.0%)

75.89 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'
8!
2

8✔
3
import {
8✔
4
  Storage as AbstractStorage,
10✔
5
  type AbstractStorageOptions,
10✔
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

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

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

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

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

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

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

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

30✔
45
  async copy(key: string, destKey: string): Promise<string> {
34✔
46
    const _key = this.sanitize(key)
22✔
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