feat: Add stub methods

This commit is contained in:
Sojin Park 2024-12-01 21:28:34 +09:00
parent 917aff0110
commit 537e8a42a8
71 changed files with 673 additions and 61 deletions

View File

@ -0,0 +1,25 @@
# stubArray
::: info
この関数は互換性のために `es-toolkit/compat` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。
`es-toolkit/compat` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。
:::
新しい空の配列を返します。
## インターフェース
```typescript
function stubArray(): [];
```
### 戻り値
(`Array`): 新しい空の配列。
## 例
```typescript
stubArray(); // Returns []
```

View File

@ -0,0 +1,25 @@
# stubFalse
::: info
この関数は互換性のために `es-toolkit/compat` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。
`es-toolkit/compat` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。
:::
`false`を返します。
## インターフェース
```typescript
function stubFalse(): false;
```
### 戻り値
(`false`): false。
## 例
```typescript
stubFalse(); // Returns false
```

View File

@ -0,0 +1,25 @@
# stubObject
::: info
この関数は互換性のために `es-toolkit/compat` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。
`es-toolkit/compat` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。
:::
空のオブジェクトを返します。
## インターフェース
```typescript
function stubObject(): {};
```
### 戻り値
(`Object`): 空のオブジェクト。
## 例
```typescript
stubObject(); // Returns {}
```

View File

@ -0,0 +1,25 @@
# stubString
::: info
この関数は互換性のために `es-toolkit/compat` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。
`es-toolkit/compat` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。
:::
空の文字列を返します。
## インターフェース
```typescript
function stubString(): '';
```
### 戻り値
(`string`): 空の文字列ます。
## 例
```typescript
stubString(); // Returns ''
```

View File

@ -0,0 +1,25 @@
# stubTrue
::: info
この関数は互換性のために `es-toolkit/compat` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。
`es-toolkit/compat` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。
:::
`true`を返します。
## インターフェース
```typescript
function stubTrue(): true;
```
### 戻り値
(`true`): `true`
## 例
```typescript
stubTrue(); // Returns true
```

View File

@ -0,0 +1,25 @@
# stubArray
::: info
이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요.
`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요.
:::
새로운 빈 배열을 반환해요.
## 인터페이스
```typescript
function stubArray(): [];
```
### 반환 값
(`[]`): 새로운 빈 배열.
## 예시
```typescript
stubArray(); // Returns []
```

View File

@ -0,0 +1,25 @@
# stubFalse
::: info
이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요.
`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요.
:::
`false`를 반환해요.
## 인터페이스
```typescript
function stubFalse(): false;
```
### 반환 값
(`false`): `false`.
## 예시
```typescript
stubFalse(); // Returns false
```

View File

@ -0,0 +1,25 @@
# stubObject
::: info
이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요.
`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요.
:::
빈 객체를 반환해요.
## 인터페이스
```typescript
function stubObject(): {};
```
### 반환 값
(`{}`): 빈 객체.
## 예시
```typescript
stubObject(); // Returns {}
```

View File

@ -0,0 +1,25 @@
# stubString
::: info
이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요.
`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요.
:::
빈 문자열을 반환해요.
## 인터페이스
```typescript
function stubString(): '';
```
### 반환 값
(`''`): 빈 문자열.
## 예시
```typescript
stubString(); // Returns ''
```

View File

@ -0,0 +1,25 @@
# stubTrue
::: info
이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요.
`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요.
:::
`true`를 반환해요.
## 인터페이스
```typescript
function stubTrue(): true;
```
### 반환 값
(`true`): `true`.
## 예시
```typescript
stubTrue(); // Returns true
```

View File

@ -0,0 +1,25 @@
# stubArray
::: info
This function is only available in `es-toolkit/compat` for compatibility reasons. It either has alternative native JavaScript APIs or isnt fully optimized yet.
When imported from `es-toolkit/compat`, it behaves exactly like lodash and provides the same functionalities, as detailed [here](../../../compatibility.md).
:::
Returns a new empty array.
## Signature
```typescript
function stubArray(): [];
```
### Returns
(`[]`): A new empty array.
## Examples
```typescript
stubArray(); // Returns []
```

View File

@ -0,0 +1,25 @@
# stubFalse
::: info
This function is only available in `es-toolkit/compat` for compatibility reasons. It either has alternative native JavaScript APIs or isnt fully optimized yet.
When imported from `es-toolkit/compat`, it behaves exactly like lodash and provides the same functionalities, as detailed [here](../../../compatibility.md).
:::
Returns false.
## Signature
```typescript
function stubFalse(): false;
```
### Returns
(`false`): false.
## Examples
```typescript
stubFalse(); // Returns false
```

View File

@ -0,0 +1,25 @@
# stubObject
::: info
This function is only available in `es-toolkit/compat` for compatibility reasons. It either has alternative native JavaScript APIs or isnt fully optimized yet.
When imported from `es-toolkit/compat`, it behaves exactly like lodash and provides the same functionalities, as detailed [here](../../../compatibility.md).
:::
Returns an empty object.
## Signature
```typescript
function stubObject(): {};
```
### Returns
(`{}`): An empty object.
## Examples
```typescript
stubObject(); // Returns {}
```

View File

@ -0,0 +1,25 @@
# stubString
::: info
This function is only available in `es-toolkit/compat` for compatibility reasons. It either has alternative native JavaScript APIs or isnt fully optimized yet.
When imported from `es-toolkit/compat`, it behaves exactly like lodash and provides the same functionalities, as detailed [here](../../../compatibility.md).
:::
Returns an empty string.
## Signature
```typescript
function stubString(): '';
```
### Returns
(`''`): An empty string.
## Examples
```typescript
stubString(); // Returns ''
```

View File

@ -0,0 +1,25 @@
# stubTrue
::: info
This function is only available in `es-toolkit/compat` for compatibility reasons. It either has alternative native JavaScript APIs or isnt fully optimized yet.
When imported from `es-toolkit/compat`, it behaves exactly like lodash and provides the same functionalities, as detailed [here](../../../compatibility.md).
:::
Returns true.
## Signature
```typescript
function stubTrue(): true;
```
### Returns
(`true`): true.
## Examples
```typescript
stubTrue(); // Returns true
```

View File

@ -0,0 +1,25 @@
# stubArray
::: info
出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API或者尚未完全优化。
`es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。
:::
返回一个新的空数组。
## 签名
```typescript
function stubArray(): [];
```
### 返回值
(`[]`): 一个新的空数组。
## 示例
```typescript
stubArray(); // Returns []
```

View File

@ -0,0 +1,25 @@
# stubFalse
::: info
出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API或者尚未完全优化。
`es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。
:::
返回 `false`
## 签名
```typescript
function stubFalse(): false;
```
### 返回值
(`false`): `false`
## 示例
```typescript
stubFalse(); // Returns false
```

View File

@ -0,0 +1,25 @@
# stubObject
::: info
出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API或者尚未完全优化。
`es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。
:::
返回一个空对象。
## 签名
```typescript
function stubObject(): {};
```
### 返回值
(`{}`): 一个空对象。
## 示例
```typescript
stubObject(); // Returns {}
```

View File

@ -0,0 +1,25 @@
# stubString
::: info
出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API或者尚未完全优化。
`es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。
:::
返回空字符串。
## 签名
```typescript
function stubString(): '';
```
### 返回值
(`''`): 空字符串。
## 示例
```typescript
stubString(); // Returns ''
```

View File

@ -0,0 +1,25 @@
# stubTrue
::: info
出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API或者尚未完全优化。
`es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。
:::
返回 `true`
## 签名
```typescript
function stubTrue(): true;
```
### 返回值
(`true`): true。
## 示例
```typescript
stubTrue(); // Returns true
```

View File

@ -1,3 +0,0 @@
export function stubArray() {
return [];
}

View File

@ -1,3 +0,0 @@
export const stubFalse = function () {
return false;
};

View File

@ -1,3 +0,0 @@
export function stubString(): string {
return '';
}

View File

@ -1,3 +0,0 @@
export const stubTrue = function () {
return true;
};

View File

@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest';
import { forEach as each } from './forEach'; import { forEach as each } from './forEach';
import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER'; import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../util/stubTrue';
describe('each', () => { describe('each', () => {
it('should iterate over array elements', () => { it('should iterate over array elements', () => {

View File

@ -3,8 +3,8 @@ import { every } from './every';
import { identity } from '../../function/identity'; import { identity } from '../../function/identity';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { empties } from '../_internal/empties'; import { empties } from '../_internal/empties';
import { stubFalse } from '../_internal/stubFalse'; import { stubFalse } from '../util/stubFalse';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../util/stubTrue';
describe('every', () => { describe('every', () => {
it('should return true for array with all elements passing predicate', () => { it('should return true for array with all elements passing predicate', () => {

View File

@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest';
import { forEach } from './forEach'; import { forEach } from './forEach';
import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER'; import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../util/stubTrue';
describe('forEach', () => { describe('forEach', () => {
it('should iterate over array elements', () => { it('should iterate over array elements', () => {

View File

@ -3,8 +3,8 @@ import { includes } from './includes';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { empties } from '../_internal/empties'; import { empties } from '../_internal/empties';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { stubFalse } from '../_internal/stubFalse';
import { toArgs } from '../_internal/toArgs'; import { toArgs } from '../_internal/toArgs';
import { stubFalse } from '../util/stubFalse';
describe('includes', () => { describe('includes', () => {
it('should ignore inherited value', () => { it('should ignore inherited value', () => {

View File

@ -3,8 +3,8 @@ import { some } from './some';
import { identity } from '../../function/identity'; import { identity } from '../../function/identity';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { empties } from '../_internal/empties'; import { empties } from '../_internal/empties';
import { stubFalse } from '../_internal/stubFalse'; import { stubFalse } from '../util/stubFalse';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../util/stubTrue';
describe('some', () => { describe('some', () => {
it('should return `true` if `predicate` returns truthy for any element', () => { it('should return `true` if `predicate` returns truthy for any element', () => {

View File

@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
import { zip } from './zip'; import { zip } from './zip';
import { unzip } from '../../array/unzip'; import { unzip } from '../../array/unzip';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { stubArray } from '../_internal/stubArray'; import { stubArray } from '../util/stubArray';
describe('zip', () => { describe('zip', () => {
const object = { const object = {

View File

@ -185,6 +185,11 @@ export { eq } from './util/eq.ts';
export { gt } from './util/gt.ts'; export { gt } from './util/gt.ts';
export { gte } from './util/gte.ts'; export { gte } from './util/gte.ts';
export { iteratee } from './util/iteratee.ts'; export { iteratee } from './util/iteratee.ts';
export { stubArray } from './util/stubArray.ts';
export { stubFalse } from './util/stubFalse.ts';
export { stubObject } from './util/stubObject.ts';
export { stubString } from './util/stubString.ts';
export { stubTrue } from './util/stubTrue.ts';
export { times } from './util/times.ts'; export { times } from './util/times.ts';
export { toArray } from './util/toArray.ts'; export { toArray } from './util/toArray.ts';
export { toFinite } from './util/toFinite.ts'; export { toFinite } from './util/toFinite.ts';
@ -194,4 +199,3 @@ export { toNumber } from './util/toNumber.ts';
export { toPath } from './util/toPath.ts'; export { toPath } from './util/toPath.ts';
export { toSafeInteger } from './util/toSafeInteger.ts'; export { toSafeInteger } from './util/toSafeInteger.ts';
export { toString } from './util/toString.ts'; export { toString } from './util/toString.ts';
export { uniqueId } from './util/uniqueId.ts';

View File

@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { inRange } from './inRange'; import { inRange } from './inRange';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../util/stubTrue';
describe('inRange', () => { describe('inRange', () => {
it('should work with an `end`', () => { it('should work with an `end`', () => {

View File

@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { random } from './random'; import { random } from './random';
import { uniq } from '../../array/uniq'; import { uniq } from '../../array/uniq';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../util/stubTrue';
describe('random', () => { describe('random', () => {
const array = Array.from({ length: 100 }); const array = Array.from({ length: 100 });

View File

@ -3,7 +3,7 @@ import { cloneDeep } from './cloneDeep';
import { range } from '../../math/range'; import { range } from '../../math/range';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { LARGE_ARRAY_SIZE } from '../_internal/LARGE_ARRAY_SIZE'; import { LARGE_ARRAY_SIZE } from '../_internal/LARGE_ARRAY_SIZE';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../util/stubTrue';
describe('cloneDeep', () => { describe('cloneDeep', () => {
it('should deep clone objects with circular references', () => { it('should deep clone objects with circular references', () => {

View File

@ -2,10 +2,10 @@ import { describe, expect, it } from 'vitest';
import { has } from './has'; import { has } from './has';
import { range } from '../../math/range'; import { range } from '../../math/range';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { stubFalse } from '../_internal/stubFalse';
import { stubTrue } from '../_internal/stubTrue';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { toArgs } from '../_internal/toArgs'; import { toArgs } from '../_internal/toArgs';
import { stubFalse } from '../util/stubFalse';
import { stubTrue } from '../util/stubTrue';
describe('has', () => { describe('has', () => {
it(`should check for own properties`, () => { it(`should check for own properties`, () => {

View File

@ -3,7 +3,7 @@ import { keysIn } from './keysIn';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { primitives } from '../_internal/primitives'; import { primitives } from '../_internal/primitives';
import { strictArgs } from '../_internal/strictArgs'; import { strictArgs } from '../_internal/strictArgs';
import { stubArray } from '../_internal/stubArray'; import { stubArray } from '../util/stubArray';
describe('keys methods', () => { describe('keys methods', () => {
const func = keysIn; const func = keysIn;

View File

@ -3,9 +3,9 @@ import { merge } from './merge';
import { range } from '../../math/range'; import { range } from '../../math/range';
import { isEqual } from '../../predicate/isEqual'; import { isEqual } from '../../predicate/isEqual';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { stubTrue } from '../_internal/stubTrue';
import { typedArrays } from '../_internal/typedArrays'; import { typedArrays } from '../_internal/typedArrays';
import { isArguments } from '../predicate/isArguments'; import { isArguments } from '../predicate/isArguments';
import { stubTrue } from '../util/stubTrue';
describe('merge', () => { describe('merge', () => {
it('should merge `source` into `object`', () => { it('should merge `source` into `object`', () => {

View File

@ -5,8 +5,8 @@ import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { strictArgs } from '../_internal/strictArgs'; import { strictArgs } from '../_internal/strictArgs';
import { stubFalse } from '../_internal/stubFalse';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { stubFalse } from '../util/stubFalse';
describe('isArguments', () => { describe('isArguments', () => {
it('should return `true` for `arguments` objects', () => { it('should return `true` for `arguments` objects', () => {

View File

@ -3,8 +3,8 @@ import { isArrayBuffer } from './isArrayBuffer';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubFalse } from '../_internal/stubFalse';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { stubFalse } from '../util/stubFalse';
describe('isArrayBuffer', () => { describe('isArrayBuffer', () => {
it('should return `true` for array buffers', () => { it('should return `true` for array buffers', () => {

View File

@ -3,8 +3,8 @@ import { isDate } from './isDate';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubFalse } from '../_internal/stubFalse';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { stubFalse } from '../util/stubFalse';
describe('isDate', () => { describe('isDate', () => {
it('should return `true` for dates', () => { it('should return `true` for dates', () => {

View File

@ -4,8 +4,8 @@ import { args } from '../_internal/args';
import { empties } from '../_internal/empties'; import { empties } from '../_internal/empties';
import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER'; import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubTrue } from '../_internal/stubTrue';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { stubTrue } from '../util/stubTrue';
describe('isEmpty', () => { describe('isEmpty', () => {
it('should return `true` for empty values', () => { it('should return `true` for empty values', () => {

View File

@ -3,7 +3,7 @@ import { isEqual } from 'es-toolkit/compat';
import { noop } from '../../function/noop'; import { noop } from '../../function/noop';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { arrayViews } from '../_internal/arrayViews'; import { arrayViews } from '../_internal/arrayViews';
import { stubFalse } from '../_internal/stubFalse'; import { stubFalse } from '../util/stubFalse';
describe('isEqual', () => { describe('isEqual', () => {
const symbol1 = Symbol ? Symbol('a') : true; const symbol1 = Symbol ? Symbol('a') : true;
@ -605,7 +605,14 @@ describe('isEqual', () => {
expect(isEqual(/x/gi, /x/g)).toBe(false); expect(isEqual(/x/gi, /x/g)).toBe(false);
expect(isEqual(/x/, /y/)).toBe(false); expect(isEqual(/x/, /y/)).toBe(false);
expect(isEqual(/x/g, { global: true, ignoreCase: false, multiline: false, source: 'x' })).toBe(false); expect(
isEqual(/x/g, {
global: true,
ignoreCase: false,
multiline: false,
source: 'x',
})
).toBe(false);
}); });
it('should compare sets', () => { it('should compare sets', () => {

View File

@ -6,7 +6,7 @@ import { noop } from '../../function/noop';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubC } from '../_internal/stubC'; import { stubC } from '../_internal/stubC';
import { stubFalse } from '../_internal/stubFalse'; import { stubFalse } from '../util/stubFalse';
describe('isEqualWith', () => { describe('isEqualWith', () => {
it('should provide correct `customizer` arguments', () => { it('should provide correct `customizer` arguments', () => {

View File

@ -2,9 +2,9 @@ import { describe, expect, it } from 'vitest';
import { isInteger } from './isInteger'; import { isInteger } from './isInteger';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { stubFalse } from '../_internal/stubFalse';
import { stubTrue } from '../_internal/stubTrue';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { stubFalse } from '../util/stubFalse';
import { stubTrue } from '../util/stubTrue';
const MAX_INTEGER = 1.7976931348623157e308; const MAX_INTEGER = 1.7976931348623157e308;

View File

@ -3,9 +3,9 @@ import { isMap } from './isMap';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubFalse } from '../_internal/stubFalse';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { weakMap } from '../_internal/weakMap'; import { weakMap } from '../_internal/weakMap';
import { stubFalse } from '../util/stubFalse';
describe('isMap', () => { describe('isMap', () => {
it('should return `true` for maps', () => { it('should return `true` for maps', () => {

View File

@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
import { isArrayMatch, isMapMatch, isMatch, isSetMatch } from './isMatch'; import { isArrayMatch, isMapMatch, isMatch, isSetMatch } from './isMatch';
import { noop } from '../../function/noop'; import { noop } from '../../function/noop';
import { empties } from '../_internal/empties'; import { empties } from '../_internal/empties';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../util/stubTrue';
describe('isMatch', () => { describe('isMatch', () => {
it('should handle null correctly', () => { it('should handle null correctly', () => {

View File

@ -3,8 +3,8 @@ import { isObject } from './isObject';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubFalse } from '../_internal/stubFalse';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { stubFalse } from '../util/stubFalse';
describe('isObject', () => { describe('isObject', () => {
it('should return `true` if value is an object', () => { it('should return `true` if value is an object', () => {

View File

@ -3,8 +3,8 @@ import { isObjectLike } from './isObjectLike';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubFalse } from '../_internal/stubFalse';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { stubFalse } from '../util/stubFalse';
describe('isObjectLike', () => { describe('isObjectLike', () => {
it('should return `true` for objects', () => { it('should return `true` for objects', () => {

View File

@ -3,8 +3,8 @@ import { isRegExp } from './isRegExp';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubFalse } from '../_internal/stubFalse';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { stubFalse } from '../util/stubFalse';
/** /**
* https://github.com/lodash/lodash/blob/main/test/isRegExp.spec.js * https://github.com/lodash/lodash/blob/main/test/isRegExp.spec.js

View File

@ -2,9 +2,9 @@ import { describe, expect, it } from 'vitest';
import { isSafeInteger } from './isSafeInteger.ts'; import { isSafeInteger } from './isSafeInteger.ts';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { stubFalse } from '../_internal/stubFalse';
import { stubTrue } from '../_internal/stubTrue';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { stubFalse } from '../util/stubFalse.ts';
import { stubTrue } from '../util/stubTrue.ts';
const MAX_INTEGER = 1.7976931348623157e308; const MAX_INTEGER = 1.7976931348623157e308;

View File

@ -3,9 +3,9 @@ import { isSet } from './isSet';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubFalse } from '../_internal/stubFalse';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
import { weakSet } from '../_internal/weakSet'; import { weakSet } from '../_internal/weakSet';
import { stubFalse } from '../util/stubFalse';
describe('isSet', () => { describe('isSet', () => {
it('should return `true` for sets', () => { it('should return `true` for sets', () => {

View File

@ -3,7 +3,7 @@ import { isSymbol } from './isSymbol';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubFalse } from '../_internal/stubFalse'; import { stubFalse } from '../util/stubFalse';
describe('isSymbol', () => { describe('isSymbol', () => {
it('should return `true` for symbols', () => { it('should return `true` for symbols', () => {

View File

@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest';
import { isTypedArray } from './isTypedArray'; import { isTypedArray } from './isTypedArray';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { stubFalse } from '../_internal/stubFalse';
import { typedArrays } from '../_internal/typedArrays'; import { typedArrays } from '../_internal/typedArrays';
import { stubFalse } from '../util/stubFalse';
/** /**
* @see https://github.com/lodash/lodash/blob/main/test/isTypedArray.spec.js * @see https://github.com/lodash/lodash/blob/main/test/isTypedArray.spec.js

View File

@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
import { matches } from './matches'; import { matches } from './matches';
import { noop } from '../../function/noop'; import { noop } from '../../function/noop';
import { empties } from '../_internal/empties'; import { empties } from '../_internal/empties';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../util/stubTrue';
describe('matches', () => { describe('matches', () => {
it(`should perform a deep comparison between \`source\` and \`object\``, () => { it(`should perform a deep comparison between \`source\` and \`object\``, () => {
@ -247,7 +247,13 @@ describe('matches', () => {
expect(actual2).toEqual(expected2); expect(actual2).toEqual(expected2);
const objects3 = [{ a: { b: 2 } }, { a: { b: 2, c: 3 } }, { a: { b: 2, c: undefined } }]; const objects3 = [
{ a: { b: 2 } },
{ a: { b: 2, c: 3 } },
{
a: { b: 2, c: undefined },
},
];
const actual3 = objects3.map(matches({ a: { c: undefined } })); const actual3 = objects3.map(matches({ a: { c: undefined } }));
const expected3 = [false, false, true]; const expected3 = [false, false, true];

View File

@ -3,9 +3,9 @@ import { matchesProperty } from './matchesProperty';
import { noop } from '../../function/noop'; import { noop } from '../../function/noop';
import { range } from '../../math/range'; import { range } from '../../math/range';
import { numberProto } from '../_internal/numberProto'; import { numberProto } from '../_internal/numberProto';
import { stubFalse } from '../_internal/stubFalse';
import { stubTrue } from '../_internal/stubTrue';
import { cloneDeep } from '../object/cloneDeep'; import { cloneDeep } from '../object/cloneDeep';
import { stubFalse } from '../util/stubFalse';
import { stubTrue } from '../util/stubTrue';
describe('matchesProperty', () => { describe('matchesProperty', () => {
it('should create a function that performs a deep comparison between a property value and `srcValue`', () => { it('should create a function that performs a deep comparison between a property value and `srcValue`', () => {
@ -337,7 +337,13 @@ describe('matchesProperty', () => {
expect(actual).toEqual(expected); expect(actual).toEqual(expected);
objects = [{ a: { a: 1 } }, { a: { a: 1, b: 1 } }, { a: { a: 1, b: undefined } }]; objects = [
{ a: { a: 1 } },
{ a: { a: 1, b: 1 } },
{
a: { a: 1, b: undefined },
},
];
actual = objects.map(matchesProperty('a', { b: undefined })); actual = objects.map(matchesProperty('a', { b: undefined }));
expect(actual).toEqual(expected); expect(actual).toEqual(expected);

View File

@ -1,10 +1,10 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { template, templateSettings } from './template'; import { template, templateSettings } from './template';
import { numberTag } from '../_internal/numberTag'; import { numberTag } from '../_internal/numberTag';
import { stubFalse } from '../_internal/stubFalse';
import { stubString } from '../_internal/stubString';
import { stubTrue } from '../_internal/stubTrue';
import * as esToolkit from '../index'; import * as esToolkit from '../index';
import { stubFalse } from '../util/stubFalse';
import { stubString } from '../util/stubString';
import { stubTrue } from '../util/stubTrue';
describe('template', () => { describe('template', () => {
it('should escape values in "escape" delimiters', () => { it('should escape values in "escape" delimiters', () => {

View File

@ -1,8 +1,8 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { constant } from './constant'; import { constant } from './constant';
import { stubTrue } from './stubTrue';
import { empties } from '../_internal/empties'; import { empties } from '../_internal/empties';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { stubTrue } from '../_internal/stubTrue';
import * as esToolkit from '../index'; import * as esToolkit from '../index';
describe('constant', () => { describe('constant', () => {

View File

@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { iteratee } from './iteratee'; import { iteratee } from './iteratee';
import { stubFalse } from './stubFalse';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubFalse } from '../_internal/stubFalse';
import { partial, partialRight } from '../index'; import { partial, partialRight } from '../index';
import * as esToolkit from '../index'; import * as esToolkit from '../index';

View File

@ -0,0 +1,8 @@
import { describe, expect, it } from 'vitest';
import { stubArray } from './stubArray';
describe('stubArray', () => {
it('should return an empty array', () => {
expect(stubArray()).toEqual([]);
});
});

View File

@ -0,0 +1,10 @@
/**
* Returns a new empty array.
*
* @returns {Array} A new empty array.
* @example
* stubArray() // Returns []
*/
export function stubArray(): [] {
return [];
}

View File

@ -0,0 +1,8 @@
import { describe, expect, it } from 'vitest';
import { stubFalse } from './stubFalse';
describe('stubFalse', () => {
it('should return `false`', () => {
expect(stubFalse()).toEqual(false);
});
});

View File

@ -0,0 +1,10 @@
/**
* Returns false.
*
* @returns {boolean} false.
* @example
* stubFalse() // Returns false
*/
export function stubFalse(): false {
return false;
}

View File

@ -0,0 +1,8 @@
import { describe, expect, it } from 'vitest';
import { stubObject } from './stubObject';
describe('stubObject', () => {
it('should return an empty object', () => {
expect(stubObject()).toEqual({});
});
});

View File

@ -0,0 +1,10 @@
/**
* Returns an empty object.
*
* @returns {Object} An empty object.
* @example
* stubObject() // Returns {}
*/
export function stubObject(): {} {
return {};
}

View File

@ -0,0 +1,8 @@
import { describe, expect, it } from 'vitest';
import { stubString } from './stubString';
describe('stubString', () => {
it('should return an empty string', () => {
expect(stubString()).toEqual('');
});
});

View File

@ -0,0 +1,10 @@
/**
* Returns an empty string.
*
* @returns {string} An empty string.
* @example
* stubString() // Returns ''
*/
export function stubString(): '' {
return '';
}

View File

@ -0,0 +1,8 @@
import { describe, expect, it } from 'vitest';
import { stubTrue } from './stubTrue';
describe('stubTrue', () => {
it('should return `true`', () => {
expect(stubTrue()).toEqual(true);
});
});

View File

@ -0,0 +1,10 @@
/**
* Returns true.
*
* @returns {boolean} true.
* @example
* stubTrue() // Returns true
*/
export function stubTrue(): true {
return true;
}

View File

@ -1,9 +1,9 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { stubArray } from './stubArray';
import { times } from './times'; import { times } from './times';
import { doubled } from '../_internal/doubled'; import { doubled } from '../_internal/doubled';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubArray } from '../_internal/stubArray';
describe('times', () => { describe('times', () => {
it('should coerce non-finite `n` values to `0`', () => { it('should coerce non-finite `n` values to `0`', () => {

View File

@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { stubString } from './stubString';
import { toString } from './toString'; import { toString } from './toString';
import { stubString } from '../_internal/stubString';
import { symbol } from '../_internal/symbol'; import { symbol } from '../_internal/symbol';
describe('toString', () => { describe('toString', () => {

View File

@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
import { isEqualWith } from './isEqualWith'; import { isEqualWith } from './isEqualWith';
import { args } from '../compat/_internal/args'; import { args } from '../compat/_internal/args';
import { arrayViews } from '../compat/_internal/arrayViews'; import { arrayViews } from '../compat/_internal/arrayViews';
import { stubFalse } from '../compat/_internal/stubFalse'; import { stubFalse } from '../compat/util/stubFalse';
import { noop } from '../function'; import { noop } from '../function';
describe('isEqualWith', () => { describe('isEqualWith', () => {
@ -667,7 +667,18 @@ describe('isEqualWith', () => {
expect(isEqualWith(/x/gi, /x/g, noop)).toBe(false); expect(isEqualWith(/x/gi, /x/g, noop)).toBe(false);
expect(isEqualWith(/x/, /y/, noop)).toBe(false); expect(isEqualWith(/x/, /y/, noop)).toBe(false);
expect(isEqualWith(/x/g, { global: true, ignoreCase: false, multiline: false, source: 'x' }, noop)).toBe(false); expect(
isEqualWith(
/x/g,
{
global: true,
ignoreCase: false,
multiline: false,
source: 'x',
},
noop
)
).toBe(false);
}); });
it('should compare sets when customizer returns undefined', () => { it('should compare sets when customizer returns undefined', () => {