diff --git a/docs/ja/reference/compat/util/stubArray.md b/docs/ja/reference/compat/util/stubArray.md new file mode 100644 index 00000000..cff197b2 --- /dev/null +++ b/docs/ja/reference/compat/util/stubArray.md @@ -0,0 +1,25 @@ +# stubArray + +::: info +この関数は互換性のために `es-toolkit/compat` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。 + +`es-toolkit/compat` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。 +::: + +新しい空の配列を返します。 + +## インターフェース + +```typescript +function stubArray(): []; +``` + +### 戻り値 + +(`Array`): 新しい空の配列。 + +## 例 + +```typescript +stubArray(); // Returns [] +``` diff --git a/docs/ja/reference/compat/util/stubFalse.md b/docs/ja/reference/compat/util/stubFalse.md new file mode 100644 index 00000000..7d7f4298 --- /dev/null +++ b/docs/ja/reference/compat/util/stubFalse.md @@ -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 +``` diff --git a/docs/ja/reference/compat/util/stubObject.md b/docs/ja/reference/compat/util/stubObject.md new file mode 100644 index 00000000..6a8f5927 --- /dev/null +++ b/docs/ja/reference/compat/util/stubObject.md @@ -0,0 +1,25 @@ +# stubObject + +::: info +この関数は互換性のために `es-toolkit/compat` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。 + +`es-toolkit/compat` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。 +::: + +空のオブジェクトを返します。 + +## インターフェース + +```typescript +function stubObject(): {}; +``` + +### 戻り値 + +(`Object`): 空のオブジェクト。 + +## 例 + +```typescript +stubObject(); // Returns {} +``` diff --git a/docs/ja/reference/compat/util/stubString.md b/docs/ja/reference/compat/util/stubString.md new file mode 100644 index 00000000..86fe6d21 --- /dev/null +++ b/docs/ja/reference/compat/util/stubString.md @@ -0,0 +1,25 @@ +# stubString + +::: info +この関数は互換性のために `es-toolkit/compat` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。 + +`es-toolkit/compat` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。 +::: + +空の文字列を返します。 + +## インターフェース + +```typescript +function stubString(): ''; +``` + +### 戻り値 + +(`string`): 空の文字列ます。 + +## 例 + +```typescript +stubString(); // Returns '' +``` diff --git a/docs/ja/reference/compat/util/stubTrue.md b/docs/ja/reference/compat/util/stubTrue.md new file mode 100644 index 00000000..5fe7a4df --- /dev/null +++ b/docs/ja/reference/compat/util/stubTrue.md @@ -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 +``` diff --git a/docs/ko/reference/compat/util/stubArray.md b/docs/ko/reference/compat/util/stubArray.md new file mode 100644 index 00000000..fceab829 --- /dev/null +++ b/docs/ko/reference/compat/util/stubArray.md @@ -0,0 +1,25 @@ +# stubArray + +::: info +이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요. + +`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요. +::: + +새로운 빈 배열을 반환해요. + +## 인터페이스 + +```typescript +function stubArray(): []; +``` + +### 반환 값 + +(`[]`): 새로운 빈 배열. + +## 예시 + +```typescript +stubArray(); // Returns [] +``` diff --git a/docs/ko/reference/compat/util/stubFalse.md b/docs/ko/reference/compat/util/stubFalse.md new file mode 100644 index 00000000..73dd16fd --- /dev/null +++ b/docs/ko/reference/compat/util/stubFalse.md @@ -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 +``` diff --git a/docs/ko/reference/compat/util/stubObject.md b/docs/ko/reference/compat/util/stubObject.md new file mode 100644 index 00000000..a15c5abf --- /dev/null +++ b/docs/ko/reference/compat/util/stubObject.md @@ -0,0 +1,25 @@ +# stubObject + +::: info +이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요. + +`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요. +::: + +빈 객체를 반환해요. + +## 인터페이스 + +```typescript +function stubObject(): {}; +``` + +### 반환 값 + +(`{}`): 빈 객체. + +## 예시 + +```typescript +stubObject(); // Returns {} +``` diff --git a/docs/ko/reference/compat/util/stubString.md b/docs/ko/reference/compat/util/stubString.md new file mode 100644 index 00000000..7ca07256 --- /dev/null +++ b/docs/ko/reference/compat/util/stubString.md @@ -0,0 +1,25 @@ +# stubString + +::: info +이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요. + +`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요. +::: + +빈 문자열을 반환해요. + +## 인터페이스 + +```typescript +function stubString(): ''; +``` + +### 반환 값 + +(`''`): 빈 문자열. + +## 예시 + +```typescript +stubString(); // Returns '' +``` diff --git a/docs/ko/reference/compat/util/stubTrue.md b/docs/ko/reference/compat/util/stubTrue.md new file mode 100644 index 00000000..7cfb5ab0 --- /dev/null +++ b/docs/ko/reference/compat/util/stubTrue.md @@ -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 +``` diff --git a/docs/reference/compat/util/stubArray.md b/docs/reference/compat/util/stubArray.md new file mode 100644 index 00000000..0a4ea041 --- /dev/null +++ b/docs/reference/compat/util/stubArray.md @@ -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 isn’t 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 [] +``` diff --git a/docs/reference/compat/util/stubFalse.md b/docs/reference/compat/util/stubFalse.md new file mode 100644 index 00000000..41e72ebc --- /dev/null +++ b/docs/reference/compat/util/stubFalse.md @@ -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 isn’t 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 +``` diff --git a/docs/reference/compat/util/stubObject.md b/docs/reference/compat/util/stubObject.md new file mode 100644 index 00000000..962f9e32 --- /dev/null +++ b/docs/reference/compat/util/stubObject.md @@ -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 isn’t 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 {} +``` diff --git a/docs/reference/compat/util/stubString.md b/docs/reference/compat/util/stubString.md new file mode 100644 index 00000000..3b3d4483 --- /dev/null +++ b/docs/reference/compat/util/stubString.md @@ -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 isn’t 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 '' +``` diff --git a/docs/reference/compat/util/stubTrue.md b/docs/reference/compat/util/stubTrue.md new file mode 100644 index 00000000..a9b42a4a --- /dev/null +++ b/docs/reference/compat/util/stubTrue.md @@ -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 isn’t 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 +``` diff --git a/docs/zh_hans/reference/compat/util/stubArray.md b/docs/zh_hans/reference/compat/util/stubArray.md new file mode 100644 index 00000000..5ac8e9e3 --- /dev/null +++ b/docs/zh_hans/reference/compat/util/stubArray.md @@ -0,0 +1,25 @@ +# stubArray + +::: info +出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API,或者尚未完全优化。 + +从 `es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。 +::: + +返回一个新的空数组。 + +## 签名 + +```typescript +function stubArray(): []; +``` + +### 返回值 + +(`[]`): 一个新的空数组。 + +## 示例 + +```typescript +stubArray(); // Returns [] +``` diff --git a/docs/zh_hans/reference/compat/util/stubFalse.md b/docs/zh_hans/reference/compat/util/stubFalse.md new file mode 100644 index 00000000..0c11ab08 --- /dev/null +++ b/docs/zh_hans/reference/compat/util/stubFalse.md @@ -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 +``` diff --git a/docs/zh_hans/reference/compat/util/stubObject.md b/docs/zh_hans/reference/compat/util/stubObject.md new file mode 100644 index 00000000..f8f5be21 --- /dev/null +++ b/docs/zh_hans/reference/compat/util/stubObject.md @@ -0,0 +1,25 @@ +# stubObject + +::: info +出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API,或者尚未完全优化。 + +从 `es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。 +::: + +返回一个空对象。 + +## 签名 + +```typescript +function stubObject(): {}; +``` + +### 返回值 + +(`{}`): 一个空对象。 + +## 示例 + +```typescript +stubObject(); // Returns {} +``` diff --git a/docs/zh_hans/reference/compat/util/stubString.md b/docs/zh_hans/reference/compat/util/stubString.md new file mode 100644 index 00000000..953ec024 --- /dev/null +++ b/docs/zh_hans/reference/compat/util/stubString.md @@ -0,0 +1,25 @@ +# stubString + +::: info +出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API,或者尚未完全优化。 + +从 `es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。 +::: + +返回空字符串。 + +## 签名 + +```typescript +function stubString(): ''; +``` + +### 返回值 + +(`''`): 空字符串。 + +## 示例 + +```typescript +stubString(); // Returns '' +``` diff --git a/docs/zh_hans/reference/compat/util/stubTrue.md b/docs/zh_hans/reference/compat/util/stubTrue.md new file mode 100644 index 00000000..34df34c7 --- /dev/null +++ b/docs/zh_hans/reference/compat/util/stubTrue.md @@ -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 +``` diff --git a/src/compat/_internal/stubArray.ts b/src/compat/_internal/stubArray.ts deleted file mode 100644 index af739998..00000000 --- a/src/compat/_internal/stubArray.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function stubArray() { - return []; -} diff --git a/src/compat/_internal/stubFalse.ts b/src/compat/_internal/stubFalse.ts deleted file mode 100644 index 9d3ea39e..00000000 --- a/src/compat/_internal/stubFalse.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const stubFalse = function () { - return false; -}; diff --git a/src/compat/_internal/stubString.ts b/src/compat/_internal/stubString.ts deleted file mode 100644 index 782ff451..00000000 --- a/src/compat/_internal/stubString.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function stubString(): string { - return ''; -} diff --git a/src/compat/_internal/stubTrue.ts b/src/compat/_internal/stubTrue.ts deleted file mode 100644 index 58939b70..00000000 --- a/src/compat/_internal/stubTrue.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const stubTrue = function () { - return true; -}; diff --git a/src/compat/array/each.spec.ts b/src/compat/array/each.spec.ts index 547085e0..b8f23e76 100644 --- a/src/compat/array/each.spec.ts +++ b/src/compat/array/each.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest'; import { forEach as each } from './forEach'; import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER'; import { slice } from '../_internal/slice'; -import { stubTrue } from '../_internal/stubTrue'; +import { stubTrue } from '../util/stubTrue'; describe('each', () => { it('should iterate over array elements', () => { diff --git a/src/compat/array/every.spec.ts b/src/compat/array/every.spec.ts index 457b9af8..4f4942bc 100644 --- a/src/compat/array/every.spec.ts +++ b/src/compat/array/every.spec.ts @@ -3,8 +3,8 @@ import { every } from './every'; import { identity } from '../../function/identity'; import { args } from '../_internal/args'; import { empties } from '../_internal/empties'; -import { stubFalse } from '../_internal/stubFalse'; -import { stubTrue } from '../_internal/stubTrue'; +import { stubFalse } from '../util/stubFalse'; +import { stubTrue } from '../util/stubTrue'; describe('every', () => { it('should return true for array with all elements passing predicate', () => { diff --git a/src/compat/array/forEach.spec.ts b/src/compat/array/forEach.spec.ts index 9dc93ee0..7dd0c8a0 100644 --- a/src/compat/array/forEach.spec.ts +++ b/src/compat/array/forEach.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest'; import { forEach } from './forEach'; import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER'; import { slice } from '../_internal/slice'; -import { stubTrue } from '../_internal/stubTrue'; +import { stubTrue } from '../util/stubTrue'; describe('forEach', () => { it('should iterate over array elements', () => { diff --git a/src/compat/array/includes.spec.ts b/src/compat/array/includes.spec.ts index 48c89e96..73342ab8 100644 --- a/src/compat/array/includes.spec.ts +++ b/src/compat/array/includes.spec.ts @@ -3,8 +3,8 @@ import { includes } from './includes'; import { args } from '../_internal/args'; import { empties } from '../_internal/empties'; import { falsey } from '../_internal/falsey'; -import { stubFalse } from '../_internal/stubFalse'; import { toArgs } from '../_internal/toArgs'; +import { stubFalse } from '../util/stubFalse'; describe('includes', () => { it('should ignore inherited value', () => { diff --git a/src/compat/array/some.spec.ts b/src/compat/array/some.spec.ts index 941d6c33..1478ade9 100644 --- a/src/compat/array/some.spec.ts +++ b/src/compat/array/some.spec.ts @@ -3,8 +3,8 @@ import { some } from './some'; import { identity } from '../../function/identity'; import { args } from '../_internal/args'; import { empties } from '../_internal/empties'; -import { stubFalse } from '../_internal/stubFalse'; -import { stubTrue } from '../_internal/stubTrue'; +import { stubFalse } from '../util/stubFalse'; +import { stubTrue } from '../util/stubTrue'; describe('some', () => { it('should return `true` if `predicate` returns truthy for any element', () => { diff --git a/src/compat/array/zip.spec.ts b/src/compat/array/zip.spec.ts index 0ba787b7..bffbde97 100644 --- a/src/compat/array/zip.spec.ts +++ b/src/compat/array/zip.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'; import { zip } from './zip'; import { unzip } from '../../array/unzip'; import { falsey } from '../_internal/falsey'; -import { stubArray } from '../_internal/stubArray'; +import { stubArray } from '../util/stubArray'; describe('zip', () => { const object = { diff --git a/src/compat/index.ts b/src/compat/index.ts index 9def789e..664a0d57 100644 --- a/src/compat/index.ts +++ b/src/compat/index.ts @@ -185,6 +185,11 @@ export { eq } from './util/eq.ts'; export { gt } from './util/gt.ts'; export { gte } from './util/gte.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 { toArray } from './util/toArray.ts'; export { toFinite } from './util/toFinite.ts'; @@ -194,4 +199,3 @@ export { toNumber } from './util/toNumber.ts'; export { toPath } from './util/toPath.ts'; export { toSafeInteger } from './util/toSafeInteger.ts'; export { toString } from './util/toString.ts'; -export { uniqueId } from './util/uniqueId.ts'; diff --git a/src/compat/math/inRange.spec.ts b/src/compat/math/inRange.spec.ts index 3778ae72..9171fab2 100644 --- a/src/compat/math/inRange.spec.ts +++ b/src/compat/math/inRange.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; import { inRange } from './inRange'; import { falsey } from '../_internal/falsey'; -import { stubTrue } from '../_internal/stubTrue'; +import { stubTrue } from '../util/stubTrue'; describe('inRange', () => { it('should work with an `end`', () => { diff --git a/src/compat/math/random.spec.ts b/src/compat/math/random.spec.ts index 380143b9..7d954d79 100644 --- a/src/compat/math/random.spec.ts +++ b/src/compat/math/random.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; import { random } from './random'; import { uniq } from '../../array/uniq'; -import { stubTrue } from '../_internal/stubTrue'; +import { stubTrue } from '../util/stubTrue'; describe('random', () => { const array = Array.from({ length: 100 }); diff --git a/src/compat/object/cloneDeep.spec.ts b/src/compat/object/cloneDeep.spec.ts index 5dba106f..458d2be4 100644 --- a/src/compat/object/cloneDeep.spec.ts +++ b/src/compat/object/cloneDeep.spec.ts @@ -3,7 +3,7 @@ import { cloneDeep } from './cloneDeep'; import { range } from '../../math/range'; import { args } from '../_internal/args'; import { LARGE_ARRAY_SIZE } from '../_internal/LARGE_ARRAY_SIZE'; -import { stubTrue } from '../_internal/stubTrue'; +import { stubTrue } from '../util/stubTrue'; describe('cloneDeep', () => { it('should deep clone objects with circular references', () => { diff --git a/src/compat/object/has.spec.ts b/src/compat/object/has.spec.ts index 93d15f9c..08a60787 100644 --- a/src/compat/object/has.spec.ts +++ b/src/compat/object/has.spec.ts @@ -2,10 +2,10 @@ import { describe, expect, it } from 'vitest'; import { has } from './has'; import { range } from '../../math/range'; import { args } from '../_internal/args'; -import { stubFalse } from '../_internal/stubFalse'; -import { stubTrue } from '../_internal/stubTrue'; import { symbol } from '../_internal/symbol'; import { toArgs } from '../_internal/toArgs'; +import { stubFalse } from '../util/stubFalse'; +import { stubTrue } from '../util/stubTrue'; describe('has', () => { it(`should check for own properties`, () => { diff --git a/src/compat/object/keysIn.spec.ts b/src/compat/object/keysIn.spec.ts index 54f6d462..4abec0be 100644 --- a/src/compat/object/keysIn.spec.ts +++ b/src/compat/object/keysIn.spec.ts @@ -3,7 +3,7 @@ import { keysIn } from './keysIn'; import { args } from '../_internal/args'; import { primitives } from '../_internal/primitives'; import { strictArgs } from '../_internal/strictArgs'; -import { stubArray } from '../_internal/stubArray'; +import { stubArray } from '../util/stubArray'; describe('keys methods', () => { const func = keysIn; diff --git a/src/compat/object/merge.spec.ts b/src/compat/object/merge.spec.ts index 576853d3..f0e77633 100644 --- a/src/compat/object/merge.spec.ts +++ b/src/compat/object/merge.spec.ts @@ -3,9 +3,9 @@ import { merge } from './merge'; import { range } from '../../math/range'; import { isEqual } from '../../predicate/isEqual'; import { args } from '../_internal/args'; -import { stubTrue } from '../_internal/stubTrue'; import { typedArrays } from '../_internal/typedArrays'; import { isArguments } from '../predicate/isArguments'; +import { stubTrue } from '../util/stubTrue'; describe('merge', () => { it('should merge `source` into `object`', () => { diff --git a/src/compat/predicate/isArguments.spec.ts b/src/compat/predicate/isArguments.spec.ts index 0a184db7..1ef5a1d0 100644 --- a/src/compat/predicate/isArguments.spec.ts +++ b/src/compat/predicate/isArguments.spec.ts @@ -5,8 +5,8 @@ import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; import { strictArgs } from '../_internal/strictArgs'; -import { stubFalse } from '../_internal/stubFalse'; import { symbol } from '../_internal/symbol'; +import { stubFalse } from '../util/stubFalse'; describe('isArguments', () => { it('should return `true` for `arguments` objects', () => { diff --git a/src/compat/predicate/isArrayBuffer.spec.ts b/src/compat/predicate/isArrayBuffer.spec.ts index 32c5d8f3..ed2d5eb6 100644 --- a/src/compat/predicate/isArrayBuffer.spec.ts +++ b/src/compat/predicate/isArrayBuffer.spec.ts @@ -3,8 +3,8 @@ import { isArrayBuffer } from './isArrayBuffer'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; -import { stubFalse } from '../_internal/stubFalse'; import { symbol } from '../_internal/symbol'; +import { stubFalse } from '../util/stubFalse'; describe('isArrayBuffer', () => { it('should return `true` for array buffers', () => { diff --git a/src/compat/predicate/isDate.spec.ts b/src/compat/predicate/isDate.spec.ts index df9dfd11..d764d197 100644 --- a/src/compat/predicate/isDate.spec.ts +++ b/src/compat/predicate/isDate.spec.ts @@ -3,8 +3,8 @@ import { isDate } from './isDate'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; -import { stubFalse } from '../_internal/stubFalse'; import { symbol } from '../_internal/symbol'; +import { stubFalse } from '../util/stubFalse'; describe('isDate', () => { it('should return `true` for dates', () => { diff --git a/src/compat/predicate/isEmpty.spec.ts b/src/compat/predicate/isEmpty.spec.ts index 7e6d694c..ddcf5e76 100644 --- a/src/compat/predicate/isEmpty.spec.ts +++ b/src/compat/predicate/isEmpty.spec.ts @@ -4,8 +4,8 @@ import { args } from '../_internal/args'; import { empties } from '../_internal/empties'; import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER'; import { slice } from '../_internal/slice'; -import { stubTrue } from '../_internal/stubTrue'; import { symbol } from '../_internal/symbol'; +import { stubTrue } from '../util/stubTrue'; describe('isEmpty', () => { it('should return `true` for empty values', () => { diff --git a/src/compat/predicate/isEqual.spec.ts b/src/compat/predicate/isEqual.spec.ts index b60ee132..20770466 100644 --- a/src/compat/predicate/isEqual.spec.ts +++ b/src/compat/predicate/isEqual.spec.ts @@ -3,7 +3,7 @@ import { isEqual } from 'es-toolkit/compat'; import { noop } from '../../function/noop'; import { args } from '../_internal/args'; import { arrayViews } from '../_internal/arrayViews'; -import { stubFalse } from '../_internal/stubFalse'; +import { stubFalse } from '../util/stubFalse'; describe('isEqual', () => { const symbol1 = Symbol ? Symbol('a') : true; @@ -605,7 +605,14 @@ describe('isEqual', () => { expect(isEqual(/x/gi, /x/g)).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', () => { diff --git a/src/compat/predicate/isEqualWith.spec.ts b/src/compat/predicate/isEqualWith.spec.ts index de93791e..1091c216 100644 --- a/src/compat/predicate/isEqualWith.spec.ts +++ b/src/compat/predicate/isEqualWith.spec.ts @@ -6,7 +6,7 @@ import { noop } from '../../function/noop'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; import { stubC } from '../_internal/stubC'; -import { stubFalse } from '../_internal/stubFalse'; +import { stubFalse } from '../util/stubFalse'; describe('isEqualWith', () => { it('should provide correct `customizer` arguments', () => { diff --git a/src/compat/predicate/isInteger.spec.ts b/src/compat/predicate/isInteger.spec.ts index e77c7478..aad8bb06 100644 --- a/src/compat/predicate/isInteger.spec.ts +++ b/src/compat/predicate/isInteger.spec.ts @@ -2,9 +2,9 @@ import { describe, expect, it } from 'vitest'; import { isInteger } from './isInteger'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; -import { stubFalse } from '../_internal/stubFalse'; -import { stubTrue } from '../_internal/stubTrue'; import { symbol } from '../_internal/symbol'; +import { stubFalse } from '../util/stubFalse'; +import { stubTrue } from '../util/stubTrue'; const MAX_INTEGER = 1.7976931348623157e308; diff --git a/src/compat/predicate/isMap.spec.ts b/src/compat/predicate/isMap.spec.ts index 4a780aaa..a579e26b 100644 --- a/src/compat/predicate/isMap.spec.ts +++ b/src/compat/predicate/isMap.spec.ts @@ -3,9 +3,9 @@ import { isMap } from './isMap'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; -import { stubFalse } from '../_internal/stubFalse'; import { symbol } from '../_internal/symbol'; import { weakMap } from '../_internal/weakMap'; +import { stubFalse } from '../util/stubFalse'; describe('isMap', () => { it('should return `true` for maps', () => { diff --git a/src/compat/predicate/isMatch.spec.ts b/src/compat/predicate/isMatch.spec.ts index ec223d13..2a5ad38b 100644 --- a/src/compat/predicate/isMatch.spec.ts +++ b/src/compat/predicate/isMatch.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'; import { isArrayMatch, isMapMatch, isMatch, isSetMatch } from './isMatch'; import { noop } from '../../function/noop'; import { empties } from '../_internal/empties'; -import { stubTrue } from '../_internal/stubTrue'; +import { stubTrue } from '../util/stubTrue'; describe('isMatch', () => { it('should handle null correctly', () => { diff --git a/src/compat/predicate/isObject.spec.ts b/src/compat/predicate/isObject.spec.ts index 9267709d..404be25c 100644 --- a/src/compat/predicate/isObject.spec.ts +++ b/src/compat/predicate/isObject.spec.ts @@ -3,8 +3,8 @@ import { isObject } from './isObject'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; -import { stubFalse } from '../_internal/stubFalse'; import { symbol } from '../_internal/symbol'; +import { stubFalse } from '../util/stubFalse'; describe('isObject', () => { it('should return `true` if value is an object', () => { diff --git a/src/compat/predicate/isObjectLike.spec.ts b/src/compat/predicate/isObjectLike.spec.ts index 63e4ea91..d41e4bcf 100644 --- a/src/compat/predicate/isObjectLike.spec.ts +++ b/src/compat/predicate/isObjectLike.spec.ts @@ -3,8 +3,8 @@ import { isObjectLike } from './isObjectLike'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; -import { stubFalse } from '../_internal/stubFalse'; import { symbol } from '../_internal/symbol'; +import { stubFalse } from '../util/stubFalse'; describe('isObjectLike', () => { it('should return `true` for objects', () => { diff --git a/src/compat/predicate/isRegExp.spec.ts b/src/compat/predicate/isRegExp.spec.ts index 08e6a240..2dc607c4 100644 --- a/src/compat/predicate/isRegExp.spec.ts +++ b/src/compat/predicate/isRegExp.spec.ts @@ -3,8 +3,8 @@ import { isRegExp } from './isRegExp'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; -import { stubFalse } from '../_internal/stubFalse'; import { symbol } from '../_internal/symbol'; +import { stubFalse } from '../util/stubFalse'; /** * https://github.com/lodash/lodash/blob/main/test/isRegExp.spec.js diff --git a/src/compat/predicate/isSafeInteger.spec.ts b/src/compat/predicate/isSafeInteger.spec.ts index 855c11a5..41b7047c 100644 --- a/src/compat/predicate/isSafeInteger.spec.ts +++ b/src/compat/predicate/isSafeInteger.spec.ts @@ -2,9 +2,9 @@ import { describe, expect, it } from 'vitest'; import { isSafeInteger } from './isSafeInteger.ts'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; -import { stubFalse } from '../_internal/stubFalse'; -import { stubTrue } from '../_internal/stubTrue'; import { symbol } from '../_internal/symbol'; +import { stubFalse } from '../util/stubFalse.ts'; +import { stubTrue } from '../util/stubTrue.ts'; const MAX_INTEGER = 1.7976931348623157e308; diff --git a/src/compat/predicate/isSet.spec.ts b/src/compat/predicate/isSet.spec.ts index 1323602e..1a9a66d8 100644 --- a/src/compat/predicate/isSet.spec.ts +++ b/src/compat/predicate/isSet.spec.ts @@ -3,9 +3,9 @@ import { isSet } from './isSet'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; -import { stubFalse } from '../_internal/stubFalse'; import { symbol } from '../_internal/symbol'; import { weakSet } from '../_internal/weakSet'; +import { stubFalse } from '../util/stubFalse'; describe('isSet', () => { it('should return `true` for sets', () => { diff --git a/src/compat/predicate/isSymbol.spec.ts b/src/compat/predicate/isSymbol.spec.ts index 34a42bcc..91b0fb17 100644 --- a/src/compat/predicate/isSymbol.spec.ts +++ b/src/compat/predicate/isSymbol.spec.ts @@ -3,7 +3,7 @@ import { isSymbol } from './isSymbol'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; -import { stubFalse } from '../_internal/stubFalse'; +import { stubFalse } from '../util/stubFalse'; describe('isSymbol', () => { it('should return `true` for symbols', () => { diff --git a/src/compat/predicate/isTypedArray.spec.ts b/src/compat/predicate/isTypedArray.spec.ts index 4135316a..706df2a2 100644 --- a/src/compat/predicate/isTypedArray.spec.ts +++ b/src/compat/predicate/isTypedArray.spec.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest'; import { isTypedArray } from './isTypedArray'; import { args } from '../_internal/args'; import { falsey } from '../_internal/falsey'; -import { stubFalse } from '../_internal/stubFalse'; import { typedArrays } from '../_internal/typedArrays'; +import { stubFalse } from '../util/stubFalse'; /** * @see https://github.com/lodash/lodash/blob/main/test/isTypedArray.spec.js diff --git a/src/compat/predicate/matches.spec.ts b/src/compat/predicate/matches.spec.ts index 38dc71ad..0e7b53a6 100644 --- a/src/compat/predicate/matches.spec.ts +++ b/src/compat/predicate/matches.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'; import { matches } from './matches'; import { noop } from '../../function/noop'; import { empties } from '../_internal/empties'; -import { stubTrue } from '../_internal/stubTrue'; +import { stubTrue } from '../util/stubTrue'; describe('matches', () => { it(`should perform a deep comparison between \`source\` and \`object\``, () => { @@ -247,7 +247,13 @@ describe('matches', () => { 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 expected3 = [false, false, true]; diff --git a/src/compat/predicate/matchesProperty.spec.ts b/src/compat/predicate/matchesProperty.spec.ts index cfb7082c..b8b48a92 100644 --- a/src/compat/predicate/matchesProperty.spec.ts +++ b/src/compat/predicate/matchesProperty.spec.ts @@ -3,9 +3,9 @@ import { matchesProperty } from './matchesProperty'; import { noop } from '../../function/noop'; import { range } from '../../math/range'; import { numberProto } from '../_internal/numberProto'; -import { stubFalse } from '../_internal/stubFalse'; -import { stubTrue } from '../_internal/stubTrue'; import { cloneDeep } from '../object/cloneDeep'; +import { stubFalse } from '../util/stubFalse'; +import { stubTrue } from '../util/stubTrue'; describe('matchesProperty', () => { 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); - 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 })); expect(actual).toEqual(expected); diff --git a/src/compat/string/template.spec.ts b/src/compat/string/template.spec.ts index 9cba952c..e63ee61e 100644 --- a/src/compat/string/template.spec.ts +++ b/src/compat/string/template.spec.ts @@ -1,10 +1,10 @@ import { describe, expect, it } from 'vitest'; import { template, templateSettings } from './template'; 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 { stubFalse } from '../util/stubFalse'; +import { stubString } from '../util/stubString'; +import { stubTrue } from '../util/stubTrue'; describe('template', () => { it('should escape values in "escape" delimiters', () => { diff --git a/src/compat/util/constant.spec.ts b/src/compat/util/constant.spec.ts index f0dcac3c..730a8538 100644 --- a/src/compat/util/constant.spec.ts +++ b/src/compat/util/constant.spec.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from 'vitest'; import { constant } from './constant'; +import { stubTrue } from './stubTrue'; import { empties } from '../_internal/empties'; import { falsey } from '../_internal/falsey'; -import { stubTrue } from '../_internal/stubTrue'; import * as esToolkit from '../index'; describe('constant', () => { diff --git a/src/compat/util/iteratee.spec.ts b/src/compat/util/iteratee.spec.ts index b3bf82c2..45aa87d9 100644 --- a/src/compat/util/iteratee.spec.ts +++ b/src/compat/util/iteratee.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; import { iteratee } from './iteratee'; +import { stubFalse } from './stubFalse'; import { slice } from '../_internal/slice'; -import { stubFalse } from '../_internal/stubFalse'; import { partial, partialRight } from '../index'; import * as esToolkit from '../index'; diff --git a/src/compat/util/stubArray.spec.ts b/src/compat/util/stubArray.spec.ts new file mode 100644 index 00000000..f47807bc --- /dev/null +++ b/src/compat/util/stubArray.spec.ts @@ -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([]); + }); +}); diff --git a/src/compat/util/stubArray.ts b/src/compat/util/stubArray.ts new file mode 100644 index 00000000..21f5ac1e --- /dev/null +++ b/src/compat/util/stubArray.ts @@ -0,0 +1,10 @@ +/** + * Returns a new empty array. + * + * @returns {Array} A new empty array. + * @example + * stubArray() // Returns [] + */ +export function stubArray(): [] { + return []; +} diff --git a/src/compat/util/stubFalse.spec.ts b/src/compat/util/stubFalse.spec.ts new file mode 100644 index 00000000..6639b33b --- /dev/null +++ b/src/compat/util/stubFalse.spec.ts @@ -0,0 +1,8 @@ +import { describe, expect, it } from 'vitest'; +import { stubFalse } from './stubFalse'; + +describe('stubFalse', () => { + it('should return `false`', () => { + expect(stubFalse()).toEqual(false); + }); +}); diff --git a/src/compat/util/stubFalse.ts b/src/compat/util/stubFalse.ts new file mode 100644 index 00000000..26aa9e3d --- /dev/null +++ b/src/compat/util/stubFalse.ts @@ -0,0 +1,10 @@ +/** + * Returns false. + * + * @returns {boolean} false. + * @example + * stubFalse() // Returns false + */ +export function stubFalse(): false { + return false; +} diff --git a/src/compat/util/stubObject.spec.ts b/src/compat/util/stubObject.spec.ts new file mode 100644 index 00000000..2a226150 --- /dev/null +++ b/src/compat/util/stubObject.spec.ts @@ -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({}); + }); +}); diff --git a/src/compat/util/stubObject.ts b/src/compat/util/stubObject.ts new file mode 100644 index 00000000..d6058225 --- /dev/null +++ b/src/compat/util/stubObject.ts @@ -0,0 +1,10 @@ +/** + * Returns an empty object. + * + * @returns {Object} An empty object. + * @example + * stubObject() // Returns {} + */ +export function stubObject(): {} { + return {}; +} diff --git a/src/compat/util/stubString.spec.ts b/src/compat/util/stubString.spec.ts new file mode 100644 index 00000000..b293d89c --- /dev/null +++ b/src/compat/util/stubString.spec.ts @@ -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(''); + }); +}); diff --git a/src/compat/util/stubString.ts b/src/compat/util/stubString.ts new file mode 100644 index 00000000..a8553ac4 --- /dev/null +++ b/src/compat/util/stubString.ts @@ -0,0 +1,10 @@ +/** + * Returns an empty string. + * + * @returns {string} An empty string. + * @example + * stubString() // Returns '' + */ +export function stubString(): '' { + return ''; +} diff --git a/src/compat/util/stubTrue.spec.ts b/src/compat/util/stubTrue.spec.ts new file mode 100644 index 00000000..5697cbad --- /dev/null +++ b/src/compat/util/stubTrue.spec.ts @@ -0,0 +1,8 @@ +import { describe, expect, it } from 'vitest'; +import { stubTrue } from './stubTrue'; + +describe('stubTrue', () => { + it('should return `true`', () => { + expect(stubTrue()).toEqual(true); + }); +}); diff --git a/src/compat/util/stubTrue.ts b/src/compat/util/stubTrue.ts new file mode 100644 index 00000000..40bd50ce --- /dev/null +++ b/src/compat/util/stubTrue.ts @@ -0,0 +1,10 @@ +/** + * Returns true. + * + * @returns {boolean} true. + * @example + * stubTrue() // Returns true + */ +export function stubTrue(): true { + return true; +} diff --git a/src/compat/util/times.spec.ts b/src/compat/util/times.spec.ts index 3aa5299d..7a893a8b 100644 --- a/src/compat/util/times.spec.ts +++ b/src/compat/util/times.spec.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from 'vitest'; +import { stubArray } from './stubArray'; import { times } from './times'; import { doubled } from '../_internal/doubled'; import { falsey } from '../_internal/falsey'; import { slice } from '../_internal/slice'; -import { stubArray } from '../_internal/stubArray'; describe('times', () => { it('should coerce non-finite `n` values to `0`', () => { diff --git a/src/compat/util/toString.spec.ts b/src/compat/util/toString.spec.ts index 13a3fe9c..93a1fd82 100644 --- a/src/compat/util/toString.spec.ts +++ b/src/compat/util/toString.spec.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; +import { stubString } from './stubString'; import { toString } from './toString'; -import { stubString } from '../_internal/stubString'; import { symbol } from '../_internal/symbol'; describe('toString', () => { diff --git a/src/predicate/isEqualWith.spec.ts b/src/predicate/isEqualWith.spec.ts index 94775730..92912960 100644 --- a/src/predicate/isEqualWith.spec.ts +++ b/src/predicate/isEqualWith.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'; import { isEqualWith } from './isEqualWith'; import { args } from '../compat/_internal/args'; import { arrayViews } from '../compat/_internal/arrayViews'; -import { stubFalse } from '../compat/_internal/stubFalse'; +import { stubFalse } from '../compat/util/stubFalse'; import { noop } from '../function'; describe('isEqualWith', () => { @@ -667,7 +667,18 @@ describe('isEqualWith', () => { expect(isEqualWith(/x/gi, /x/g, 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', () => {