npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

data-processing

v1.0.15

Published

This is a data processing project

Downloads

14

Readme

data-processingBuild Status

这是一个对数据做处理的项目

功能

getTime

描述: 对输入的时间字符串或者时间戳处理,返回一个经过处理的时间对象

参数

| 参数 | 描述 | 类型 | 默认值 | | ------- | -------------------- | -------------- | -------- | | dateStr | 时间字符串或者时间戳 | string,number | 当前时间 |

返回值

{
  year: 2020, // 年
  month: 3, // 月
  day: 1, // 日
  hour: 2, // 时
  minute: 20, // 分
  second: 33, // 秒
  date: 1583000433000, // 时间戳
  dateDay: "2020年3月1日"
}

getRegExp

描述: 对字符串根据相应的正则进行过滤,内置了几个常用的正则

参数

| 参数 | 描述 | 类型 | 默认值 | | ------ | -------------------------- | -------------- | ------ | | str | 需要处理的字符串 | string | 无 | | regExp | 正则表达式或者自带的模式名 | string,RegExp | 无 |

regExp 参数
  1. getChinese: 将非中文过滤掉
  2. getUChinese: 将中文过滤掉
  3. getNumber :将非数字过滤
  4. getUNumber :将数字过滤

返回值

过滤之后的字符串


removeChild

描述: 递归的删除指定的对象的空属性(属性值为[]、null、'')或者数组中对象的空属性

注意: 该功能只删除指定的并且为空的属性

参数

| 参数 | 描述 | 类型 | 默认值 | | ---------- | ---------------------- | ------------- | -------- | | data | 需要处理的对象或者数组 | object,array | 无 | | removeAttr | 需要删除的属性名 | string | children |

返回值

处理之后的数组或者对象


verify

描述:对字符串进行正则验证,成功返回 true,失败返回 flase

参数

| 参数 | 描述 | 类型 | 默认值 | | ------ | -------------------------- | -------------- | ------ | | str | 需要处理的字符串 | string | 无 | | regExp | 正则表达式或者自带的模式名 | string,RegExp | 无 |

regExp 参数
  1. email: 邮箱
  2. idCard: 身份证
  3. phone :手机

返回值

成功返回 true,失败返回 flase


screening

描述: 对数组对象的数据进行过滤

数组对象: [{},{}]

参数

| 参数 | 描述 | 类型 | 默认值 | | ----- | ------------------ | ------------------ | ------ | | datas | 需要处理的数组对象 | Array | 无 | | map | 映射,需要的属性 | obj,Array | 无 |

map 说明

如果为对象:

{
  name: oldName // key: 表示过滤后你要的属性名 value: 表示原来的属性名
}

如果为数组: 数组中包含需要的属性

返回值

过滤之后的数组对象


copyText

描述: 将提供的字符串加到剪贴板(支持移动端)

参数

| 参数 | 描述 | 类型 | 默认值 | | -------- | ---------------- | -------------- | ------ | | text | 需要复制的内容 | number,string | 无 | | callBack | 成功后的回调参数 | Function | 无 |

返回值

true

downFile

描述: 提供前端接受文件流下载功能

参数

| 参数 | 描述 | 类型 | 默认值 | | -------- | ---------------- | ---------- | --------- | | data | 文件流 | Array | 无 | | fileName | 文件名(带后缀) | String | 无 String |

返回值

printing

描述:根据提供的html片段调用浏览器的打印功能

参数

| 参数 | 描述 | 类型 | 默认值 | | -------- | ---------------- | ---------- | --------- | | html | html片段 | string | 无 |

返回值

true | false

下载及使用

下载

npm i data-processing | cnpm i data-processing

使用

import { getTime, getRegExp, removeChild, verify, screening, copyText } from 'data-processing/dist'

getTime(dateStr)

getRegExp(str, RegExp | string)

removeChild({} | [], attrName:string)

verify('[email protected]', 'email')

screening(data, ["name"])

copyText(string, callback)