{"id":13559902,"url":"https://github.com/proYang/outils","last_synced_at":"2025-04-03T15:31:11.045Z","repository":{"id":37664587,"uuid":"109802250","full_name":"proYang/outils","owner":"proYang","description":":rocket: 前端业务代码工具库","archived":false,"fork":false,"pushed_at":"2022-12-06T17:37:01.000Z","size":848,"stargazers_count":2620,"open_issues_count":39,"forks_count":593,"subscribers_count":65,"default_branch":"master","last_synced_at":"2025-03-29T05:37:25.549Z","etag":null,"topics":["javascript","tool","utils"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/outils","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/proYang.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":"2017-11-07T07:38:36.000Z","updated_at":"2025-03-18T07:57:59.000Z","dependencies_parsed_at":"2022-08-08T21:15:35.741Z","dependency_job_id":null,"html_url":"https://github.com/proYang/outils","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proYang%2Foutils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proYang%2Foutils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proYang%2Foutils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proYang%2Foutils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/proYang","download_url":"https://codeload.github.com/proYang/outils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247027816,"owners_count":20871598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["javascript","tool","utils"],"created_at":"2024-08-01T13:00:34.963Z","updated_at":"2025-04-03T15:31:06.032Z","avatar_url":"https://github.com/proYang.png","language":"JavaScript","readme":"[![outils](https://cdn.slane.cn//outils-logo-2018-11-09_23-12-54.png)](https://github.com/proYang/outils)\r\n# outils\r\n[![npm](https://img.shields.io/npm/v/outils.svg)](https://www.npmjs.com/package/outils) \r\n[![Build Status](https://travis-ci.org/proYang/outils.svg?branch=master)](https://travis-ci.org/proYang/outils)\r\n[![Coverage](https://coveralls.io/repos/github/proYang/outils/badge.svg?branch=master)](https://coveralls.io/github/proYang/outils)\r\n[![LICENSE MIT](https://img.shields.io/npm/l/outils.svg)](https://www.npmjs.com/package/outils) \r\n\r\n \r\n前端业务代码工具库  \r\n\r\n\u003e 目的：高效率完成前端业务代码\r\n\r\n业务开发过程中，会经常用到`日期格式化`、`url参数转对象`、`浏览器类型判断`、`节流函数`等常用函数，为避免不同项目多次复制粘贴的麻烦，这里统一封装，并发布到npm，以提高开发效率。如果你也有常用的代码，欢迎为本项目提交pr。\r\n\r\n## :building_construction:  安装使用\r\n\r\n1. 直接下载`min`目录下的[outils.min.js](https://github.com/proYang/outils/blob/master/min/outils.min.js)使用，支持UMD通用模块规范  \r\n2. 使用npm安装\r\n\r\n### 浏览器:\r\n``` html\r\n  \u003cscript src=\"outils.min.js\"\u003e\u003c/script\u003e\r\n  \u003cscript\u003e\r\n      var OS = outils.getOS()\r\n  \u003c/script\u003e\r\n```\r\n\r\n### npm:\r\n``` bash\r\n$ npm install --save-dev outils\r\n```\r\n\r\nwebpack、RequireJS、SeaJS等\r\n\r\n``` javascript\r\n// 完整引入\r\nconst outils = require('outils')\r\nconst OS = outils.getOS()\r\n```\r\n\r\n**推荐使用方法**  \r\n\r\n你真的不需要完整引入所有函数，所以只引入需要使用的方法即可。\r\n``` javascript\r\n// 只引入部分方法('outils/\u003c方法名\u003e')\r\nconst getOS = require('outils/getOS')\r\nconst OS = getOS()\r\n```\r\n## :package:  API文档\r\n\r\n### Array  \r\n#### \u0026emsp;\u0026emsp;[arrayEqual][arrayEqual]\u0026emsp;\u0026emsp;判断两个数组是否相等 \r\n\r\n### Class\r\n#### \u0026emsp;\u0026emsp;[addClass][addClass]\u0026emsp;\u0026emsp;为元素添加class  \r\n#### \u0026emsp;\u0026emsp;[hasClass][hasClass]\u0026emsp;\u0026emsp;判断元素是否有某个class  \r\n#### \u0026emsp;\u0026emsp;[removeClass][removeClass]\u0026emsp;\u0026emsp;为元素移除class  \r\n\r\n### Cookie \r\n#### \u0026emsp;\u0026emsp;[getCookie][getCookie]\u0026emsp;\u0026emsp;根据name读取Cookie  \r\n#### \u0026emsp;\u0026emsp;[removeCookie][removeCookie]\u0026emsp;\u0026emsp;根据name删除Cookie\r\n#### \u0026emsp;\u0026emsp;[setCookie][setCookie]\u0026emsp;\u0026emsp;添加Cookie \r\n\r\n### Device  \r\n#### \u0026emsp;\u0026emsp;[getExplore][getExplore]\u0026emsp;\u0026emsp;获取浏览器类型和版本号  \r\n#### \u0026emsp;\u0026emsp;[getOS][getOS]\u0026emsp;\u0026emsp;获取操作系统类型\r\n\r\n### Dom  \r\n#### \u0026emsp;\u0026emsp;[getScrollTop][getScrollTop]\u0026emsp;\u0026emsp;获取滚动条距顶部的距离\r\n#### \u0026emsp;\u0026emsp;[offset][offset]\u0026emsp;\u0026emsp;获取一个元素的距离文档(document)的位置，类似jQ中的offset()\r\n#### \u0026emsp;\u0026emsp;[scrollTo][scrollTo]\u0026emsp;\u0026emsp;在${duration}时间内，滚动条平滑滚动到${to}指定位置\r\n#### \u0026emsp;\u0026emsp;[setScrollTop][setScrollTop]\u0026emsp;\u0026emsp;设置滚动条距顶部的距离\r\n#### \u0026emsp;\u0026emsp;[windowResize][windowResize]\u0026emsp;\u0026emsp;H5软键盘缩回、弹起回调\r\n\r\n### Function  \r\n#### \u0026emsp;\u0026emsp;[debounce][debounce]\u0026emsp;\u0026emsp;函数防抖   \r\n#### \u0026emsp;\u0026emsp;[throttle][throttle]\u0026emsp;\u0026emsp;函数节流   \r\n\r\n### Keycode  \r\n#### \u0026emsp;\u0026emsp;[getKeyName][getKeyName]\u0026emsp;\u0026emsp;根据keycode获得键名 \r\n\r\n### Object  \r\n#### \u0026emsp;\u0026emsp;[deepClone][deepClone]\u0026emsp;\u0026emsp;深拷贝，支持常见类型\r\n#### \u0026emsp;\u0026emsp;[isEmptyObject][isEmptyObject]\u0026emsp;\u0026emsp;判断Object是否为空\r\n\r\n### Random  \r\n#### \u0026emsp;\u0026emsp;[randomColor][randomColor] \u0026emsp;\u0026emsp;随机生成颜色\r\n#### \u0026emsp;\u0026emsp;[randomNum][randomNum]\u0026emsp;\u0026emsp;生成指定范围随机数 \r\n\r\n### Regexp  \r\n#### \u0026emsp;\u0026emsp;[isColor][isColor]\u0026emsp;\u0026emsp;判断是否为16进制颜色，rgb 或 rgba\r\n#### \u0026emsp;\u0026emsp;[isEmail][isEmail]\u0026emsp;\u0026emsp;判断是否为邮箱地址 \r\n#### \u0026emsp;\u0026emsp;[isIdCard][isIdCard]\u0026emsp;\u0026emsp;判断是否为身份证号\r\n#### \u0026emsp;\u0026emsp;[isPhoneNum][isPhoneNum]\u0026emsp;\u0026emsp;判断是否为手机号  \r\n#### \u0026emsp;\u0026emsp;[isUrl][isUrl]\u0026emsp;\u0026emsp;判断是否为URL地址\r\n\r\n### String  \r\n#### \u0026emsp;\u0026emsp;[digitUppercase][digitUppercase]\u0026emsp;\u0026emsp;现金额转大写\r\n\r\n### Support  \r\n#### \u0026emsp;\u0026emsp;[isSupportWebP][isSupportWebP]\u0026emsp;\u0026emsp;判断浏览器是否支持webP格式图片\r\n#### \r\n\r\n### Time  \r\n#### \u0026emsp;\u0026emsp;[formatPassTime][formatPassTime]\u0026emsp;\u0026emsp;格式化${startTime}距现在的已过时间\r\n#### \u0026emsp;\u0026emsp;[formatRemainTime][formatRemainTime]\u0026emsp;\u0026emsp;格式化现在距${endTime}的剩余时间\r\n#### \u0026emsp;\u0026emsp;[isLeapYear][isLeapYear]\u0026emsp;\u0026emsp;判断是否为闰年\r\n#### \u0026emsp;\u0026emsp;[isSameDay][isSameDay]\u0026emsp;\u0026emsp;判断是否为同一天\r\n#### \u0026emsp;\u0026emsp;[timeLeft][timeLeft]\u0026emsp;\u0026emsp;计算${startTime - endTime}的剩余时间\r\n#### \u0026emsp;\u0026emsp;[monthDays][monthDays]\u0026emsp;\u0026emsp;获取指定日期月份的总天数\r\n\r\n### Url\r\n#### \u0026emsp;\u0026emsp;[parseQueryString][parseQueryString]\u0026emsp;\u0026emsp;url参数转对象\r\n#### \u0026emsp;\u0026emsp;[stringfyQueryString][stringfyQueryString]\u0026emsp;\u0026emsp;对象序列化\r\n\r\n[arrayEqual]:https://github.com/proYang/outils/blob/master/src/array/arrayEqual.js\r\n\r\n[addClass]:https://github.com/proYang/outils/blob/master/src/class/addClass.js\r\n[hasClass]:https://github.com/proYang/outils/blob/master/src/class/hasClass.js\r\n[removeClass]:https://github.com/proYang/outils/blob/master/src/class/removeClass.js\r\n\r\n[getCookie]:https://github.com/proYang/outils/blob/master/src/cookie/getCookie.js\r\n[removeCookie]:https://github.com/proYang/outils/blob/master/src/cookie/removeCookie.js\r\n[setCookie]:https://github.com/proYang/outils/blob/master/src/cookie/setCookie.js\r\n\r\n[getExplore]:https://github.com/proYang/outils/blob/master/src/device/getExplore.js\r\n[getOS]:https://github.com/proYang/outils/blob/master/src/device/getOS.js\r\n\r\n[getScrollTop]:https://github.com/proYang/outils/blob/master/src/dom/getScrollTop.js\r\n[offset]:https://github.com/proYang/outils/blob/master/src/dom/offset.js\r\n[scrollTo]:https://github.com/proYang/outils/blob/master/src/dom/scrollTo.js\r\n[setScrollTop]:https://github.com/proYang/outils/blob/master/src/dom/setScrollTop.js\r\n[windowResize]:https://github.com/proYang/outils/blob/master/src/dom/windowResize.js\r\n\r\n[debounce]:https://github.com/proYang/outils/blob/master/src/function/debounce.js\r\n[throttle]:https://github.com/proYang/outils/blob/master/src/function/throttle.js\r\n\r\n[getKeyName]:https://github.com/proYang/outils/blob/master/src/keycode/getKeyName.js\r\n\r\n[deepClone]:https://github.com/proYang/outils/blob/master/src/object/deepClone.js\r\n[isEmptyObject]:https://github.com/proYang/outils/blob/master/src/object/isEmptyObject.js\r\n\r\n[randomColor]:https://github.com/proYang/outils/blob/master/src/random/randomColor.js\r\n[randomNum]:https://github.com/proYang/outils/blob/master/src/random/randomNum.js\r\n\r\n[isColor]:https://github.com/proYang/outils/blob/master/src/regexp/isColor.js\r\n[isEmail]:https://github.com/proYang/outils/blob/master/src/regexp/isEmail.js\r\n[isIdCard]:https://github.com/proYang/outils/blob/master/src/regexp/isIdCard.js\r\n[isPhoneNum]:https://github.com/proYang/outils/blob/master/src/regexp/isPhoneNum.js\r\n[isUrl]:https://github.com/proYang/outils/blob/master/src/regexp/isUrl.js\r\n\r\n[digitUppercase]:https://github.com/proYang/outils/blob/master/src/string/digitUppercase.js\r\n\r\n[isSupportWebP]:https://github.com/proYang/outils/blob/master/src/support/isSupportWebP.js\r\n\r\n[formatPassTime]:https://github.com/proYang/outils/blob/master/src/time/formatPassTime.js\r\n[formatRemainTime]:https://github.com/proYang/outils/blob/master/src/time/formatRemainTime.js\r\n[isLeapYear]:https://github.com/proYang/outils/blob/master/src/time/isLeapYear.js\r\n[isSameDay]:https://github.com/proYang/outils/blob/master/src/time/isSameDay.js\r\n[timeLeft]:https://github.com/proYang/outils/blob/master/src/time/timeLeft.js\r\n[monthDays]:https://github.com/proYang/outils/blob/master/src/time/monthDays.js\r\n\r\n[parseQueryString]:https://github.com/proYang/outils/blob/master/src/url/parseQueryString.js\r\n[stringfyQueryString]:https://github.com/proYang/outils/blob/master/src/url/stringfyQueryString.js\r\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FproYang%2Foutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FproYang%2Foutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FproYang%2Foutils/lists"}