{"id":20364267,"url":"https://github.com/rvanasa/mo-convert","last_synced_at":"2025-08-14T05:13:46.937Z","repository":{"id":190730622,"uuid":"683237367","full_name":"rvanasa/mo-convert","owner":"rvanasa","description":"90+ consistently named Motoko base library type conversions.","archived":false,"fork":false,"pushed_at":"2025-02-18T17:45:04.000Z","size":347,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-15T15:18:29.130Z","etag":null,"topics":["base-library","candid","convenience","dfinity","icp","internet-computer","json","learning","motoko","tooling","type-conversion"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mo-convert","language":"Motoko","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/rvanasa.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-08-26T00:10:15.000Z","updated_at":"2025-02-18T17:45:08.000Z","dependencies_parsed_at":"2025-03-04T18:44:09.605Z","dependency_job_id":"1124deee-0c16-4456-9bea-6ad3ef906c72","html_url":"https://github.com/rvanasa/mo-convert","commit_stats":null,"previous_names":["rvanasa/mo-convert"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rvanasa/mo-convert","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvanasa%2Fmo-convert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvanasa%2Fmo-convert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvanasa%2Fmo-convert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvanasa%2Fmo-convert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rvanasa","download_url":"https://codeload.github.com/rvanasa/mo-convert/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvanasa%2Fmo-convert/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270364971,"owners_count":24571423,"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","status":"online","status_checked_at":"2025-08-14T02:00:10.309Z","response_time":75,"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":["base-library","candid","convenience","dfinity","icp","internet-computer","json","learning","motoko","tooling","type-conversion"],"created_at":"2024-11-15T00:10:48.271Z","updated_at":"2025-08-14T05:13:46.902Z","avatar_url":"https://github.com/rvanasa.png","language":"Motoko","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `mo-convert` \u0026nbsp;[![npm version](https://img.shields.io/npm/v/mo-convert.svg?logo=npm)](https://www.npmjs.com/package/mo-convert) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/rvanasa/mo-convert/issues)\n\n\u003e ### Systematic [Motoko](https://github.com/dfinity/motoko#readme) base library type conversions.\n\n---\n\nThis repository includes Motoko source code and a JSON metadata file containing all base library type conversions\nwith consistent `B.fromA : A -\u003e B` and `A.fromB : B -\u003e A` signatures. `mo-convert` is intended as a stepping stone for community\nlanguage tooling and for those such as myself who have trouble remembering whether the function was named `Array.toBuffer()` or `Buffer.fromArray()`.\n\n## Quick Start (Motoko):\n\nAdd the following to your [`mops.toml`](https://mops.one/docs/install) config file:\n\n```toml\n[dependencies]\nconvert = \"https://github.com/rvanasa/mo-convert\"\n```\n\nInclude the following import in your Motoko source code:\n\n```motoko\nimport C \"mo:convert\";\n```\n\nGo to town:\n\n```motoko\nlet nat = 123;\nlet text = C.Text.fromNat(nat); // =\u003e \"123\"\n\nlet option = C.Option.fromResult(#ok true); // =\u003e ?true\n\nlet array = [1, 2, 3];\nlet buffer = C.Buffer.fromArray\u003cNat\u003e(array);\n\n// Chain conversions with the piping operator\nlet pipe = (\n  array\n  |\u003e C.Iter.fromArray _\n  |\u003e C.List.fromIter _\n  |\u003e C.Array.fromList _\n);\n```\n\n## Quick Start (Node.js):\n\nRun the following command to install the `mo-convert` npm package:\n\n```sh\nnpm i --save-dev mo-convert\n```\n\nAccess the type conversion metadata:\n\n```js\nconst { conversions } = require('mo-convert');\n\nconsole.log('All type conversions:', conversions);\n```\n\nExample JSON entry:\n\n```js\nconversions[0] ==\n{\n  from: \"Array\",\n  to: \"Blob\",\n  module: \"Blob\",\n  name: \"fromArray\",\n  signature: \"Blob.fromArray(bytes : [Nat8]) : Blob\",\n  prim: \"arrayToBlob\",\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvanasa%2Fmo-convert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frvanasa%2Fmo-convert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvanasa%2Fmo-convert/lists"}