@hairy/utils 0.6.3 → 0.6.5

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.cjs.js CHANGED
@@ -56,27 +56,27 @@ __export(src_exports, {
56
56
  isWeex: () => isWeex,
57
57
  isWindow: () => isWindow,
58
58
  objectToFormData: () => objectToFormData,
59
- pPipe: () => import_p_pipe.default,
59
+ pPipe: () => pPipe,
60
60
  pipe: () => pipe,
61
61
  weexPlatform: () => weexPlatform
62
62
  });
63
63
  module.exports = __toCommonJS(src_exports);
64
64
 
65
65
  // src/is/index.ts
66
- var isBrowser = typeof window !== "undefined";
67
- var isWeex = typeof WXEnvironment !== "undefined" && !!WXEnvironment.platform;
68
- var weexPlatform = isWeex && WXEnvironment.platform.toLowerCase();
69
- var UA = isBrowser && window.navigator.userAgent.toLowerCase();
70
- var isIE = UA && /msie|trident/.test(UA);
71
- var isIE9 = UA && UA.indexOf("msie 9.0") > 0;
72
- var isIE11 = isBrowser && navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
73
- var isEdge = UA && UA.indexOf("edge/") > 0;
74
- var isAndroid = UA && UA.indexOf("android") > 0 || weexPlatform === "android";
75
- var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA) || weexPlatform === "ios";
76
- var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
77
- var isPhantomJS = UA && /phantomjs/.test(UA);
78
- var isFF = typeof UA == "string" && UA.match(/firefox\/(\d+)/);
79
- var isMobile = isBrowser && navigator.userAgent.toLowerCase().includes("mobile");
66
+ var isBrowser = () => typeof window !== "undefined";
67
+ var isWeex = () => typeof WXEnvironment !== "undefined" && !!WXEnvironment.platform;
68
+ var weexPlatform = () => isWeex() && WXEnvironment.platform.toLowerCase();
69
+ var UA = () => isBrowser() && window.navigator.userAgent.toLowerCase() || "";
70
+ var isIE = () => UA() && /msie|trident/.test(UA());
71
+ var isIE9 = () => UA() && UA().indexOf("msie 9.0") > 0;
72
+ var isIE11 = () => isBrowser() && navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
73
+ var isEdge = () => UA() && UA().indexOf("edge/") > 0;
74
+ var isAndroid = () => UA() && UA().indexOf("android") > 0 || weexPlatform() === "android";
75
+ var isIOS = () => UA() && /iphone|ipad|ipod|ios/.test(UA()) || weexPlatform() === "ios";
76
+ var isChrome = () => UA() && /chrome\/\d+/.test(UA()) && !isEdge();
77
+ var isPhantomJS = () => UA() && /phantomjs/.test(UA());
78
+ var isFF = () => typeof UA() === "string" && UA().match(/firefox\/(\d+)/);
79
+ var isMobile = () => isBrowser() && navigator.userAgent.toLowerCase().includes("mobile");
80
80
 
81
81
  // src/lang/index.ts
82
82
  var import_isObject = __toESM(require("lodash/isObject"));
@@ -90,7 +90,7 @@ function objectToFormData(object) {
90
90
  return formData;
91
91
  }
92
92
  function isFormData(value) {
93
- return isObject(value) && isBrowser && value instanceof FormData;
93
+ return isObject(value) && isBrowser() && value instanceof FormData;
94
94
  }
95
95
  function isWindow(value) {
96
96
  return typeof window !== "undefined" && toString.call(value) === "[object Window]";
@@ -127,8 +127,21 @@ function isTypeof(target, type) {
127
127
  return getTypeof(target) === type;
128
128
  }
129
129
 
130
+ // ../../node_modules/.pnpm/p-pipe@4.0.0/node_modules/p-pipe/index.js
131
+ function pPipe(...functions) {
132
+ if (functions.length === 0) {
133
+ throw new Error("Expected at least one argument");
134
+ }
135
+ return async (input) => {
136
+ let currentValue = input;
137
+ for (const function_ of functions) {
138
+ currentValue = await function_(currentValue);
139
+ }
140
+ return currentValue;
141
+ };
142
+ }
143
+
130
144
  // src/util/index.ts
131
- var import_p_pipe = __toESM(require("p-pipe"));
132
145
  var import_delay = __toESM(require("delay"));
133
146
  var pipe = (...fns) => fns.reduce((v, f) => f(v));
134
147
  var compose = (...fns) => fns.reduceRight((v, f) => f(v));
package/dist/index.d.ts CHANGED
@@ -2,20 +2,20 @@ import { PipeFn, ComposeFn } from 'pipe-and-compose-types';
2
2
  export { default as pPipe } from 'p-pipe';
3
3
  export { default as delay } from 'delay';
4
4
 
5
- declare const isBrowser: boolean;
6
- declare const isWeex: boolean;
7
- declare const weexPlatform: any;
8
- declare const UA: string | false;
9
- declare const isIE: boolean | "";
10
- declare const isIE9: boolean | "";
11
- declare const isIE11: boolean;
12
- declare const isEdge: boolean | "";
13
- declare const isAndroid: boolean;
14
- declare const isIOS: boolean;
15
- declare const isChrome: boolean | "";
16
- declare const isPhantomJS: boolean | "";
17
- declare const isFF: false | RegExpMatchArray | null;
18
- declare const isMobile: boolean;
5
+ declare const isBrowser: () => boolean;
6
+ declare const isWeex: () => boolean;
7
+ declare const weexPlatform: () => any;
8
+ declare const UA: () => string;
9
+ declare const isIE: () => boolean | "";
10
+ declare const isIE9: () => boolean | "";
11
+ declare const isIE11: () => boolean;
12
+ declare const isEdge: () => boolean | "";
13
+ declare const isAndroid: () => boolean;
14
+ declare const isIOS: () => boolean;
15
+ declare const isChrome: () => boolean | "";
16
+ declare const isPhantomJS: () => boolean | "";
17
+ declare const isFF: () => false | RegExpMatchArray | null;
18
+ declare const isMobile: () => boolean;
19
19
 
20
20
  /**
21
21
  * 将 formData 转换为 object
package/dist/index.esm.js CHANGED
@@ -1,18 +1,18 @@
1
1
  // src/is/index.ts
2
- var isBrowser = typeof window !== "undefined";
3
- var isWeex = typeof WXEnvironment !== "undefined" && !!WXEnvironment.platform;
4
- var weexPlatform = isWeex && WXEnvironment.platform.toLowerCase();
5
- var UA = isBrowser && window.navigator.userAgent.toLowerCase();
6
- var isIE = UA && /msie|trident/.test(UA);
7
- var isIE9 = UA && UA.indexOf("msie 9.0") > 0;
8
- var isIE11 = isBrowser && navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
9
- var isEdge = UA && UA.indexOf("edge/") > 0;
10
- var isAndroid = UA && UA.indexOf("android") > 0 || weexPlatform === "android";
11
- var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA) || weexPlatform === "ios";
12
- var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
13
- var isPhantomJS = UA && /phantomjs/.test(UA);
14
- var isFF = typeof UA == "string" && UA.match(/firefox\/(\d+)/);
15
- var isMobile = isBrowser && navigator.userAgent.toLowerCase().includes("mobile");
2
+ var isBrowser = () => typeof window !== "undefined";
3
+ var isWeex = () => typeof WXEnvironment !== "undefined" && !!WXEnvironment.platform;
4
+ var weexPlatform = () => isWeex() && WXEnvironment.platform.toLowerCase();
5
+ var UA = () => isBrowser() && window.navigator.userAgent.toLowerCase() || "";
6
+ var isIE = () => UA() && /msie|trident/.test(UA());
7
+ var isIE9 = () => UA() && UA().indexOf("msie 9.0") > 0;
8
+ var isIE11 = () => isBrowser() && navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
9
+ var isEdge = () => UA() && UA().indexOf("edge/") > 0;
10
+ var isAndroid = () => UA() && UA().indexOf("android") > 0 || weexPlatform() === "android";
11
+ var isIOS = () => UA() && /iphone|ipad|ipod|ios/.test(UA()) || weexPlatform() === "ios";
12
+ var isChrome = () => UA() && /chrome\/\d+/.test(UA()) && !isEdge();
13
+ var isPhantomJS = () => UA() && /phantomjs/.test(UA());
14
+ var isFF = () => typeof UA() === "string" && UA().match(/firefox\/(\d+)/);
15
+ var isMobile = () => isBrowser() && navigator.userAgent.toLowerCase().includes("mobile");
16
16
 
17
17
  // src/lang/index.ts
18
18
  import _isObject from "lodash/isObject";
@@ -26,7 +26,7 @@ function objectToFormData(object) {
26
26
  return formData;
27
27
  }
28
28
  function isFormData(value) {
29
- return isObject(value) && isBrowser && value instanceof FormData;
29
+ return isObject(value) && isBrowser() && value instanceof FormData;
30
30
  }
31
31
  function isWindow(value) {
32
32
  return typeof window !== "undefined" && toString.call(value) === "[object Window]";
@@ -63,9 +63,22 @@ function isTypeof(target, type) {
63
63
  return getTypeof(target) === type;
64
64
  }
65
65
 
66
+ // ../../node_modules/.pnpm/p-pipe@4.0.0/node_modules/p-pipe/index.js
67
+ function pPipe(...functions) {
68
+ if (functions.length === 0) {
69
+ throw new Error("Expected at least one argument");
70
+ }
71
+ return async (input) => {
72
+ let currentValue = input;
73
+ for (const function_ of functions) {
74
+ currentValue = await function_(currentValue);
75
+ }
76
+ return currentValue;
77
+ };
78
+ }
79
+
66
80
  // src/util/index.ts
67
- import { default as default2 } from "p-pipe";
68
- import { default as default3 } from "delay";
81
+ import { default as default2 } from "delay";
69
82
  var pipe = (...fns) => fns.reduce((v, f) => f(v));
70
83
  var compose = (...fns) => fns.reduceRight((v, f) => f(v));
71
84
  function arange(x1, x2, stp = 1, z = [], z0 = z.length) {
@@ -95,7 +108,7 @@ export {
95
108
  atWillToUnit,
96
109
  compose,
97
110
  createDeferred,
98
- default3 as delay,
111
+ default2 as delay,
99
112
  formDataToObject,
100
113
  getTypeof,
101
114
  isAndroid,
@@ -115,7 +128,7 @@ export {
115
128
  isWeex,
116
129
  isWindow,
117
130
  objectToFormData,
118
- default2 as pPipe,
131
+ pPipe,
119
132
  pipe,
120
133
  weexPlatform
121
134
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hairy/utils",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "publishConfig": {