@xiaohuohumax/x-fetch-utils
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

x-fetch-utils

Version License GitHub Actions Workflow Status

x-fetch 工具集,包含了一些辅助函数。

🚀 快速开始

npm install @xiaohuohumax/x-fetch

📚 使用说明

import { getUriTemplateVariableNames } from "@xiaohuohumax/x-fetch-utils"

const names = getUriTemplateVariableNames("/users/{id}/comments/{commentId}")

console.log(names) // Set(2) { 'id', 'commentId' }
  • omit - 过滤对象中的指定属性
import { omit } from "@xiaohuohumax/x-fetch-utils"

const obj = { a: 1, b: 2, c: 3 }
const result = omit(obj, ["b"])

console.log(result) // { a: 1, c: 3 }
import { parseUriTemplate } from "@xiaohuohumax/x-fetch-utils"

const template = "/users/{id}/comments/{commentId}"
const variables = { id: 123, commentId: 456 }
const uri = parseUriTemplate(template, variables)

console.log(uri) // "/users/123/comments/456"
  • deleteUndefinedProperties - 删除对象中的值为 undefined 的属性
import { deleteUndefinedProperties } from "@xiaohuohumax/x-fetch-utils"

const obj = { a: 1, b: undefined, c: 3 }
deleteUndefinedProperties(obj)

console.log(obj) // { a: 1, c: 3 }

📄 License

MIT

最后:玩的开心 🎉🎉🎉🎉

Package Sidebar

Install

npm i @xiaohuohumax/x-fetch-utils

Weekly Downloads

5

Version

0.1.0

License

MIT

Unpacked Size

19.6 kB

Total Files

6

Last publish

Collaborators

  • xiaohuohumax