
Security News
Socket Releases Free Certified Patches for Nuxt Security Vulnerabilities
Socket releases free Certified Patches for high-severity Nuxt vulnerabilities, including server-side remote code execution through server island props.
public-service
Advanced tools
Array转换下拉选数据
string设置标签名称
string生成随机id
string生成随机颜色
boolean验证数据类型是否为预测类型
boolean验证手机号码和座机
string | boolean校验经度是否符合规范
string | boolean校验纬度是否符合规范
object对象深克隆
*转换表格数据
Array数组根据键名去重
*数组添加key属性
array数组中取出指定的字段
number获取表格列配置的总宽度
number获取文字的宽度
*拼接参数
cookie存值
stringcookie取值
cookie删值
localStorage 取值
array将数组按键名取出单一值可配置条件
array循环两组数据,根据条件返回新的数组
array将数组根据目标键名中取出或排除该字段
array将对象数组按照对象某一属性分组
string开始结束时间转换显示
string | null获取url拼接的参数
number获取两个坐标之间的距离
array百度坐标转高德坐标
array高德坐标转百度坐标
array高德坐标转天地图坐标
array天地图坐标转高德坐标
Promise自定义上传文件
修改网页标题
修改网页图标
string转换字节单位
string文本超出数量省略号显示
自动全屏
浏览器全屏
取消全屏
function防抖函数
function节流函数
string返回localStorage中的用户信息
boolean验证按钮权限
*获取菜单按钮
boolean验证菜单按钮权限
boolean获取菜单按钮
string毫秒转天-小时-分
string小数截取
Array转换下拉选数据
Kind: global function
Returns: Array - 根据需要生成的select option配置
| Param | Type | Default | Description |
|---|---|---|---|
| data | array | 数据源 | |
| valueIndex | string | "id" | option的value |
| labelIndex | string | "name" | option的label |
| addAll | boolean | false | 添加option {value: '', text: '全部'} |
string设置标签名称
Kind: global function
| Param | Description |
|---|---|
| data | 数据 |
| value | 值 |
string生成随机id
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| length | number | 6 | 生成的长度 |
string生成随机颜色
Kind: global function
Returns: string - #xxxxxx
boolean验证数据类型是否为预测类型
Kind: global function
| Param | Type | Description |
|---|---|---|
| tgt | any | 目标 |
| type | string | 预测类型 |
boolean验证手机号码和座机
Kind: global function
| Param | Type |
|---|---|
| value | number | string |
string | boolean校验经度是否符合规范
Kind: global function
| Param | Type |
|---|---|
| value | number | string |
string | boolean校验纬度是否符合规范
Kind: global function
| Param | Type |
|---|---|
| value | number | string |
object对象深克隆
Kind: global function
| Param | Type | Description |
|---|---|---|
| obj | object | 要克隆的对象 |
*转换表格数据
Kind: global function
| Param | Type | Description |
|---|---|---|
| data | array | 需要转换结构的源数据 |
| needColNum | boolean | 需要增加table序号列数据 |
| needKey | boolean | 需要增加唯一标识key |
| currentPage | number | 当前页 |
| pageSize | number | 每页数据数目 |
Array数组根据键名去重
Kind: global function
Returns: Array - 返回筛选后的数组对象
| Param | Type | Description |
|---|---|---|
| array | array | 需要去重的数组 |
| key | string | 指定的根据字段 |
*数组添加key属性
Kind: global function
| Param | Type | Description |
|---|---|---|
| data | array | 需要转换结构的源数据 |
| parentKey | boolean | string | 父元素Key值 |
| newKey | boolean | 子元素key |
array数组中取出指定的字段
Kind: global function
Returns: array - 返回一维数组
| Param | Type | Description |
|---|---|---|
| data | array | 数据 |
| key | string | 指定键名 |
number获取表格列配置的总宽度
Kind: global function
Returns: number - table宽度
| Param | Type | Description |
|---|---|---|
| columns | array | 表格的columns属性 |
number获取文字的宽度
Kind: global function
Returns: number - 列宽度
| Param | Type | Description |
|---|---|---|
| str | string | 文字 |
*拼接参数
Kind: global function
Returns: * - 返回导出拼接字符串
| Param | Type | Description |
|---|---|---|
| params | object | 导出文件所需参数 |
cookie存值
Kind: global function
| Param | Type | Description |
|---|---|---|
| c_name | string | 要保存字段的名称 |
| value | string | 要保存字段的值 |
stringcookie取值
Kind: global function
Returns: string - 返回字段对应的值, 若字段不存在则返回空
| Param | Type | Description |
|---|---|---|
| c_name | string | 要取得的字段名 |
cookie删值
Kind: global function
| Param | Type | Description |
|---|---|---|
| name | string | 要清空的字段名 |
localStorage 取值
Kind: global function
| Param | Type | Description |
|---|---|---|
| field | string | 要获取的对象信息 |
| fieldName | string | 要获取的对象中的信息 |
array将数组按键名取出单一值可配置条件
Kind: global function
Returns: array - 一维数组
| Param | Type | Description |
|---|---|---|
| arr | array | 目标数组 |
| key | string | 取出数据的属性名 |
| where | function | string | () |
array循环两组数据,根据条件返回新的数组
Kind: global function
Returns: array - 符合条件的数据
| Param | Type | Description |
|---|---|---|
| arr | array | 目标数组 |
| arr2 | array | 数组2 |
| keys | array | 条件名称 |
array将数组根据目标键名中取出或排除该字段
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| arr | array | 目标数组 | |
| keys | array | 目标键名 | |
| exclude | boolean | false | 是否为排除目标键名模式,默认为false; false: 按键名获取字段; true: 获取键名以外的字段 |
array将对象数组按照对象某一属性分组
Kind: global function
| Param | Type | Description |
|---|---|---|
| arr | array | 目标数组 |
| key | string | 分组根据的属性名 |
string开始结束时间转换显示
Kind: global function
Returns: string - 返回字符"YYYY~YYYY"
| Param | Type | Description |
|---|---|---|
| startTime | object | string | 开始日期 |
| endTime | object | string | 结束日期 |
| format | string | 格式化 |
| symbol | string | 转换符号 |
string | null获取url拼接的参数
Kind: global function
| Param | Type |
|---|---|
| name | string |
number获取两个坐标之间的距离
Kind: global function
| Param | Type | Description |
|---|---|---|
| lonLat | object | 坐标{longitude, latitude} |
| lonLat2 | object | 坐标{longitude, latitude} |
array百度坐标转高德坐标
Kind: global function
Returns: array - 经纬度一纬数组
| Param | Type | Description |
|---|---|---|
| lng | number | string | 经度 |
| lat | number | string | 纬度 |
array高德坐标转百度坐标
Kind: global function
Returns: array - 经纬度一纬数组
| Param | Type | Description |
|---|---|---|
| lng | number | string | 经度 |
| lat | number | string | 纬度 |
array高德坐标转天地图坐标
Kind: global function
Returns: array - 经纬度一纬数组
| Param | Type | Description |
|---|---|---|
| lng | number | string | 经度 |
| lat | number | string | 纬度 |
array天地图坐标转高德坐标
Kind: global function
Returns: array - 经纬度一纬数组
| Param | Type | Description |
|---|---|---|
| lng | number | string | 经度 |
| lat | number | string | 纬度 |
Promise自定义上传文件
Kind: global function
| Param | Type | Description |
|---|---|---|
| param | object | 上传参数 |
| name | string | 上传字段名称 |
| serverURL | string | 上传地址 |
| type | string | 文件类型 |
修改网页标题
Kind: global function
| Param | Type | Description |
|---|---|---|
| title | string | 标题 |
修改网页图标
Kind: global function
| Param | Type | Description |
|---|---|---|
| link | string | 图标地址 |
string转换字节单位
Kind: global function
| Param | Type | Description |
|---|---|---|
| limit | number | 大小 |
string文本超出数量省略号显示
Kind: global function
| Param | Type | Description |
|---|---|---|
| text | string | 文本内容 |
| length | number | 要省略文本长度(不传默认为10) |
自动全屏
浏览器全屏
Kind: global function
| Param | Type | Description |
|---|---|---|
| element | element | 节点 |
取消全屏
function防抖函数
Kind: global function
| Param | Type | Description |
|---|---|---|
| action | function | 函数(要进行防抖的函数) |
| delay | number | 传入的毫秒,在这也就是延迟时间 |
function节流函数
Kind: global function
| Param | Type | Description |
|---|---|---|
| action | function | 要执行的方法 |
| wait | number | 等待的时长 |
string返回localStorage中的用户信息
Kind: global function
| Param | Type | Description |
|---|---|---|
| sessionName | string | 要获取的对象信息 |
| name | string | 要获取的对象中的信息 |
boolean验证按钮权限
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| accessCode | string | 按钮权限编码 | |
| key | string | "accessBtn" | localStorage 存储键名 |
*获取菜单按钮
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| key | string | "accessBtn" | localStorage 存储键名 |
boolean验证菜单按钮权限
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| menuCode | string | 菜单编码 | |
| accessCode | string | 菜单权限编码 | |
| key | string | "accessMenuBtn" | localStorage 存储键名 |
boolean获取菜单按钮
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| menuCode | string | 菜单编码 | |
| key | string | "accessMenuBtn" | localStorage 存储键名 |
string毫秒转天-小时-分
Kind: global function
| Param | Type | Description |
|---|---|---|
| result | number | 毫秒数 |
string小数截取
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| value | number | 数值 | |
| float | number | 2 | 截取长度 |
FAQs
The npm package public-service receives a total of 16 weekly downloads. As such, public-service popularity was classified as not popular.
We found that public-service demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket releases free Certified Patches for high-severity Nuxt vulnerabilities, including server-side remote code execution through server island props.

Security News
An open letter signed by 50 companies, from NVIDIA and Microsoft to Mistral and Hugging Face, urges Washington not to restrict open weight AI.

Security News
/Research
A fake corepack.org site is impersonating the Node.js tool and delivers an infostealer and proxyware to developers who download it.