@zwa73/utils 1.0.247 → 1.0.249

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.
@@ -1,3 +1,3 @@
1
1
  export * from './Hbs';
2
- export type { PromoseQueueOption, EventData, DListMiddleNode, DListHeadNode, DListTailNode, DListNode, DListMaybeNode, BridgeInterface } from "@zwa73/js-utils";
3
- export { Stream, Spool, SmartCache, PromiseQueue, Piper, EventSystem, DLinkedList, Bridge } from "@zwa73/js-utils";
2
+ export type { PromoseQueueOption, EventData, DListMiddleNode, DListHeadNode, DListTailNode, DListNode, DListMaybeNode, BridgeInterface, BridgeOpt } from "@zwa73/js-utils";
3
+ export { Stream, Spool, SmartCache, SequenceQueue, PromiseQueue, Piper, EventSystem, DLinkedList, Bridge } from "@zwa73/js-utils";
@@ -14,12 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Bridge = exports.DLinkedList = exports.EventSystem = exports.Piper = exports.PromiseQueue = exports.SmartCache = exports.Spool = exports.Stream = void 0;
17
+ exports.Bridge = exports.DLinkedList = exports.EventSystem = exports.Piper = exports.PromiseQueue = exports.SequenceQueue = exports.SmartCache = exports.Spool = exports.Stream = void 0;
18
18
  __exportStar(require("./Hbs"), exports);
19
19
  var js_utils_1 = require("@zwa73/js-utils");
20
20
  Object.defineProperty(exports, "Stream", { enumerable: true, get: function () { return js_utils_1.Stream; } });
21
21
  Object.defineProperty(exports, "Spool", { enumerable: true, get: function () { return js_utils_1.Spool; } });
22
22
  Object.defineProperty(exports, "SmartCache", { enumerable: true, get: function () { return js_utils_1.SmartCache; } });
23
+ Object.defineProperty(exports, "SequenceQueue", { enumerable: true, get: function () { return js_utils_1.SequenceQueue; } });
23
24
  Object.defineProperty(exports, "PromiseQueue", { enumerable: true, get: function () { return js_utils_1.PromiseQueue; } });
24
25
  Object.defineProperty(exports, "Piper", { enumerable: true, get: function () { return js_utils_1.Piper; } });
25
26
  Object.defineProperty(exports, "EventSystem", { enumerable: true, get: function () { return js_utils_1.EventSystem; } });
@@ -45,5 +45,5 @@ declare class _UtilFunc {
45
45
  /**获取当前公网ipv4 */
46
46
  static getPublicIpv4(): Promise<string>;
47
47
  }
48
- export declare const UtilFunc: import("@zwa73/modular-mixer").ComposedClass<typeof _UtilFunc, typeof JsFunc, "__jsUtils", "match" | "failed" | "success" | "prototype" | "genUUID" | "range" | "getTime" | "initField" | "initObject" | "afterward" | "sleep" | "getNeverResolvedPromise" | "retryPromise" | "timelimitPromise" | "mapEntries" | "eachField" | "stringifyJToken" | "assertType" | "assertLiteral" | "deepClone" | "isSafeNumber" | "dedent" | "throwError" | "getFuncLoc" | "cachePool" | "memoize" | "asyncize" | "lazyFunction" | "splitToChunk" | "mergeFromChunk" | "structEqual" | "concurrent" | "dynamicImport" | "createInjectable" | "outcome" | "isStatus" | "eitherize" | "parseSrtTime" | "formatSrtTime" | "parseSrt" | "createSrt" | "ivk" | "s2l" | "l2s">;
48
+ export declare const UtilFunc: import("@zwa73/modular-mixer").ComposedClass<typeof _UtilFunc, typeof JsFunc, "__jsUtils", "match" | "failed" | "success" | "prototype" | "genUUID" | "range" | "getTime" | "initField" | "initObject" | "afterward" | "sleep" | "getNeverResolvedPromise" | "retryPromise" | "timelimitPromise" | "mapEntries" | "eachField" | "stringifyJToken" | "assertType" | "assertLiteral" | "deepClone" | "isSafeNumber" | "dedent" | "throwError" | "getFuncLoc" | "cachePool" | "memoize" | "asyncize" | "lazyFunction" | "splitToChunk" | "mergeFromChunk" | "structEqual" | "concurrent" | "dynamicImport" | "createInjectable" | "checkSharpSchema" | "outcome" | "isStatus" | "eitherize" | "parseSrtTime" | "formatSrtTime" | "parseSrt" | "createSrt" | "ivk" | "s2l" | "l2s">;
49
49
  export type UtilFunc = typeof UtilFunc;
@@ -237,15 +237,6 @@ export declare class UtilHttp<D extends Partial<RequestOption> & Required<Pick<R
237
237
  /**附加的查询表单数据 */
238
238
  query: QueryRequestData;
239
239
  }) => MPromise<SendProcData>, A>;
240
- /**发送form-data包提供的表单数据 */
241
- sendFormData(): UtilHttp<D & {
242
- headers: {
243
- "Content-Type": "multipart/form-data";
244
- };
245
- }, (opt: RequestOption, arg: {
246
- /**form-data包提供的FormData表单数据 */
247
- formdata: FormData;
248
- }) => MPromise<SendProcData>, A>;
249
240
  /**发送表单 */
250
241
  sendForm(): UtilHttp<D & {
251
242
  headers: {
@@ -255,6 +246,15 @@ export declare class UtilHttp<D extends Partial<RequestOption> & Required<Pick<R
255
246
  /**表单 */
256
247
  form: QueryRequestData;
257
248
  }) => MPromise<SendProcData>, A>;
249
+ /**发送form-data包提供的表单数据 */
250
+ sendFormData(): UtilHttp<D & {
251
+ headers: {
252
+ "Content-Type": "multipart/form-data";
253
+ };
254
+ }, (opt: RequestOption, arg: {
255
+ /**form-data包提供的FormData表单数据 */
256
+ formdata: FormData;
257
+ }) => MPromise<SendProcData>, A>;
258
258
  /**发送文件 */
259
259
  sendFile(): UtilHttp<D & {
260
260
  headers: {
@@ -268,7 +268,7 @@ export declare class UtilHttp<D extends Partial<RequestOption> & Required<Pick<R
268
268
  }) => MPromise<SendProcData>, A>;
269
269
  sendNone(): UtilHttp<D, typeof SendNoneProc, A>;
270
270
  /**自定的发送数据类型 */
271
- sendRaw<T extends any[]>(proc: SendProcCtor<T>): UtilHttp<D, typeof proc, A>;
271
+ sendRaw<T extends {}>(proc: SendProcCtor<T>): UtilHttp<D, typeof proc, A>;
272
272
  /**发送请求
273
273
  * @param datas - 数据对象
274
274
  */
package/dist/UtilHttp.js CHANGED
@@ -268,26 +268,6 @@ class UtilHttp {
268
268
  this._send = sendProc;
269
269
  return this;
270
270
  }
271
- /**发送form-data包提供的表单数据 */
272
- sendFormData() {
273
- const sendProc = (opt, arg) => {
274
- const { method } = opt;
275
- const isPost = (method == "POST");
276
- opt.headers = arg.formdata.getHeaders();
277
- return {
278
- proc: (req) => {
279
- if (isPost)
280
- arg.formdata.pipe(req);
281
- else
282
- req.end();
283
- }
284
- };
285
- };
286
- this._send = sendProc;
287
- this._data.headers ??= {};
288
- this._data.headers['Content-Type'] = 'multipart/form-data';
289
- return this;
290
- }
291
271
  /**发送表单 */
292
272
  sendForm() {
293
273
  const snedProc = (opt, arg) => {
@@ -312,6 +292,29 @@ class UtilHttp {
312
292
  this._data.headers['Content-Type'] = 'application/x-www-form-urlencoded';
313
293
  return this;
314
294
  }
295
+ /**发送form-data包提供的表单数据 */
296
+ sendFormData() {
297
+ const sendProc = (opt, arg) => {
298
+ const { method } = opt;
299
+ const isPost = (method == "POST");
300
+ opt.headers = {
301
+ ...arg.formdata.getHeaders(),
302
+ ...opt.headers,
303
+ };
304
+ return {
305
+ proc: (req) => {
306
+ if (isPost)
307
+ arg.formdata.pipe(req);
308
+ else
309
+ req.end();
310
+ }
311
+ };
312
+ };
313
+ this._send = sendProc;
314
+ this._data.headers ??= {};
315
+ this._data.headers['Content-Type'] = 'multipart/form-data';
316
+ return this;
317
+ }
315
318
  /**发送文件 */
316
319
  sendFile() {
317
320
  const proc = (opt, arg) => {
@@ -321,7 +324,10 @@ class UtilHttp {
321
324
  const formData = new form_data_1.default();
322
325
  filename = filename ?? pathe_1.default.basename(filepath);
323
326
  formData.append(filename, fs_1.default.createReadStream(filepath));
324
- opt.headers = formData.getHeaders();
327
+ opt.headers = {
328
+ ...formData.getHeaders(),
329
+ ...opt.headers
330
+ };
325
331
  return {
326
332
  proc: req => {
327
333
  if (isPost)
@@ -1 +1 @@
1
- export type { JToken, JValue, JArray, JObject, IJData, AnyFunc, Keyable, DeepReadonly, PartialOption, ProperSubset, ProperSubsetCheck, IncludeCheck, UnionCheck, Literal, LiteralCheck, AllExtends, AssignObject, Writeable, Inverted, FixedLengthTuple, Increment, RangeTuple, AnyString, UnionToIntersection, ExclusiveRecord, ExclusiveJObject, PromiseStatus, StatusVerifyFn, Await, FuncPropNames, ExtendThen, RequiredOnly, WithPrefix, Outcome, Either, Matchable, MatchableFlag, ExtractOutcome, ExtractMatchable, NeedInit, PRecord, MPromise, SPromise, SMPromise, NotPromise, AnyRecord, MReturnType, CmtTuple, Flasy, SrtSegment, ILogger, LogLevel, Asyncize } from "@zwa73/js-utils";
1
+ export type { JToken, JValue, JArray, JObject, IJData, AnyFunc, Keyable, DeepReadonly, PartialOption, ProperSubset, ProperSubsetCheck, IncludeCheck, UnionCheck, Literal, LiteralCheck, AllExtends, AssignObject, Writeable, Inverted, FixedLengthTuple, Increment, RangeTuple, AnyString, UnionToIntersection, ExclusiveRecord, ExclusiveJObject, PromiseStatus, StatusVerifyFn, Await, FuncPropNames, ExtendThen, RequiredOnly, WithPrefix, Outcome, Either, Matchable, MatchableFlag, ExtractOutcome, ExtractMatchable, NeedInit, PRecord, MPromise, SPromise, SMPromise, NotPromise, AnyRecord, MReturnType, CmtTuple, Flasy, SrtSegment, ILogger, LogLevel, Asyncize, SharpSchema, ExpandSharpSchema } from "@zwa73/js-utils";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.247",
3
+ "version": "1.0.249",
4
4
  "description": "my utils",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {