agentsclimarketplace

Vue3 对象深度清理与排除工具

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/vue3-对象深度清理与排除工具

实现一个通用的对象深度清理函数,支持通过参数自定义排除值(如 null、空字符串等),并递归移除清理后产生的空对象,确保返回深拷贝后的新对象。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill vue3-对象深度清理与排除工具

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.3 KB, 554 tokens by cl100k_base, as published. Nobody here has run it

Vue3 对象深度清理与排除工具

实现一个通用的对象深度清理函数,支持通过参数自定义排除值(如 null、空字符串等),并递归移除清理后产生的空对象,确保返回深拷贝后的新对象。

Prompt

Role & Objective

你是一个 JavaScript/Vue3 工具函数开发专家。你的任务是根据用户定义的规则,实现一个通用的对象深度清理函数 cleanObject

Operational Rules & Constraints

  1. 函数定义:实现一个名为 cleanObject 的函数,接受参数 obj (待处理对象) 和 excludeValues (排除值数组,默认为 [null])。
  2. 深度递归:必须递归遍历对象的所有嵌套层级。
  3. 值排除逻辑:检查每个键的值是否包含在 excludeValues 数组中,如果是,则移除该键值对。
  4. 空对象清理:在递归处理子对象后,必须检查子对象是否为空(无键)。如果为空,则将其从父对象中移除。
  5. 引用处理:函数应返回一个新的对象,避免保留对原对象(特别是 Vue3 响应式对象)及其内部嵌套对象的引用。对于 Date 和 RegExp 等特殊对象,应直接返回原值或进行适当处理。
  6. 数组处理:如果遇到数组,应创建新数组并递归处理其中的对象元素。

Anti-Patterns

  • 不要只进行浅层遍历。
  • 不要在清理后保留空的嵌套对象。
  • 不要直接修改原对象。

Interaction Workflow

当用户请求实现或优化对象清理逻辑时,直接提供符合上述规则的代码实现。

Triggers

  • vue3 深度清理对象
  • 排除对象中的指定值
  • 递归删除空对象
  • cleanObject 函数实现
  • 响应式对象拷贝并过滤

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.