Skip to content

OFEXJS/Utility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Utility

个人前端开发的工具箱,用于存放和管理常用的工具函数,提高开发效率。

项目简介

这是一个轻量级的前端工具库,专注于提供实用的通用函数,解决日常开发中遇到的常见问题。项目持续维护,更多实用工具函数将陆续添加。

功能模块

1. 路径处理 (fatherPath)

  • 功能描述:将路径字符串分割,并返回包含所有父级路径的数组
  • 参数
    • path: 路径字符串
    • symbol: 路径分割符
  • 返回值:包含所有父级路径的数组

2. 文件大小转换 (fileSizeConversion)

  • 功能描述:将文件字节大小转换为人类可读的格式(如 KB, MB, GB 等)
  • 参数
    • length: 文件大小(字节)
  • 返回值:格式化后的文件大小字符串

使用方法

// 导入工具函数
import { fatherPath, fileSizeConversion } from "./core";

// 路径处理示例
const pathArray = fatherPath("user/profile/settings", "/");
console.log(pathArray); // ['/', '/user', '/user/profile', '/user/profile/settings']

// 文件大小转换示例
const size = fileSizeConversion(1024 * 1024 * 2.5);
console.log(size); // '2.50 MB'

项目结构

Utility/
├── index.js           # 主入口文件
├── core/              # 核心工具函数
│   ├── index.js       # 工具函数导出
│   ├── fatherPath.js  # 路径处理工具
│   └── fileSizeConversion.js # 文件大小转换工具
├── package.json       # 项目配置
└── README.md          # 项目说明

About

日常使用的工具方法集合

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors