rattail 0.0.2 → 0.0.3
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 +8 -8
- package/lib/index.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +8 -8
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -276,7 +276,8 @@ function pascalCase(s) {
|
|
|
276
276
|
return camelize(s).replace(s.charAt(0), s.charAt(0).toUpperCase());
|
|
277
277
|
}
|
|
278
278
|
function camelize(s) {
|
|
279
|
-
|
|
279
|
+
s = s.replace(/-(\w)/g, (_, p) => p.toUpperCase());
|
|
280
|
+
return s.replace(s.charAt(0), s.charAt(0).toLowerCase());
|
|
280
281
|
}
|
|
281
282
|
function kebabCase(s) {
|
|
282
283
|
const ret = s.replace(/([A-Z])/g, " $1").trim();
|
|
@@ -291,7 +292,7 @@ function slash(path) {
|
|
|
291
292
|
}
|
|
292
293
|
var key = 0;
|
|
293
294
|
function genStringKey() {
|
|
294
|
-
return
|
|
295
|
+
return `generated-key-${key++}`;
|
|
295
296
|
}
|
|
296
297
|
function capitalizeFirstLetter(s) {
|
|
297
298
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
@@ -488,23 +489,22 @@ var key2 = 0;
|
|
|
488
489
|
function genNumberKey() {
|
|
489
490
|
return key2++;
|
|
490
491
|
}
|
|
491
|
-
function randomNumber(min = 0, max =
|
|
492
|
+
function randomNumber(min = 0, max = 100) {
|
|
492
493
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
493
494
|
}
|
|
494
495
|
|
|
495
496
|
// src/collection.ts
|
|
496
497
|
function mergeWith(object, source, callback) {
|
|
497
|
-
const isObject2 = (obj) => obj !== null && typeof obj === "object";
|
|
498
498
|
function baseMerge(target, src) {
|
|
499
499
|
for (const key3 in src) {
|
|
500
|
-
if (
|
|
500
|
+
if (hasOwn(src, key3)) {
|
|
501
501
|
const srcValue = src[key3];
|
|
502
502
|
const targetValue = target[key3];
|
|
503
|
-
const customResult = callback(targetValue, srcValue, key3, object, source);
|
|
503
|
+
const customResult = callback == null ? void 0 : callback(targetValue, srcValue, key3, object, source);
|
|
504
504
|
if (customResult !== void 0) {
|
|
505
505
|
target[key3] = customResult;
|
|
506
|
-
} else if (
|
|
507
|
-
if (
|
|
506
|
+
} else if (isObject(srcValue)) {
|
|
507
|
+
if (isObject(targetValue)) {
|
|
508
508
|
target[key3] = baseMerge(targetValue, srcValue);
|
|
509
509
|
} else {
|
|
510
510
|
target[key3] = baseMerge(isArray(srcValue) ? [] : {}, srcValue);
|
package/lib/index.d.cts
CHANGED
|
@@ -79,7 +79,7 @@ declare function slash(path: string): string;
|
|
|
79
79
|
declare function genStringKey(): string;
|
|
80
80
|
declare function capitalizeFirstLetter(s: string): string;
|
|
81
81
|
|
|
82
|
-
declare function mergeWith<TObject extends Record<string, any>, TSource extends Record<string, any>>(object: TObject, source: TSource, callback
|
|
82
|
+
declare function mergeWith<TObject extends Record<string, any>, TSource extends Record<string, any>>(object: TObject, source: TSource, callback?: (objValue: any, srcValue: any, key: string | number | symbol, object?: TObject, source?: TSource) => any | void): TObject & TSource;
|
|
83
83
|
|
|
84
84
|
declare function tryParseJSON<T>(json: string): T | undefined;
|
|
85
85
|
declare function prettyJSONObject(jsonObject: Record<string, any>): string;
|
package/lib/index.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ declare function slash(path: string): string;
|
|
|
79
79
|
declare function genStringKey(): string;
|
|
80
80
|
declare function capitalizeFirstLetter(s: string): string;
|
|
81
81
|
|
|
82
|
-
declare function mergeWith<TObject extends Record<string, any>, TSource extends Record<string, any>>(object: TObject, source: TSource, callback
|
|
82
|
+
declare function mergeWith<TObject extends Record<string, any>, TSource extends Record<string, any>>(object: TObject, source: TSource, callback?: (objValue: any, srcValue: any, key: string | number | symbol, object?: TObject, source?: TSource) => any | void): TObject & TSource;
|
|
83
83
|
|
|
84
84
|
declare function tryParseJSON<T>(json: string): T | undefined;
|
|
85
85
|
declare function prettyJSONObject(jsonObject: Record<string, any>): string;
|
package/lib/index.js
CHANGED
|
@@ -177,7 +177,8 @@ function pascalCase(s) {
|
|
|
177
177
|
return camelize(s).replace(s.charAt(0), s.charAt(0).toUpperCase());
|
|
178
178
|
}
|
|
179
179
|
function camelize(s) {
|
|
180
|
-
|
|
180
|
+
s = s.replace(/-(\w)/g, (_, p) => p.toUpperCase());
|
|
181
|
+
return s.replace(s.charAt(0), s.charAt(0).toLowerCase());
|
|
181
182
|
}
|
|
182
183
|
function kebabCase(s) {
|
|
183
184
|
const ret = s.replace(/([A-Z])/g, " $1").trim();
|
|
@@ -192,7 +193,7 @@ function slash(path) {
|
|
|
192
193
|
}
|
|
193
194
|
var key = 0;
|
|
194
195
|
function genStringKey() {
|
|
195
|
-
return
|
|
196
|
+
return `generated-key-${key++}`;
|
|
196
197
|
}
|
|
197
198
|
function capitalizeFirstLetter(s) {
|
|
198
199
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
@@ -389,23 +390,22 @@ var key2 = 0;
|
|
|
389
390
|
function genNumberKey() {
|
|
390
391
|
return key2++;
|
|
391
392
|
}
|
|
392
|
-
function randomNumber(min = 0, max =
|
|
393
|
+
function randomNumber(min = 0, max = 100) {
|
|
393
394
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
394
395
|
}
|
|
395
396
|
|
|
396
397
|
// src/collection.ts
|
|
397
398
|
function mergeWith(object, source, callback) {
|
|
398
|
-
const isObject2 = (obj) => obj !== null && typeof obj === "object";
|
|
399
399
|
function baseMerge(target, src) {
|
|
400
400
|
for (const key3 in src) {
|
|
401
|
-
if (
|
|
401
|
+
if (hasOwn(src, key3)) {
|
|
402
402
|
const srcValue = src[key3];
|
|
403
403
|
const targetValue = target[key3];
|
|
404
|
-
const customResult = callback(targetValue, srcValue, key3, object, source);
|
|
404
|
+
const customResult = callback == null ? void 0 : callback(targetValue, srcValue, key3, object, source);
|
|
405
405
|
if (customResult !== void 0) {
|
|
406
406
|
target[key3] = customResult;
|
|
407
|
-
} else if (
|
|
408
|
-
if (
|
|
407
|
+
} else if (isObject(srcValue)) {
|
|
408
|
+
if (isObject(targetValue)) {
|
|
409
409
|
target[key3] = baseMerge(targetValue, srcValue);
|
|
410
410
|
} else {
|
|
411
411
|
target[key3] = baseMerge(isArray(srcValue) ? [] : {}, srcValue);
|