{"_id":"@1-/format","name":"@1-/format","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@1-/format","version":"0.1.0","description":"Lightweight modular code formatter for JavaScript, Stylus, and SVG with language-specific processors","keywords":["formatter","code-formatting","javascript","stylus","svg"],"homepage":"https://github.com/webc-site/npm/tree/main/format","license":"MulanPSL-2.0","author":{"name":"x-at-01@googlegroups.com"},"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"bin":{"format":"bin.js"},"type":"module","exports":{".":"./_.js","./*":"./*"},"dependencies":{"@1-/fix":"^0.1.8","@1-/stylus":"^0.1.12","@3-/ext":"^0.0.2","@3-/log":"^0.1.9","@3-/svgo":"^0.1.4","@3-/write":"^0.1.2","yargs":"^18.0.0"},"_id":"@1-/format@0.1.0","bugs":{"url":"https://github.com/webc-site/npm/issues"},"_nodeVersion":"26.2.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-WjdPrXImy8WUCJFwUiP64vSwGMAigEaDok5VJxzWw9dAx49oGLEMFv9ZUdB/dhG/u1aoKq7lTkBmfaxLkV409A==","shasum":"ff106b5273a497b1e6422bd525e40620ce7b1bfc","tarball":"https://registry.npmjs.org/@1-/format/-/format-0.1.0.tgz","fileCount":7,"unpackedSize":7211,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD5+PlnjmieHAVzubkhzjwdH301RTMxAutAF7K+PKrtrQIgVKAz+AEiDVGbfhARAZf1qliD4ta7x+eGgB9d3d6wXYE="}]},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"directories":{},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/format_0.1.0_1784294077516_0.5916864199196363"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-17T13:14:37.400Z","0.1.0":"2026-07-17T13:14:37.644Z","modified":"2026-07-17T13:14:37.964Z"},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"description":"Lightweight modular code formatter for JavaScript, Stylus, and SVG with language-specific processors","homepage":"https://github.com/webc-site/npm/tree/main/format","keywords":["formatter","code-formatting","javascript","stylus","svg"],"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"author":{"name":"x-at-01@googlegroups.com"},"bugs":{"url":"https://github.com/webc-site/npm/issues"},"license":"MulanPSL-2.0","readme":"[English](#en) | [中文](#zh)\n\n---\n\n<a id=\"en\"></a>\n# @1-/format : Lightweight modular code formatter for JavaScript, Stylus, and SVG\n\n- [@1-/format : Lightweight modular code formatter for JavaScript, Stylus, and SVG](#1-format-lightweight-modular-code-formatter-for-javascript-stylus-and-svg)\n  - [Functionality](#functionality)\n  - [Usage demonstration](#usage-demonstration)\n  - [Design philosophy](#design-philosophy)\n  - [Technology stack](#technology-stack)\n  - [Code structure](#code-structure)\n  - [Historical context](#historical-context)\n  - [About](#about)\n\n## Functionality\nFormat code consistently across multiple languages using language-specific processors. Supports:\n- JavaScript: AST-based formatting with custom rules (read, readAsync, sleep, constMerge, while, utf8e, env)\n- Stylus: Parser-driven formatting using @1-/stylus\n- SVG: SVGO-based minification with custom plugin configuration\n\n## Usage demonstration\nInstall globally:\n```bash\nnpm install -g @1-/format\n```\n\nFormat files:\n```bash\nformat file.js file.styl image.svg\n```\n\nOr use as a module:\n```javascript\nimport format from '@1-/format';\n\nconst formatted = await format('path/to/file.js');\n```\n\n## Design philosophy\nThe formatter follows a strict dispatcher architecture where file extension determines processor selection. Each processor operates independently with language-specific tooling, enabling precise control without cross-language interference.\n\n![](https://cdn.jsdmirror.com/gh/webc-fs/-@4I/hUW2LqzmANnI_YOWEwVg.svg)\n\n## Technology stack\n- Runtime: Node.js with ES modules\n- JavaScript: yuku-parser + oxfmt + custom rules\n- Stylus: @1-/stylus parser and formatter\n- SVG: SVGO with custom preset configuration\n- CLI: yargs\n- Utilities: @3-/read, @3-/write, @3-/log\n\n## Code structure\n```\nsrc/\n├── _.js          # Main dispatcher routing by file extension\n├── bin.js        # CLI executable with yargs integration\n├── js.js         # JavaScript formatter delegating to @1-/fix\n├── styl.js       # Stylus formatter using @1-/stylus\n└── svg.js        # SVG formatter using @3-/svgo\n```\n\n## Historical context\nCode formatting evolved from simple text transformations to AST-based tools. @1-/format represents the modern micro-architecture approach: small, focused libraries composed together rather than monolithic solutions. This enables targeted improvements and avoids the complexity bloat of universal formatters.\n\n## About\n\nThis library is developed by [WebC.site](https://webc.site).\n\n[WebC.site](https://webc.site): A new paradigm of web development for AI\n\n\n---\n\n<a id=\"zh\"></a>\n# @1-/format : 轻量级模块化代码格式化工具，支持 JavaScript、Stylus 和 SVG\n\n- [@1-/format : 轻量级模块化代码格式化工具，支持 JavaScript、Stylus 和 SVG](#1-format-轻量级模块化代码格式化工具支持-javascriptstylus-和-svg)\n  - [功能介绍](#功能介绍)\n  - [使用演示](#使用演示)\n  - [设计思路](#设计思路)\n  - [技术栈](#技术栈)\n  - [代码结构](#代码结构)\n  - [历史故事](#历史故事)\n  - [关于](#关于)\n\n## 功能介绍\n使用语言特定处理器一致地格式化多种语言代码。支持：\n- JavaScript：基于 AST 的格式化，包含自定义规则（read、readAsync、sleep、constMerge、while、utf8e、env）\n- Stylus：解析器驱动的格式化，使用 @1-/stylus\n- SVG：基于 SVGO 的压缩，采用自定义插件配置\n\n## 使用演示\n全局安装：\n```bash\nnpm install -g @1-/format\n```\n\n格式化文件：\n```bash\nformat file.js file.styl image.svg\n```\n\n或作为模块使用：\n```javascript\nimport format from '@1-/format';\n\nconst formatted = await format('path/to/file.js');\n```\n\n## 设计思路\n格式化器采用严格的分发器架构，文件扩展名决定处理器选择。每个处理器独立运行，使用语言特定工具，实现精确控制且避免跨语言干扰。\n\n![](https://cdn.jsdmirror.com/gh/webc-fs/-@kG/vagFar18_Nzq0m26bCsQ.svg)\n\n## 技术栈\n- 运行时：Node.js ES 模块\n- JavaScript：yuku-parser + oxfmt + 自定义规则\n- Stylus：@1-/stylus 解析器和格式化器\n- SVG：SVGO 与自定义预设配置\n- CLI：yargs\n- 工具库：@3-/read、@3-/write、@3-/log\n\n## 代码结构\n```\nsrc/\n├── _.js          # 主分发器，按文件扩展名路由\n├── bin.js        # CLI 可执行文件，集成 yargs\n├── js.js         # JavaScript 格式化器，委托给 @1-/fix\n├── styl.js       # Stylus 格式化器，使用 @1-/stylus\n└── svg.js        # SVG 格式化器，使用 @3-/svgo\n```\n\n## 历史故事\n代码格式化从简单的文本转换发展为基于 AST 的工具。@1-/format 代表现代微架构方法：小型、专注的库组合使用，而非单体解决方案。这种方法支持针对性改进，避免通用格式化器的复杂性膨胀。\n\n## 关于\n\n本库由 [WebC.site](https://webc.site) 开发。\n\n[WebC.site](https://webc.site) : 面向人工智能的网站开发新范式\n\n","readmeFilename":"README.md","_rev":"1-38b87740bf7b4b339d9e6387ecdb52e7"}