@varlet/shared 3.2.14 → 3.2.15-alpha.1718191007402
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 +29 -0
- package/lib/index.d.cts +3 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +28 -0
- package/package.json +1 -1
- package/tsconfig.json +2 -1
package/lib/index.cjs
CHANGED
|
@@ -69,6 +69,7 @@ __export(src_exports, {
|
|
|
69
69
|
isURL: () => isURL,
|
|
70
70
|
isWindow: () => isWindow,
|
|
71
71
|
kebabCase: () => kebabCase,
|
|
72
|
+
mergeWith: () => mergeWith,
|
|
72
73
|
normalizeToArray: () => normalizeToArray,
|
|
73
74
|
preventDefault: () => preventDefault,
|
|
74
75
|
raf: () => raf,
|
|
@@ -311,6 +312,33 @@ function createNamespaceFn(namespace) {
|
|
|
311
312
|
};
|
|
312
313
|
};
|
|
313
314
|
}
|
|
315
|
+
|
|
316
|
+
// src/merge.ts
|
|
317
|
+
function mergeWith(object, source, customizer) {
|
|
318
|
+
const isObject2 = (obj) => obj !== null && typeof obj === "object";
|
|
319
|
+
function baseMerge(target, src) {
|
|
320
|
+
for (const key in src) {
|
|
321
|
+
if (Object.prototype.hasOwnProperty.call(src, key)) {
|
|
322
|
+
const srcValue = src[key];
|
|
323
|
+
const targetValue = target[key];
|
|
324
|
+
const customResult = customizer(targetValue, srcValue, key, object, source);
|
|
325
|
+
if (customResult !== void 0) {
|
|
326
|
+
target[key] = customResult;
|
|
327
|
+
} else if (isObject2(srcValue)) {
|
|
328
|
+
if (isObject2(targetValue)) {
|
|
329
|
+
target[key] = baseMerge(targetValue, srcValue);
|
|
330
|
+
} else {
|
|
331
|
+
target[key] = baseMerge(Array.isArray(srcValue) ? [] : {}, srcValue);
|
|
332
|
+
}
|
|
333
|
+
} else {
|
|
334
|
+
target[key] = srcValue;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return target;
|
|
339
|
+
}
|
|
340
|
+
return baseMerge(object, source);
|
|
341
|
+
}
|
|
314
342
|
// Annotate the CommonJS export names for ESM import in node:
|
|
315
343
|
0 && (module.exports = {
|
|
316
344
|
bigCamelize,
|
|
@@ -345,6 +373,7 @@ function createNamespaceFn(namespace) {
|
|
|
345
373
|
isURL,
|
|
346
374
|
isWindow,
|
|
347
375
|
kebabCase,
|
|
376
|
+
mergeWith,
|
|
348
377
|
normalizeToArray,
|
|
349
378
|
preventDefault,
|
|
350
379
|
raf,
|
package/lib/index.d.cts
CHANGED
|
@@ -56,4 +56,6 @@ declare function createNamespaceFn<N extends string>(namespace: N): <C extends s
|
|
|
56
56
|
classes: (...classes: Classes) => any[];
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
|
|
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 { BEM, ClassName, 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
CHANGED
|
@@ -56,4 +56,6 @@ declare function createNamespaceFn<N extends string>(namespace: N): <C extends s
|
|
|
56
56
|
classes: (...classes: Classes) => any[];
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
|
|
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 { BEM, ClassName, 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
CHANGED
|
@@ -244,6 +244,33 @@ function createNamespaceFn(namespace) {
|
|
|
244
244
|
};
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
|
+
|
|
248
|
+
// src/merge.ts
|
|
249
|
+
function mergeWith(object, source, customizer) {
|
|
250
|
+
const isObject2 = (obj) => obj !== null && typeof obj === "object";
|
|
251
|
+
function baseMerge(target, src) {
|
|
252
|
+
for (const key in src) {
|
|
253
|
+
if (Object.prototype.hasOwnProperty.call(src, key)) {
|
|
254
|
+
const srcValue = src[key];
|
|
255
|
+
const targetValue = target[key];
|
|
256
|
+
const customResult = customizer(targetValue, srcValue, key, object, source);
|
|
257
|
+
if (customResult !== void 0) {
|
|
258
|
+
target[key] = customResult;
|
|
259
|
+
} else if (isObject2(srcValue)) {
|
|
260
|
+
if (isObject2(targetValue)) {
|
|
261
|
+
target[key] = baseMerge(targetValue, srcValue);
|
|
262
|
+
} else {
|
|
263
|
+
target[key] = baseMerge(Array.isArray(srcValue) ? [] : {}, srcValue);
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
target[key] = srcValue;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return target;
|
|
271
|
+
}
|
|
272
|
+
return baseMerge(object, source);
|
|
273
|
+
}
|
|
247
274
|
export {
|
|
248
275
|
bigCamelize,
|
|
249
276
|
call,
|
|
@@ -277,6 +304,7 @@ export {
|
|
|
277
304
|
isURL,
|
|
278
305
|
isWindow,
|
|
279
306
|
kebabCase,
|
|
307
|
+
mergeWith,
|
|
280
308
|
normalizeToArray,
|
|
281
309
|
preventDefault,
|
|
282
310
|
raf,
|
package/package.json
CHANGED