rattail 0.0.0
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/lib/index.cjs +388 -0
- package/lib/index.d.cts +61 -0
- package/lib/index.d.ts +61 -0
- package/lib/index.js +319 -0
- package/package.json +43 -0
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __export = (target, all) => {
|
|
24
|
+
for (var name in all)
|
|
25
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
+
};
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from))
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
+
|
|
37
|
+
// src/index.ts
|
|
38
|
+
var src_exports = {};
|
|
39
|
+
__export(src_exports, {
|
|
40
|
+
bigCamelize: () => bigCamelize,
|
|
41
|
+
call: () => call,
|
|
42
|
+
camelize: () => camelize,
|
|
43
|
+
cancelAnimationFrame: () => cancelAnimationFrame,
|
|
44
|
+
clamp: () => clamp,
|
|
45
|
+
clampArrayRange: () => clampArrayRange,
|
|
46
|
+
classes: () => classes,
|
|
47
|
+
createNamespaceFn: () => createNamespaceFn,
|
|
48
|
+
debounce: () => debounce,
|
|
49
|
+
doubleRaf: () => doubleRaf,
|
|
50
|
+
find: () => find,
|
|
51
|
+
getGlobalThis: () => getGlobalThis,
|
|
52
|
+
getRect: () => getRect,
|
|
53
|
+
getScrollLeft: () => getScrollLeft,
|
|
54
|
+
getScrollTop: () => getScrollTop,
|
|
55
|
+
getStyle: () => getStyle,
|
|
56
|
+
hasOwn: () => hasOwn,
|
|
57
|
+
inBrowser: () => inBrowser,
|
|
58
|
+
inMobile: () => inMobile,
|
|
59
|
+
inViewport: () => inViewport,
|
|
60
|
+
isArray: () => isArray,
|
|
61
|
+
isBoolean: () => isBoolean,
|
|
62
|
+
isEmpty: () => isEmpty,
|
|
63
|
+
isFunction: () => isFunction,
|
|
64
|
+
isNumber: () => isNumber,
|
|
65
|
+
isNumeric: () => isNumeric,
|
|
66
|
+
isObject: () => isObject,
|
|
67
|
+
isPlainObject: () => isPlainObject,
|
|
68
|
+
isString: () => isString,
|
|
69
|
+
isURL: () => isURL,
|
|
70
|
+
isWindow: () => isWindow,
|
|
71
|
+
kebabCase: () => kebabCase,
|
|
72
|
+
mergeWith: () => mergeWith,
|
|
73
|
+
normalizeToArray: () => normalizeToArray,
|
|
74
|
+
preventDefault: () => preventDefault,
|
|
75
|
+
raf: () => raf,
|
|
76
|
+
removeArrayBlank: () => removeArrayBlank,
|
|
77
|
+
removeItem: () => removeItem,
|
|
78
|
+
requestAnimationFrame: () => requestAnimationFrame,
|
|
79
|
+
slash: () => slash,
|
|
80
|
+
supportTouch: () => supportTouch,
|
|
81
|
+
throttle: () => throttle,
|
|
82
|
+
toDataURL: () => toDataURL,
|
|
83
|
+
toNumber: () => toNumber,
|
|
84
|
+
toggleItem: () => toggleItem,
|
|
85
|
+
uniq: () => uniq
|
|
86
|
+
});
|
|
87
|
+
module.exports = __toCommonJS(src_exports);
|
|
88
|
+
|
|
89
|
+
// src/is.ts
|
|
90
|
+
var isString = (val) => typeof val === "string";
|
|
91
|
+
var isBoolean = (val) => typeof val === "boolean";
|
|
92
|
+
var isNumber = (val) => typeof val === "number";
|
|
93
|
+
var isNumeric = (val) => isNumber(val) || isString(val) && /^[-+]?\d+$/.test(val);
|
|
94
|
+
var isPlainObject = (val) => Object.prototype.toString.call(val) === "[object Object]";
|
|
95
|
+
var isObject = (val) => typeof val === "object" && val !== null;
|
|
96
|
+
var isFunction = (val) => typeof val === "function";
|
|
97
|
+
var isArray = (val) => Array.isArray(val);
|
|
98
|
+
var isURL = (val) => {
|
|
99
|
+
if (!val) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return /^(http)|(\.*\/)/.test(val);
|
|
103
|
+
};
|
|
104
|
+
var isEmpty = (val) => val === void 0 || val === null || val === "" || isArray(val) && !val.length;
|
|
105
|
+
var isWindow = (val) => val === window;
|
|
106
|
+
var supportTouch = () => inBrowser() && "ontouchstart" in window;
|
|
107
|
+
var inBrowser = () => typeof window !== "undefined";
|
|
108
|
+
var inMobile = () => inBrowser() && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
109
|
+
var { hasOwnProperty } = Object.prototype;
|
|
110
|
+
var hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
111
|
+
|
|
112
|
+
// src/array.ts
|
|
113
|
+
var uniq = (arr) => [...new Set(arr)];
|
|
114
|
+
var normalizeToArray = (value) => isArray(value) ? value : [value];
|
|
115
|
+
var removeItem = (arr, item) => {
|
|
116
|
+
if (arr.length) {
|
|
117
|
+
const index = arr.indexOf(item);
|
|
118
|
+
if (index > -1) {
|
|
119
|
+
return arr.splice(index, 1);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var toggleItem = (arr, item) => {
|
|
124
|
+
arr.includes(item) ? removeItem(arr, item) : arr.push(item);
|
|
125
|
+
return arr;
|
|
126
|
+
};
|
|
127
|
+
var removeArrayBlank = (arr) => arr.filter((item) => item != null);
|
|
128
|
+
var find = (arr, callback, from = "start") => {
|
|
129
|
+
let i = from === "start" ? 0 : arr.length - 1;
|
|
130
|
+
while (arr.length > 0 && i >= 0 && i <= arr.length - 1) {
|
|
131
|
+
const flag = callback(arr[i], i, arr);
|
|
132
|
+
if (flag) {
|
|
133
|
+
return [arr[i], i];
|
|
134
|
+
}
|
|
135
|
+
from === "start" ? i++ : i--;
|
|
136
|
+
}
|
|
137
|
+
return [null, -1];
|
|
138
|
+
};
|
|
139
|
+
var classes = (...classes2) => classes2.map((className) => {
|
|
140
|
+
if (isArray(className)) {
|
|
141
|
+
const [condition, truthy, falsy = null] = className;
|
|
142
|
+
return condition ? truthy : falsy;
|
|
143
|
+
}
|
|
144
|
+
return className;
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// src/elements.ts
|
|
148
|
+
var getGlobalThis = () => {
|
|
149
|
+
if (typeof globalThis !== "undefined") {
|
|
150
|
+
return globalThis;
|
|
151
|
+
}
|
|
152
|
+
if (inBrowser()) {
|
|
153
|
+
return window;
|
|
154
|
+
}
|
|
155
|
+
return typeof global !== "undefined" ? global : self;
|
|
156
|
+
};
|
|
157
|
+
var requestAnimationFrame = (fn) => {
|
|
158
|
+
const globalThis2 = getGlobalThis();
|
|
159
|
+
return globalThis2.requestAnimationFrame ? globalThis2.requestAnimationFrame(fn) : globalThis2.setTimeout(fn);
|
|
160
|
+
};
|
|
161
|
+
var cancelAnimationFrame = (handle) => {
|
|
162
|
+
const globalThis2 = getGlobalThis();
|
|
163
|
+
globalThis2.cancelAnimationFrame ? globalThis2.cancelAnimationFrame(handle) : globalThis2.clearTimeout(handle);
|
|
164
|
+
};
|
|
165
|
+
var raf = () => new Promise((resolve) => {
|
|
166
|
+
requestAnimationFrame(resolve);
|
|
167
|
+
});
|
|
168
|
+
var doubleRaf = () => new Promise((resolve) => {
|
|
169
|
+
requestAnimationFrame(() => {
|
|
170
|
+
requestAnimationFrame(resolve);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
var getStyle = (element) => window.getComputedStyle(element);
|
|
174
|
+
var getRect = (element) => {
|
|
175
|
+
if (isWindow(element)) {
|
|
176
|
+
const width = element.innerWidth;
|
|
177
|
+
const height = element.innerHeight;
|
|
178
|
+
const rect = {
|
|
179
|
+
x: 0,
|
|
180
|
+
y: 0,
|
|
181
|
+
top: 0,
|
|
182
|
+
left: 0,
|
|
183
|
+
right: width,
|
|
184
|
+
bottom: height,
|
|
185
|
+
width,
|
|
186
|
+
height
|
|
187
|
+
};
|
|
188
|
+
return __spreadProps(__spreadValues({}, rect), {
|
|
189
|
+
toJSON: () => rect
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return element.getBoundingClientRect();
|
|
193
|
+
};
|
|
194
|
+
var inViewport = (element) => {
|
|
195
|
+
const { top, bottom, left, right } = getRect(element);
|
|
196
|
+
const { width, height } = getRect(window);
|
|
197
|
+
const xInViewport = left <= width && right >= 0;
|
|
198
|
+
const yInViewport = top <= height && bottom >= 0;
|
|
199
|
+
return xInViewport && yInViewport;
|
|
200
|
+
};
|
|
201
|
+
var toDataURL = (file) => new Promise((resolve) => {
|
|
202
|
+
const fileReader = new FileReader();
|
|
203
|
+
fileReader.onload = () => {
|
|
204
|
+
resolve(fileReader.result);
|
|
205
|
+
};
|
|
206
|
+
fileReader.readAsDataURL(file);
|
|
207
|
+
});
|
|
208
|
+
var preventDefault = (event) => {
|
|
209
|
+
if (event.cancelable === false) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
event.preventDefault();
|
|
213
|
+
};
|
|
214
|
+
var getScrollTop = (element) => {
|
|
215
|
+
const top = "scrollTop" in element ? element.scrollTop : element.scrollY;
|
|
216
|
+
return Math.max(top, 0);
|
|
217
|
+
};
|
|
218
|
+
var getScrollLeft = (element) => {
|
|
219
|
+
const left = "scrollLeft" in element ? element.scrollLeft : element.scrollX;
|
|
220
|
+
return Math.max(left, 0);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// src/function.ts
|
|
224
|
+
var debounce = (fn, delay = 0) => {
|
|
225
|
+
let timer;
|
|
226
|
+
return function(...args) {
|
|
227
|
+
if (timer) {
|
|
228
|
+
clearTimeout(timer);
|
|
229
|
+
}
|
|
230
|
+
timer = setTimeout(() => {
|
|
231
|
+
fn.apply(this, args);
|
|
232
|
+
}, delay);
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
var throttle = (fn, delay = 200) => {
|
|
236
|
+
let timer;
|
|
237
|
+
let start = 0;
|
|
238
|
+
return function loop(...args) {
|
|
239
|
+
const now = Date.now();
|
|
240
|
+
const elapsed = now - start;
|
|
241
|
+
if (!start) {
|
|
242
|
+
start = now;
|
|
243
|
+
}
|
|
244
|
+
if (timer) {
|
|
245
|
+
clearTimeout(timer);
|
|
246
|
+
}
|
|
247
|
+
if (elapsed >= delay) {
|
|
248
|
+
fn.apply(this, args);
|
|
249
|
+
start = now;
|
|
250
|
+
} else {
|
|
251
|
+
timer = setTimeout(() => {
|
|
252
|
+
loop.apply(this, args);
|
|
253
|
+
}, delay - elapsed);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
function call(fn, ...args) {
|
|
258
|
+
if (isArray(fn)) {
|
|
259
|
+
return fn.map((f) => f(...args));
|
|
260
|
+
}
|
|
261
|
+
if (fn) {
|
|
262
|
+
return fn(...args);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// src/number.ts
|
|
267
|
+
var toNumber = (val) => {
|
|
268
|
+
if (val == null) return 0;
|
|
269
|
+
if (isString(val)) {
|
|
270
|
+
val = parseFloat(val);
|
|
271
|
+
val = Number.isNaN(val) ? 0 : val;
|
|
272
|
+
return val;
|
|
273
|
+
}
|
|
274
|
+
if (isBoolean(val)) return Number(val);
|
|
275
|
+
return val;
|
|
276
|
+
};
|
|
277
|
+
var clamp = (num, min, max) => Math.min(max, Math.max(min, num));
|
|
278
|
+
var clampArrayRange = (index, arr) => clamp(index, 0, arr.length - 1);
|
|
279
|
+
|
|
280
|
+
// src/string.ts
|
|
281
|
+
var bigCamelize = (s) => camelize(s).replace(s.charAt(0), s.charAt(0).toUpperCase());
|
|
282
|
+
var camelize = (s) => s.replace(/-(\w)/g, (_, p) => p.toUpperCase());
|
|
283
|
+
var kebabCase = (s) => {
|
|
284
|
+
const ret = s.replace(/([A-Z])/g, " $1").trim();
|
|
285
|
+
return ret.split(" ").join("-").toLowerCase();
|
|
286
|
+
};
|
|
287
|
+
var slash = (path) => {
|
|
288
|
+
const isExtendedLengthPath = path.startsWith("\\\\?\\");
|
|
289
|
+
if (isExtendedLengthPath) {
|
|
290
|
+
return path;
|
|
291
|
+
}
|
|
292
|
+
return path.replace(/\\/g, "/");
|
|
293
|
+
};
|
|
294
|
+
function createNamespaceFn(namespace) {
|
|
295
|
+
return (name) => {
|
|
296
|
+
const componentName = `${namespace}-${name}`;
|
|
297
|
+
const createBEM = (suffix) => {
|
|
298
|
+
if (!suffix) {
|
|
299
|
+
return componentName;
|
|
300
|
+
}
|
|
301
|
+
if (suffix[0] === "$") {
|
|
302
|
+
return suffix.replace("$", namespace);
|
|
303
|
+
}
|
|
304
|
+
return suffix.startsWith("--") ? `${componentName}${suffix}` : `${componentName}__${suffix}`;
|
|
305
|
+
};
|
|
306
|
+
return {
|
|
307
|
+
name: bigCamelize(componentName),
|
|
308
|
+
n: createBEM,
|
|
309
|
+
classes
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/merge.ts
|
|
315
|
+
function mergeWith(object, source, customizer) {
|
|
316
|
+
const isObject2 = (obj) => obj !== null && typeof obj === "object";
|
|
317
|
+
function baseMerge(target, src) {
|
|
318
|
+
for (const key in src) {
|
|
319
|
+
if (Object.prototype.hasOwnProperty.call(src, key)) {
|
|
320
|
+
const srcValue = src[key];
|
|
321
|
+
const targetValue = target[key];
|
|
322
|
+
const customResult = customizer(targetValue, srcValue, key, object, source);
|
|
323
|
+
if (customResult !== void 0) {
|
|
324
|
+
target[key] = customResult;
|
|
325
|
+
} else if (isObject2(srcValue)) {
|
|
326
|
+
if (isObject2(targetValue)) {
|
|
327
|
+
target[key] = baseMerge(targetValue, srcValue);
|
|
328
|
+
} else {
|
|
329
|
+
target[key] = baseMerge(isArray(srcValue) ? [] : {}, srcValue);
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
target[key] = srcValue;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return target;
|
|
337
|
+
}
|
|
338
|
+
return baseMerge(object, source);
|
|
339
|
+
}
|
|
340
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
341
|
+
0 && (module.exports = {
|
|
342
|
+
bigCamelize,
|
|
343
|
+
call,
|
|
344
|
+
camelize,
|
|
345
|
+
cancelAnimationFrame,
|
|
346
|
+
clamp,
|
|
347
|
+
clampArrayRange,
|
|
348
|
+
classes,
|
|
349
|
+
createNamespaceFn,
|
|
350
|
+
debounce,
|
|
351
|
+
doubleRaf,
|
|
352
|
+
find,
|
|
353
|
+
getGlobalThis,
|
|
354
|
+
getRect,
|
|
355
|
+
getScrollLeft,
|
|
356
|
+
getScrollTop,
|
|
357
|
+
getStyle,
|
|
358
|
+
hasOwn,
|
|
359
|
+
inBrowser,
|
|
360
|
+
inMobile,
|
|
361
|
+
inViewport,
|
|
362
|
+
isArray,
|
|
363
|
+
isBoolean,
|
|
364
|
+
isEmpty,
|
|
365
|
+
isFunction,
|
|
366
|
+
isNumber,
|
|
367
|
+
isNumeric,
|
|
368
|
+
isObject,
|
|
369
|
+
isPlainObject,
|
|
370
|
+
isString,
|
|
371
|
+
isURL,
|
|
372
|
+
isWindow,
|
|
373
|
+
kebabCase,
|
|
374
|
+
mergeWith,
|
|
375
|
+
normalizeToArray,
|
|
376
|
+
preventDefault,
|
|
377
|
+
raf,
|
|
378
|
+
removeArrayBlank,
|
|
379
|
+
removeItem,
|
|
380
|
+
requestAnimationFrame,
|
|
381
|
+
slash,
|
|
382
|
+
supportTouch,
|
|
383
|
+
throttle,
|
|
384
|
+
toDataURL,
|
|
385
|
+
toNumber,
|
|
386
|
+
toggleItem,
|
|
387
|
+
uniq
|
|
388
|
+
});
|
package/lib/index.d.cts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
declare const uniq: (arr: Array<any>) => any[];
|
|
2
|
+
declare const normalizeToArray: <T>(value: T | T[]) => T[];
|
|
3
|
+
declare const removeItem: <T>(arr: Array<T>, item: T) => T[] | undefined;
|
|
4
|
+
declare const toggleItem: <T>(arr: Array<T>, item: T) => T[];
|
|
5
|
+
declare const removeArrayBlank: <T>(arr: Array<T | null | undefined>) => T[];
|
|
6
|
+
declare const find: <T>(arr: Array<T>, callback: (item: T, index: number, array: Array<T>) => any, from?: "start" | "end") => [T, number] | [null, -1];
|
|
7
|
+
type ClassName = string | undefined | null;
|
|
8
|
+
type Classes = (ClassName | [any, ClassName, ClassName?])[];
|
|
9
|
+
declare const classes: (...classes: Classes) => any[];
|
|
10
|
+
|
|
11
|
+
declare const getGlobalThis: () => typeof globalThis;
|
|
12
|
+
declare const requestAnimationFrame: (fn: FrameRequestCallback) => number;
|
|
13
|
+
declare const cancelAnimationFrame: (handle: number) => void;
|
|
14
|
+
declare const raf: () => Promise<unknown>;
|
|
15
|
+
declare const doubleRaf: () => Promise<unknown>;
|
|
16
|
+
declare const getStyle: (element: Element) => CSSStyleDeclaration;
|
|
17
|
+
declare const getRect: (element: Element | Window) => DOMRect;
|
|
18
|
+
declare const inViewport: (element: HTMLElement) => boolean;
|
|
19
|
+
declare const toDataURL: (file: File) => Promise<string>;
|
|
20
|
+
declare const preventDefault: (event: Event) => void;
|
|
21
|
+
declare const getScrollTop: (element: Element | Window) => number;
|
|
22
|
+
declare const getScrollLeft: (element: Element | Window) => number;
|
|
23
|
+
|
|
24
|
+
declare const debounce: (fn: any, delay?: number) => (this: unknown, ...args: any[]) => void;
|
|
25
|
+
declare const throttle: (fn: any, delay?: number) => (() => void);
|
|
26
|
+
declare function call<P extends any[], R>(fn?: ((...arg: P) => R) | ((...arg: P) => R)[] | null, ...args: P): R | R[] | undefined;
|
|
27
|
+
|
|
28
|
+
declare const isString: (val: unknown) => val is string;
|
|
29
|
+
declare const isBoolean: (val: unknown) => val is boolean;
|
|
30
|
+
declare const isNumber: (val: unknown) => val is number;
|
|
31
|
+
declare const isNumeric: (val: unknown) => val is number | string;
|
|
32
|
+
declare const isPlainObject: (val: unknown) => val is Record<string, any>;
|
|
33
|
+
declare const isObject: (val: unknown) => val is Record<string, any>;
|
|
34
|
+
declare const isFunction: (val: unknown) => val is Function;
|
|
35
|
+
declare const isArray: (val: unknown) => val is Array<any>;
|
|
36
|
+
declare const isURL: (val: string | undefined | null) => boolean;
|
|
37
|
+
declare const isEmpty: (val: unknown) => boolean;
|
|
38
|
+
declare const isWindow: (val: unknown) => val is Window;
|
|
39
|
+
declare const supportTouch: () => boolean;
|
|
40
|
+
declare const inBrowser: () => boolean;
|
|
41
|
+
declare const inMobile: () => boolean;
|
|
42
|
+
declare const hasOwn: <T extends object>(val: T, key: PropertyKey) => key is keyof T;
|
|
43
|
+
|
|
44
|
+
declare const toNumber: (val: number | string | boolean | undefined | null) => number;
|
|
45
|
+
declare const clamp: (num: number, min: number, max: number) => number;
|
|
46
|
+
declare const clampArrayRange: (index: number, arr: Array<unknown>) => number;
|
|
47
|
+
|
|
48
|
+
declare const bigCamelize: (s: string) => string;
|
|
49
|
+
declare const camelize: (s: string) => string;
|
|
50
|
+
declare const kebabCase: (s: string) => string;
|
|
51
|
+
declare const slash: (path: string) => string;
|
|
52
|
+
type BEM<S extends string | undefined, N extends string, NC extends string> = S extends undefined ? NC : S extends `$--${infer CM}` ? `${N}--${CM}` : S extends `--${infer M}` ? `${NC}--${M}` : `${NC}__${S}`;
|
|
53
|
+
declare function createNamespaceFn<N extends string>(namespace: N): <C extends string>(name: C) => {
|
|
54
|
+
name: string;
|
|
55
|
+
n: <S extends string | undefined = undefined>(suffix?: S) => BEM<S, typeof namespace, `${N}-${C}`>;
|
|
56
|
+
classes: (...classes: Classes) => any[];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
declare function mergeWith<TObject extends Record<string, any>, TSource extends Record<string, any>>(object: TObject, source: TSource, customizer: (objValue: any, srcValue: any, key: string | number | symbol, object?: TObject, source?: TSource) => any | void): TObject & TSource;
|
|
60
|
+
|
|
61
|
+
export { type BEM, type ClassName, type Classes, bigCamelize, call, camelize, cancelAnimationFrame, clamp, clampArrayRange, classes, createNamespaceFn, debounce, doubleRaf, find, getGlobalThis, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inMobile, inViewport, isArray, isBoolean, isEmpty, isFunction, isNumber, isNumeric, isObject, isPlainObject, isString, isURL, isWindow, kebabCase, mergeWith, normalizeToArray, preventDefault, raf, removeArrayBlank, removeItem, requestAnimationFrame, slash, supportTouch, throttle, toDataURL, toNumber, toggleItem, uniq };
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
declare const uniq: (arr: Array<any>) => any[];
|
|
2
|
+
declare const normalizeToArray: <T>(value: T | T[]) => T[];
|
|
3
|
+
declare const removeItem: <T>(arr: Array<T>, item: T) => T[] | undefined;
|
|
4
|
+
declare const toggleItem: <T>(arr: Array<T>, item: T) => T[];
|
|
5
|
+
declare const removeArrayBlank: <T>(arr: Array<T | null | undefined>) => T[];
|
|
6
|
+
declare const find: <T>(arr: Array<T>, callback: (item: T, index: number, array: Array<T>) => any, from?: "start" | "end") => [T, number] | [null, -1];
|
|
7
|
+
type ClassName = string | undefined | null;
|
|
8
|
+
type Classes = (ClassName | [any, ClassName, ClassName?])[];
|
|
9
|
+
declare const classes: (...classes: Classes) => any[];
|
|
10
|
+
|
|
11
|
+
declare const getGlobalThis: () => typeof globalThis;
|
|
12
|
+
declare const requestAnimationFrame: (fn: FrameRequestCallback) => number;
|
|
13
|
+
declare const cancelAnimationFrame: (handle: number) => void;
|
|
14
|
+
declare const raf: () => Promise<unknown>;
|
|
15
|
+
declare const doubleRaf: () => Promise<unknown>;
|
|
16
|
+
declare const getStyle: (element: Element) => CSSStyleDeclaration;
|
|
17
|
+
declare const getRect: (element: Element | Window) => DOMRect;
|
|
18
|
+
declare const inViewport: (element: HTMLElement) => boolean;
|
|
19
|
+
declare const toDataURL: (file: File) => Promise<string>;
|
|
20
|
+
declare const preventDefault: (event: Event) => void;
|
|
21
|
+
declare const getScrollTop: (element: Element | Window) => number;
|
|
22
|
+
declare const getScrollLeft: (element: Element | Window) => number;
|
|
23
|
+
|
|
24
|
+
declare const debounce: (fn: any, delay?: number) => (this: unknown, ...args: any[]) => void;
|
|
25
|
+
declare const throttle: (fn: any, delay?: number) => (() => void);
|
|
26
|
+
declare function call<P extends any[], R>(fn?: ((...arg: P) => R) | ((...arg: P) => R)[] | null, ...args: P): R | R[] | undefined;
|
|
27
|
+
|
|
28
|
+
declare const isString: (val: unknown) => val is string;
|
|
29
|
+
declare const isBoolean: (val: unknown) => val is boolean;
|
|
30
|
+
declare const isNumber: (val: unknown) => val is number;
|
|
31
|
+
declare const isNumeric: (val: unknown) => val is number | string;
|
|
32
|
+
declare const isPlainObject: (val: unknown) => val is Record<string, any>;
|
|
33
|
+
declare const isObject: (val: unknown) => val is Record<string, any>;
|
|
34
|
+
declare const isFunction: (val: unknown) => val is Function;
|
|
35
|
+
declare const isArray: (val: unknown) => val is Array<any>;
|
|
36
|
+
declare const isURL: (val: string | undefined | null) => boolean;
|
|
37
|
+
declare const isEmpty: (val: unknown) => boolean;
|
|
38
|
+
declare const isWindow: (val: unknown) => val is Window;
|
|
39
|
+
declare const supportTouch: () => boolean;
|
|
40
|
+
declare const inBrowser: () => boolean;
|
|
41
|
+
declare const inMobile: () => boolean;
|
|
42
|
+
declare const hasOwn: <T extends object>(val: T, key: PropertyKey) => key is keyof T;
|
|
43
|
+
|
|
44
|
+
declare const toNumber: (val: number | string | boolean | undefined | null) => number;
|
|
45
|
+
declare const clamp: (num: number, min: number, max: number) => number;
|
|
46
|
+
declare const clampArrayRange: (index: number, arr: Array<unknown>) => number;
|
|
47
|
+
|
|
48
|
+
declare const bigCamelize: (s: string) => string;
|
|
49
|
+
declare const camelize: (s: string) => string;
|
|
50
|
+
declare const kebabCase: (s: string) => string;
|
|
51
|
+
declare const slash: (path: string) => string;
|
|
52
|
+
type BEM<S extends string | undefined, N extends string, NC extends string> = S extends undefined ? NC : S extends `$--${infer CM}` ? `${N}--${CM}` : S extends `--${infer M}` ? `${NC}--${M}` : `${NC}__${S}`;
|
|
53
|
+
declare function createNamespaceFn<N extends string>(namespace: N): <C extends string>(name: C) => {
|
|
54
|
+
name: string;
|
|
55
|
+
n: <S extends string | undefined = undefined>(suffix?: S) => BEM<S, typeof namespace, `${N}-${C}`>;
|
|
56
|
+
classes: (...classes: Classes) => any[];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
declare function mergeWith<TObject extends Record<string, any>, TSource extends Record<string, any>>(object: TObject, source: TSource, customizer: (objValue: any, srcValue: any, key: string | number | symbol, object?: TObject, source?: TSource) => any | void): TObject & TSource;
|
|
60
|
+
|
|
61
|
+
export { type BEM, type ClassName, type Classes, bigCamelize, call, camelize, cancelAnimationFrame, clamp, clampArrayRange, classes, createNamespaceFn, debounce, doubleRaf, find, getGlobalThis, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inMobile, inViewport, isArray, isBoolean, isEmpty, isFunction, isNumber, isNumeric, isObject, isPlainObject, isString, isURL, isWindow, kebabCase, mergeWith, normalizeToArray, preventDefault, raf, removeArrayBlank, removeItem, requestAnimationFrame, slash, supportTouch, throttle, toDataURL, toNumber, toggleItem, uniq };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// src/is.ts
|
|
22
|
+
var isString = (val) => typeof val === "string";
|
|
23
|
+
var isBoolean = (val) => typeof val === "boolean";
|
|
24
|
+
var isNumber = (val) => typeof val === "number";
|
|
25
|
+
var isNumeric = (val) => isNumber(val) || isString(val) && /^[-+]?\d+$/.test(val);
|
|
26
|
+
var isPlainObject = (val) => Object.prototype.toString.call(val) === "[object Object]";
|
|
27
|
+
var isObject = (val) => typeof val === "object" && val !== null;
|
|
28
|
+
var isFunction = (val) => typeof val === "function";
|
|
29
|
+
var isArray = (val) => Array.isArray(val);
|
|
30
|
+
var isURL = (val) => {
|
|
31
|
+
if (!val) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return /^(http)|(\.*\/)/.test(val);
|
|
35
|
+
};
|
|
36
|
+
var isEmpty = (val) => val === void 0 || val === null || val === "" || isArray(val) && !val.length;
|
|
37
|
+
var isWindow = (val) => val === window;
|
|
38
|
+
var supportTouch = () => inBrowser() && "ontouchstart" in window;
|
|
39
|
+
var inBrowser = () => typeof window !== "undefined";
|
|
40
|
+
var inMobile = () => inBrowser() && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
41
|
+
var { hasOwnProperty } = Object.prototype;
|
|
42
|
+
var hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
43
|
+
|
|
44
|
+
// src/array.ts
|
|
45
|
+
var uniq = (arr) => [...new Set(arr)];
|
|
46
|
+
var normalizeToArray = (value) => isArray(value) ? value : [value];
|
|
47
|
+
var removeItem = (arr, item) => {
|
|
48
|
+
if (arr.length) {
|
|
49
|
+
const index = arr.indexOf(item);
|
|
50
|
+
if (index > -1) {
|
|
51
|
+
return arr.splice(index, 1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var toggleItem = (arr, item) => {
|
|
56
|
+
arr.includes(item) ? removeItem(arr, item) : arr.push(item);
|
|
57
|
+
return arr;
|
|
58
|
+
};
|
|
59
|
+
var removeArrayBlank = (arr) => arr.filter((item) => item != null);
|
|
60
|
+
var find = (arr, callback, from = "start") => {
|
|
61
|
+
let i = from === "start" ? 0 : arr.length - 1;
|
|
62
|
+
while (arr.length > 0 && i >= 0 && i <= arr.length - 1) {
|
|
63
|
+
const flag = callback(arr[i], i, arr);
|
|
64
|
+
if (flag) {
|
|
65
|
+
return [arr[i], i];
|
|
66
|
+
}
|
|
67
|
+
from === "start" ? i++ : i--;
|
|
68
|
+
}
|
|
69
|
+
return [null, -1];
|
|
70
|
+
};
|
|
71
|
+
var classes = (...classes2) => classes2.map((className) => {
|
|
72
|
+
if (isArray(className)) {
|
|
73
|
+
const [condition, truthy, falsy = null] = className;
|
|
74
|
+
return condition ? truthy : falsy;
|
|
75
|
+
}
|
|
76
|
+
return className;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// src/elements.ts
|
|
80
|
+
var getGlobalThis = () => {
|
|
81
|
+
if (typeof globalThis !== "undefined") {
|
|
82
|
+
return globalThis;
|
|
83
|
+
}
|
|
84
|
+
if (inBrowser()) {
|
|
85
|
+
return window;
|
|
86
|
+
}
|
|
87
|
+
return typeof global !== "undefined" ? global : self;
|
|
88
|
+
};
|
|
89
|
+
var requestAnimationFrame = (fn) => {
|
|
90
|
+
const globalThis2 = getGlobalThis();
|
|
91
|
+
return globalThis2.requestAnimationFrame ? globalThis2.requestAnimationFrame(fn) : globalThis2.setTimeout(fn);
|
|
92
|
+
};
|
|
93
|
+
var cancelAnimationFrame = (handle) => {
|
|
94
|
+
const globalThis2 = getGlobalThis();
|
|
95
|
+
globalThis2.cancelAnimationFrame ? globalThis2.cancelAnimationFrame(handle) : globalThis2.clearTimeout(handle);
|
|
96
|
+
};
|
|
97
|
+
var raf = () => new Promise((resolve) => {
|
|
98
|
+
requestAnimationFrame(resolve);
|
|
99
|
+
});
|
|
100
|
+
var doubleRaf = () => new Promise((resolve) => {
|
|
101
|
+
requestAnimationFrame(() => {
|
|
102
|
+
requestAnimationFrame(resolve);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var getStyle = (element) => window.getComputedStyle(element);
|
|
106
|
+
var getRect = (element) => {
|
|
107
|
+
if (isWindow(element)) {
|
|
108
|
+
const width = element.innerWidth;
|
|
109
|
+
const height = element.innerHeight;
|
|
110
|
+
const rect = {
|
|
111
|
+
x: 0,
|
|
112
|
+
y: 0,
|
|
113
|
+
top: 0,
|
|
114
|
+
left: 0,
|
|
115
|
+
right: width,
|
|
116
|
+
bottom: height,
|
|
117
|
+
width,
|
|
118
|
+
height
|
|
119
|
+
};
|
|
120
|
+
return __spreadProps(__spreadValues({}, rect), {
|
|
121
|
+
toJSON: () => rect
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return element.getBoundingClientRect();
|
|
125
|
+
};
|
|
126
|
+
var inViewport = (element) => {
|
|
127
|
+
const { top, bottom, left, right } = getRect(element);
|
|
128
|
+
const { width, height } = getRect(window);
|
|
129
|
+
const xInViewport = left <= width && right >= 0;
|
|
130
|
+
const yInViewport = top <= height && bottom >= 0;
|
|
131
|
+
return xInViewport && yInViewport;
|
|
132
|
+
};
|
|
133
|
+
var toDataURL = (file) => new Promise((resolve) => {
|
|
134
|
+
const fileReader = new FileReader();
|
|
135
|
+
fileReader.onload = () => {
|
|
136
|
+
resolve(fileReader.result);
|
|
137
|
+
};
|
|
138
|
+
fileReader.readAsDataURL(file);
|
|
139
|
+
});
|
|
140
|
+
var preventDefault = (event) => {
|
|
141
|
+
if (event.cancelable === false) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
};
|
|
146
|
+
var getScrollTop = (element) => {
|
|
147
|
+
const top = "scrollTop" in element ? element.scrollTop : element.scrollY;
|
|
148
|
+
return Math.max(top, 0);
|
|
149
|
+
};
|
|
150
|
+
var getScrollLeft = (element) => {
|
|
151
|
+
const left = "scrollLeft" in element ? element.scrollLeft : element.scrollX;
|
|
152
|
+
return Math.max(left, 0);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/function.ts
|
|
156
|
+
var debounce = (fn, delay = 0) => {
|
|
157
|
+
let timer;
|
|
158
|
+
return function(...args) {
|
|
159
|
+
if (timer) {
|
|
160
|
+
clearTimeout(timer);
|
|
161
|
+
}
|
|
162
|
+
timer = setTimeout(() => {
|
|
163
|
+
fn.apply(this, args);
|
|
164
|
+
}, delay);
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
var throttle = (fn, delay = 200) => {
|
|
168
|
+
let timer;
|
|
169
|
+
let start = 0;
|
|
170
|
+
return function loop(...args) {
|
|
171
|
+
const now = Date.now();
|
|
172
|
+
const elapsed = now - start;
|
|
173
|
+
if (!start) {
|
|
174
|
+
start = now;
|
|
175
|
+
}
|
|
176
|
+
if (timer) {
|
|
177
|
+
clearTimeout(timer);
|
|
178
|
+
}
|
|
179
|
+
if (elapsed >= delay) {
|
|
180
|
+
fn.apply(this, args);
|
|
181
|
+
start = now;
|
|
182
|
+
} else {
|
|
183
|
+
timer = setTimeout(() => {
|
|
184
|
+
loop.apply(this, args);
|
|
185
|
+
}, delay - elapsed);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
function call(fn, ...args) {
|
|
190
|
+
if (isArray(fn)) {
|
|
191
|
+
return fn.map((f) => f(...args));
|
|
192
|
+
}
|
|
193
|
+
if (fn) {
|
|
194
|
+
return fn(...args);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/number.ts
|
|
199
|
+
var toNumber = (val) => {
|
|
200
|
+
if (val == null) return 0;
|
|
201
|
+
if (isString(val)) {
|
|
202
|
+
val = parseFloat(val);
|
|
203
|
+
val = Number.isNaN(val) ? 0 : val;
|
|
204
|
+
return val;
|
|
205
|
+
}
|
|
206
|
+
if (isBoolean(val)) return Number(val);
|
|
207
|
+
return val;
|
|
208
|
+
};
|
|
209
|
+
var clamp = (num, min, max) => Math.min(max, Math.max(min, num));
|
|
210
|
+
var clampArrayRange = (index, arr) => clamp(index, 0, arr.length - 1);
|
|
211
|
+
|
|
212
|
+
// src/string.ts
|
|
213
|
+
var bigCamelize = (s) => camelize(s).replace(s.charAt(0), s.charAt(0).toUpperCase());
|
|
214
|
+
var camelize = (s) => s.replace(/-(\w)/g, (_, p) => p.toUpperCase());
|
|
215
|
+
var kebabCase = (s) => {
|
|
216
|
+
const ret = s.replace(/([A-Z])/g, " $1").trim();
|
|
217
|
+
return ret.split(" ").join("-").toLowerCase();
|
|
218
|
+
};
|
|
219
|
+
var slash = (path) => {
|
|
220
|
+
const isExtendedLengthPath = path.startsWith("\\\\?\\");
|
|
221
|
+
if (isExtendedLengthPath) {
|
|
222
|
+
return path;
|
|
223
|
+
}
|
|
224
|
+
return path.replace(/\\/g, "/");
|
|
225
|
+
};
|
|
226
|
+
function createNamespaceFn(namespace) {
|
|
227
|
+
return (name) => {
|
|
228
|
+
const componentName = `${namespace}-${name}`;
|
|
229
|
+
const createBEM = (suffix) => {
|
|
230
|
+
if (!suffix) {
|
|
231
|
+
return componentName;
|
|
232
|
+
}
|
|
233
|
+
if (suffix[0] === "$") {
|
|
234
|
+
return suffix.replace("$", namespace);
|
|
235
|
+
}
|
|
236
|
+
return suffix.startsWith("--") ? `${componentName}${suffix}` : `${componentName}__${suffix}`;
|
|
237
|
+
};
|
|
238
|
+
return {
|
|
239
|
+
name: bigCamelize(componentName),
|
|
240
|
+
n: createBEM,
|
|
241
|
+
classes
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// src/merge.ts
|
|
247
|
+
function mergeWith(object, source, customizer) {
|
|
248
|
+
const isObject2 = (obj) => obj !== null && typeof obj === "object";
|
|
249
|
+
function baseMerge(target, src) {
|
|
250
|
+
for (const key in src) {
|
|
251
|
+
if (Object.prototype.hasOwnProperty.call(src, key)) {
|
|
252
|
+
const srcValue = src[key];
|
|
253
|
+
const targetValue = target[key];
|
|
254
|
+
const customResult = customizer(targetValue, srcValue, key, object, source);
|
|
255
|
+
if (customResult !== void 0) {
|
|
256
|
+
target[key] = customResult;
|
|
257
|
+
} else if (isObject2(srcValue)) {
|
|
258
|
+
if (isObject2(targetValue)) {
|
|
259
|
+
target[key] = baseMerge(targetValue, srcValue);
|
|
260
|
+
} else {
|
|
261
|
+
target[key] = baseMerge(isArray(srcValue) ? [] : {}, srcValue);
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
target[key] = srcValue;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return target;
|
|
269
|
+
}
|
|
270
|
+
return baseMerge(object, source);
|
|
271
|
+
}
|
|
272
|
+
export {
|
|
273
|
+
bigCamelize,
|
|
274
|
+
call,
|
|
275
|
+
camelize,
|
|
276
|
+
cancelAnimationFrame,
|
|
277
|
+
clamp,
|
|
278
|
+
clampArrayRange,
|
|
279
|
+
classes,
|
|
280
|
+
createNamespaceFn,
|
|
281
|
+
debounce,
|
|
282
|
+
doubleRaf,
|
|
283
|
+
find,
|
|
284
|
+
getGlobalThis,
|
|
285
|
+
getRect,
|
|
286
|
+
getScrollLeft,
|
|
287
|
+
getScrollTop,
|
|
288
|
+
getStyle,
|
|
289
|
+
hasOwn,
|
|
290
|
+
inBrowser,
|
|
291
|
+
inMobile,
|
|
292
|
+
inViewport,
|
|
293
|
+
isArray,
|
|
294
|
+
isBoolean,
|
|
295
|
+
isEmpty,
|
|
296
|
+
isFunction,
|
|
297
|
+
isNumber,
|
|
298
|
+
isNumeric,
|
|
299
|
+
isObject,
|
|
300
|
+
isPlainObject,
|
|
301
|
+
isString,
|
|
302
|
+
isURL,
|
|
303
|
+
isWindow,
|
|
304
|
+
kebabCase,
|
|
305
|
+
mergeWith,
|
|
306
|
+
normalizeToArray,
|
|
307
|
+
preventDefault,
|
|
308
|
+
raf,
|
|
309
|
+
removeArrayBlank,
|
|
310
|
+
removeItem,
|
|
311
|
+
requestAnimationFrame,
|
|
312
|
+
slash,
|
|
313
|
+
supportTouch,
|
|
314
|
+
throttle,
|
|
315
|
+
toDataURL,
|
|
316
|
+
toNumber,
|
|
317
|
+
toggleItem,
|
|
318
|
+
uniq
|
|
319
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rattail",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "lib/index.cjs",
|
|
6
|
+
"module": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./lib/index.js",
|
|
12
|
+
"require": "./lib/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"description": "shared utils of common",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"shared",
|
|
18
|
+
"utils",
|
|
19
|
+
"common"
|
|
20
|
+
],
|
|
21
|
+
"author": "haoziqaq <357229046@qq.com>",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"files": [
|
|
24
|
+
"lib"
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/varletjs/rattail.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/varletjs/rattail/issues"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^22.8.1",
|
|
35
|
+
"typescript": "^5.6.3",
|
|
36
|
+
"tsup": "8.3.5",
|
|
37
|
+
"@varlet/release": "^0.3.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"dev": "tsup src/index.ts --format esm --out-dir=lib --watch --dts",
|
|
41
|
+
"build": "tsup src/index.ts --format esm,cjs --out-dir=lib --dts --clean"
|
|
42
|
+
}
|
|
43
|
+
}
|