functional-patterns
在 TypeScript 中应用函数式模式
可变逻辑和隐藏的副作用会让 Node.js 服务难以测试。此技能展示用于可预测 TypeScript 设计的函数式模式。
使用我的智能体安装
将此请求复制给你的智能体,其中包含权威 Skill 页面和清单。
Review the Skillstore skill "functional-patterns" from https://skillstore.io/skills/doubleslashse-functional-patterns.md and its manifest at https://skillstore.io/api/skills/doubleslashse-functional-patterns/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.你的智能体仍应展示其计划,并按安全策略请求必要确认。
Agent 可读资源
当 AI Agent、爬虫或脚本需要干净上下文,而不是读取完整页面时,请使用这些链接。
测试它
正在使用“functional-patterns”。 审查一个混合了验证、数据库写入和通知调用的结账服务。
预期结果:
- 验证和价格计算应移入纯函数。
- 数据库写入和通知应保留在薄薄的非纯外壳中。
- 注入存储库和通知客户端,以便测试可以使用 fake。
正在使用“functional-patterns”。 帮助为导入作业设计类型化错误处理。
预期结果:
- 使用 Result 处理验证和处理失败。
- 对不是错误的可选查找结果使用 Option。
- 在从工作流返回之前,将每个失败映射为领域错误。
正在使用“functional-patterns”。 向 TypeScript 团队教授不可变更新。
预期结果:
- 展示使用对象展开进行浅层更新。
- 使用数组 map、filter 和展开,而不是变更。
- 在能提升安全性的地方将共享数据标记为 readonly。
安全审计
安全All static findings are false positives caused by Markdown code fences, TypeScript template literals, and illustrative logging examples. No prompt injection, command execution intent, data exfiltration, or system reconnaissance behavior was found in SKILL.md.
风险因素
⚙️ 外部命令 (20)
分享与引用此报告
分享版本化评估报告、中性徽章、嵌入卡片和引用。Skillstore 只报告证据,不判断该 Skill 是否安全。
复制报告链接
https://skillstore.io/skills/doubleslashse-functional-patterns/audits/8?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown 徽章
[](https://skillstore.io/skills/doubleslashse-functional-patterns?utm_source=security_passport_badge)HTML 徽章
<a href="https://skillstore.io/skills/doubleslashse-functional-patterns?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/doubleslashse-functional-patterns/security.svg" alt="Skillstore security assessment" loading="lazy"></a>嵌入卡片
<iframe src="https://skillstore.io/embed/skills/doubleslashse-functional-patterns.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>学术引用 (APA · BibTeX · CFF)
APA 引用
DoubleslashSE. (2026). functional-patterns security audit report (audit version 8) [Author version unspecified]. Skillstore. https://skillstore.io/skills/doubleslashse-functional-patterns/audits/8BibTeX 引用
@techreport{doubleslashse-doubleslashse-functional-patterns-2026,
author = {DoubleslashSE},
title = {functional-patterns security audit report (audit version 8)},
institution = {Skillstore},
year = {2026},
number = {8},
url = {https://skillstore.io/skills/doubleslashse-functional-patterns/audits/8},
note = {Author version unspecified}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "functional-patterns security audit report (audit version 8)"
version: "unspecified"
type: report
authors:
- name: "DoubleslashSE"
date-released: "2026-07-06"
url: "https://skillstore.io/skills/doubleslashse-functional-patterns/audits/8"
identifiers:
- type: other
value: "skillstore:doubleslashse-functional-patterns:audit:8"
description: "Skillstore immutable audit report identifier"
Skillstore 评分
评分依据 证据置信度: 高你能构建什么
重构服务逻辑
将业务规则与 I/O 分离,使服务行为更易于测试和审查。
教授可测试的 TypeScript
使用简洁示例向团队解释纯函数、不可变性和组合。
设计错误处理
使用 Result 和 Option 模式来建模可恢复失败,而不是依赖隐藏异常。
试试这些提示
解释 TypeScript 服务中的纯核心、非纯外壳模式。包括何时使用它以及常见错误。
审查这个 TypeScript 函数,并建议使用纯函数和不可变更新进行函数式重构:[paste function].
为此请求流程设计一个基于 Result 的管道。展示验证、处理、格式化和类型化错误边界:[describe flow].
分析这个 Node.js 服务边界中的副作用、依赖注入、可测试性和函数式组合机会:[paste summary].
最佳实践
- 在添加新抽象之前,将纯业务规则与 I/O 分离。
- 转换共享领域对象时使用不可变更新。
- 当调用方必须处理可恢复错误时,使用 Result 或 Option 建模。
避免
- 在预期为纯函数的函数中隐藏数据库或网络调用。
- 在共享服务代码中变更请求对象或领域对象。
- 添加会掩盖简单逻辑的函数式抽象。
常见问题
这个技能会安装函数式编程库吗?
它只对高级函数式程序员有用吗?
它能帮助测试吗?
它会取代特定框架的架构指导吗?
我可以在现有 Node.js 代码中使用这些模式吗?
它会让每个函数都变成纯函数吗?
开发者详情
许可证
MIT
Skillstore 修订
r1
版本提示
作者未声明版本。
引用
72d5025b022c77f7a51bdf5c1637c689c80e89d1
维护新鲜度
2026/7/20
使用量
7 次下载 · 237 次浏览
文件结构
📄 SKILL.md