{"id":17217590,"url":"https://github.com/jirevwe/omi","last_synced_at":"2025-04-13T23:23:50.109Z","repository":{"id":41790187,"uuid":"191068061","full_name":"jirevwe/omi","owner":"jirevwe","description":"Array as a stream","archived":false,"fork":false,"pushed_at":"2022-12-09T05:42:14.000Z","size":830,"stargazers_count":9,"open_issues_count":13,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T13:40:33.022Z","etag":null,"topics":["array","javascript","library","list","nodejs","stream","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jirevwe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-10T00:03:11.000Z","updated_at":"2021-10-07T21:48:25.000Z","dependencies_parsed_at":"2023-01-25T11:46:28.166Z","dependency_job_id":null,"html_url":"https://github.com/jirevwe/omi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirevwe%2Fomi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirevwe%2Fomi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirevwe%2Fomi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirevwe%2Fomi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jirevwe","download_url":"https://codeload.github.com/jirevwe/omi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248795186,"owners_count":21162726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["array","javascript","library","list","nodejs","stream","typescript"],"created_at":"2024-10-15T03:44:21.916Z","updated_at":"2025-04-13T23:23:50.084Z","avatar_url":"https://github.com/jirevwe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Omi 🌊\n\nThis lib was inspired by [@shinout's](https://github.com/shinout) [ArrayStream](https://github.com/shinout/ArrayStream).\n\nThis a tiny tool that turns a array of objects into a stream to which items can be added to. I wrote this because a few stream libs I found didn't allow me add items to it after I'd already created the stream. Plus I wanted to learn a little about streams in NodeJs.\n\n## Usage\n\n```ts\nimport Omi, { OmiEvent } from '.';\n\nconst omi = new Omi\u003cnumber\u003e([]);\n\nomi.on(OmiEvent.DATA, (data, key) =\u003e {\n  console.log(key, data);\n});\n\nomi.on(OmiEvent.END, () =\u003e {\n  console.log('Stream closed');\n});\n\nomi.on(OmiEvent.ERROR, error =\u003e {\n  console.log(error);\n});\n\nsetTimeout(() =\u003e {\n  omi.add([...Array.from({ length: 100 }).keys()].map((i: number) =\u003e i ** i));\n}, 1000);\n\nsetTimeout(() =\u003e {\n  omi.add([...Array.from({ length: 100 }).keys()].map((i: number) =\u003e 2 ** i));\n}, 3000);\n```\n\n## Usage with `Stream`s or `Transform`ers\n\n```ts\nimport { createWriteStream } from 'fs';\nimport Omi from '..';\nimport faker from 'faker';\nimport { join } from 'path';\nimport { Transform } from 'stream';\n\nconst omi = new Omi\u003cstring\u003e([], false);\n\nconst uppercaseTransformer = new Transform({\n  transform(chunk, encoding, callback) {\n    const upperCase = chunk.toString().toUpperCase() + '\\n';\n    this.push(upperCase);\n    callback();\n  }\n});\n\n// create a write stream to the file system\nconst writeStream = createWriteStream(join(__dirname, '../../test.txt'));\n\n// pipe the data into the file as it is recieved\nomi.pipe(uppercaseTransformer).pipe(writeStream);\n\n// add data to the stream\nomi.add(\n  [...Array.from({ length: 100 }).keys()].map(() =\u003e faker.lorem.lines(1))\n);\n\n// add data to the stream\nomi.add(\n  [...Array.from({ length: 100 }).keys()].map(() =\u003e faker.internet.email())\n);\n```\n\n## Contribution\n\nPRs are welcome 😬\n\n## TODO\n\n- Write tests\n\n## PS\n\nWe're hiring, DM me on twitter [@rtukpe](https://twitter.com/rtukpe) 😎\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirevwe%2Fomi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjirevwe%2Fomi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirevwe%2Fomi/lists"}