es-toolkit 1.23.0-dev.740 → 1.23.0-dev.741
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/_chunk/{flowRight-DFVdlB.js → flowRight-Cf9ldK.js} +48 -0
- package/dist/_chunk/{isJSONObject-CLSJHE.js → isWeakSet-CjpFwn.js} +26 -202
- package/dist/_chunk/noop-2IwLUk.js +5 -0
- package/dist/_chunk/{pad-Bgd7Ah.js → pad-BWiShN.js} +52 -7
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.js +218 -48
- package/dist/compat/index.mjs +21 -21
- package/dist/compat/predicate/isMap.mjs +0 -7
- package/dist/function/index.js +5 -5
- package/dist/index.js +27 -28
- package/dist/predicate/index.js +20 -20
- package/dist/predicate/isEqualWith.mjs +0 -7
- package/dist/string/index.js +2 -3
- package/package.json +4 -4
- package/dist/_chunk/deburr-BPmkoM.js +0 -47
- package/dist/_chunk/partialRight-CRhV1h.js +0 -53
|
@@ -116,6 +116,52 @@ function unary(func) {
|
|
|
116
116
|
return ary(func, 1);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
function partial(func, ...partialArgs) {
|
|
120
|
+
return function (...providedArgs) {
|
|
121
|
+
const args = [];
|
|
122
|
+
let startIndex = 0;
|
|
123
|
+
for (let i = 0; i < partialArgs.length; i++) {
|
|
124
|
+
const arg = partialArgs[i];
|
|
125
|
+
if (arg === partial.placeholder) {
|
|
126
|
+
args.push(providedArgs[startIndex++]);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
args.push(arg);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
133
|
+
args.push(providedArgs[i]);
|
|
134
|
+
}
|
|
135
|
+
return func.apply(this, args);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const partialPlaceholder = Symbol('partial.placeholder');
|
|
139
|
+
partial.placeholder = partialPlaceholder;
|
|
140
|
+
|
|
141
|
+
function partialRight(func, ...partialArgs) {
|
|
142
|
+
return function (...providedArgs) {
|
|
143
|
+
const placeholderLength = partialArgs.filter(arg => arg === partialRightPlaceholder).length;
|
|
144
|
+
const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
|
|
145
|
+
const args = [];
|
|
146
|
+
let providedIndex = 0;
|
|
147
|
+
for (let i = 0; i < rangeLength; i++) {
|
|
148
|
+
args.push(providedArgs[providedIndex++]);
|
|
149
|
+
}
|
|
150
|
+
for (let i = 0; i < partialArgs.length; i++) {
|
|
151
|
+
const arg = partialArgs[i];
|
|
152
|
+
if (arg === partialRight.placeholder) {
|
|
153
|
+
args.push(providedArgs[providedIndex++]);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
args.push(arg);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return func.apply(this, args);
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const partialRightPlaceholder = Symbol('partialRight.placeholder');
|
|
163
|
+
partialRight.placeholder = partialRightPlaceholder;
|
|
164
|
+
|
|
119
165
|
function rest(func, startIndex = func.length - 1) {
|
|
120
166
|
return function (...args) {
|
|
121
167
|
const rest = args.slice(startIndex);
|
|
@@ -149,5 +195,7 @@ exports.flowRight = flowRight;
|
|
|
149
195
|
exports.memoize = memoize;
|
|
150
196
|
exports.negate = negate;
|
|
151
197
|
exports.once = once;
|
|
198
|
+
exports.partial = partial;
|
|
199
|
+
exports.partialRight = partialRight;
|
|
152
200
|
exports.rest = rest;
|
|
153
201
|
exports.unary = unary;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const isPlainObject = require('./isPlainObject-DgrsU7.js');
|
|
4
|
-
const
|
|
5
|
-
require('./deburr-BPmkoM.js');
|
|
4
|
+
const noop = require('./noop-2IwLUk.js');
|
|
6
5
|
|
|
7
6
|
function isArrayBuffer(value) {
|
|
8
7
|
return value instanceof ArrayBuffer;
|
|
@@ -61,201 +60,6 @@ function eq(value, other) {
|
|
|
61
60
|
return value === other || (Number.isNaN(value) && Number.isNaN(other));
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
function isNil(x) {
|
|
65
|
-
return x == null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function bind(func, thisObj, ...partialArgs) {
|
|
69
|
-
const bound = function (...providedArgs) {
|
|
70
|
-
const args = [];
|
|
71
|
-
let startIndex = 0;
|
|
72
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
73
|
-
const arg = partialArgs[i];
|
|
74
|
-
if (arg === bind.placeholder) {
|
|
75
|
-
args.push(providedArgs[startIndex++]);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
args.push(arg);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
82
|
-
args.push(providedArgs[i]);
|
|
83
|
-
}
|
|
84
|
-
if (this instanceof bound) {
|
|
85
|
-
return new func(...args);
|
|
86
|
-
}
|
|
87
|
-
return func.apply(thisObj, args);
|
|
88
|
-
};
|
|
89
|
-
return bound;
|
|
90
|
-
}
|
|
91
|
-
const bindPlaceholder = Symbol('bind.placeholder');
|
|
92
|
-
bind.placeholder = bindPlaceholder;
|
|
93
|
-
|
|
94
|
-
function bindKey(object, key, ...partialArgs) {
|
|
95
|
-
const bound = function (...providedArgs) {
|
|
96
|
-
const args = [];
|
|
97
|
-
let startIndex = 0;
|
|
98
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
99
|
-
const arg = partialArgs[i];
|
|
100
|
-
if (arg === bindKey.placeholder) {
|
|
101
|
-
args.push(providedArgs[startIndex++]);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
args.push(arg);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
108
|
-
args.push(providedArgs[i]);
|
|
109
|
-
}
|
|
110
|
-
if (this instanceof bound) {
|
|
111
|
-
return new object[key](...args);
|
|
112
|
-
}
|
|
113
|
-
return object[key].apply(object, args);
|
|
114
|
-
};
|
|
115
|
-
return bound;
|
|
116
|
-
}
|
|
117
|
-
const bindKeyPlaceholder = Symbol('bindKey.placeholder');
|
|
118
|
-
bindKey.placeholder = bindKeyPlaceholder;
|
|
119
|
-
|
|
120
|
-
function curry(func, arity = func.length, guard) {
|
|
121
|
-
arity = guard ? func.length : arity;
|
|
122
|
-
arity = Number.parseInt(arity, 10);
|
|
123
|
-
if (Number.isNaN(arity) || arity < 1) {
|
|
124
|
-
arity = 0;
|
|
125
|
-
}
|
|
126
|
-
const wrapper = function (...partialArgs) {
|
|
127
|
-
const holders = partialArgs.filter(item => item === curry.placeholder);
|
|
128
|
-
const length = partialArgs.length - holders.length;
|
|
129
|
-
if (length < arity) {
|
|
130
|
-
return makeCurry(func, arity - length, partialArgs);
|
|
131
|
-
}
|
|
132
|
-
if (this instanceof wrapper) {
|
|
133
|
-
return new func(...partialArgs);
|
|
134
|
-
}
|
|
135
|
-
return func.apply(this, partialArgs);
|
|
136
|
-
};
|
|
137
|
-
wrapper.placeholder = curryPlaceholder;
|
|
138
|
-
return wrapper;
|
|
139
|
-
}
|
|
140
|
-
function makeCurry(func, arity, partialArgs) {
|
|
141
|
-
function wrapper(...providedArgs) {
|
|
142
|
-
const holders = providedArgs.filter(item => item === curry.placeholder);
|
|
143
|
-
const length = providedArgs.length - holders.length;
|
|
144
|
-
providedArgs = composeArgs$1(providedArgs, partialArgs);
|
|
145
|
-
if (length < arity) {
|
|
146
|
-
return makeCurry(func, arity - length, providedArgs);
|
|
147
|
-
}
|
|
148
|
-
if (this instanceof wrapper) {
|
|
149
|
-
return new func(...providedArgs);
|
|
150
|
-
}
|
|
151
|
-
return func.apply(this, providedArgs);
|
|
152
|
-
}
|
|
153
|
-
wrapper.placeholder = curryPlaceholder;
|
|
154
|
-
return wrapper;
|
|
155
|
-
}
|
|
156
|
-
function composeArgs$1(providedArgs, partialArgs) {
|
|
157
|
-
const args = [];
|
|
158
|
-
let startIndex = 0;
|
|
159
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
160
|
-
const arg = partialArgs[i];
|
|
161
|
-
if (arg === curry.placeholder && startIndex < providedArgs.length) {
|
|
162
|
-
args.push(providedArgs[startIndex++]);
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
args.push(arg);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
169
|
-
args.push(providedArgs[i]);
|
|
170
|
-
}
|
|
171
|
-
return args;
|
|
172
|
-
}
|
|
173
|
-
const curryPlaceholder = Symbol('curry.placeholder');
|
|
174
|
-
curry.placeholder = curryPlaceholder;
|
|
175
|
-
|
|
176
|
-
function curryRight(func, arity = func.length, guard) {
|
|
177
|
-
arity = guard ? func.length : arity;
|
|
178
|
-
arity = Number.parseInt(arity, 10);
|
|
179
|
-
if (Number.isNaN(arity) || arity < 1) {
|
|
180
|
-
arity = 0;
|
|
181
|
-
}
|
|
182
|
-
const wrapper = function (...partialArgs) {
|
|
183
|
-
const holders = partialArgs.filter(item => item === curryRight.placeholder);
|
|
184
|
-
const length = partialArgs.length - holders.length;
|
|
185
|
-
if (length < arity) {
|
|
186
|
-
return makeCurryRight(func, arity - length, partialArgs);
|
|
187
|
-
}
|
|
188
|
-
if (this instanceof wrapper) {
|
|
189
|
-
return new func(...partialArgs);
|
|
190
|
-
}
|
|
191
|
-
return func.apply(this, partialArgs);
|
|
192
|
-
};
|
|
193
|
-
wrapper.placeholder = curryRightPlaceholder;
|
|
194
|
-
return wrapper;
|
|
195
|
-
}
|
|
196
|
-
function makeCurryRight(func, arity, partialArgs) {
|
|
197
|
-
function wrapper(...providedArgs) {
|
|
198
|
-
const holders = providedArgs.filter(item => item === curryRight.placeholder);
|
|
199
|
-
const length = providedArgs.length - holders.length;
|
|
200
|
-
providedArgs = composeArgs(providedArgs, partialArgs);
|
|
201
|
-
if (length < arity) {
|
|
202
|
-
return makeCurryRight(func, arity - length, providedArgs);
|
|
203
|
-
}
|
|
204
|
-
if (this instanceof wrapper) {
|
|
205
|
-
return new func(...providedArgs);
|
|
206
|
-
}
|
|
207
|
-
return func.apply(this, providedArgs);
|
|
208
|
-
}
|
|
209
|
-
wrapper.placeholder = curryRightPlaceholder;
|
|
210
|
-
return wrapper;
|
|
211
|
-
}
|
|
212
|
-
function composeArgs(providedArgs, partialArgs) {
|
|
213
|
-
const placeholderLength = partialArgs.filter(arg => arg === curryRight.placeholder).length;
|
|
214
|
-
const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
|
|
215
|
-
const args = [];
|
|
216
|
-
let providedIndex = 0;
|
|
217
|
-
for (let i = 0; i < rangeLength; i++) {
|
|
218
|
-
args.push(providedArgs[providedIndex++]);
|
|
219
|
-
}
|
|
220
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
221
|
-
const arg = partialArgs[i];
|
|
222
|
-
if (arg === curryRight.placeholder) {
|
|
223
|
-
if (providedIndex < providedArgs.length) {
|
|
224
|
-
args.push(providedArgs[providedIndex++]);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
args.push(arg);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
args.push(arg);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return args;
|
|
235
|
-
}
|
|
236
|
-
const curryRightPlaceholder = Symbol('curryRight.placeholder');
|
|
237
|
-
curryRight.placeholder = curryRightPlaceholder;
|
|
238
|
-
|
|
239
|
-
function isLength(value) {
|
|
240
|
-
return Number.isSafeInteger(value) && value >= 0;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function isSet(value) {
|
|
244
|
-
return value instanceof Set;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function isRegExp(value) {
|
|
248
|
-
return value instanceof RegExp;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function isWeakMap(value) {
|
|
252
|
-
return value instanceof WeakMap;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function isWeakSet(value) {
|
|
256
|
-
return value instanceof WeakSet;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
63
|
function isEqualWith(a, b, areValuesEqual) {
|
|
260
64
|
return isEqualWithImpl(a, b, undefined, undefined, undefined, undefined, areValuesEqual);
|
|
261
65
|
}
|
|
@@ -435,13 +239,17 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
435
239
|
}
|
|
436
240
|
|
|
437
241
|
function isEqual(a, b) {
|
|
438
|
-
return isEqualWith(a, b,
|
|
242
|
+
return isEqualWith(a, b, noop.noop);
|
|
439
243
|
}
|
|
440
244
|
|
|
441
245
|
function isMap(value) {
|
|
442
246
|
return value instanceof Map;
|
|
443
247
|
}
|
|
444
248
|
|
|
249
|
+
function isNil(x) {
|
|
250
|
+
return x == null;
|
|
251
|
+
}
|
|
252
|
+
|
|
445
253
|
function isNotNil(x) {
|
|
446
254
|
return x != null;
|
|
447
255
|
}
|
|
@@ -454,10 +262,18 @@ function isUndefined(x) {
|
|
|
454
262
|
return x === undefined;
|
|
455
263
|
}
|
|
456
264
|
|
|
265
|
+
function isLength(value) {
|
|
266
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
267
|
+
}
|
|
268
|
+
|
|
457
269
|
function isFunction(value) {
|
|
458
270
|
return typeof value === 'function';
|
|
459
271
|
}
|
|
460
272
|
|
|
273
|
+
function isRegExp(value) {
|
|
274
|
+
return value instanceof RegExp;
|
|
275
|
+
}
|
|
276
|
+
|
|
461
277
|
function isJSONArray(value) {
|
|
462
278
|
if (!Array.isArray(value)) {
|
|
463
279
|
return false;
|
|
@@ -499,12 +315,20 @@ function isJSONObject(obj) {
|
|
|
499
315
|
return true;
|
|
500
316
|
}
|
|
501
317
|
|
|
318
|
+
function isSet(value) {
|
|
319
|
+
return value instanceof Set;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function isWeakMap(value) {
|
|
323
|
+
return value instanceof WeakMap;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function isWeakSet(value) {
|
|
327
|
+
return value instanceof WeakSet;
|
|
328
|
+
}
|
|
329
|
+
|
|
502
330
|
exports.argumentsTag = argumentsTag;
|
|
503
|
-
exports.bind = bind;
|
|
504
|
-
exports.bindKey = bindKey;
|
|
505
331
|
exports.booleanTag = booleanTag;
|
|
506
|
-
exports.curry = curry;
|
|
507
|
-
exports.curryRight = curryRight;
|
|
508
332
|
exports.eq = eq;
|
|
509
333
|
exports.getSymbols = getSymbols;
|
|
510
334
|
exports.getTag = getTag;
|
|
@@ -18,19 +18,14 @@ function camelCase(str) {
|
|
|
18
18
|
return `${first.toLowerCase()}${rest.map(word => capitalize(word)).join('')}`;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function kebabCase(str) {
|
|
22
|
-
const words = getWords(str);
|
|
23
|
-
return words.map(word => word.toLowerCase()).join('-');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
21
|
function snakeCase(str) {
|
|
27
22
|
const words = getWords(str);
|
|
28
23
|
return words.map(word => word.toLowerCase()).join('_');
|
|
29
24
|
}
|
|
30
25
|
|
|
31
|
-
function
|
|
26
|
+
function kebabCase(str) {
|
|
32
27
|
const words = getWords(str);
|
|
33
|
-
return words.map(word => word.toLowerCase()).join('
|
|
28
|
+
return words.map(word => word.toLowerCase()).join('-');
|
|
34
29
|
}
|
|
35
30
|
|
|
36
31
|
function upperCase(str) {
|
|
@@ -45,6 +40,11 @@ function upperCase(str) {
|
|
|
45
40
|
return result;
|
|
46
41
|
}
|
|
47
42
|
|
|
43
|
+
function lowerCase(str) {
|
|
44
|
+
const words = getWords(str);
|
|
45
|
+
return words.map(word => word.toLowerCase()).join(' ');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
48
|
function pascalCase(str) {
|
|
49
49
|
const words = getWords(str);
|
|
50
50
|
return words.map(word => capitalize(word)).join('');
|
|
@@ -112,6 +112,50 @@ function lowerFirst(str) {
|
|
|
112
112
|
return str.substring(0, 1).toLowerCase() + str.substring(1);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
const deburrMap = new Map(Object.entries({
|
|
116
|
+
Æ: 'Ae',
|
|
117
|
+
Ð: 'D',
|
|
118
|
+
Ø: 'O',
|
|
119
|
+
Þ: 'Th',
|
|
120
|
+
ß: 'ss',
|
|
121
|
+
æ: 'ae',
|
|
122
|
+
ð: 'd',
|
|
123
|
+
ø: 'o',
|
|
124
|
+
þ: 'th',
|
|
125
|
+
Đ: 'D',
|
|
126
|
+
đ: 'd',
|
|
127
|
+
Ħ: 'H',
|
|
128
|
+
ħ: 'h',
|
|
129
|
+
ı: 'i',
|
|
130
|
+
IJ: 'IJ',
|
|
131
|
+
ij: 'ij',
|
|
132
|
+
ĸ: 'k',
|
|
133
|
+
Ŀ: 'L',
|
|
134
|
+
ŀ: 'l',
|
|
135
|
+
Ł: 'L',
|
|
136
|
+
ł: 'l',
|
|
137
|
+
ʼn: "'n",
|
|
138
|
+
Ŋ: 'N',
|
|
139
|
+
ŋ: 'n',
|
|
140
|
+
Œ: 'Oe',
|
|
141
|
+
œ: 'oe',
|
|
142
|
+
Ŧ: 'T',
|
|
143
|
+
ŧ: 't',
|
|
144
|
+
ſ: 's',
|
|
145
|
+
}));
|
|
146
|
+
function deburr(str) {
|
|
147
|
+
str = str.normalize('NFD');
|
|
148
|
+
let result = '';
|
|
149
|
+
for (let i = 0; i < str.length; i++) {
|
|
150
|
+
const char = str[i];
|
|
151
|
+
if ((char >= '\u0300' && char <= '\u036f') || (char >= '\ufe20' && char <= '\ufe23')) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
result += deburrMap.get(char) ?? char;
|
|
155
|
+
}
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
|
|
115
159
|
const htmlEscapes = {
|
|
116
160
|
'&': '&',
|
|
117
161
|
'<': '<',
|
|
@@ -145,6 +189,7 @@ function pad(str, length, chars = ' ') {
|
|
|
145
189
|
exports.camelCase = camelCase;
|
|
146
190
|
exports.capitalize = capitalize;
|
|
147
191
|
exports.constantCase = constantCase;
|
|
192
|
+
exports.deburr = deburr;
|
|
148
193
|
exports.escape = escape;
|
|
149
194
|
exports.escapeRegExp = escapeRegExp;
|
|
150
195
|
exports.getWords = getWords;
|