Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zhi-common

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zhi-common - npm Package Compare versions

Comparing version 1.6.2 to 1.8.0

8

dist/index.d.ts
import ZhiCommon from "./lib/zhi-common";
import ZhiUtil from "./lib/ZhiUtil";
import DateUtil from "./lib/dateUtil";
import HtmlUtil from "./lib/htmlUtil";
import JsonUtil from "./lib/jsonUtil";
import StrUtil from "./lib/strUtil";
import ObjectUtil from "./lib/objectUtil";
export { ZhiCommon };
export { ZhiUtil };
export { DateUtil, HtmlUtil, JsonUtil, StrUtil, ObjectUtil };

@@ -9,3 +9,3 @@ /**

declare class DateUtil {
private readonly TIME_SPLIT;
private static readonly TIME_SPLIT;
/**

@@ -19,3 +19,3 @@ * 给日期添加小时

*/
private addHoursToDate;
private static addHoursToDate;
/**

@@ -30,3 +30,3 @@ * 转换ISO日期为中文日期的通用转换方法

*/
private formatIsoToZhDateFormat;
private static formatIsoToZhDateFormat;
/**

@@ -37,3 +37,3 @@ * 转换ISO日期为中文完整时间

*/
formatIsoToZh(str: string): string;
static formatIsoToZh(str: string): string;
/**

@@ -44,3 +44,3 @@ * 转换ISO日期为中文日期

*/
formatIsoToZhDate(str: string): string;
static formatIsoToZhDate(str: string): string;
/**

@@ -51,20 +51,20 @@ * 转换ISO日期为中文时间

*/
formatIsoToZhTime(str: string): string;
static formatIsoToZhTime(str: string): string;
/**
* 当前日期时间完整格式,格式:2023-03-10 02:03:43
*/
nowZh(): string;
static nowZh(): string;
/**
* 当前日期,格式:2023-03-10
*/
nowDateZh(): string;
static nowDateZh(): string;
/**
* 当前时间,格式:02:03:43
*/
nowTimeZh(): string;
static nowTimeZh(): string;
/**
* 当前年份
*/
nowYear(): number;
static nowYear(): number;
}
export default DateUtil;

@@ -5,4 +5,2 @@ /**

declare class HtmlUtil {
private readonly mdUtil;
constructor();
/**

@@ -13,3 +11,3 @@ * 移除标题数字

*/
removeTitleNumber(str: string): string;
static removeTitleNumber(str: string): string;
/**

@@ -20,3 +18,3 @@ * 删除挂件的HTML

*/
removeWidgetTag(str: string): string;
static removeWidgetTag(str: string): string;
/**

@@ -27,3 +25,3 @@ * 删除Markdown文本的挂件的HTML

*/
removeMdWidgetTag(str: string): string;
static removeMdWidgetTag(str: string): string;
/**

@@ -34,3 +32,3 @@ * 去除html标签,残缺不全也可以

*/
filterHtml(str: string): string;
static filterHtml(str: string): string;
/**

@@ -43,16 +41,4 @@ * 截取指定长度html

*/
parseHtml(html: string, length: number, ignore?: boolean): string;
static parseHtml(html: string, length: number, ignore?: boolean): string;
/**
* 将Markdown转换为HTML
*
* @param md - Markdown
*/
mdToHtml(md: string): Promise<string>;
/**
* 将Markdown转换为纯文本
*
* @param md - Markdown
*/
mdToPlainText(md: string): Promise<string>;
/**
* 移除H1标签

@@ -62,3 +48,3 @@ *

*/
removeH1(html: string): string;
static removeH1(html: string): string;
/**

@@ -78,4 +64,4 @@ * 移除Markdown里面的H1标签

*/
removeMdH1(md: string): string;
static removeMdH1(md: string): string;
}
export default HtmlUtil;

@@ -1,2 +0,1 @@

import { JSONSchemaType } from "ajv";
/**

@@ -10,13 +9,10 @@ * 校验 JSON schema

declare class JsonUtil {
private ajv;
constructor();
validateJson<T>(schema: JSONSchemaType<T>, data: T): {
valid: boolean;
error?: string;
};
validateObjectSchema(schemaObject: object, dataObject: object): {
valid: boolean;
error?: string;
};
/**
* 安全的解析json
*
* @param str json字符串
* @param def 默认值
*/
static safeParse<T>(str: string, def: T): T;
}
export default JsonUtil;

@@ -14,4 +14,4 @@ /**

*/
isEmptyObject(obj: any): boolean;
static isEmptyObject(obj: any): boolean;
}
export default ObjectUtil;

@@ -17,3 +17,3 @@ /**

*/
f(str: string, ...args: (string | number | boolean | object)[]): string;
static f(str: string, ...args: (string | number | boolean | object)[]): string;
/**

@@ -24,3 +24,3 @@ * 字符串拼接

*/
appendStr(...str: string[]): string;
static appendStr(...str: string[]): string;
/**

@@ -32,3 +32,3 @@ * 判断字符串中,是否包含数组中任何一个元素

*/
includeInArray(str: string, arr: string[]): boolean;
static includeInArray(str: string, arr: string[]): boolean;
/**

@@ -41,3 +41,3 @@ * 截取指定长度的字符串

*/
getByLength(str: string, length: number, ignore?: boolean): string;
static getByLength(str: string, length: number, ignore?: boolean): string;
/**

@@ -48,3 +48,3 @@ * 字符串空值检测

*/
isEmptyString(str: any): boolean;
static isEmptyString(str: any): boolean;
/**

@@ -56,3 +56,3 @@ * 路径组合,解决多出来/的问题

*/
pathJoin(path1: string, path2: string): string;
static pathJoin(path1: string, path2: string): string;
/**

@@ -63,4 +63,4 @@ * 强转boolean

*/
parseBoolean(val: any): boolean;
static parseBoolean(val: any): boolean;
}
export default StrUtil;
import JsonUtil from "./jsonUtil";
import DateUtil from "./dateUtil";
import StrUtil from "./strUtil";
import VersionUtil from "./versionUtil";
import HtmlUtil from "./htmlUtil";
import MarkdownUtil from "./markdownUtil";
import ObjectUtil from "./objectUtil";

@@ -16,11 +14,8 @@ /**

declare class ZhiCommon {
readonly dateUtil: DateUtil;
readonly strUtil: StrUtil;
readonly versionUtil: VersionUtil;
readonly htmlUtil: HtmlUtil;
readonly markdownUtil: MarkdownUtil;
readonly jsonUtil: JsonUtil;
readonly objectUtil: ObjectUtil;
constructor();
static readonly dateUtil: typeof DateUtil;
static readonly strUtil: typeof StrUtil;
static readonly htmlUtil: typeof HtmlUtil;
static readonly jsonUtil: typeof JsonUtil;
static readonly objectUtil: typeof ObjectUtil;
}
export default ZhiCommon;
{
"name": "zhi-common",
"version": "1.6.2",
"version": "1.8.0",
"type": "module",

@@ -30,13 +30,4 @@ "description": "a collection of util tools",

"@terwer/tsconfig": "workspace:*",
"@terwer/vite-config-custom": "workspace:*",
"@types/showdown": "^2.0.1"
},
"dependencies": {
"ajv": "^8.12.0",
"compare-versions": "5.0.3",
"showdown": "^2.1.0",
"zhi-device": "workspace:*",
"zhi-env": "workspace:*",
"zhi-log": "workspace:*"
"@terwer/vite-config-custom": "workspace:*"
}
}

@@ -18,9 +18,3 @@ # zhi-common

```
├── zhi-device
├── zhi-env
├── zhi-log
├── lute
├── showdown
├── compare-versions
├── ajv
## Congregations! zhi-env need no deps, it is just pure js code 🎉
```

@@ -27,0 +21,0 @@

{
"name": "zhi-common",
"version": "1.6.2",
"version": "1.8.0",
"type": "module",

@@ -21,15 +21,6 @@ "description": "a collection of util tools",

"devDependencies": {
"@types/showdown": "^2.0.1",
"@terwer/eslint-config-custom": "1.2.0",
"@terwer/tsconfig": "1.0.0",
"@terwer/vite-config-custom": "0.6.0"
"@terwer/vite-config-custom": "0.6.3",
"@terwer/tsconfig": "1.0.0"
},
"dependencies": {
"ajv": "^8.12.0",
"compare-versions": "5.0.3",
"showdown": "^2.1.0",
"zhi-device": "0.7.3",
"zhi-env": "1.17.2",
"zhi-log": "1.13.3"
},
"scripts": {

@@ -36,0 +27,0 @@ "serve": "vite",

@@ -18,9 +18,3 @@ # zhi-common

```
├── zhi-device
├── zhi-env
├── zhi-log
├── lute
├── showdown
├── compare-versions
├── ajv
## Congregations! zhi-env need no deps, it is just pure js code 🎉
```

@@ -27,0 +21,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc