lodash
Lodash 通过降低 array、number、objects、string 等等的使用难度从而让 JavaScript 变得更简单。 Lodash 的模块化方法 非常适用于:
遍历 array、object 和 string
对值进行操作和检测
创建符合功能的函数
官网 https://www.lodashjs.com/
| # install |
| npm i --save lodash |
| // Load the full build. |
| var _ = require('lodash'); |
| // Load the core build. |
| var _ = require('lodash/core'); |
| // Load the FP build for immutable auto-curried iteratee-first data-last methods. |
| var fp = require('lodash/fp'); |
| // Load method categories. |
| var array = require('lodash/array'); |
| var object = require('lodash/fp/object'); |
| |
| // Cherry-pick methods for smaller browserify/rollup/webpack bundles. |
| var at = require('lodash/at'); |
| var curryN = require('lodash/fp/curryN'); |
classnames 优化类名控制
classNames
https://github.com/JedWatson/classnames
| # install |
| npm install classnames |
| # use |
| classNames('foo', 'bar'); // => 'foo bar' |
| classNames('foo', { bar: true }); // => 'foo bar' |
| classNames({ 'foo-bar': true }); // => 'foo-bar' |
| classNames({ 'foo-bar': false }); // => '' |
| classNames({ foo: true }, { bar: true }); // => 'foo bar' |
| classNames({ foo: true, bar: true }); // => 'foo bar' |
| |
| // lots of arguments of various types |
| classNames('foo', { bar: true, duck: false }, 'baz', { quux: true }); // => 'foo bar baz quux' |
| |
| // other falsy values are just ignored |
| classNames(null, false, 'bar', undefined, 0, { baz: null }, ''); // => 'bar' |
uuid 生成随机uuid
see https://github.com/uuidjs/uuid
| #install |
| npm install uuid |
| #use |
| import { v4 as uuidv4 } from 'uuid'; |
| uuidv4(); |
dayjs 要求以当前时间为标准,生成固定格式时间
see https://dayjs.gitee.io/zh-CN/
| |
| npm install dayjs |
| |
| import dayjs from "dayjs"; |
| |
| dayjs(new Date()).format('MM-DD hh:mm') |
| |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】