# func.js-old **Repository Path**: holyhigh2/func.js-old ## Basic Information - **Project Name**: func.js-old - **Description**: 全面、便捷、一致化、高性能的纯函数开发包。基于模块化开发,聚焦解决大量重复场景与常用需求 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: 1.x - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 5 - **Forks**: 2 - **Created**: 2021-01-03 - **Last Updated**: 2023-04-01 ## Categories & Tags **Categories**: javascript-toolkits **Tags**: JavaScript, function, 函数库, Nodejs, 高性能 ## README # ![Func.js](https://holyhigh2.gitee.io/func.js/img/logo2.png) ## 介绍 全面、便捷、一致化、高性能的纯函数开发包。基于模块化开发,聚焦解决大量重复场景与常用需求,如 ## 基本特性 - 一致化的集合操作,如object/set/array/collection/list的遍历、映射、断言、聚合等 ```js //遍历对象 _.each({'1':'a','2':'b','3':'c'},console.log) //遍历DOM _.each(document.body.children,console.log) //遍历数组 _.each([1,2,3],console.log) //遍历Set _.each(new Set([1,2,3]),console.log) ``` - 常见的arraylike需求,如去重、扁平化、切片等 ```js //[1,2,4,"a","1",null] console.log(_.unique([1,2,2,4,4,'a','1','a',null,null])) ``` - 日期时间的量化操作、判断、格式化等 ```js //true console.log(_.isSameDay(new Date('2020-05-01'),'2020/5/1')) ``` - 数字格式化、处理等 ```js //¥1,234.10元 console.log(_.formatNumber(1234.1,'¥,000.00元')) ``` - 深度clone、各种字符串转换等 ```js //1-0-0- console.log(_.padEnd('1',6,'-0')) ``` - tree操作 ```js //tree nodes... console.log(_.arrayToTree(data,'id','pid',{sortKey:'sortNo',attrMap:{text:'name'}})) ``` ## 高级特性 - 部分应用 ```js // 2748 let hax2num = _.partial(parseInt,undefined,16); console.log(hax2num('abc')) ``` - 函数管道 ```js //6-12 _([1,2,3,4]) .map(v=>v*3) .filter(v=>v%2===0) .join('-') .value() ``` - 自定义扩展 ```js //mixins _.mixin({ select:_.get, from:_.chain, where:_.filter, top:_.head }); //invoke _.from(list) .where(conditions) .top() .select(field) .value() ``` ## 源码构建 1. npm install —— 安装依赖 2. npm run test —— 编译测试包,并启动测试页 3. npm run build —— 编译生产包 ## 使用说明 更多信息请访问[Func.js 文档网站](https://holyhigh2.gitee.io/func.js)