{"id":18862803,"url":"https://github.com/eik-lib/sink-memory","last_synced_at":"2026-05-31T08:00:56.682Z","repository":{"id":249819174,"uuid":"832651228","full_name":"eik-lib/sink-memory","owner":"eik-lib","description":"An in-memory Sink implementation for use in automated tests","archived":false,"fork":false,"pushed_at":"2026-05-30T20:50:12.000Z","size":481,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-05-30T22:19:53.333Z","etag":null,"topics":["eik","eik-sink"],"latest_commit_sha":null,"homepage":"https://eik.dev","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eik-lib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-23T12:57:29.000Z","updated_at":"2026-05-30T20:50:14.000Z","dependencies_parsed_at":"2025-01-01T05:26:20.039Z","dependency_job_id":"94700a1a-63e0-42a9-b0aa-06dcfbfa07b5","html_url":"https://github.com/eik-lib/sink-memory","commit_stats":null,"previous_names":["eik-lib/sink-memory"],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/eik-lib/sink-memory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fsink-memory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fsink-memory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fsink-memory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fsink-memory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eik-lib","download_url":"https://codeload.github.com/eik-lib/sink-memory/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fsink-memory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33723549,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eik","eik-sink"],"created_at":"2024-11-08T04:35:48.073Z","updated_at":"2026-05-31T08:00:56.662Z","avatar_url":"https://github.com/eik-lib.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @eik/sink-memory\n\nA Sink implementation that runs completely in memory, designed for automated tests.\n\n## Usage\n\n```sh\nnpm install @eik/sink-memory\n```\n\n```js\nimport { pipeline } from 'node:stream';\nimport express from 'express';\nimport Sink from '@eik/sink-memory';\n\nconst app = express();\nconst sink = new Sink();\n\napp.get('/file.js', async (req, res, next) =\u003e {\n    try {\n        const file = await sink.read('/path/to/file/file.js');\n        pipeline(file.stream, res, (error) =\u003e {\n            if (error) return next(error);\n        });\n    } catch (error) {\n        next(error);\n    }\n});\n\napp.listen(8000);\n```\n\n## API\n\nThe sink instance has the following API:\n\n### .write(filePath, contentType)\n\nMethod for writing a file to in-memory storage.\n\nThis method takes the following arguments:\n\n-   `filePath` - String - Path to the file to be stored - Required.\n-   `contentType` - String - The content type of the file - Required.\n\nResolves with a writable stream.\n\n```js\nimport { pipeline } from 'node:stream';\n\nconst fromStream = new SomeReadableStream();\nconst sink = new Sink({ ... });\n\ntry {\n    const file = await sink.write('/path/to/file/file.js', 'application/javascript');\n    pipeline(fromStream, file.stream, (error) =\u003e {\n        if (error) console.log(error);\n    });\n} catch (error) {\n    console.log(error);\n}\n```\n\n### .read(filePath)\n\nMethod for reading a file from storage.\n\nThis method takes the following arguments:\n\n-   `filePath` - String - Path to the file to be read - Required.\n\nResolves with a [ReadFile][read-file] object which holds metadata about\nthe file and a readable stream with the byte stream of the file on the\n`.stream` property.\n\n```js\nimport { pipeline } from 'node:stream';\n\nconst toStream = new SomeWritableStream();\nconst sink = new Sink({ ... });\n\ntry {\n    const file = await sink.read('/path/to/file/file.js');\n    pipeline(file.stream, toStream, (error) =\u003e {\n        if (error) console.log(error);\n    });\n} catch (error) {\n    console.log(error);\n}\n```\n\n### .delete(filePath)\n\nMethod for deleting a file in storage.\n\nThis method takes the following arguments:\n\n-   `filePath` - String - Path to the file to be deleted - Required.\n\nResolves if file is deleted and rejects if file could not be deleted.\n\n```js\nconst sink = new Sink({ ... });\n\ntry {\n    await sink.delete('/path/to/file/file.js');\n} catch (error) {\n    console.log(error);\n}\n```\n\n### .exist(filePath)\n\nMethod for checking if a file exist in the storage.\n\nThis method takes the following arguments:\n\n-   `filePath` - String - Path to the file to be checked for existence - Required.\n\nResolves if file exists and rejects if file does not exist.\n\n```js\nconst sink = new Sink({ ... });\n\ntry {\n    await sink.exist('/path/to/file/file.js');\n} catch (error) {\n    console.log(error);\n}\n```\n\n[eik]: https://github.com/eik-lib\n[read-file]: https://github.com/eik-lib/common/blob/master/lib/classes/read-file.js\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feik-lib%2Fsink-memory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feik-lib%2Fsink-memory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feik-lib%2Fsink-memory/lists"}