パッケージの詳細

nice-fns

l24680444MIT2.1.1

A modern and nice library of JS functions.

web, node, lodash, es-toolkit

readme

nice-fns

一个基于 TypeScript 和 ESToolkit 开发的现代 JS 函数库。

文档地址

安装方式

# npm
npm i nice-fns

# yarn or pnpm
pnpm add nice-fns

使用方式

import { addUnit } from 'nice-fns'

addUnit('10')
// => '10px'

迁移至 v2.1

  • 删除部分函数全局配置以保证应用侧捆绑器能够正常 treeshaking
    • addUnit.defaultUnit
    • classState.is
    • clientRun.resolveProfile -> resolveClientRunProfile
    • clientRun.defaults
    • createScrollbarHelper.getScrollLeft -> getScrollLeft,其他函数类似
    • scaleDom.getScale -> getScaled
    • scaleDom.revert -> revertScaled
    • toDictionary.builtinMethods
  • es-toolkit 兼容层改为由 nice-fns/compat 提供

迁移至 v2.x

  • 替换 lodash 为 es-toolkit
  • 移除废弃的函数参数
  • createLogger 支持子模块功能
  • toDictionary 移除内部函数排序支持
  • 重命名 toValue 为 resolveValue
  • 删除了部分函数
    • baseAssign
    • createCallbacks
    • fromEntries
    • toEntries
    • protoOf
  • es-toolkit 不支持 lodash 的函数

迁移至 v1.x

  1. arrayToMap 移除 filter 配置项,对象数组转换时依据改为 primaryKey 不为空值。
  2. createBEM 修复 namespace 为函数变更时不会变换结果中的 namespace
  3. createCallbacks 移除配置项和单一执行方式,回调句柄将保持唯一性,runAll 变更为 run
  4. 部分函数返回中的 null 变更为 undefined
  5. Extname 更名为 ExtName,相关文件名和变量名已变更。
  6. tree 相关函数类型重构。
  7. toDictionarysize 函数变更为 size 属性,类型重构。

更新履歴

Changelog

2.1.1 (2025-05-14)

Chores

  • src: 顶级作用于部分变量添加 / @PURE / 注释,用于标记可树摇 (ca0e00c)

2.1.0 (2025-03-21)

Bug Fixes

  • 修复 docs:build 命令报错 (847a623)
  • 修复 docs:build 命令报错 (888655e)
  • 修复 docs:build 命令报错 (1464ad4)
  • 修复文档构建失败 (187275e)

Refactors

  • 重构项目并升级依赖 (5fd6448)

2.0.1 (2025-03-20)

2.0.0 (2025-03-20)

Refactors

  • esToolkit: 重构工具库并替换底层依赖 lodash 改为 es-toolkit (decd6e4)
  • types: 将类型定义迁移到独立模块 (b8904ca)

Docs

  • README: 更新 v2.x 版本迁移指南 (55c092c)

1.10.0 (2024-09-11)

Features

  • 🎸 getFullURL.defaultBase 支持回调方式 (f619425)

Chores

  • 🤖 移除无效类型 (e54c1ac)

1.9.0 (2024-08-16)

Features

  • 🎸 add callWithSignal (61a792b)
  • 🎸 add createEventHook (eae85a4)
  • 🎸 add isPromise, isPromiseLike (d01e470)
  • 🎸 add parallelCall (d9db95b)
  • 🎸 add serialCall (270968f)

Chores

  • 🤖 替换 createCallbacks() 为 createEventHook() (8eb1ddc)
  • 🤖 完善 callWithSignal 单元测试 (b5dcd10)
  • 🤖 完善 parallelCall、serialCall 测试用例 (83ac30c)
  • 🤖 优化 castError (8ede79d)
  • 🤖 update deps (c064aca)

1.8.1 (2024-07-26)

Chores

  • 🤖 parseContentDisposition 优化入参类型 (6e6c74d)

1.8.0 (2024-07-08)

Features

Bug Fixes

  • 🐛 修复 createScrollbarHelper 在 dpr 小于 1 时 addScroll 系列函数无效 (96c9eb6)

Chores

  • 🤖 replace defaultWindow to clientRun (a7b2edc)
  • 🤖 scaleDom 支持获取元素的缩放比例 (82efb01)

1.7.5 (2024-07-06)

Bug Fixes

  • 🐛 修复 createScrollbarHelper 在 dpr 小于 1 时 addScroll 系列函数无效 (96c9eb6)

Chores

  • 🤖 scaleDom 支持获取元素的缩放比例 (82efb01)

1.7.4 (2024-07-01)

Bug Fixes

  • 🐛 修复 createScrollbarHelper 的 isReach 系列函数计算误差 (4f8601c)

Chores

  • 🤖 优化 findUpElement 类型声明 (f46b860)

1.7.3 (2024-06-24)

Chores

  • 🤖 优化 createScrollbarHelper (7b6aa8c)

1.7.2 (2024-06-24)

Chores

1.7.1 (2024-06-24)

Chores

  • 🤖 优化 scaleDom 实现方式 (1b07a61)

1.7.0 (2024-06-22)

Features

  • 🎸 scaleDom 支持还原 (6521f44)

Chores

  • 🤖 优化 scaleDom 错误边界 (175dd31)

1.6.2 (2024-06-22)

Chores

  • 🤖 优化 scaleDom 错误边界 (175dd31)

1.6.1 (2024-06-22)

Chores

  • 🤖 优化 listenWindowResize (11e2245)
  • 🤖 优化 scaleDom 缩放逻辑 (e2a7e28)

1.6.0 (2024-06-22)

Features

  • 🎸 add createScrollbarHelper (1f8b795)
  • 🎸 add listenWindowResize (95bef5e)
  • 🎸 add scaleDom (84982db)

Chores

  • 🤖 优化 createFlexible 功能 (78c0cd1)

1.5.6 (2024-06-11)

Chores

  • 🤖 优化 createFlexible 功能 (78c0cd1)

1.5.5 (2024-06-11)

Chores

  • 🤖 更改 createFlexible.bodyFontSize 默认值为 inherit (5cb639d)
  • 🤖 更改部署脚本 (a67b777)

1.5.4 (2024-06-05)

Bug Fixes

  • 🐛 修复部署脚本 403 权限问题 (596bf01)

Chores

  • 🤖 更改文档部署方式 (a673ac1)
  • 🤖 修改部署脚本 (e8ed0c9)
  • 🤖 优化函数类型 (e0c2620)
  • 🤖 update homepage (c4ef851)

1.5.3 (2024-06-05)

Chores

  • 🤖 优化函数类型 (e0c2620)

1.5.2 (2024-05-22)

Chores

  • 🤖 更改 createFlexible.rootFontSize 默认值 (0dbcfd9)
  • 🤖 优化 createFlexible.rootFontSize 配置 (0cac62b)

1.5.1 (2024-05-22)

Chores

  • 🤖 优化 createFlexible.rootFontSize 配置 (0cac62b)

1.5.0 (2024-05-22)

Features

  • 🎸 add createFlexible、getDpr、detectHalfPX (ae33c25)

1.4.2 (2024-05-08)

Chores

  • 🤖 优化 toArrayTree 类型 (478971b)

1.4.1 (2024-04-24)

Features

  • 🎸 add flattenPaths (cb7e36b)
  • 🎸 toArrayTree 支持仅移除空子级属性功能 (7721921)

Bug Fixes

  • 🐛 修复 flattenPaths 错误引用 lodash (2adc9a1)

1.4.0 (2024-04-24)

Features

  • 🎸 add flattenPaths (cb7e36b)
  • 🎸 toArrayTree 支持仅移除空子级属性功能 (7721921)

1.3.0 (2024-04-23)

Features

  • 🎸 toArrayTree 支持仅移除空子级属性功能 (7721921)

1.2.2 (2024-04-16)

Features

Chores

  • 🤖 格式化代码 (d484a6f)
  • 🤖 优化 toDictionary 内置函数类型 (da07143)
  • 🤖 优化 useDictionary 类型 (9285508)

1.2.1 (2024-04-15)

Features

Chores

  • 🤖 格式化代码 (d484a6f)
  • 🤖 优化 toDictionary 内置函数类型 (da07143)

1.2.0 (2024-04-02)

Features

Chores

1.1.0 (2024-03-21)

Features

  • 🎸 timerWithControl support cleanup callback (96b5039)

1.0.2 (2024-03-08)

Chores

  • 🤖 优化 parseContentDisposition 正则 (4adc1cd)

1.0.1 (2024-03-07)

Chores

  • 🤖 优化 Dictionary 类型 (6fbc593)

1.0.0 (2024-03-01)

1.0.0-1 (2024-02-07)

Chores

  • 🤖 rename extname to extName (c6cc10f)

Refactors

  • 💡 重构函数类型和实现 (1db1147)

1.0.0-0 (2024-02-07)

Refactors

  • 💡 重构函数类型和实现 (1db1147)

0.5.1 (2023-12-29)

Chores

  • 🤖 使用 ES6 已支持函数替换 lodash 函数 (524df72)
  • 🤖 优化发布脚本 (afb4f3e)

0.5.0 (2023-12-29)

Features

  • 🎸 添加工具函数 arrayToMap (bc30add)
  • 🎸 toDictionary 新增 getKey、getKeyByValue 方法 (f1b69e0)

0.4.2 (2023-12-26)

Bug Fixes

  • 🐛 修复 toDictionary 部分函数返回类型 (e84c98e)

Chores

  • 🤖 发布前增加类型校验 (0b3cb96)

0.4.1 (2023-12-24)

Features

  • 🎸 parseJSON 支持 onNil 直接设置默认值 (d6dd335)

0.4.0 (2023-12-19)

Features

  • 🎸 添加工具函数 createLogger (f877b1b)
  • 🎸 createLogger 新增 format 函数 (e7d0b79)

0.3.0 (2023-12-19)

Features

  • 🎸 添加工具函数 createLogger (f877b1b)

0.2.2 (2023-12-19)

Chores

  • 🤖 优化 classState 和 toDictionary 类型 (a15cad7)
  • 🤖 优化函数类型 (40a2e3e)

0.2.1 (2023-12-18)

Chores

  • 🤖 优化函数类型 (40a2e3e)

0.2.0 (2023-12-18)

Chores

  • 🤖 简化树结构转换和字典转换函数类型 (a1fe20b)
  • 🤖 移除部分函数默认配置 (6ba87eb)
  • 🤖 优化函数类型 (d16866a)
  • 🤖 优化树结构转换函数类型 (8c781fc)

0.1.2 (2023-12-14)

Chores

  • 🤖 优化树结构数据转换类型 (74bc11a)

0.1.1 (2023-12-13)

Bug Fixes

  • 🐛 修复 toDictionary 导出函数名错误 (cd0fb93)

0.1.0 (2023-12-13)

Features

  • 🎸 添加工具函数 classState (738e501)
  • 🎸 添加工具函数 createDictionary、arrayToDictionary (3285ceb)
  • 🎸 添加工具函数 cssVar、cssVarName (60e12b4)
  • 🎸 添加工具函数 getExtnameByFileType、getFileTypeByExtname (d03706e)
  • 🎸 添加工具函数 getRootFontSize、getScrollParent (814baa0)
  • 🎸 添加工具函数 getWindowSize、scalePx (5224d6c)
  • 🎸 添加工具函数 parseContentDisposition (84fd653)
  • 🎸 添加工具函数 pxToRem、pxToViewport (93eebfe)
  • 🎸 添加工具函数 unitToPx、saveAs (4b5072f)

Chores

  • 🤖 补充 createDictionary、arrayToDictionary 内置方法 (3db8a2a)
  • 🤖 更改 unbuild 配置 (16c10e8)
  • 🤖 优化 package.json 的 exports 配置 (cd1836b)
  • 🤖 重命名 objectCompactcompactObject (8d8b795)

Refactors

  • 💡 重构 createDictionary 和 arrayToDictionary 为 toDictionary (1e909ce)
  • 💡 重构 saveAs,摆脱 file-saver 依赖 (5d8d330)

0.1.0-3 (2023-12-08)

Features

  • 🎸 添加工具函数 cssVar、cssVarName (60e12b4)
  • 🎸 添加工具函数 getExtnameByFileType、getFileTypeByExtname (d03706e)
  • 🎸 添加工具函数 getRootFontSize、getScrollParent (814baa0)
  • 🎸 添加工具函数 getWindowSize、scalePx (5224d6c)
  • 🎸 添加工具函数 parseContentDisposition (84fd653)
  • 🎸 添加工具函数 pxToRem、pxToViewport (93eebfe)
  • 🎸 添加工具函数 unitToPx、saveAs (4b5072f)

Refactors

  • 💡 重构 saveAs,摆脱 file-saver 依赖 (5d8d330)

0.1.0-2 (2023-12-08)

Features

  • 🎸 添加工具函数 cssVar、cssVarName (60e12b4)
  • 🎸 添加工具函数 getExtnameByFileType、getFileTypeByExtname (d03706e)
  • 🎸 添加工具函数 getRootFontSize、getScrollParent (814baa0)
  • 🎸 添加工具函数 getWindowSize、scalePx (5224d6c)
  • 🎸 添加工具函数 parseContentDisposition (84fd653)
  • 🎸 添加工具函数 pxToRem、pxToViewport (93eebfe)
  • 🎸 添加工具函数 unitToPx、saveAs (4b5072f)

0.1.0-1 (2023-12-07)

Features

  • 🎸 添加工具函数 createBEM (9bff803)

Chores

  • 🤖 优化 release-it 配置 (c353f01)

Docs

0.1.0-0 (2023-12-07)

Features

  • 🎸 初始化项目 (4f74b4f)
  • 🎸 开发工具函数并添加测试用例 (9bb677a)
  • 🎸 添加工具函数 (c28561e)
  • 🎸 添加工具函数 addUnit、isNumeric (38993a4)
  • 🎸 添加网站文档 (b3ae28c)

Chores

  • 🤖 优化代码注释 (ad292f4)