{"id":18733144,"url":"https://github.com/bioforestchain/util","last_synced_at":"2025-11-14T00:30:16.407Z","repository":{"id":59740126,"uuid":"475372299","full_name":"BioforestChain/Util","owner":"BioforestChain","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-24T07:13:35.000Z","size":759,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-09T00:33:16.152Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/BioforestChain.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}},"created_at":"2022-03-29T09:31:57.000Z","updated_at":"2022-09-20T07:54:40.000Z","dependencies_parsed_at":"2024-10-24T22:16:49.005Z","dependency_job_id":"4870db24-4c73-411e-8cbd-0ea3178422bc","html_url":"https://github.com/BioforestChain/Util","commit_stats":{"total_commits":94,"total_committers":6,"mean_commits":"15.666666666666666","dds":"0.46808510638297873","last_synced_commit":"5d32b0f535abf52d4da56f4ba4a5794b2e9d957e"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FUtil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FUtil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FUtil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FUtil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BioforestChain","download_url":"https://codeload.github.com/BioforestChain/Util/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239605124,"owners_count":19666998,"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":[],"created_at":"2024-11-07T15:08:51.839Z","updated_at":"2025-11-14T00:30:16.344Z","avatar_url":"https://github.com/BioforestChain.png","language":"TypeScript","readme":"# Bnqkl-Util\n\ntypescript util packages\n\n## 如何使用\n\n### 如何在 nodejs 中使用\n\n编译会分发出两个包： `@bnqkl/util-node` 与 `@bnqkl/util-web` 。不会再有其它子包（也就是说所有的自包现在已经全部聚合成一个包）。\n\n\u003e 如果要兼容原本的用法： `npm i @bfchain/util@npm:@bnqkl/util-node` (`npm install \u003calias\u003e@npm:\u003cname\u003e`)。或者在 pakcage.json/deps 中写： `\"@bfchain/util\": \"npm:@bnqkl/util@^1.0.0\"`\n\n### 如何在 dnt 中使用\n\n\u003e [dnt](https://github.com/denoland/dnt) 是一个将 Deno 转化成 Node 的工具。本项目也使用这个工具进行开发。\n\u003e 本项目之所以使用这个方案，是因为有多平台分发的需求，而 deno 的 importMap 可以很好的解决这个问题。\n\u003e 如果您的项目也有类似的需求，需要将一套代码分发到多个包中，那么可以使用本项目的解决方案：\n\n1.  配置 [npm.json]('./scripts/npm.json')\n1.  编译 [build_npm.ts]('./scripts/build_npm.ts')\n1.  发布 [pub_npm.ts]('./scripts/pub_npm.ts')\n\n如果您也选择了这个方案，说明您的目标是编译到 nodejs 平台， 那么这里的建议是使用 `https://esm.sh/` 来获取 npm 包，比如：\n\n```ts\nimport { Inject } from \"https://esm.sh/@bnqkl/util-node@1.0.0\";\n```\n\n然后再通过 [importMap](https://deno.land/manual@v1.25.3/linking_to_external_code/import_maps) 的配置来编译来将`https://esm.sh/@bnqkl/util-node` 修改成 `https://esm.sh/@bnqkl/util-web` 以分发到不同的包中。\n\n### 如何在 deno 中使用\n\n```ts\nimport { Inject } from \"https://deno.land/x/bnqkl_util@1.0.0/mod.ts\";\n```\n\n## 命名规范\n\n1. 代码中：`$`开头的为着“无副作用函数”，主要有两类：\n   1. `$`+`小写`：为无副作用函数（需要在 jsdoc 中声明`@inline`）\n   1. `$`+`大写`：为 TypeScript 类型定义与推断\n1. 代码中：`纯大写`+`下划线` 通常为“零成本抽象”定义，目前只有一类：`const enum`\n\n1. 文件中：包含`!`意味着“宏”，会被编译期间动态替换掉的\n   1. `import/export`的`path`中如果是`!`开头，说明该路径会在`importMap`配置中被动态替换\n   1. 文件名称:`!`+`profile`的会随着编译去替换到`importMap`中的目标文件，目前`profile`只有两种：`node`/`browser`\n1. 代码中：无副作用函数调用带有`!`声明的，会被编译器内联：\n\n   ```ts\n   // 无副作用函数\n   const $add = (a, b, ...rest) =\u003e a + b;\n   // 源代码\n   const res = $add!(...args);\n   // 编译结果\n   let $someFun_return;\n   {\n     // decalre argument\n     const [a, b, ..rest] = args\n     // replace source code\n     // if arrow function , add return keyword\n     // then replace return keyword as `someFun_return = `\n     $someFun_return = a + b;\n   }\n   // replacement function call\n   const res = $someFun_return;\n   ```\n\n```\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbioforestchain%2Futil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbioforestchain%2Futil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbioforestchain%2Futil/lists"}