{"id":13740673,"url":"https://github.com/bwireman/delay","last_synced_at":"2025-08-07T14:47:44.222Z","repository":{"id":113981819,"uuid":"397437302","full_name":"bwireman/delay","owner":"bwireman","description":"A dead simple data-structure for delaying side effects. Written in the excellent gleam language. Available on the Beam \u0026 in the browser!","archived":false,"fork":false,"pushed_at":"2025-02-08T17:51:40.000Z","size":331,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-28T18:45:59.956Z","etag":null,"topics":["bun","delay","deno","elixir","erlang","gleam","javascript","monad","nodejs","sideeffects"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/delay/index.html","language":"Gleam","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/bwireman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2021-08-18T01:29:49.000Z","updated_at":"2025-02-08T17:51:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"70daebfe-3882-4bf2-8a0e-316f4910bc43","html_url":"https://github.com/bwireman/delay","commit_stats":{"total_commits":67,"total_committers":1,"mean_commits":67.0,"dds":0.0,"last_synced_commit":"eac3c755b98b18e64ca76d861da37b16f03e8cd9"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/bwireman/delay","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwireman%2Fdelay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwireman%2Fdelay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwireman%2Fdelay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwireman%2Fdelay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bwireman","download_url":"https://codeload.github.com/bwireman/delay/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwireman%2Fdelay/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265495436,"owners_count":23776630,"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":["bun","delay","deno","elixir","erlang","gleam","javascript","monad","nodejs","sideeffects"],"created_at":"2024-08-03T04:00:51.117Z","updated_at":"2025-07-16T08:10:28.819Z","avatar_url":"https://github.com/bwireman.png","language":"Gleam","readme":"# Delay ⌚\n\nA dead simple data-structure for delaying side effects ⌚! Written in the excellent [gleam ✨](https://gleam.run/) language. Supporting both Erlang \u0026 Javascript targets\n\n[![test](https://github.com/bwireman/delay/actions/workflows/test.yml/badge.svg)](https://github.com/bwireman/delay/actions/workflows/test.yml)\n[![commits](https://img.shields.io/github/last-commit/bwireman/delay)](https://github.com/bwireman/delay/commit/main)\n[![mit](https://img.shields.io/github/license/bwireman/delay?color=brightgreen)](https://github.com/bwireman/delay/blob/main/LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen)](http://makeapullrequest.com)\n[![1.1.0](https://img.shields.io/hexpm/v/delay?color=brightgreen\u0026style=flat)](https://hexdocs.pm/delay/index.html)\n[![gleam erlang](https://img.shields.io/badge/erlang%20%E2%98%8E%EF%B8%8F-red?style=flat\u0026label=gleam%20%E2%9C%A8)](https://gleam.run)\n[![hex.pm downloads](https://img.shields.io/hexpm/dt/delay?label=hex.pm%20downloads)](https://hex.pm/packages/delay/)\n[![gleam js](https://img.shields.io/badge/%20gleam%20%E2%9C%A8-js%20%F0%9F%8C%B8-yellow)](https://gleam.run/news/v0.16-gleam-compiles-to-javascript/)\n[![npm](https://img.shields.io/npm/dt/delay-gleam?label=npm%20downloads)](https://www.npmjs.com/package/delay-gleam)\n\n\n## Basic Usage\n\n```gleam\nimport gleam/io\nimport delay\n\nlet d = delay.delay_effect(fn() {\n  io.println(\"Hello\")\n  Ok(1)\n}) |\u003e delay.map(fn(x) {\n  io.println(\"World\")\n  Ok(x + 1)\n})\n\nlet res = delay.run(d)\n// Hello\n// World\n// res = Ok(2)\n```\n\n## More info\n\nThe result of `delay_effect` is really just a first class function with a nice API wrapper. It isn't executed until put through one of `run/1`, `drain/1`, `fallthrough/1` or one of the other functions in order to execute a delayed effect. And can be called as many times as you want.\n\n```gleam\nimport gleam/io\nimport delay\n\nlet d = delay.delay_effect(fn() {\n  io.println(\"Hello\")\n  Error(\"bummer\")\n}) |\u003e delay.map(fn(x) {\n  io.println(\"World\")\n  Ok(x + 1)\n})\n\nlet res = delay.run(d)\n// Hello\n// res = Error(\"bummer\")\n```\n\nIf one of the functions in the chain fails, the rest will short circuit and the error will be returned.\n\nEffects can be retried as well via `retry/3`\n\n```gleam\n// using the same effect `d` from above\n\nlet res = delay.retry(d, 3, 200)\n|\u003e delay.run()\n// Hello\n// Hello\n// Hello\n// Hello\n// res = Error(\"bummer\")\n```\n\n## Usage within Javascript 🌸 directly\nIf you want to use this library from javascript alone, but aren't ready to embrace gleam, you can install it from [npm](https://www.npmjs.com/package/delay-gleam)!\nDocs can be found [here](https://hexdocs.pm/delay/index.html)\n\n```sh\nnpm i delay-gleam\n```\n\n```javascript\nimport { delay_effect, map, run } from \"delay-gleam\"\nimport { ok, error, get } from \"delay-gleam/extras\"\n\nd = delay_effect(() =\u003e error(console.log(\"123\")))\nd = map(d, (_) =\u003e ok(console.log(\"456\")))\nget(run(d))\n// 123\n```\n\n### Extras\nHelper functions for using this library directly in javascript can be found [here](/dist/extras/extras.mjs)\n\n\n## FAQ\n\nDoesn't the concept of a delayed side effect kind of lose value in the world of actor model concurrency and zero shared memory?!\n\n\u003e A little\n\nThen why did you write this?\n\n\u003e For fun\n\nIs gleam ✨ actually excellent?\n\n\u003e So far\n","funding_links":[],"categories":["Packages"],"sub_categories":["Data Structures"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwireman%2Fdelay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbwireman%2Fdelay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwireman%2Fdelay/lists"}