es-toolkit 1.49.0 → 1.50.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/CHANGELOG.md +46 -0
- package/dist/array/partition.d.mts +5 -4
- package/dist/array/partition.d.ts +5 -4
- package/dist/array/unzipWith.js +1 -1
- package/dist/array/unzipWith.mjs +1 -1
- package/dist/browser.global.js +3 -3
- package/dist/compat/_internal/ListIterateeCustom.d.mts +3 -2
- package/dist/compat/_internal/ListIterateeCustom.d.ts +3 -2
- package/dist/compat/_internal/assignValue.js +2 -3
- package/dist/compat/_internal/assignValue.mjs +2 -3
- package/dist/compat/_internal/createPadding.js +14 -0
- package/dist/compat/_internal/createPadding.mjs +13 -0
- package/dist/compat/_internal/isDeepKey.js +14 -1
- package/dist/compat/_internal/isDeepKey.mjs +14 -1
- package/dist/compat/_internal/isIterateeCall.js +2 -3
- package/dist/compat/_internal/isIterateeCall.mjs +2 -3
- package/dist/compat/_internal/regexMultiByte.js +11 -0
- package/dist/compat/_internal/regexMultiByte.mjs +11 -0
- package/dist/compat/array/every.js +5 -24
- package/dist/compat/array/every.mjs +5 -24
- package/dist/compat/array/filter.d.mts +7 -3
- package/dist/compat/array/filter.d.ts +7 -3
- package/dist/compat/array/filter.js +11 -11
- package/dist/compat/array/filter.mjs +11 -11
- package/dist/compat/array/find.d.mts +10 -6
- package/dist/compat/array/find.d.ts +10 -6
- package/dist/compat/array/find.js +1 -1
- package/dist/compat/array/find.mjs +1 -1
- package/dist/compat/array/findIndex.d.mts +0 -1
- package/dist/compat/array/findIndex.d.ts +0 -1
- package/dist/compat/array/findIndex.js +2 -1
- package/dist/compat/array/findIndex.mjs +2 -1
- package/dist/compat/array/findLast.d.mts +1 -1
- package/dist/compat/array/findLast.d.ts +1 -1
- package/dist/compat/array/findLast.js +12 -12
- package/dist/compat/array/findLast.mjs +12 -12
- package/dist/compat/array/findLastIndex.js +1 -0
- package/dist/compat/array/findLastIndex.mjs +1 -0
- package/dist/compat/array/flatMap.js +3 -2
- package/dist/compat/array/flatMap.mjs +3 -2
- package/dist/compat/array/flatMapDepth.js +2 -2
- package/dist/compat/array/flatMapDepth.mjs +2 -2
- package/dist/compat/array/flatten.d.mts +4 -5
- package/dist/compat/array/flatten.d.ts +4 -5
- package/dist/compat/array/flatten.js +14 -15
- package/dist/compat/array/flatten.mjs +14 -15
- package/dist/compat/array/flattenDeep.d.mts +1 -1
- package/dist/compat/array/flattenDeep.d.ts +1 -1
- package/dist/compat/array/flattenDeep.js +2 -2
- package/dist/compat/array/flattenDeep.mjs +2 -2
- package/dist/compat/array/flattenDepth.js +18 -2
- package/dist/compat/array/flattenDepth.mjs +18 -2
- package/dist/compat/array/groupBy.js +5 -4
- package/dist/compat/array/groupBy.mjs +4 -3
- package/dist/compat/array/includes.js +8 -3
- package/dist/compat/array/includes.mjs +8 -3
- package/dist/compat/array/intersectionBy.js +12 -5
- package/dist/compat/array/intersectionBy.mjs +12 -5
- package/dist/compat/array/intersectionWith.js +2 -3
- package/dist/compat/array/intersectionWith.mjs +2 -3
- package/dist/compat/array/invokeMap.js +3 -7
- package/dist/compat/array/invokeMap.mjs +3 -4
- package/dist/compat/array/lastIndexOf.js +3 -2
- package/dist/compat/array/lastIndexOf.mjs +3 -2
- package/dist/compat/array/nth.js +2 -2
- package/dist/compat/array/nth.mjs +2 -2
- package/dist/compat/array/pullAllWith.js +2 -3
- package/dist/compat/array/pullAllWith.mjs +2 -3
- package/dist/compat/array/size.js +2 -0
- package/dist/compat/array/size.mjs +2 -0
- package/dist/compat/array/sortedIndexOf.js +2 -3
- package/dist/compat/array/sortedIndexOf.mjs +2 -3
- package/dist/compat/array/sortedLastIndexOf.js +2 -3
- package/dist/compat/array/sortedLastIndexOf.mjs +2 -3
- package/dist/compat/compat.d.mts +4 -3
- package/dist/compat/compat.d.ts +4 -3
- package/dist/compat/compat.js +10 -11
- package/dist/compat/compat.mjs +10 -11
- package/dist/compat/index.d.mts +4 -3
- package/dist/compat/index.d.ts +4 -3
- package/dist/compat/index.js +10 -9
- package/dist/compat/index.mjs +10 -9
- package/dist/compat/math/inRange.d.mts +5 -2
- package/dist/compat/math/inRange.d.ts +5 -2
- package/dist/compat/math/inRange.js +14 -11
- package/dist/compat/math/inRange.mjs +14 -11
- package/dist/compat/math/maxBy.d.mts +1 -1
- package/dist/compat/math/maxBy.d.ts +1 -1
- package/dist/compat/math/maxBy.js +18 -4
- package/dist/compat/math/maxBy.mjs +18 -4
- package/dist/compat/math/minBy.d.mts +1 -1
- package/dist/compat/math/minBy.d.ts +1 -1
- package/dist/compat/math/minBy.js +18 -4
- package/dist/compat/math/minBy.mjs +18 -4
- package/dist/compat/object/assign.js +2 -3
- package/dist/compat/object/assign.mjs +2 -3
- package/dist/compat/object/assignIn.js +2 -3
- package/dist/compat/object/assignIn.mjs +2 -3
- package/dist/compat/object/assignInWith.js +2 -3
- package/dist/compat/object/assignInWith.mjs +2 -3
- package/dist/compat/object/assignWith.js +2 -3
- package/dist/compat/object/assignWith.mjs +2 -3
- package/dist/compat/object/create.js +1 -1
- package/dist/compat/object/create.mjs +1 -1
- package/dist/compat/object/defaults.js +2 -3
- package/dist/compat/object/defaults.mjs +2 -3
- package/dist/compat/object/has.js +1 -1
- package/dist/compat/object/has.mjs +1 -1
- package/dist/compat/object/hasIn.js +1 -1
- package/dist/compat/object/hasIn.mjs +1 -1
- package/dist/compat/object/unset.js +1 -1
- package/dist/compat/object/unset.mjs +1 -1
- package/dist/compat/object/values.js +5 -1
- package/dist/compat/object/values.mjs +5 -1
- package/dist/compat/predicate/isMatchWith.js +4 -5
- package/dist/compat/predicate/isMatchWith.mjs +4 -5
- package/dist/compat/string/camelCase.js +6 -2
- package/dist/compat/string/camelCase.mjs +6 -2
- package/dist/compat/string/kebabCase.js +2 -2
- package/dist/compat/string/kebabCase.mjs +2 -2
- package/dist/compat/string/lowerCase.js +2 -2
- package/dist/compat/string/lowerCase.mjs +2 -2
- package/dist/compat/string/pad.js +10 -3
- package/dist/compat/string/pad.mjs +10 -3
- package/dist/compat/string/padEnd.js +7 -1
- package/dist/compat/string/padEnd.mjs +7 -1
- package/dist/compat/string/padStart.js +7 -1
- package/dist/compat/string/padStart.mjs +7 -1
- package/dist/compat/string/snakeCase.js +2 -2
- package/dist/compat/string/snakeCase.mjs +2 -2
- package/dist/compat/string/startCase.js +1 -1
- package/dist/compat/string/startCase.mjs +1 -1
- package/dist/compat/string/template.d.mts +1 -1
- package/dist/compat/string/template.d.ts +1 -1
- package/dist/compat/string/templateSettings.d.mts +18 -1
- package/dist/compat/string/templateSettings.d.ts +18 -1
- package/dist/compat/string/templateSettings.js +4 -1
- package/dist/compat/string/templateSettings.mjs +5 -1
- package/dist/compat/string/truncate.js +2 -9
- package/dist/compat/string/truncate.mjs +1 -8
- package/dist/compat/string/upperCase.js +2 -2
- package/dist/compat/string/upperCase.mjs +2 -2
- package/dist/compat/util/eq.d.mts +17 -1
- package/dist/compat/util/eq.d.ts +17 -1
- package/dist/compat/util/eq.js +19 -1
- package/dist/compat/util/eq.mjs +19 -1
- package/dist/compat/util/toArray.js +2 -1
- package/dist/compat/util/toArray.mjs +2 -1
- package/dist/fp/flow.d.mts +213 -0
- package/dist/fp/flow.d.ts +213 -0
- package/dist/fp/flow.js +50 -0
- package/dist/fp/flow.mjs +50 -0
- package/dist/fp/index.d.mts +2 -1
- package/dist/fp/index.d.ts +2 -1
- package/dist/fp/index.js +3 -1
- package/dist/fp/index.mjs +3 -2
- package/dist/fp/pipe.js +8 -12
- package/dist/fp/pipe.mjs +8 -12
- package/dist/map/hasValue.js +2 -2
- package/dist/map/hasValue.mjs +2 -2
- package/dist/predicate/isEqualWith.js +2 -3
- package/dist/predicate/isEqualWith.mjs +2 -3
- package/dist/string/deburr.js +1 -1
- package/dist/string/deburr.mjs +1 -1
- package/dist/types/DeepPartial.d.mts +21 -0
- package/dist/types/DeepPartial.d.ts +21 -0
- package/dist/types/DeepReadonly.d.mts +22 -0
- package/dist/types/DeepReadonly.d.ts +22 -0
- package/dist/types/NonEmptyArray.d.mts +14 -0
- package/dist/types/NonEmptyArray.d.ts +14 -0
- package/dist/types/Simplify.d.mts +18 -0
- package/dist/types/Simplify.d.ts +18 -0
- package/dist/types/ValueOf.d.mts +14 -0
- package/dist/types/ValueOf.d.ts +14 -0
- package/dist/types/Writable.d.mts +15 -0
- package/dist/types/Writable.d.ts +15 -0
- package/dist/types/index.d.mts +7 -0
- package/dist/types/index.d.ts +7 -0
- package/package.json +23 -7
- package/types.d.ts +1 -0
- package/dist/_internal/isEqualsSameValueZero.d.mts +0 -17
- package/dist/_internal/isEqualsSameValueZero.d.ts +0 -17
- package/dist/_internal/isEqualsSameValueZero.js +0 -19
- package/dist/_internal/isEqualsSameValueZero.mjs +0 -19
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
require("../util/eq.js");
|
|
1
|
+
const require_eq = require("../util/eq.js");
|
|
3
2
|
const require_keys = require("./keys.js");
|
|
4
3
|
//#region src/compat/object/assignWith.ts
|
|
5
4
|
/**
|
|
@@ -41,7 +40,7 @@ function assignWithImpl(object, source, getValueToAssign) {
|
|
|
41
40
|
const objValue = object[key];
|
|
42
41
|
const srcValue = source[key];
|
|
43
42
|
const newValue = getValueToAssign?.(objValue, srcValue, key, object, source) ?? srcValue;
|
|
44
|
-
if (!(key in object) || !
|
|
43
|
+
if (!(key in object) || !require_eq.eq(objValue, newValue)) object[key] = newValue;
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
//#endregion
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../util/eq.mjs";
|
|
1
|
+
import { eq } from "../util/eq.mjs";
|
|
3
2
|
import { keys } from "./keys.mjs";
|
|
4
3
|
//#region src/compat/object/assignWith.ts
|
|
5
4
|
/**
|
|
@@ -41,7 +40,7 @@ function assignWithImpl(object, source, getValueToAssign) {
|
|
|
41
40
|
const objValue = object[key];
|
|
42
41
|
const srcValue = source[key];
|
|
43
42
|
const newValue = getValueToAssign?.(objValue, srcValue, key, object, source) ?? srcValue;
|
|
44
|
-
if (!(key in object) || !
|
|
43
|
+
if (!(key in object) || !eq(objValue, newValue)) object[key] = newValue;
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_isObject = require("../predicate/isObject.js");
|
|
2
|
-
const require_assignValue = require("../_internal/assignValue.js");
|
|
3
2
|
const require_keys = require("./keys.js");
|
|
3
|
+
const require_assignValue = require("../_internal/assignValue.js");
|
|
4
4
|
//#region src/compat/object/create.ts
|
|
5
5
|
/**
|
|
6
6
|
* Creates an object that inherits from the prototype object.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isObject } from "../predicate/isObject.mjs";
|
|
2
|
-
import { assignValue } from "../_internal/assignValue.mjs";
|
|
3
2
|
import { keys } from "./keys.mjs";
|
|
3
|
+
import { assignValue } from "../_internal/assignValue.mjs";
|
|
4
4
|
//#region src/compat/object/create.ts
|
|
5
5
|
/**
|
|
6
6
|
* Creates an object that inherits from the prototype object.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
require("../util/eq.js");
|
|
1
|
+
const require_eq = require("../util/eq.js");
|
|
3
2
|
const require_isNil = require("../../predicate/isNil.js");
|
|
4
3
|
const require_isIterateeCall = require("../_internal/isIterateeCall.js");
|
|
5
4
|
//#region src/compat/object/defaults.ts
|
|
@@ -38,7 +37,7 @@ function defaults(object, ...sources) {
|
|
|
38
37
|
for (let j = 0; j < keys.length; j++) {
|
|
39
38
|
const key = keys[j];
|
|
40
39
|
const value = object[key];
|
|
41
|
-
if (value === void 0 || !Object.hasOwn(object, key) &&
|
|
40
|
+
if (value === void 0 || !Object.hasOwn(object, key) && require_eq.eq(value, objectProto[key])) object[key] = source[key];
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
return object;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../util/eq.mjs";
|
|
1
|
+
import { eq } from "../util/eq.mjs";
|
|
3
2
|
import { isNil } from "../../predicate/isNil.mjs";
|
|
4
3
|
import { isIterateeCall } from "../_internal/isIterateeCall.mjs";
|
|
5
4
|
//#region src/compat/object/defaults.ts
|
|
@@ -38,7 +37,7 @@ function defaults(object, ...sources) {
|
|
|
38
37
|
for (let j = 0; j < keys.length; j++) {
|
|
39
38
|
const key = keys[j];
|
|
40
39
|
const value = object[key];
|
|
41
|
-
if (value === void 0 || !Object.hasOwn(object, key) &&
|
|
40
|
+
if (value === void 0 || !Object.hasOwn(object, key) && eq(value, objectProto[key])) object[key] = source[key];
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
return object;
|
|
@@ -35,7 +35,7 @@ const require_isArguments = require("../predicate/isArguments.js");
|
|
|
35
35
|
function has(object, path) {
|
|
36
36
|
let resolvedPath;
|
|
37
37
|
if (Array.isArray(path)) resolvedPath = path;
|
|
38
|
-
else if (typeof path === "string" && require_isDeepKey.isDeepKey(path) &&
|
|
38
|
+
else if (typeof path === "string" && require_isDeepKey.isDeepKey(path) && !(path in Object(object))) resolvedPath = require_toPath.toPath(path);
|
|
39
39
|
else resolvedPath = [path];
|
|
40
40
|
if (resolvedPath.length === 0) return false;
|
|
41
41
|
let current = object;
|
|
@@ -35,7 +35,7 @@ import { isArguments } from "../predicate/isArguments.mjs";
|
|
|
35
35
|
function has(object, path) {
|
|
36
36
|
let resolvedPath;
|
|
37
37
|
if (Array.isArray(path)) resolvedPath = path;
|
|
38
|
-
else if (typeof path === "string" && isDeepKey(path) &&
|
|
38
|
+
else if (typeof path === "string" && isDeepKey(path) && !(path in Object(object))) resolvedPath = toPath(path);
|
|
39
39
|
else resolvedPath = [path];
|
|
40
40
|
if (resolvedPath.length === 0) return false;
|
|
41
41
|
let current = object;
|
|
@@ -45,7 +45,7 @@ function hasIn(object, path) {
|
|
|
45
45
|
if (object == null) return false;
|
|
46
46
|
let resolvedPath;
|
|
47
47
|
if (Array.isArray(path)) resolvedPath = path;
|
|
48
|
-
else if (typeof path === "string" && require_isDeepKey.isDeepKey(path) &&
|
|
48
|
+
else if (typeof path === "string" && require_isDeepKey.isDeepKey(path) && !(path in Object(object))) resolvedPath = require_toPath.toPath(path);
|
|
49
49
|
else resolvedPath = [path];
|
|
50
50
|
if (resolvedPath.length === 0) return false;
|
|
51
51
|
let current = object;
|
|
@@ -45,7 +45,7 @@ function hasIn(object, path) {
|
|
|
45
45
|
if (object == null) return false;
|
|
46
46
|
let resolvedPath;
|
|
47
47
|
if (Array.isArray(path)) resolvedPath = path;
|
|
48
|
-
else if (typeof path === "string" && isDeepKey(path) &&
|
|
48
|
+
else if (typeof path === "string" && isDeepKey(path) && !(path in Object(object))) resolvedPath = toPath(path);
|
|
49
49
|
else resolvedPath = [path];
|
|
50
50
|
if (resolvedPath.length === 0) return false;
|
|
51
51
|
let current = object;
|
|
@@ -40,7 +40,7 @@ function unset(obj, path) {
|
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
case "string":
|
|
43
|
-
if (obj?.[path] === void 0 && require_isDeepKey.isDeepKey(path)) return unsetWithPath(obj, require_toPath.toPath(path));
|
|
43
|
+
if (obj?.[path] === void 0 && require_isDeepKey.isDeepKey(path) && !Object.hasOwn(obj, path)) return unsetWithPath(obj, require_toPath.toPath(path));
|
|
44
44
|
if (require_isUnsafeProperty.isUnsafeProperty(path)) return false;
|
|
45
45
|
try {
|
|
46
46
|
delete obj[path];
|
|
@@ -40,7 +40,7 @@ function unset(obj, path) {
|
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
case "string":
|
|
43
|
-
if (obj?.[path] === void 0 && isDeepKey(path)) return unsetWithPath(obj, toPath(path));
|
|
43
|
+
if (obj?.[path] === void 0 && isDeepKey(path) && !Object.hasOwn(obj, path)) return unsetWithPath(obj, toPath(path));
|
|
44
44
|
if (isUnsafeProperty(path)) return false;
|
|
45
45
|
try {
|
|
46
46
|
delete obj[path];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_keys = require("./keys.js");
|
|
1
2
|
//#region src/compat/object/values.ts
|
|
2
3
|
/**
|
|
3
4
|
* Creates an array of the own enumerable property values of `object`.
|
|
@@ -10,7 +11,10 @@
|
|
|
10
11
|
*/
|
|
11
12
|
function values(object) {
|
|
12
13
|
if (object == null) return [];
|
|
13
|
-
|
|
14
|
+
const objectKeys = require_keys.keys(object);
|
|
15
|
+
const result = new Array(objectKeys.length);
|
|
16
|
+
for (let i = 0; i < objectKeys.length; i++) result[i] = object[objectKeys[i]];
|
|
17
|
+
return result;
|
|
14
18
|
}
|
|
15
19
|
//#endregion
|
|
16
20
|
exports.values = values;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { keys } from "./keys.mjs";
|
|
1
2
|
//#region src/compat/object/values.ts
|
|
2
3
|
/**
|
|
3
4
|
* Creates an array of the own enumerable property values of `object`.
|
|
@@ -10,7 +11,10 @@
|
|
|
10
11
|
*/
|
|
11
12
|
function values(object) {
|
|
12
13
|
if (object == null) return [];
|
|
13
|
-
|
|
14
|
+
const objectKeys = keys(object);
|
|
15
|
+
const result = new Array(objectKeys.length);
|
|
16
|
+
for (let i = 0; i < objectKeys.length; i++) result[i] = object[objectKeys[i]];
|
|
17
|
+
return result;
|
|
14
18
|
}
|
|
15
19
|
//#endregion
|
|
16
20
|
export { values };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_isPrimitive = require("../../predicate/isPrimitive.js");
|
|
2
|
-
const
|
|
3
|
-
require("../util/eq.js");
|
|
2
|
+
const require_eq = require("../util/eq.js");
|
|
4
3
|
const require_isObject = require("./isObject.js");
|
|
5
4
|
//#region src/compat/predicate/isMatchWith.ts
|
|
6
5
|
/**
|
|
@@ -86,14 +85,14 @@ function isMatchWithInternal(target, source, compare, stack, isRoot = false) {
|
|
|
86
85
|
case "object": return isObjectMatch(target, source, compare, stack);
|
|
87
86
|
case "function":
|
|
88
87
|
if (Object.keys(source).length > 0) return isMatchWithInternal(target, { ...source }, compare, stack, isRoot);
|
|
89
|
-
return
|
|
88
|
+
return require_eq.eq(target, source);
|
|
90
89
|
default:
|
|
91
|
-
if (!require_isObject.isObject(target)) return
|
|
90
|
+
if (!require_isObject.isObject(target)) return require_eq.eq(target, source);
|
|
92
91
|
if (isRoot) {
|
|
93
92
|
if (typeof source === "string") return source === "";
|
|
94
93
|
return true;
|
|
95
94
|
}
|
|
96
|
-
return
|
|
95
|
+
return require_eq.eq(target, source);
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
function isObjectMatch(target, source, compare, stack) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isPrimitive } from "../../predicate/isPrimitive.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import "../util/eq.mjs";
|
|
2
|
+
import { eq } from "../util/eq.mjs";
|
|
4
3
|
import { isObject } from "./isObject.mjs";
|
|
5
4
|
//#region src/compat/predicate/isMatchWith.ts
|
|
6
5
|
/**
|
|
@@ -86,14 +85,14 @@ function isMatchWithInternal(target, source, compare, stack, isRoot = false) {
|
|
|
86
85
|
case "object": return isObjectMatch(target, source, compare, stack);
|
|
87
86
|
case "function":
|
|
88
87
|
if (Object.keys(source).length > 0) return isMatchWithInternal(target, { ...source }, compare, stack, isRoot);
|
|
89
|
-
return
|
|
88
|
+
return eq(target, source);
|
|
90
89
|
default:
|
|
91
|
-
if (!isObject(target)) return
|
|
90
|
+
if (!isObject(target)) return eq(target, source);
|
|
92
91
|
if (isRoot) {
|
|
93
92
|
if (typeof source === "string") return source === "";
|
|
94
93
|
return true;
|
|
95
94
|
}
|
|
96
|
-
return
|
|
95
|
+
return eq(target, source);
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
function isObjectMatch(target, source, compare, stack) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_capitalize = require("../../string/capitalize.js");
|
|
2
2
|
const require_deburr = require("./deburr.js");
|
|
3
|
+
const require_words = require("./words.js");
|
|
3
4
|
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
4
5
|
//#region src/compat/string/camelCase.ts
|
|
5
6
|
/**
|
|
@@ -18,7 +19,10 @@ const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
|
18
19
|
* const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'
|
|
19
20
|
*/
|
|
20
21
|
function camelCase(str) {
|
|
21
|
-
|
|
22
|
+
const splitWords = require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str)));
|
|
23
|
+
if (splitWords.length === 0) return "";
|
|
24
|
+
const [first, ...rest] = splitWords;
|
|
25
|
+
return `${first.toLowerCase()}${rest.map((word) => require_capitalize.capitalize(word)).join("")}`;
|
|
22
26
|
}
|
|
23
27
|
//#endregion
|
|
24
28
|
exports.camelCase = camelCase;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { capitalize } from "../../string/capitalize.mjs";
|
|
2
2
|
import { deburr } from "./deburr.mjs";
|
|
3
|
+
import { words } from "./words.mjs";
|
|
3
4
|
import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
|
|
4
5
|
//#region src/compat/string/camelCase.ts
|
|
5
6
|
/**
|
|
@@ -18,7 +19,10 @@ import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
|
|
|
18
19
|
* const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'
|
|
19
20
|
*/
|
|
20
21
|
function camelCase(str) {
|
|
21
|
-
|
|
22
|
+
const splitWords = words(normalizeForCase(deburr(str)));
|
|
23
|
+
if (splitWords.length === 0) return "";
|
|
24
|
+
const [first, ...rest] = splitWords;
|
|
25
|
+
return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join("")}`;
|
|
22
26
|
}
|
|
23
27
|
//#endregion
|
|
24
28
|
export { camelCase };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_kebabCase = require("../../string/kebabCase.js");
|
|
2
1
|
const require_deburr = require("./deburr.js");
|
|
2
|
+
const require_words = require("./words.js");
|
|
3
3
|
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
4
4
|
//#region src/compat/string/kebabCase.ts
|
|
5
5
|
/**
|
|
@@ -17,7 +17,7 @@ const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
|
17
17
|
* const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'
|
|
18
18
|
*/
|
|
19
19
|
function kebabCase(str) {
|
|
20
|
-
return
|
|
20
|
+
return require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str))).map((word) => word.toLowerCase()).join("-");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
exports.kebabCase = kebabCase;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { kebabCase as kebabCase$1 } from "../../string/kebabCase.mjs";
|
|
2
1
|
import { deburr } from "./deburr.mjs";
|
|
2
|
+
import { words } from "./words.mjs";
|
|
3
3
|
import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
|
|
4
4
|
//#region src/compat/string/kebabCase.ts
|
|
5
5
|
/**
|
|
@@ -17,7 +17,7 @@ import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
|
|
|
17
17
|
* const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'
|
|
18
18
|
*/
|
|
19
19
|
function kebabCase(str) {
|
|
20
|
-
return
|
|
20
|
+
return words(normalizeForCase(deburr(str))).map((word) => word.toLowerCase()).join("-");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { kebabCase };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_lowerCase = require("../../string/lowerCase.js");
|
|
2
1
|
const require_deburr = require("./deburr.js");
|
|
2
|
+
const require_words = require("./words.js");
|
|
3
3
|
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
4
4
|
//#region src/compat/string/lowerCase.ts
|
|
5
5
|
/**
|
|
@@ -17,7 +17,7 @@ const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
|
17
17
|
* const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'
|
|
18
18
|
*/
|
|
19
19
|
function lowerCase(str) {
|
|
20
|
-
return
|
|
20
|
+
return require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str))).map((word) => word.toLowerCase()).join(" ");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
exports.lowerCase = lowerCase;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { lowerCase as lowerCase$1 } from "../../string/lowerCase.mjs";
|
|
2
1
|
import { deburr } from "./deburr.mjs";
|
|
2
|
+
import { words } from "./words.mjs";
|
|
3
3
|
import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
|
|
4
4
|
//#region src/compat/string/lowerCase.ts
|
|
5
5
|
/**
|
|
@@ -17,7 +17,7 @@ import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
|
|
|
17
17
|
* const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'
|
|
18
18
|
*/
|
|
19
19
|
function lowerCase(str) {
|
|
20
|
-
return
|
|
20
|
+
return words(normalizeForCase(deburr(str))).map((word) => word.toLowerCase()).join(" ");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { lowerCase };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const require_pad = require("../../string/pad.js");
|
|
2
1
|
const require_toString = require("../util/toString.js");
|
|
2
|
+
const require_toInteger = require("../util/toInteger.js");
|
|
3
|
+
const require_createPadding = require("../_internal/createPadding.js");
|
|
3
4
|
//#region src/compat/string/pad.ts
|
|
4
5
|
/**
|
|
5
6
|
* Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
|
|
@@ -17,8 +18,14 @@ const require_toString = require("../util/toString.js");
|
|
|
17
18
|
* const result4 = pad('abc', 2); // result will be 'abc'
|
|
18
19
|
*
|
|
19
20
|
*/
|
|
20
|
-
function pad(str, length, chars) {
|
|
21
|
-
|
|
21
|
+
function pad(str, length = 0, chars = " ") {
|
|
22
|
+
const value = require_toString.toString(str);
|
|
23
|
+
const targetLength = require_toInteger.toInteger(length);
|
|
24
|
+
const strLength = require_createPadding.stringSize(value);
|
|
25
|
+
if (targetLength <= strLength) return value;
|
|
26
|
+
const mid = (targetLength - strLength) / 2;
|
|
27
|
+
const padChars = `${chars}`;
|
|
28
|
+
return require_createPadding.createPadding(Math.floor(mid), padChars) + value + require_createPadding.createPadding(Math.ceil(mid), padChars);
|
|
22
29
|
}
|
|
23
30
|
//#endregion
|
|
24
31
|
exports.pad = pad;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { pad as pad$1 } from "../../string/pad.mjs";
|
|
2
1
|
import { toString } from "../util/toString.mjs";
|
|
2
|
+
import { toInteger } from "../util/toInteger.mjs";
|
|
3
|
+
import { createPadding, stringSize } from "../_internal/createPadding.mjs";
|
|
3
4
|
//#region src/compat/string/pad.ts
|
|
4
5
|
/**
|
|
5
6
|
* Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
|
|
@@ -17,8 +18,14 @@ import { toString } from "../util/toString.mjs";
|
|
|
17
18
|
* const result4 = pad('abc', 2); // result will be 'abc'
|
|
18
19
|
*
|
|
19
20
|
*/
|
|
20
|
-
function pad(str, length, chars) {
|
|
21
|
-
|
|
21
|
+
function pad(str, length = 0, chars = " ") {
|
|
22
|
+
const value = toString(str);
|
|
23
|
+
const targetLength = toInteger(length);
|
|
24
|
+
const strLength = stringSize(value);
|
|
25
|
+
if (targetLength <= strLength) return value;
|
|
26
|
+
const mid = (targetLength - strLength) / 2;
|
|
27
|
+
const padChars = `${chars}`;
|
|
28
|
+
return createPadding(Math.floor(mid), padChars) + value + createPadding(Math.ceil(mid), padChars);
|
|
22
29
|
}
|
|
23
30
|
//#endregion
|
|
24
31
|
export { pad };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const require_toString = require("../util/toString.js");
|
|
2
|
+
const require_toInteger = require("../util/toInteger.js");
|
|
3
|
+
const require_createPadding = require("../_internal/createPadding.js");
|
|
2
4
|
//#region src/compat/string/padEnd.ts
|
|
3
5
|
/**
|
|
4
6
|
* Pads the end of a string with a given character until it reaches the specified length.
|
|
@@ -18,7 +20,11 @@ const require_toString = require("../util/toString.js");
|
|
|
18
20
|
* const result4 = padEnd('abc', 2); // result will be 'abc'
|
|
19
21
|
*/
|
|
20
22
|
function padEnd(str, length = 0, chars = " ") {
|
|
21
|
-
|
|
23
|
+
const value = require_toString.toString(str);
|
|
24
|
+
const targetLength = require_toInteger.toInteger(length);
|
|
25
|
+
const strLength = require_createPadding.stringSize(value);
|
|
26
|
+
if (targetLength <= strLength) return value;
|
|
27
|
+
return value + require_createPadding.createPadding(targetLength - strLength, `${chars}`);
|
|
22
28
|
}
|
|
23
29
|
//#endregion
|
|
24
30
|
exports.padEnd = padEnd;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { toString } from "../util/toString.mjs";
|
|
2
|
+
import { toInteger } from "../util/toInteger.mjs";
|
|
3
|
+
import { createPadding, stringSize } from "../_internal/createPadding.mjs";
|
|
2
4
|
//#region src/compat/string/padEnd.ts
|
|
3
5
|
/**
|
|
4
6
|
* Pads the end of a string with a given character until it reaches the specified length.
|
|
@@ -18,7 +20,11 @@ import { toString } from "../util/toString.mjs";
|
|
|
18
20
|
* const result4 = padEnd('abc', 2); // result will be 'abc'
|
|
19
21
|
*/
|
|
20
22
|
function padEnd(str, length = 0, chars = " ") {
|
|
21
|
-
|
|
23
|
+
const value = toString(str);
|
|
24
|
+
const targetLength = toInteger(length);
|
|
25
|
+
const strLength = stringSize(value);
|
|
26
|
+
if (targetLength <= strLength) return value;
|
|
27
|
+
return value + createPadding(targetLength - strLength, `${chars}`);
|
|
22
28
|
}
|
|
23
29
|
//#endregion
|
|
24
30
|
export { padEnd };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const require_toString = require("../util/toString.js");
|
|
2
|
+
const require_toInteger = require("../util/toInteger.js");
|
|
3
|
+
const require_createPadding = require("../_internal/createPadding.js");
|
|
2
4
|
//#region src/compat/string/padStart.ts
|
|
3
5
|
/**
|
|
4
6
|
* Pads the start of a string with a given character until it reaches the specified length.
|
|
@@ -18,7 +20,11 @@ const require_toString = require("../util/toString.js");
|
|
|
18
20
|
* const result4 = padStart('abc', 2); // result will be 'abc'
|
|
19
21
|
*/
|
|
20
22
|
function padStart(str, length = 0, chars = " ") {
|
|
21
|
-
|
|
23
|
+
const value = require_toString.toString(str);
|
|
24
|
+
const targetLength = require_toInteger.toInteger(length);
|
|
25
|
+
const strLength = require_createPadding.stringSize(value);
|
|
26
|
+
if (targetLength <= strLength) return value;
|
|
27
|
+
return require_createPadding.createPadding(targetLength - strLength, `${chars}`) + value;
|
|
22
28
|
}
|
|
23
29
|
//#endregion
|
|
24
30
|
exports.padStart = padStart;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { toString } from "../util/toString.mjs";
|
|
2
|
+
import { toInteger } from "../util/toInteger.mjs";
|
|
3
|
+
import { createPadding, stringSize } from "../_internal/createPadding.mjs";
|
|
2
4
|
//#region src/compat/string/padStart.ts
|
|
3
5
|
/**
|
|
4
6
|
* Pads the start of a string with a given character until it reaches the specified length.
|
|
@@ -18,7 +20,11 @@ import { toString } from "../util/toString.mjs";
|
|
|
18
20
|
* const result4 = padStart('abc', 2); // result will be 'abc'
|
|
19
21
|
*/
|
|
20
22
|
function padStart(str, length = 0, chars = " ") {
|
|
21
|
-
|
|
23
|
+
const value = toString(str);
|
|
24
|
+
const targetLength = toInteger(length);
|
|
25
|
+
const strLength = stringSize(value);
|
|
26
|
+
if (targetLength <= strLength) return value;
|
|
27
|
+
return createPadding(targetLength - strLength, `${chars}`) + value;
|
|
22
28
|
}
|
|
23
29
|
//#endregion
|
|
24
30
|
export { padStart };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_snakeCase = require("../../string/snakeCase.js");
|
|
2
1
|
const require_deburr = require("./deburr.js");
|
|
2
|
+
const require_words = require("./words.js");
|
|
3
3
|
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
4
4
|
//#region src/compat/string/snakeCase.ts
|
|
5
5
|
/**
|
|
@@ -17,7 +17,7 @@ const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
|
17
17
|
* const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'
|
|
18
18
|
*/
|
|
19
19
|
function snakeCase(str) {
|
|
20
|
-
return
|
|
20
|
+
return require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str))).map((word) => word.toLowerCase()).join("_");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
exports.snakeCase = snakeCase;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { snakeCase as snakeCase$1 } from "../../string/snakeCase.mjs";
|
|
2
1
|
import { deburr } from "./deburr.mjs";
|
|
2
|
+
import { words } from "./words.mjs";
|
|
3
3
|
import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
|
|
4
4
|
//#region src/compat/string/snakeCase.ts
|
|
5
5
|
/**
|
|
@@ -17,7 +17,7 @@ import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
|
|
|
17
17
|
* const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'
|
|
18
18
|
*/
|
|
19
19
|
function snakeCase(str) {
|
|
20
|
-
return
|
|
20
|
+
return words(normalizeForCase(deburr(str))).map((word) => word.toLowerCase()).join("_");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { snakeCase };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_words = require("../../string/words.js");
|
|
2
1
|
const require_deburr = require("./deburr.js");
|
|
2
|
+
const require_words = require("./words.js");
|
|
3
3
|
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
4
4
|
//#region src/compat/string/startCase.ts
|
|
5
5
|
/**
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { escape } from "./escape.mjs";
|
|
2
|
+
import { template } from "./template.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/compat/string/templateSettings.d.ts
|
|
5
|
+
declare const templateSettings: {
|
|
6
|
+
escape: RegExp;
|
|
7
|
+
evaluate: RegExp;
|
|
8
|
+
interpolate: RegExp;
|
|
9
|
+
variable: string;
|
|
10
|
+
imports: {
|
|
11
|
+
_: {
|
|
12
|
+
escape: typeof escape;
|
|
13
|
+
template: typeof template;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { templateSettings };
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { escape } from "./escape.js";
|
|
2
|
+
import { template } from "./template.js";
|
|
3
|
+
|
|
4
|
+
//#region src/compat/string/templateSettings.d.ts
|
|
5
|
+
declare const templateSettings: {
|
|
6
|
+
escape: RegExp;
|
|
7
|
+
evaluate: RegExp;
|
|
8
|
+
interpolate: RegExp;
|
|
9
|
+
variable: string;
|
|
10
|
+
imports: {
|
|
11
|
+
_: {
|
|
12
|
+
escape: typeof escape;
|
|
13
|
+
template: typeof template;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { templateSettings };
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
const require_isObject = require("../predicate/isObject.js");
|
|
2
|
+
const require_regexMultiByte = require("../_internal/regexMultiByte.js");
|
|
2
3
|
//#region src/compat/string/truncate.ts
|
|
3
4
|
/**
|
|
4
|
-
* Used to compose unicode character classes.
|
|
5
|
-
* @link https://github.com/lodash/lodash/blob/4.17.21-es/_hasUnicode.js
|
|
6
|
-
*
|
|
7
|
-
* Used to detect strings with zero-width joiners or code points from the astral planes.
|
|
8
|
-
* @link http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/
|
|
9
|
-
*/
|
|
10
|
-
const regexMultiByte = /[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/;
|
|
11
|
-
/**
|
|
12
5
|
* This regex might more completely detect unicode, but it is slower and this project
|
|
13
6
|
* desires to mimic the behavior of lodash.
|
|
14
7
|
*/
|
|
@@ -46,7 +39,7 @@ function truncate(string, options) {
|
|
|
46
39
|
const lengthOmission = Array.from(omission).length;
|
|
47
40
|
const lengthBase = Math.max(length - lengthOmission, 0);
|
|
48
41
|
let strArray = void 0;
|
|
49
|
-
if (regexMultiByte.test(string)) {
|
|
42
|
+
if (require_regexMultiByte.regexMultiByte.test(string)) {
|
|
50
43
|
strArray = Array.from(string);
|
|
51
44
|
i = strArray.length;
|
|
52
45
|
}
|