New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

data-processing

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-processing - npm Package Compare versions

Comparing version
1.0.7
to
1.0.8
+2
-1
dist/model/getRegExp/index.d.ts

@@ -10,5 +10,6 @@ /**

* > 4. getUNumber :将数字过滤
* > 5. getSrc :将html中所有src中的地址按照数组返回
* @returns {string} 处理过后的字符串
*/
declare function getRegExp(str: string, regExp: RegExp | string): string;
declare function getRegExp(str: string, regExp: RegExp | string): string | string[];
export default getRegExp;

@@ -8,3 +8,4 @@ "use strict";

getNumber: /[\D]/g,
getUNumber: /[\d]/g
getUNumber: /[\d]/g,
getSrc: /[^http:]/g
};

@@ -20,9 +21,76 @@ /**

* > 4. getUNumber :将数字过滤
* > 5. getSrc :将html中所有src中的地址按照数组返回
* @returns {string} 处理过后的字符串
*/
function getRegExp(str, regExp) {
regExp = typeof regExp === 'string' ? RegTypeMap[regExp] : regExp;
str = str.replace(regExp, '');
return str;
switch (regExp) {
case "getSrc":
regExp = RegTypeMap[regExp];
str = str.replace(regExp, ',');
return str.split(",");
default:
regExp = typeof regExp === 'string' ? RegTypeMap[regExp] : regExp;
str = str.replace(regExp, '');
return str;
}
}
console.log(getRegExp(`
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<link rel="canonical" href="https://blog.csdn.net/linggty/article/details/90241748"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="report" content='{"pid":"blog"}'>
<meta name="referrer" content="always">
<meta http-equiv="Cache-Control" content="no-siteapp" /><link rel="alternate" media="handheld" href="#" />
<meta name="shenma-site-verification" content="5a59773ab8077d4a62bf469ab966a63b_1497598848">
<meta name="csdn-baidu-search" content='{"autorun":true,"install":true,"keyword":"js字符串与数组互转_Java_linggty的博客-CSDN博客"}'>
<link href="https://csdnimg.cn/public/favicon.ico" rel="SHORTCUT ICON">
<title>js字符串与数组互转_Java_linggty的博客-CSDN博客</title>
<meta name="description" content="字符串转数组首先声明一个测试用的字符串let str = abcdsplit方法 使用特定的分隔Java">
<script src='//g.csdnimg.cn/tingyun/1.8.3/blog.js' type='text/javascript'></script>
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/detail-17e6f72b2e.min.css">
<script type="application/ld+json">{"@context":"https:\/\/ziyuan.baidu.com\/contexts\/cambrian.jsonld","@id":"https:\/\/blog.csdn.net\/linggty\/java\/article\/details\/90241748","appid":1638831770136827,"title":"js\u5b57\u7b26\u4e32\u4e0e\u6570\u7ec4\u4e92\u8f6c_Java_linggty\u7684\u535a\u5ba2-CSDN\u535a\u5ba2","pubDate":"2019-05-15T17:55:33","upDate":"2019-05-15T17:55:33"}</script>
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/themes/skin-blackboard/skin-blackboard-b6ae258d29.min.css">
<!-- 自定义皮肤样式-->
<script type="text/javascript">
var username = "linggty";
var blog_address = "https://blog.csdn.net/linggty";
var static_host = "https://csdnimg.cn/release/phoenix/";
var currentUserName = "";
var isOwner = false;
var loginUrl = "http://passport.csdn.net/account/login?from=https://blog.csdn.net/linggty/java/article/details/90241748"
var blogUrl = "https://blog.csdn.net/";
var curSkin = "skin-blackboard";
// 收藏所需数据
var articleTitle = "js字符串与数组互转";
var articleDesc = "字符串转数组首先声明一个测试用的字符串let str = abcdsplit方法 使用特定的分隔Java";
var articleTitles = "js字符串与数组互转_Java_linggty的博客-CSDN博客";
var nickName = "CinseYoung";
var isCorporate = false;
var subDomainBlogUrl = "https://blog.csdn.net/"
var digg_base_url = "https://blog.csdn.net/linggty";
var articleDetailUrl = "https://blog.csdn.net/linggty/article/details/90241748";
var isShowThird = "1"
var canRead = true;
</script>
<script src="https://csdnimg.cn/public/common/libs/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
<!--js引用-->
<script src="//g.csdnimg.cn/??fixed-sidebar/1.1.6/fixed-sidebar.js,report/1.4.7/report.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://csdnimg.cn/public/sandalstrap/1.4/css/sandalstrap.min.css">
`, "getSrc"))
exports.default = getRegExp;
{
"name": "data-processing",
"version": "1.0.7",
"version": "1.0.8",
"description": "This is a data processing project",

@@ -8,3 +8,3 @@ "main": "index.js",

"build": "tsc",
"test": "jest"
"test": "jest --config jestconfig.json"
},

@@ -22,5 +22,11 @@ "repository": "git+https://github.com/Aisanyi/dataProcessing.git",

"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@babel/preset-typescript": "^7.9.0",
"@types/jest": "^25.2.1",
"babel-jest": "^25.4.0",
"jest": "^25.3.0",
"ts-jest": "^25.4.0",
"typescript": "^3.8.3"
}
}
# data-processing[![Build Status](https://travis-ci.org/Aisanyi/dataProcessing.svg?branch=master)](https://travis-ci.org/Aisanyi/dataProcessing)
> 这是一个对数据做处理的项目,目前只有对时间的处理
> 这是一个对数据做处理的项目

@@ -4,0 +4,0 @@ ## 功能

'use strict';
const { getRegExp } = require('../dist');
test('测试getRegExp过滤非中文', () => {
expect(getRegExp('asdaksd-%%%5qweq积分哈世界大会发', 'getChinese')).toBe('积分哈世界大会发');
});
test('测试getRegExp过滤中文', () => {
expect(getRegExp('asdaksd%%3234&&积分哈世界大会发', 'getUChinese')).toBe('asdaksd%%3234&&');
});
test('测试getRegExp过滤非数字', () => {
expect(getRegExp('123456哈四大皆空很疯狂al;sk', 'getNumber')).toBe('123456');
});
test('测试getRegExp过滤数字', () => {
expect(getRegExp('123456哈四大皆空很疯狂al;sk', 'getUNumber')).toBe('哈四大皆空很疯狂al;sk');
});
'use strict';
const { getTime } = require('../dist');
test('传入为string', () => {
const result = getTime('2020.3.1 2:20:33');
let date = new Date('2020.3.1 2:20:33')
expect(result).toEqual({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
date: date.getTime(),
dateDay: `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`,
});
});
test('传入为string,2020-3-1', () => {
const result = getTime('2020-3-1 2:20:33');
let date = new Date('2020.3.1 2:20:33')
expect(result).toEqual({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
date: date.getTime(),
dateDay: `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`,
});
});
test('传入为string,2020年3月1日', () => {
const result = getTime('2020年3月1日 2:20:33');
let date = new Date('2020.3.1 2:20:33')
expect(result).toEqual({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
date: date.getTime(),
dateDay: `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`,
});
});
test('传入为number,时间戳', () => {
let date = new Date('2020.3.1 2:20:33')
const result = getTime(date.getTime());
expect(result).toEqual({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
date: date.getTime(),
dateDay: `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`,
});
});
test('不传值', () => {
const result = getTime();
let date = new Date()
expect(result).toEqual({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
date: result.date,
dateDay: `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`,
});
});
test('传值为空字符串', () => {
const result = getTime('');
let date = new Date()
expect(result).toEqual({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: 0,
minute: 0,
second: 0,
date: new Date(`${date.getFullYear()}.${date.getMonth() + 1}.${date.getDate()}`).getTime(),
dateDay: `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`,
});
});
'use strict';
const { removeChild } = require('../dist');
test('data为数组,删除空children', ()=>{
const data = [
{
name: '李梦冬20',
children: []
},
{
name: '李梦冬30',
children: [
{
name: '李意睆',
children: null
}
]
}
]
const expected = [
{
name: '李梦冬20'
},
{
name: '李梦冬30',
children: [
{
name: '李意睆'
}
]
}
]
const received = removeChild(data)
expect(received[0]).toMatchObject(expected[0])
expect(received[1]).toMatchObject(expected[1])
})
test('data为数组为空,删除空children', ()=>{
const data = []
const expected = []
const received = removeChild(data)
expect(received).toStrictEqual(expected)
})
test('data为对象,删除空children', ()=>{
const data = {
name: '李波',
children: [
{
name: '李梦冬',
children: ''
},
{
name: '李梦君',
children: null
}
]
}
const expected = {
name: '李波',
children: [
{
name: '李梦冬'
},
{
name: '李梦君'
}
]
}
const received = removeChild(data)
expect(received).toMatchObject(expected)
})
test('data为对象,并且children为null,删除空children', ()=>{
const data = {
name: '李波',
children: null
}
const expected = {
name: '李波'
}
const received = removeChild(data)
expect(received).toMatchObject(expected)
})
test('data为对象,并且为空对象,删除空children', ()=>{
const data = {}
const expected = {}
const received = removeChild(data)
expect(received).toEqual(expected)
})