qmwts 1.0.9 → 1.0.11

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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import NumberUtils from './src/utils/number-utils';
2
- import JsonUtils from './src/utils/json-utils';
3
- import UUIDUtils from './src/utils/uuid-utils';
1
+ import NumberUtils from './utils/number-utils';
2
+ import JsonUtils from './utils/json-utils';
3
+ import UUIDUtils from './utils/uuid-utils';
4
4
  export { NumberUtils, JsonUtils, UUIDUtils };
package/dist/index.js CHANGED
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UUIDUtils = exports.JsonUtils = exports.NumberUtils = void 0;
4
4
  // https://www.jianshu.com/p/8fa2c50720e4
5
- var number_utils_1 = require("./src/utils/number-utils");
5
+ var number_utils_1 = require("./utils/number-utils");
6
6
  exports.NumberUtils = number_utils_1.default;
7
- var json_utils_1 = require("./src/utils/json-utils");
7
+ var json_utils_1 = require("./utils/json-utils");
8
8
  exports.JsonUtils = json_utils_1.default;
9
- var uuid_utils_1 = require("./src/utils/uuid-utils");
9
+ var uuid_utils_1 = require("./utils/uuid-utils");
10
10
  exports.UUIDUtils = uuid_utils_1.default;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "qmwts",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "tsc",
8
8
  "test": "jest"
@@ -13,5 +13,8 @@
13
13
  "jest": "^29.6.2",
14
14
  "ts-jest": "^29.1.1",
15
15
  "typescript": "^5.1.6"
16
- }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ]
17
20
  }
package/index.test.js DELETED
@@ -1,9 +0,0 @@
1
- const { NumberUtils, JsonUtils, UUIDUtils } = require('./index')
2
- test('isNumber', () => {
3
- expect(NumberUtils.thousandths(1)).toBe('1.00')
4
- expect(JsonUtils.toJSONArray("{\"1\":1}")).toStrictEqual([])
5
- console.log(UUIDUtils.uuid())
6
- console.log(UUIDUtils.uuid())
7
- console.log(UUIDUtils.uuid())
8
- console.log(UUIDUtils.uuid())
9
- })
package/index.ts DELETED
@@ -1,11 +0,0 @@
1
- // https://www.jianshu.com/p/8fa2c50720e4
2
- import NumberUtils from './src/utils/number-utils'
3
- import JsonUtils from './src/utils/json-utils'
4
- import UUIDUtils from './src/utils/uuid-utils'
5
-
6
- export {
7
- NumberUtils,
8
- JsonUtils,
9
- UUIDUtils
10
- }
11
-
package/jest.config.js DELETED
@@ -1,5 +0,0 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- module.exports = {
3
- preset: 'ts-jest',
4
- testEnvironment: 'node',
5
- };
@@ -1,42 +0,0 @@
1
- export default {
2
- isPrototypeObject(o: any): boolean {
3
- return Object.prototype.toString.call(o) === '[object Object]'
4
- },
5
- isPrototypeArray(o: any): boolean {
6
- return Object.prototype.toString.call(o) === '[object Array]'
7
- },
8
- isJSONObject(o: any): boolean {
9
- if (this.isPrototypeObject(o))
10
- return true
11
- try {
12
- return this.isPrototypeObject(JSON.parse(o))
13
- } catch (e) {
14
- return false
15
- }
16
- },
17
- isJSONArray(o: any): boolean {
18
- if (this.isPrototypeArray(o))
19
- return true
20
- try {
21
- return this.isPrototypeArray(JSON.parse(o))
22
- } catch (e) {
23
- return false
24
- }
25
- },
26
- toJSONObject<T>(o: any): T {
27
- if (this.isPrototypeObject(o))
28
- return <T>o
29
- return this.isJSONObject(o) ? <T>JSON.parse(o) : <T>{}
30
- },
31
- toJSONArray<T>(o: any): T[] {
32
- if (this.isPrototypeArray(o))
33
- return <T[]>o
34
- return this.isJSONArray(o) ? <T[]>JSON.parse(o) : <T[]>[]
35
- },
36
- optionalChaining(o: any = {}, chain: string): any {
37
- const chaining = chain.split('.')
38
- for (const key of chaining)
39
- o = o[key] || ''
40
- return o
41
- }
42
- }
@@ -1,26 +0,0 @@
1
- export default {
2
- // 判断是否数字
3
- ifNaN(number: any, substitute: any): any {
4
- return this.isNumber(number) ? +number : substitute
5
- },
6
- isNumber(number: any): boolean {
7
- number = String(number).trim()
8
- return number !== '' && isFinite(+number) && !isNaN(+number)
9
- },
10
- // 增加千分位分隔符
11
- thousandths(number: any, fixed: number = 2): string {
12
- if (!this.isNumber(number))
13
- return ''
14
- number = (+number).toFixed(fixed)
15
- return number.replace(/\d+/, (x: string) => {
16
- return x.replace(/(\d)(?=(\d{3})+$)/g, (y: string) => {
17
- return y + ','
18
- })
19
- })
20
- },
21
- summation(array: any[] = []): number {
22
- return array.reduce((prev, curr) => {
23
- return prev + this.ifNaN(curr, 0)
24
- }, 0)
25
- }
26
- }
@@ -1,9 +0,0 @@
1
- export default {
2
- uuid(): string {
3
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
4
- const r = (Math.random() * 16) | 0
5
- const v = c === 'x' ? r : (r & 0x3) | 0x8
6
- return v.toString(16)
7
- })
8
- }
9
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES5",
4
- "module": "commonjs",
5
- "declaration": true,
6
- "strict": true,
7
- "outDir": "./dist"
8
- }
9
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes