jiangxtx / benz

A collection of front-end web developer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

benz

A collection of most common Utils, UIs, Componets, and so on. Aim to abstract codes away from the business in your projects.

Why named "benz"

It comes from "Mercedes-Benz", aiming to be higher, swifter, and stronger. This is its Persuit.

lodash-lite

utils/lodash-lite库,旨在替代lodash库中最最常用的几个功能。

**背景:**实际项目使用中,发现lodash中使用频率最高的往往就那么几个方法,但是却为此引入了整个lodash库,有点得不偿失。

为什么不通过Tree-shaking方法来引用lodash呢?

好问题!通过import {get, throttle} from 'lodash';这样的书写,并加以Tree-shaking相关配置,的确能够达到lodash瘦身的效果。但是,这种很容易出锅!一方面在于:总有同学一不小心就会写成import _ from 'lodash';这样的书写方式,从而无形中又把lodash整个库给打包进来了;另一方面在于:还有部分开发者偏爱import throttle from 'lodash/throttle';这样引用的,看似单独引入了包,但很容易造成lodash版本不一致的BUG。

一言蔽之,处处都是坑啊。基于此,方才封装了最最常用的几个函数(不会超出一只手指头的数量),即能满足超过90%的日常lodash需求。

About

A collection of front-end web developer.

License:MIT License


Languages

Language:TypeScript 65.1%Language:JavaScript 31.4%Language:SCSS 3.5%