{"id":41342678,"url":"https://github.com/txs1992/mt-utils","last_synced_at":"2026-01-23T06:52:38.912Z","repository":{"id":34469232,"uuid":"179441492","full_name":"txs1992/mt-utils","owner":"txs1992","description":"一些业务中常用的工具函数，Some commonly used tool functions in business.","archived":false,"fork":false,"pushed_at":"2023-01-03T19:14:56.000Z","size":263,"stargazers_count":2,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-10T17:12:50.450Z","etag":null,"topics":["business","css-supports","get-scroll-element","is-object","is-scroll-element","object-serialization","util","utils"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/txs1992.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-04T07:08:03.000Z","updated_at":"2021-03-22T23:27:34.000Z","dependencies_parsed_at":"2023-01-15T07:31:11.506Z","dependency_job_id":null,"html_url":"https://github.com/txs1992/mt-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/txs1992/mt-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txs1992%2Fmt-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txs1992%2Fmt-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txs1992%2Fmt-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txs1992%2Fmt-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/txs1992","download_url":"https://codeload.github.com/txs1992/mt-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txs1992%2Fmt-utils/sbom","scorecard":{"id":904597,"data":{"date":"2025-08-11","repo":{"name":"github.com/txs1992/mt-utils","commit":"70371c71c793df912d19c3fa57893d73a9d0f85d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/8 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"28 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-h9rv-jmmf-4pgx","Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T16:52:47.696Z","repository_id":34469232,"created_at":"2025-08-24T16:52:47.697Z","updated_at":"2025-08-24T16:52:47.697Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28682263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["business","css-supports","get-scroll-element","is-object","is-scroll-element","object-serialization","util","utils"],"created_at":"2026-01-23T06:52:38.758Z","updated_at":"2026-01-23T06:52:38.883Z","avatar_url":"https://github.com/txs1992.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n\tmt-utils\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://img.shields.io/travis/txs1992/mt-utils.svg\"\u003e\n    \u003cimg src=\"http://img.shields.io/travis/txs1992/mt-utils.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://img.shields.io/npm/dt/mt-utils.svg\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dt/mt-utils.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://img.shields.io/npm/dm/mt-utils.svg\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/mt-utils.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://img.shields.io/npm/v/mt-utils.svg\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/mt-utils.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://img.shields.io/npm/l/mt-utils.svg\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/l/mt-utils.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://img.shields.io/node/v/passport.svg\"\u003e\n    \u003cimg src=\"https://img.shields.io/node/v/passport.svg\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e 一个业务中常用的工具函数的封装库\n\n## npm 使用示例\n\n```js\nimport { cssSupports } from 'mt-utils'\n\ncssSupports('position')\n```\n\n## CDN 使用示例\n\n```html\n\u003c!-- 记得修改最新的版本号 --\u003e\n\u003cscript src=\"https://unpkg.com/mt-utils@0.0.2/lib/index.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  window.MtUtils.cssSupports('position')\n\u003c/script\u003e\n```\n\n## 功能目录\n\n- [CSS 能力检测](#csssupports-css-能力检测)\n- [判断对象](#isObject-判断是否是对象)\n- [对象序列化](#obj2qs-对象转换查询字符串)\n- [判断滚动元素](#isScrollElement-判断滚动元素)\n- [获取第一个子级滚动元素](#getScrollElementOfFirstChild-获取第一个子级滚动元素)\n- [获取第一个父级滚动元素](#getScrollElementOfFirstParent-获取第一个父级滚动元素)\n- [获取周的最后一天](#getEndDateOfWeek-获取周的最后一天)\n- [驼峰转短横线](#camelToKebab-驼峰转短横线)\n- [短横线转驼峰](#kebabToCamel-短横线转驼峰)\n\n#### cssSupports CSS 能力检测\n\n- **参数**\n  - `prop` : `String` css 属性名称\n  - `value`: [`String` | `undefined`] css 属性值\n- **返回值** Boolean\n- **描述**\n\n  \u003e 判断浏览器是否支持传入的的 css 属性，以及对应的 css 属性值。如果不传 value 参数，只判断是否支持 css 属性，否则判断是否支持属性与值。\n\n- **示例**\n\n```js\n// 检测是否支持 position 属性\ncssSupports('position')\n\n// 判断是否支持 sticky 定位\ncssSupports('position', 'sticky')\n```\n\n[返回目录](#功能目录)\n\n### isObject 判断是否是对象\n\n- **参数**\n  - `value` : `Obejct`\n- **返回值** Boolean\n- **描述**\n\n  \u003e 根据给定的值，判断是否是对象\n\n- **示例**\n\n```js\n// 判断传入的值是不是一个对象。\nisObject({})\n```\n\n[返回目录](#功能目录)\n\n### obj2qs 对象转换查询字符串\n\n- **参数**\n  - `obj` : `Obejct`\n  - `first`: `Boolean` 是否添加 `\u0026` 符号，默认不添加\n  - `transcoding`: `Boolean` 是否对值进行 encodeURIComponent 转码，默认开启转码。\n- **返回值** Boolean\n- **描述**\n\n  \u003e 根据给定的对象将其转换成查询字符串，如果传入的不是对象返回空字符串。有些时候我们需要必须通过 get 请求将对象或是数组等参数传递给接口，例如下载数据，而直接传递对象接口可能无法解析，所以需要将参数序列化。\n\n- **示例**\n\n```js\n// 默认调用，即不添加 ？ 连接符，并转码。\nobj2qs({ name: 'mt', age: 10, ids: [1, 2, 3], map: { a: 'b', b: 'c' } })\n// 转换结果：\"name=mt\u0026age=10\u0026ids=%5B1%2C2%2C3%5D\u0026map=%7B%22a%22%3A%22b%22%2C%22b%22%3A%22c%22%7D\"\n\n// 不添加 ？ 连接符，并且不转码。\nobj2qs(\n  { name: 'mt', age: 10, ids: [1, 2, 3], map: { a: 'b', b: 'c' } },\n  false,\n  false\n)\n// 转换结果：\"name=mt\u0026age=10\u0026ids=[1,2,3]\u0026map={\"a\":\"b\",\"b\":\"c\"}\"\n\n// 添加 ? 连接符，并开启转码\nobj2qs(\n  { name: 'mt', age: 10, ids: [1, 2, 3], map: { a: 'b', b: 'c' } },\n  true,\n  true\n)\n// 转换结果：\"?name=mt\u0026age=10\u0026ids=%5B1%2C2%2C3%5D\u0026map=%7B%22a%22%3A%22b%22%2C%22b%22%3A%22c%22%7D\"\n```\n\n[返回目录](#功能目录)\n\n#### isScrollElement 判断滚动元素\n\n- **参数**\n  - `el` : `Element` DOM 元素\n  - `direction`: `String` 水平或者垂直滚动，默认 vertical。\n    - `可选值`: [`vertical`, `horizontal`]\n- **返回值** Boolean\n- **描述**\n\n  \u003e 根据给定的 DOM 元素判断该元素是否是一个滚动元素。\n\n- **示例**\n\n```js\n// 判断 body 是否是一个滚动元素。\nisScrollElement(document.body, 'vertical')\n```\n\n[返回目录](#功能目录)\n\n### getScrollElementOfFirstChild 获取第一个子级滚动元素\n\n- **参数**\n  - `el` : `Element` DOM 元素\n  - `direction`: `String` 水平或者垂直滚动，默认 vertical。\n    - `可选值`: [`vertical`, `horizontal`]\n- **返回值** [`Element`, `null`]\n- **描述**\n\n  \u003e 根据给定的 DOM 元素，获取距离该元素最近的子级动元素(会一直向下查找到最后一级)，如果该元素的子级元素中没有滚动元素，则返回 null。\n\n- **示例**\n\n```js\ngetScrollElementOfFirstChild(document.querySelector('.content'), 'vertical')\n```\n\n[返回目录](#功能目录)\n\n### getScrollElementOfFirstParent 获取第一个父级滚动元素\n\n- **参数**\n  - `el` : `Element` DOM 元素\n  - `direction`: `String` 水平或者垂直滚动，默认 vertical。\n    - `可选值`: [`vertical`, `horizontal`]\n- **返回值** [`Element`, `null`]\n- **描述**\n\n  \u003e 根据给定的 DOM 元素，获取距离该元素最近的父级滚动元素(向上查找到最顶级)，如果该元素的父级元素中没有滚动元素，则返回 null。\n\n- **示例**\n\n```js\ngetScrollElementOfFirstParent(document.querySelector('.content'), 'vertical')\n```\n\n[返回目录](#功能目录)\n\n### getEndDateOfWeek 获取周的最后一天\n\n- **参数**\n  - `date` : `Date` 日期对象\n  - `startDay`: `Number` 周的开始日期，国内是从周一开始，而国外是从周末开始。\n- **返回值** `Date`\n- **描述**\n\n  \u003e 根据给定的日期对象返回当前周的最后一天\n\n- **示例**\n\n```js\ngetEndDateOfWeek(new Date())\n```\n\n[返回目录](#功能目录)\n\n### camelToKebab 驼峰转短横线\n\n- **参数**\n  - `str` : `String` 需要转换的字符串\n- **返回值** `String`\n- **描述**\n\n  \u003e 根据给定的驼峰格式字符串返回短横线格式字符串\n\n- **示例**\n\n```js\ncamelToKebab('MtUtils') // 返回 mt-utils\n```\n\n[返回目录](#功能目录)\n\n### kebabToCamel 短横线转驼峰\n\n- **参数**\n  - `str` : `String` 需要转换的字符串\n- **返回值** `String`\n- **描述**\n\n  \u003e 根据给定的短横线格式字符串返回驼峰格式字符串\n\n- **示例**\n\n```js\nkebabToCamel('mt-utils') // 返回 MtUtils\n```\n\n[返回目录](#功能目录)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftxs1992%2Fmt-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftxs1992%2Fmt-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftxs1992%2Fmt-utils/lists"}