qidian-shared 0.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ export declare function toMoney(money: string | number | undefined | null, precision?: number, multiple?: number): string;
2
+ export declare function toMoneyTrimmed(money: string | number | undefined | null, precision?: number, multiple?: number): string;
3
+ export declare function toMoneyWithK(money: string | number | undefined, precision?: number): string | number;
4
+ export declare function toPrecision(num: string | number, precision?: number): number;
@@ -0,0 +1,27 @@
1
+ export declare function noop(): void;
2
+ export declare function isEmpty(val: unknown): boolean;
3
+ export declare function hasOwn(val: Record<string, unknown>, key: string | number | symbol): key is keyof typeof val;
4
+ export declare function createEnum<const T extends Record<string | number, string | ({
5
+ label: string;
6
+ } & Record<string, unknown>)>>(obj: T): {
7
+ map: { [K in keyof T]: T[K] extends string ? {
8
+ value: K;
9
+ label: T[K];
10
+ } : T[K] extends {
11
+ value: infer V;
12
+ } ? {
13
+ value: V;
14
+ } & Omit<T[K], "value"> : {
15
+ value: K;
16
+ } & T[K]; };
17
+ options: { [K_1 in keyof T]: T[K_1] extends string ? {
18
+ value: K_1;
19
+ label: T[K_1];
20
+ } : T[K_1] extends {
21
+ value: infer V;
22
+ } ? {
23
+ value: V;
24
+ } & Omit<T[K_1], "value"> : {
25
+ value: K_1;
26
+ } & T[K_1]; }[keyof T][];
27
+ };
@@ -0,0 +1,5 @@
1
+ import CryptoJS from 'crypto-js';
2
+ export declare function generateAesKey(): CryptoJS.lib.WordArray;
3
+ export declare function encryptBase64(str: CryptoJS.lib.WordArray): string;
4
+ export declare function decryptBase64(str: string): string;
5
+ export declare function encryptWithAes(message: string, aesKey: CryptoJS.lib.WordArray, iv?: CryptoJS.lib.WordArray, mode?: typeof CryptoJS.mode.ECB, padding?: typeof CryptoJS.pad.Pkcs7): string;
@@ -0,0 +1,8 @@
1
+ export * from './calc';
2
+ export * from './common';
3
+ export * from './crypto';
4
+ export * from './promise';
5
+ export * from './str';
6
+ export * from './type';
7
+ export * from './url';
8
+ export * from './vite';
@@ -0,0 +1,16 @@
1
+ export interface PlatformInfo {
2
+ system: string;
3
+ beWrapped: boolean;
4
+ engine: string;
5
+ supporter: string;
6
+ shell: string;
7
+ shellVs: string;
8
+ networkType: string;
9
+ systemVs: string;
10
+ platform: string;
11
+ client: string;
12
+ engineVs: string;
13
+ supporterVs: string;
14
+ webp: boolean;
15
+ }
16
+ export declare function getPlatformInfo(): PlatformInfo;
@@ -0,0 +1,2 @@
1
+ export declare function to<T, U = Error>(promise: Promise<T>, errorExt?: object): Promise<[U, undefined] | [null, T]>;
2
+ export declare function suspectedWrapperPromise<T, U = Error>(p: T | Promise<T>): Promise<[U, undefined] | [null, T]>;
@@ -0,0 +1 @@
1
+ export declare function initialConversion(str: string, isLowerCase?: boolean): string;
@@ -0,0 +1,6 @@
1
+ export declare const objToStr: () => string;
2
+ export declare const toTypeStr: (val: unknown) => string;
3
+ export declare const isFunction: (val: unknown) => val is (...any: unknown[]) => unknown;
4
+ export declare const isObject: <T extends Record<string, unknown> = Record<string, unknown>>(val: unknown) => val is T;
5
+ export declare const isPromise: (val: unknown) => val is Promise<unknown>;
6
+ export declare const identifyType: (val: unknown) => string;
@@ -0,0 +1,4 @@
1
+ export declare function getUrlParams(url?: string): Record<string, string>;
2
+ export declare function getUrlParam(key: string, url?: string): string;
3
+ export declare function deleteUrlParams(params: Array<string>, url?: string): string;
4
+ export declare function setUrlParam(key: string, value: string | number | boolean | null | undefined, url?: string, andString?: string, newKey?: string): string;
@@ -0,0 +1 @@
1
+ export declare function devProxy(env: Record<string, string>, prefix?: string): Record<string, string | object>;
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "qidian-shared",
3
+ "version": "0.0.1-beta.0",
4
+ "description": "QiDian 共享工具函数和钩子",
5
+ "type": "module",
6
+ "author": "qidian",
7
+ "license": "MIT",
8
+ "main": "dist/qidian-shared.cjs.js",
9
+ "module": "dist/qidian-shared.es.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/qidian-shared.es.js",
15
+ "require": "./dist/qidian-shared.cjs.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "LICENSE",
21
+ "README.md"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsc --noEmit && vite build && tsc",
25
+ "type-check": "tsc --noEmit",
26
+ "lint": "eslint . --fix --cache",
27
+ "format": "prettier --write src/"
28
+ },
29
+ "dependencies": {
30
+ "crypto-js": "catalog:deps",
31
+ "vue-request": "catalog:deps"
32
+ },
33
+ "devDependencies": {
34
+ "@vitejs/plugin-vue": "catalog:bundle",
35
+ "vite": "catalog:bundle",
36
+ "vue": "catalog:deps",
37
+ "typescript": "catalog:types",
38
+ "@types/crypto-js": "catalog:types"
39
+ },
40
+ "peerDependencies": {
41
+ "vue": ">=3.1.0"
42
+ }
43
+ }