{"id":27142732,"url":"https://github.com/yjhmelody/as-container","last_synced_at":"2026-04-01T22:05:21.485Z","repository":{"id":43485221,"uuid":"351330494","full_name":"yjhmelody/as-container","owner":"yjhmelody","description":"AssemblyScript version of Rust Option\u003cT\u003e and Result\u003cO, E\u003e etc.","archived":false,"fork":false,"pushed_at":"2024-05-09T22:09:29.000Z","size":1615,"stargazers_count":26,"open_issues_count":4,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-28T00:37:57.379Z","etag":null,"topics":["assemblyscript","box","container","option","result"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/yjhmelody.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-03-25T06:22:31.000Z","updated_at":"2025-12-13T06:48:42.000Z","dependencies_parsed_at":"2023-11-17T09:52:38.369Z","dependency_job_id":"5aa10728-1fd5-4838-ad43-56beef2883c9","html_url":"https://github.com/yjhmelody/as-container","commit_stats":{"total_commits":73,"total_committers":4,"mean_commits":18.25,"dds":0.4657534246575342,"last_synced_commit":"449addc5171e34cf10ac802ce69029b209eae397"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/yjhmelody/as-container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjhmelody%2Fas-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjhmelody%2Fas-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjhmelody%2Fas-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjhmelody%2Fas-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yjhmelody","download_url":"https://codeload.github.com/yjhmelody/as-container/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjhmelody%2Fas-container/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["assemblyscript","box","container","option","result"],"created_at":"2025-04-08T07:59:22.839Z","updated_at":"2026-04-01T22:05:21.464Z","avatar_url":"https://github.com/yjhmelody.png","language":"TypeScript","funding_links":[],"categories":["Packages"],"sub_categories":["Utility"],"readme":"# as-container\n\n![CI](https://github.com/yjhmelody/as-container/workflows/CI/badge.svg)\n[![npm version](https://img.shields.io/npm/v/as-container?color=light-green\u0026label=npm%20package)](https://img.shields.io/npm/v/as-container?color=light-green\u0026label=npm%20package)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/yjhmelody/as-container)\n\nas-container provides some utils such as `Option` and `Result` inspired by Rust for other people to use.\n\n## APIs\n\n### Box\n\nBox is used to wrap non-nullable(or primitive) value such as i32. Box offers all operator overloads to call the inner type operator.\n\nBox usage scenarios are mainly used when a function or field needs to be null. This is very common in the case of generic functions and generic classes. The generics you write for reference types cannot be used for basic types, and Box is a reference type.\n\n```ts\nimport { Box } from \"as-container\";\n\nlet box = Box.from(2);\nlet box2 = Box.from(1);\nexpect(box == box2).toStrictEqual(false);\nexpect(box != box2).toStrictEqual(true);\n```\n\nMore examples can be found in [unit tests](./assembly/__tests__/box.spec.ts)\n\n### Option\n\nOption offers some operations inspired by Rust.\n\n```ts\nimport { Option } from \"as-container\";\n\nconst x = Option.Some(\"some\");\nexpect(x.map\u003cstring\u003e((s) =\u003e s + s).unwrap()).toBe(\"somesome\");\n```\n\nMore examples can be found in [unit tests](./assembly/__tests__/primitive/option.spec.ts)\n\n### Result\n\nResult offers some operations inspired by Rust.\n\n```ts\nimport { Result } from \"as-container\";\n\nconst x = Result.Ok\u003cstring, string\u003e(\"233\");\nexpect(x.map\u003cstring\u003e((s) =\u003e s + s).unwrap()).toBe(\"233233\");\n```\n\nMore examples can be found in [unit tests](./assembly/__tests__/primitive/result.spec.ts)\n\n### Others\n\n`as-container` offers two versions of Result/Option. They provide the same API, but different implementations.\n\nThe default version can handle any type including primitive type. But because the primitive types need one more byte to record state, it may take more overhead.\n\nIf you always use reference types as Option/Result parameters and need better performance, then you can use the type with the same name under `as-container/reference`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjhmelody%2Fas-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyjhmelody%2Fas-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjhmelody%2Fas-container/lists"}