@hairy/utils 0.6.8 → 0.6.9
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 +92 -34
- package/dist/index.d.ts +21 -26
- package/dist/index.mjs +113 -33
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,17 +30,64 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// ../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isObjectLike.js
|
|
34
|
+
var require_isObjectLike = __commonJS({
|
|
35
|
+
"../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isObjectLike.js"(exports, module2) {
|
|
36
|
+
function isObjectLike(value) {
|
|
37
|
+
return !!value && typeof value == "object";
|
|
38
|
+
}
|
|
39
|
+
module2.exports = isObjectLike;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// ../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isNumber.js
|
|
44
|
+
var require_isNumber = __commonJS({
|
|
45
|
+
"../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isNumber.js"(exports, module2) {
|
|
46
|
+
var isObjectLike = require_isObjectLike();
|
|
47
|
+
var numberTag = "[object Number]";
|
|
48
|
+
var objectProto = global.Object.prototype;
|
|
49
|
+
var objectToString = objectProto.toString;
|
|
50
|
+
function isNumber2(value) {
|
|
51
|
+
return typeof value == "number" || isObjectLike(value) && objectToString.call(value) == numberTag;
|
|
52
|
+
}
|
|
53
|
+
module2.exports = isNumber2;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// ../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isArray.js
|
|
58
|
+
var require_isArray = __commonJS({
|
|
59
|
+
"../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isArray.js"(exports, module2) {
|
|
60
|
+
var isArray = Array.isArray;
|
|
61
|
+
module2.exports = isArray;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// ../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isString.js
|
|
66
|
+
var require_isString = __commonJS({
|
|
67
|
+
"../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isString.js"(exports, module2) {
|
|
68
|
+
var isArray = require_isArray();
|
|
69
|
+
var isObjectLike = require_isObjectLike();
|
|
70
|
+
var stringTag = "[object String]";
|
|
71
|
+
var objectProto = global.Object.prototype;
|
|
72
|
+
var objectToString = objectProto.toString;
|
|
73
|
+
function isString2(value) {
|
|
74
|
+
return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag;
|
|
75
|
+
}
|
|
76
|
+
module2.exports = isString2;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
30
80
|
// src/index.ts
|
|
31
81
|
var src_exports = {};
|
|
32
82
|
__export(src_exports, {
|
|
33
83
|
UA: () => UA,
|
|
34
84
|
arange: () => arange,
|
|
35
|
-
atWillToSize: () => atWillToSize,
|
|
36
|
-
atWillToUnit: () => atWillToUnit,
|
|
37
85
|
compose: () => compose,
|
|
38
86
|
createDeferred: () => createDeferred,
|
|
39
87
|
delay: () => import_delay.default,
|
|
40
88
|
formDataToObject: () => formDataToObject,
|
|
89
|
+
formatSize: () => formatSize,
|
|
90
|
+
formatUnit: () => formatUnit,
|
|
41
91
|
getTypeof: () => getTypeof,
|
|
42
92
|
isAndroid: () => isAndroid,
|
|
43
93
|
isBrowser: () => isBrowser,
|
|
@@ -58,7 +108,8 @@ __export(src_exports, {
|
|
|
58
108
|
objectToFormData: () => objectToFormData,
|
|
59
109
|
pPipe: () => pPipe,
|
|
60
110
|
pipe: () => pipe,
|
|
61
|
-
weexPlatform: () => weexPlatform
|
|
111
|
+
weexPlatform: () => weexPlatform,
|
|
112
|
+
whenever: () => whenever
|
|
62
113
|
});
|
|
63
114
|
module.exports = __toCommonJS(src_exports);
|
|
64
115
|
|
|
@@ -79,7 +130,6 @@ var isFF = () => typeof UA() === "string" && UA().match(/firefox\/(\d+)/);
|
|
|
79
130
|
var isMobile = () => isBrowser() && navigator.userAgent.toLowerCase().includes("mobile");
|
|
80
131
|
|
|
81
132
|
// src/lang/index.ts
|
|
82
|
-
var import_isObject = __toESM(require("lodash/isObject"));
|
|
83
133
|
function formDataToObject(formData) {
|
|
84
134
|
return Object.fromEntries(formData.entries());
|
|
85
135
|
}
|
|
@@ -96,25 +146,25 @@ function isWindow(value) {
|
|
|
96
146
|
return typeof window !== "undefined" && toString.call(value) === "[object Window]";
|
|
97
147
|
}
|
|
98
148
|
function isObject(value) {
|
|
99
|
-
return
|
|
149
|
+
return typeof value === "object" && !Array.isArray(value);
|
|
100
150
|
}
|
|
101
151
|
|
|
102
152
|
// src/size/index.ts
|
|
103
|
-
var import_isNumber = __toESM(
|
|
104
|
-
var import_isString = __toESM(
|
|
105
|
-
function
|
|
153
|
+
var import_isNumber = __toESM(require_isNumber());
|
|
154
|
+
var import_isString = __toESM(require_isString());
|
|
155
|
+
function formatUnit(value, unit = "px") {
|
|
106
156
|
if (!((0, import_isString.default)(value) || (0, import_isNumber.default)(value)))
|
|
107
157
|
return "";
|
|
108
158
|
return (0, import_isString.default)(value) && /\D/g.test(value) ? value : value + unit;
|
|
109
159
|
}
|
|
110
|
-
function
|
|
111
|
-
const
|
|
112
|
-
if (typeof
|
|
113
|
-
return { width:
|
|
114
|
-
if (Array.isArray(
|
|
115
|
-
return { width:
|
|
116
|
-
if (typeof
|
|
117
|
-
return { width:
|
|
160
|
+
function formatSize(dimension, unit) {
|
|
161
|
+
const _formatUnit = (value) => formatUnit(value, unit);
|
|
162
|
+
if (typeof dimension === "string" || typeof dimension === "number")
|
|
163
|
+
return { width: _formatUnit(dimension), height: _formatUnit(dimension) };
|
|
164
|
+
if (Array.isArray(dimension))
|
|
165
|
+
return { width: _formatUnit(dimension[0]), height: _formatUnit(dimension[1]) };
|
|
166
|
+
if (typeof dimension === "object")
|
|
167
|
+
return { width: _formatUnit(dimension.width), height: _formatUnit(dimension.height) };
|
|
118
168
|
return { width: "", height: "" };
|
|
119
169
|
}
|
|
120
170
|
|
|
@@ -127,6 +177,21 @@ function isTypeof(target, type) {
|
|
|
127
177
|
return getTypeof(target) === type;
|
|
128
178
|
}
|
|
129
179
|
|
|
180
|
+
// src/util/deferred.ts
|
|
181
|
+
function createDeferred() {
|
|
182
|
+
let resolve, reject;
|
|
183
|
+
const promise = new Promise((_resolve, _reject) => {
|
|
184
|
+
resolve = _resolve;
|
|
185
|
+
reject = _reject;
|
|
186
|
+
});
|
|
187
|
+
promise.resolve = (v) => {
|
|
188
|
+
resolve(v);
|
|
189
|
+
return promise;
|
|
190
|
+
};
|
|
191
|
+
promise.reject = reject;
|
|
192
|
+
return promise;
|
|
193
|
+
}
|
|
194
|
+
|
|
130
195
|
// ../../node_modules/.pnpm/p-pipe@4.0.0/node_modules/p-pipe/index.js
|
|
131
196
|
function pPipe(...functions) {
|
|
132
197
|
if (functions.length === 0) {
|
|
@@ -141,10 +206,10 @@ function pPipe(...functions) {
|
|
|
141
206
|
};
|
|
142
207
|
}
|
|
143
208
|
|
|
144
|
-
// src/util/
|
|
209
|
+
// src/util/third.ts
|
|
145
210
|
var import_delay = __toESM(require("delay"));
|
|
146
|
-
|
|
147
|
-
|
|
211
|
+
|
|
212
|
+
// src/util/index.ts
|
|
148
213
|
function arange(x1, x2, stp = 1, z = [], z0 = z.length) {
|
|
149
214
|
if (!x2)
|
|
150
215
|
x1 -= x2 = x1;
|
|
@@ -152,29 +217,21 @@ function arange(x1, x2, stp = 1, z = [], z0 = z.length) {
|
|
|
152
217
|
z[z0++] = x1;
|
|
153
218
|
return z;
|
|
154
219
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
reject = _reject;
|
|
160
|
-
});
|
|
161
|
-
promise.resolve = (v) => {
|
|
162
|
-
resolve(v);
|
|
163
|
-
return promise;
|
|
164
|
-
};
|
|
165
|
-
promise.reject = reject;
|
|
166
|
-
return promise;
|
|
220
|
+
var pipe = (...fns) => fns.reduce((v, f) => f(v));
|
|
221
|
+
var compose = (...fns) => fns.reduceRight((v, f) => f(v));
|
|
222
|
+
function whenever(value, callback) {
|
|
223
|
+
return value ? callback(value) : void 0;
|
|
167
224
|
}
|
|
168
225
|
// Annotate the CommonJS export names for ESM import in node:
|
|
169
226
|
0 && (module.exports = {
|
|
170
227
|
UA,
|
|
171
228
|
arange,
|
|
172
|
-
atWillToSize,
|
|
173
|
-
atWillToUnit,
|
|
174
229
|
compose,
|
|
175
230
|
createDeferred,
|
|
176
231
|
delay,
|
|
177
232
|
formDataToObject,
|
|
233
|
+
formatSize,
|
|
234
|
+
formatUnit,
|
|
178
235
|
getTypeof,
|
|
179
236
|
isAndroid,
|
|
180
237
|
isBrowser,
|
|
@@ -195,5 +252,6 @@ function createDeferred() {
|
|
|
195
252
|
objectToFormData,
|
|
196
253
|
pPipe,
|
|
197
254
|
pipe,
|
|
198
|
-
weexPlatform
|
|
255
|
+
weexPlatform,
|
|
256
|
+
whenever
|
|
199
257
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -30,12 +30,12 @@ declare function isFormData(value: any): value is FormData;
|
|
|
30
30
|
declare function isWindow(value: any): value is Window;
|
|
31
31
|
declare function isObject(value: any): value is object;
|
|
32
32
|
|
|
33
|
-
type
|
|
34
|
-
type
|
|
33
|
+
type Numeric = string | number | bigint;
|
|
34
|
+
type DynamicObject = {
|
|
35
35
|
[key: string]: any;
|
|
36
36
|
};
|
|
37
|
-
type
|
|
38
|
-
[key: string]:
|
|
37
|
+
type NumericObject = {
|
|
38
|
+
[key: string]: Numeric;
|
|
39
39
|
};
|
|
40
40
|
type StringObject = {
|
|
41
41
|
[key: string]: string;
|
|
@@ -68,27 +68,20 @@ type Arrayable<T> = T | T[];
|
|
|
68
68
|
type Option<L extends Key = 'label', V extends Key = 'value', C extends Key = 'children'> = {
|
|
69
69
|
[P in L]?: string;
|
|
70
70
|
} & {
|
|
71
|
-
[P in V]?:
|
|
71
|
+
[P in V]?: Numeric;
|
|
72
72
|
} & {
|
|
73
73
|
[P in C]?: Option<L, V, C>[];
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
declare function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
height: AtwillNumber;
|
|
76
|
+
declare function formatUnit(value: Numeric, unit?: string): string;
|
|
77
|
+
type Dimension = Numeric | [Numeric, Numeric] | {
|
|
78
|
+
width: Numeric;
|
|
79
|
+
height: Numeric;
|
|
81
80
|
};
|
|
82
|
-
|
|
81
|
+
declare function formatSize(dimension: Dimension, unit?: string): {
|
|
83
82
|
width: string;
|
|
84
83
|
height: string;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* 将 size 转换为宽高,用于元素宽高
|
|
88
|
-
* @param size AtWillSize
|
|
89
|
-
* @returns
|
|
90
|
-
*/
|
|
91
|
-
declare function atWillToSize(size: AtWillSize, unit?: string): Size;
|
|
84
|
+
};
|
|
92
85
|
|
|
93
86
|
type TypeofType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'null' | 'regexp';
|
|
94
87
|
/**
|
|
@@ -105,17 +98,19 @@ declare function getTypeof(target: any): TypeofType;
|
|
|
105
98
|
*/
|
|
106
99
|
declare function isTypeof(target: any, type: TypeofType): boolean;
|
|
107
100
|
|
|
108
|
-
declare const pipe: (...fns: any[]) => any;
|
|
109
|
-
declare const compose: (...fns: any[]) => any;
|
|
110
|
-
/**
|
|
111
|
-
* 生成区间数组
|
|
112
|
-
* arange(<start>, <stop>, [step=1], [target=[]], [at])
|
|
113
|
-
*/
|
|
114
|
-
declare function arange(x1: number, x2?: number, stp?: number, z?: number[], z0?: number): number[];
|
|
115
101
|
type Deferred<T = void> = Promise<T> & {
|
|
116
102
|
resolve: (value: T) => void;
|
|
117
103
|
reject: (value?: any) => void;
|
|
118
104
|
};
|
|
119
105
|
declare function createDeferred<T = void>(): Deferred<T>;
|
|
120
106
|
|
|
121
|
-
|
|
107
|
+
/**
|
|
108
|
+
* 生成区间数组
|
|
109
|
+
* arange(<start>, <stop>, [step=1], [target=[]], [at])
|
|
110
|
+
*/
|
|
111
|
+
declare function arange(x1: number, x2?: number, stp?: number, z?: number[], z0?: number): number[];
|
|
112
|
+
declare const pipe: (...fns: any[]) => any;
|
|
113
|
+
declare const compose: (...fns: any[]) => any;
|
|
114
|
+
declare function whenever<T, C extends (value: Exclude<T, null | undefined>) => any>(value: T, callback: C): ReturnType<C> | undefined;
|
|
115
|
+
|
|
116
|
+
export { Arrayable, Awaitable, BooleanLike, DeepKeyof, DeepPartial, DeepReadonly, DeepReplace, DeepRequired, Deferred, Dimension, DynamicObject, Key, NumberObject, Numeric, NumericObject, Option, StringObject, SymbolObject, TypeofType, UA, arange, compose, createDeferred, formDataToObject, formatSize, formatUnit, getTypeof, isAndroid, isBrowser, isChrome, isEdge, isFF, isFormData, isIE, isIE11, isIE9, isIOS, isMobile, isObject, isPhantomJS, isTypeof, isWeex, isWindow, objectToFormData, pipe, weexPlatform, whenever };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isObjectLike.js
|
|
28
|
+
var require_isObjectLike = __commonJS({
|
|
29
|
+
"../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isObjectLike.js"(exports, module) {
|
|
30
|
+
function isObjectLike(value) {
|
|
31
|
+
return !!value && typeof value == "object";
|
|
32
|
+
}
|
|
33
|
+
module.exports = isObjectLike;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isNumber.js
|
|
38
|
+
var require_isNumber = __commonJS({
|
|
39
|
+
"../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isNumber.js"(exports, module) {
|
|
40
|
+
var isObjectLike = require_isObjectLike();
|
|
41
|
+
var numberTag = "[object Number]";
|
|
42
|
+
var objectProto = global.Object.prototype;
|
|
43
|
+
var objectToString = objectProto.toString;
|
|
44
|
+
function isNumber2(value) {
|
|
45
|
+
return typeof value == "number" || isObjectLike(value) && objectToString.call(value) == numberTag;
|
|
46
|
+
}
|
|
47
|
+
module.exports = isNumber2;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// ../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isArray.js
|
|
52
|
+
var require_isArray = __commonJS({
|
|
53
|
+
"../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isArray.js"(exports, module) {
|
|
54
|
+
var isArray = Array.isArray;
|
|
55
|
+
module.exports = isArray;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// ../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isString.js
|
|
60
|
+
var require_isString = __commonJS({
|
|
61
|
+
"../../node_modules/.pnpm/lodash@4.0.0/node_modules/lodash/isString.js"(exports, module) {
|
|
62
|
+
var isArray = require_isArray();
|
|
63
|
+
var isObjectLike = require_isObjectLike();
|
|
64
|
+
var stringTag = "[object String]";
|
|
65
|
+
var objectProto = global.Object.prototype;
|
|
66
|
+
var objectToString = objectProto.toString;
|
|
67
|
+
function isString2(value) {
|
|
68
|
+
return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag;
|
|
69
|
+
}
|
|
70
|
+
module.exports = isString2;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
1
74
|
// src/is/index.ts
|
|
2
75
|
var isBrowser = () => typeof window !== "undefined";
|
|
3
76
|
var isWeex = () => typeof WXEnvironment !== "undefined" && !!WXEnvironment.platform;
|
|
@@ -15,7 +88,6 @@ var isFF = () => typeof UA() === "string" && UA().match(/firefox\/(\d+)/);
|
|
|
15
88
|
var isMobile = () => isBrowser() && navigator.userAgent.toLowerCase().includes("mobile");
|
|
16
89
|
|
|
17
90
|
// src/lang/index.ts
|
|
18
|
-
import _isObject from "lodash/isObject";
|
|
19
91
|
function formDataToObject(formData) {
|
|
20
92
|
return Object.fromEntries(formData.entries());
|
|
21
93
|
}
|
|
@@ -32,25 +104,25 @@ function isWindow(value) {
|
|
|
32
104
|
return typeof window !== "undefined" && toString.call(value) === "[object Window]";
|
|
33
105
|
}
|
|
34
106
|
function isObject(value) {
|
|
35
|
-
return
|
|
107
|
+
return typeof value === "object" && !Array.isArray(value);
|
|
36
108
|
}
|
|
37
109
|
|
|
38
110
|
// src/size/index.ts
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function
|
|
42
|
-
if (!(
|
|
111
|
+
var import_isNumber = __toESM(require_isNumber());
|
|
112
|
+
var import_isString = __toESM(require_isString());
|
|
113
|
+
function formatUnit(value, unit = "px") {
|
|
114
|
+
if (!((0, import_isString.default)(value) || (0, import_isNumber.default)(value)))
|
|
43
115
|
return "";
|
|
44
|
-
return
|
|
116
|
+
return (0, import_isString.default)(value) && /\D/g.test(value) ? value : value + unit;
|
|
45
117
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
if (typeof
|
|
49
|
-
return { width:
|
|
50
|
-
if (Array.isArray(
|
|
51
|
-
return { width:
|
|
52
|
-
if (typeof
|
|
53
|
-
return { width:
|
|
118
|
+
function formatSize(dimension, unit) {
|
|
119
|
+
const _formatUnit = (value) => formatUnit(value, unit);
|
|
120
|
+
if (typeof dimension === "string" || typeof dimension === "number")
|
|
121
|
+
return { width: _formatUnit(dimension), height: _formatUnit(dimension) };
|
|
122
|
+
if (Array.isArray(dimension))
|
|
123
|
+
return { width: _formatUnit(dimension[0]), height: _formatUnit(dimension[1]) };
|
|
124
|
+
if (typeof dimension === "object")
|
|
125
|
+
return { width: _formatUnit(dimension.width), height: _formatUnit(dimension.height) };
|
|
54
126
|
return { width: "", height: "" };
|
|
55
127
|
}
|
|
56
128
|
|
|
@@ -63,6 +135,21 @@ function isTypeof(target, type) {
|
|
|
63
135
|
return getTypeof(target) === type;
|
|
64
136
|
}
|
|
65
137
|
|
|
138
|
+
// src/util/deferred.ts
|
|
139
|
+
function createDeferred() {
|
|
140
|
+
let resolve, reject;
|
|
141
|
+
const promise = new Promise((_resolve, _reject) => {
|
|
142
|
+
resolve = _resolve;
|
|
143
|
+
reject = _reject;
|
|
144
|
+
});
|
|
145
|
+
promise.resolve = (v) => {
|
|
146
|
+
resolve(v);
|
|
147
|
+
return promise;
|
|
148
|
+
};
|
|
149
|
+
promise.reject = reject;
|
|
150
|
+
return promise;
|
|
151
|
+
}
|
|
152
|
+
|
|
66
153
|
// ../../node_modules/.pnpm/p-pipe@4.0.0/node_modules/p-pipe/index.js
|
|
67
154
|
function pPipe(...functions) {
|
|
68
155
|
if (functions.length === 0) {
|
|
@@ -77,10 +164,10 @@ function pPipe(...functions) {
|
|
|
77
164
|
};
|
|
78
165
|
}
|
|
79
166
|
|
|
80
|
-
// src/util/
|
|
167
|
+
// src/util/third.ts
|
|
81
168
|
import { default as default2 } from "delay";
|
|
82
|
-
|
|
83
|
-
|
|
169
|
+
|
|
170
|
+
// src/util/index.ts
|
|
84
171
|
function arange(x1, x2, stp = 1, z = [], z0 = z.length) {
|
|
85
172
|
if (!x2)
|
|
86
173
|
x1 -= x2 = x1;
|
|
@@ -88,28 +175,20 @@ function arange(x1, x2, stp = 1, z = [], z0 = z.length) {
|
|
|
88
175
|
z[z0++] = x1;
|
|
89
176
|
return z;
|
|
90
177
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
reject = _reject;
|
|
96
|
-
});
|
|
97
|
-
promise.resolve = (v) => {
|
|
98
|
-
resolve(v);
|
|
99
|
-
return promise;
|
|
100
|
-
};
|
|
101
|
-
promise.reject = reject;
|
|
102
|
-
return promise;
|
|
178
|
+
var pipe = (...fns) => fns.reduce((v, f) => f(v));
|
|
179
|
+
var compose = (...fns) => fns.reduceRight((v, f) => f(v));
|
|
180
|
+
function whenever(value, callback) {
|
|
181
|
+
return value ? callback(value) : void 0;
|
|
103
182
|
}
|
|
104
183
|
export {
|
|
105
184
|
UA,
|
|
106
185
|
arange,
|
|
107
|
-
atWillToSize,
|
|
108
|
-
atWillToUnit,
|
|
109
186
|
compose,
|
|
110
187
|
createDeferred,
|
|
111
188
|
default2 as delay,
|
|
112
189
|
formDataToObject,
|
|
190
|
+
formatSize,
|
|
191
|
+
formatUnit,
|
|
113
192
|
getTypeof,
|
|
114
193
|
isAndroid,
|
|
115
194
|
isBrowser,
|
|
@@ -130,5 +209,6 @@ export {
|
|
|
130
209
|
objectToFormData,
|
|
131
210
|
pPipe,
|
|
132
211
|
pipe,
|
|
133
|
-
weexPlatform
|
|
212
|
+
weexPlatform,
|
|
213
|
+
whenever
|
|
134
214
|
};
|