条件移除元素
使用 lodash 的 _.dropWhile 在满足条件时从数组开头移除元素
此工具从数组开头移除元素,直到谓词首次返回 false 为止。
**功能特性:**
- 多种谓词类型,灵活过滤
- 支持数字和字符串比较
- 适用于任何数据类型的数组
- 使用 lodash 的 _.dropWhile 确保可靠操作
**示例:**
输入:`[1, 2, 3, 4, 5]`
谓词:小于 3
输出:`[3, 4, 5]`(移除 1 和 2,因为它们 < 3)
**谓词类型:**
- **less-than**: 当值 < n 时移除
- **greater-than**: 当值 > n 时移除
- **equals**: 当值 === n 时移除
- **not-equals**: 当值 !== n 时移除
- **string-contains**: 当字符串包含子串时移除
- **string-starts-with**: 当字符串以指定前缀开头时移除
- **string-ends-with**: 当字符串以指定后缀结尾时移除
- **is-nullish**: 当值为 null/undefined 时移除
- **is-truthy**: 当值为真值时移除
- **is-falsey**: 当值为假值时移除
API 文档
请求端点
POST /zh/api/tools/drop-while
请求参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| array | textarea | 是 | 输入 JSON 数组 |
| predicateType | select | 是 | 选择移除元素的条件 |
| compareValue | text | 否 | 比较值(大多数谓词需要) |
响应格式
{
"result": "Processed text content",
"error": "Error message (optional)",
"message": "Notification message (optional)",
"metadata": {
"key": "value"
}
}
文本:
文本
AI MCP 文档
将此工具添加到您的 MCP 服务器配置中:
{
"mcpServers": {
"elysiatools-drop-while": {
"name": "drop-while",
"description": "使用 lodash 的 _.dropWhile 在满足条件时从数组开头移除元素",
"baseUrl": "https://elysiatools.com/mcp/sse?toolId=drop-while",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}
你可以串联多个工具,比如:`https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`,最多20个。
如果遇见问题,请联系我们:[email protected]