cvitool 1.0.773 → 1.0.774

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.
@@ -42,6 +42,17 @@ interface getFileTypeRes {
42
42
  extname: string;
43
43
  mime: string;
44
44
  }
45
+ interface validateRes {
46
+ message: string;
47
+ field: string;
48
+ pass: boolean;
49
+ }
50
+ interface checkURLResourceRes {
51
+ isEffective: boolean;
52
+ message?: string;
53
+ resHeaders?: CustomObject;
54
+ resBody?: CustomObject | string;
55
+ }
45
56
  declare const RegStr: {
46
57
  zzs: string;
47
58
  zxs: (digit: number) => string;
@@ -123,12 +134,7 @@ declare function getMediaFileType(target: string | Buffer | Readable): Promise<g
123
134
  * @param url
124
135
  * @returns
125
136
  */
126
- declare function checkURLResource(url: string, timeout?: number): Promise<{
127
- isEffective: boolean;
128
- message?: string;
129
- resHeaders?: CustomObject;
130
- resBody?: CustomObject | string;
131
- }>;
137
+ declare function checkURLResource(url: string, timeout?: number): Promise<checkURLResourceRes>;
132
138
  /**
133
139
  * 写入json文件
134
140
  * @param data 待写入json对象
@@ -161,11 +167,7 @@ declare function validate(value: {
161
167
  }, finalFunc?: (value: any) => {
162
168
  pass: boolean;
163
169
  message?: string;
164
- }): {
165
- message: string;
166
- field: string;
167
- pass: boolean;
168
- };
170
+ }): validateRes;
169
171
  /**
170
172
  * 提取对象中的路径path及值映射
171
173
  * @param obj
@@ -185,4 +187,4 @@ declare function getURLExtname(url: string): string;
185
187
  * @returns
186
188
  */
187
189
  declare function getFileType(input: string | Buffer | Readable, reqUrlTimeout?: number): Promise<getFileTypeRes>;
188
- export { randomStringOptions, getMediaFileTypeRes, CustomObject, getFileTypeRes, randomString, encryptCBC, decryptCBC, md5, execCmdCommand, getValueType, getMediaFileType, checkURLResource, writeJsonFileSync, readJsonFileSync, uuid, validate, RegStr, getObjPathMapValue, getURLExtname, getFileType };
190
+ export { randomStringOptions, getMediaFileTypeRes, CustomObject, getFileTypeRes, validateRes, checkURLResourceRes, randomString, encryptCBC, decryptCBC, md5, execCmdCommand, getValueType, getMediaFileType, checkURLResource, writeJsonFileSync, readJsonFileSync, uuid, validate, RegStr, getObjPathMapValue, getURLExtname, getFileType };
@@ -354,10 +354,9 @@ function getMediaFileType(target) {
354
354
  */
355
355
  function checkURLResource(url, timeout) {
356
356
  return __awaiter(this, void 0, void 0, function* () {
357
- let obj = {
357
+ const obj = {
358
358
  isEffective: true
359
359
  };
360
- obj = { isEffective: true };
361
360
  try {
362
361
  const res = yield hgo.get(url, { resType: 'stream', timeout });
363
362
  res.resBody.destroy();
@@ -637,7 +636,7 @@ function getFileType(input_1) {
637
636
  return __awaiter(this, arguments, void 0, function* (input, reqUrlTimeout = 10 * 1000) {
638
637
  let stream = input;
639
638
  if (getValueType(input) === 'string') {
640
- if (input.startsWith('http') || input.startsWith('https')) {
639
+ if (input.startsWith('http')) {
641
640
  const res = yield hgo.get(input, { resType: 'stream', timeout: reqUrlTimeout });
642
641
  stream = res.resBody;
643
642
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cvitool",
3
- "version": "1.0.773",
3
+ "version": "1.0.774",
4
4
  "description": "cvitool",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/cutil.ts CHANGED
@@ -57,6 +57,19 @@ interface getFileTypeRes {
57
57
  mime: string
58
58
  }
59
59
 
60
+ interface validateRes {
61
+ message: string,
62
+ field: string,
63
+ pass: boolean
64
+ }
65
+
66
+ interface checkURLResourceRes {
67
+ isEffective: boolean,
68
+ message?: string,
69
+ resHeaders?: CustomObject,
70
+ resBody?: CustomObject | string
71
+ }
72
+
60
73
  const RegStr = {
61
74
  zzs: '^[1-9]\\d*$',
62
75
  zxs: (digit: number) => `^(0|[1-9]\\d*)(\\.\\d{1,${digit}})$`,
@@ -378,10 +391,9 @@ async function getMediaFileType(target: string | Buffer | Readable): Promise<get
378
391
  * @returns
379
392
  */
380
393
  async function checkURLResource(url: string, timeout?: number) {
381
- let obj: { isEffective: boolean, message?: string, resHeaders?: CustomObject, resBody?: CustomObject | string } = {
394
+ const obj: checkURLResourceRes = {
382
395
  isEffective: true
383
396
  };
384
- obj = { isEffective: true };
385
397
  try {
386
398
  const res = await hgo.get(url, { resType: 'stream', timeout });
387
399
  (res.resBody as Readable).destroy();
@@ -441,8 +453,8 @@ function uuid() {
441
453
  * @param rule
442
454
  * @returns
443
455
  */
444
- function validate(value: { [key: string]: any }, rule: { [key: string]: validateParams }, finalFunc?: (value: any) => { pass: boolean, message?: string }): { message: string, field: string, pass: boolean } {
445
- const result = {
456
+ function validate(value: { [key: string]: any }, rule: { [key: string]: validateParams }, finalFunc?: (value: any) => { pass: boolean, message?: string }): validateRes {
457
+ const result: validateRes = {
446
458
  message: '',
447
459
  field: '',
448
460
  pass: true
@@ -668,7 +680,7 @@ function getURLExtname(url: string) {
668
680
  async function getFileType(input: string | Buffer | Readable, reqUrlTimeout = 10 * 1000): Promise<getFileTypeRes> {
669
681
  let stream: Readable = input as Readable;
670
682
  if (getValueType(input) === 'string') {
671
- if ((input as string).startsWith('http') || (input as string).startsWith('https')) {
683
+ if ((input as string).startsWith('http')) {
672
684
  const res = await hgo.get(input as string, { resType: 'stream', timeout: reqUrlTimeout });
673
685
  stream = res.resBody as Readable;
674
686
  } else {
@@ -698,6 +710,8 @@ export {
698
710
  getMediaFileTypeRes,
699
711
  CustomObject,
700
712
  getFileTypeRes,
713
+ validateRes,
714
+ checkURLResourceRes,
701
715
  randomString,
702
716
  encryptCBC,
703
717
  decryptCBC,