mirror of
https://github.com/toss/es-toolkit.git
synced 2024-12-26 17:34:35 +03:00
feat: Add stub methods
This commit is contained in:
parent
917aff0110
commit
537e8a42a8
25
docs/ja/reference/compat/util/stubArray.md
Normal file
25
docs/ja/reference/compat/util/stubArray.md
Normal 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 []
|
||||
```
|
25
docs/ja/reference/compat/util/stubFalse.md
Normal file
25
docs/ja/reference/compat/util/stubFalse.md
Normal 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
|
||||
```
|
25
docs/ja/reference/compat/util/stubObject.md
Normal file
25
docs/ja/reference/compat/util/stubObject.md
Normal 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 {}
|
||||
```
|
25
docs/ja/reference/compat/util/stubString.md
Normal file
25
docs/ja/reference/compat/util/stubString.md
Normal 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 ''
|
||||
```
|
25
docs/ja/reference/compat/util/stubTrue.md
Normal file
25
docs/ja/reference/compat/util/stubTrue.md
Normal 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
|
||||
```
|
25
docs/ko/reference/compat/util/stubArray.md
Normal file
25
docs/ko/reference/compat/util/stubArray.md
Normal file
@ -0,0 +1,25 @@
|
||||
# stubArray
|
||||
|
||||
::: info
|
||||
이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요.
|
||||
|
||||
`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요.
|
||||
:::
|
||||
|
||||
새로운 빈 배열을 반환해요.
|
||||
|
||||
## 인터페이스
|
||||
|
||||
```typescript
|
||||
function stubArray(): [];
|
||||
```
|
||||
|
||||
### 반환 값
|
||||
|
||||
(`[]`): 새로운 빈 배열.
|
||||
|
||||
## 예시
|
||||
|
||||
```typescript
|
||||
stubArray(); // Returns []
|
||||
```
|
25
docs/ko/reference/compat/util/stubFalse.md
Normal file
25
docs/ko/reference/compat/util/stubFalse.md
Normal 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
|
||||
```
|
25
docs/ko/reference/compat/util/stubObject.md
Normal file
25
docs/ko/reference/compat/util/stubObject.md
Normal file
@ -0,0 +1,25 @@
|
||||
# stubObject
|
||||
|
||||
::: info
|
||||
이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요.
|
||||
|
||||
`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요.
|
||||
:::
|
||||
|
||||
빈 객체를 반환해요.
|
||||
|
||||
## 인터페이스
|
||||
|
||||
```typescript
|
||||
function stubObject(): {};
|
||||
```
|
||||
|
||||
### 반환 값
|
||||
|
||||
(`{}`): 빈 객체.
|
||||
|
||||
## 예시
|
||||
|
||||
```typescript
|
||||
stubObject(); // Returns {}
|
||||
```
|
25
docs/ko/reference/compat/util/stubString.md
Normal file
25
docs/ko/reference/compat/util/stubString.md
Normal file
@ -0,0 +1,25 @@
|
||||
# stubString
|
||||
|
||||
::: info
|
||||
이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요.
|
||||
|
||||
`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요.
|
||||
:::
|
||||
|
||||
빈 문자열을 반환해요.
|
||||
|
||||
## 인터페이스
|
||||
|
||||
```typescript
|
||||
function stubString(): '';
|
||||
```
|
||||
|
||||
### 반환 값
|
||||
|
||||
(`''`): 빈 문자열.
|
||||
|
||||
## 예시
|
||||
|
||||
```typescript
|
||||
stubString(); // Returns ''
|
||||
```
|
25
docs/ko/reference/compat/util/stubTrue.md
Normal file
25
docs/ko/reference/compat/util/stubTrue.md
Normal 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
|
||||
```
|
25
docs/reference/compat/util/stubArray.md
Normal file
25
docs/reference/compat/util/stubArray.md
Normal 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 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 []
|
||||
```
|
25
docs/reference/compat/util/stubFalse.md
Normal file
25
docs/reference/compat/util/stubFalse.md
Normal 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 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
|
||||
```
|
25
docs/reference/compat/util/stubObject.md
Normal file
25
docs/reference/compat/util/stubObject.md
Normal 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 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 {}
|
||||
```
|
25
docs/reference/compat/util/stubString.md
Normal file
25
docs/reference/compat/util/stubString.md
Normal 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 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 ''
|
||||
```
|
25
docs/reference/compat/util/stubTrue.md
Normal file
25
docs/reference/compat/util/stubTrue.md
Normal 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 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
|
||||
```
|
25
docs/zh_hans/reference/compat/util/stubArray.md
Normal file
25
docs/zh_hans/reference/compat/util/stubArray.md
Normal file
@ -0,0 +1,25 @@
|
||||
# stubArray
|
||||
|
||||
::: info
|
||||
出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API,或者尚未完全优化。
|
||||
|
||||
从 `es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。
|
||||
:::
|
||||
|
||||
返回一个新的空数组。
|
||||
|
||||
## 签名
|
||||
|
||||
```typescript
|
||||
function stubArray(): [];
|
||||
```
|
||||
|
||||
### 返回值
|
||||
|
||||
(`[]`): 一个新的空数组。
|
||||
|
||||
## 示例
|
||||
|
||||
```typescript
|
||||
stubArray(); // Returns []
|
||||
```
|
25
docs/zh_hans/reference/compat/util/stubFalse.md
Normal file
25
docs/zh_hans/reference/compat/util/stubFalse.md
Normal 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
|
||||
```
|
25
docs/zh_hans/reference/compat/util/stubObject.md
Normal file
25
docs/zh_hans/reference/compat/util/stubObject.md
Normal file
@ -0,0 +1,25 @@
|
||||
# stubObject
|
||||
|
||||
::: info
|
||||
出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API,或者尚未完全优化。
|
||||
|
||||
从 `es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。
|
||||
:::
|
||||
|
||||
返回一个空对象。
|
||||
|
||||
## 签名
|
||||
|
||||
```typescript
|
||||
function stubObject(): {};
|
||||
```
|
||||
|
||||
### 返回值
|
||||
|
||||
(`{}`): 一个空对象。
|
||||
|
||||
## 示例
|
||||
|
||||
```typescript
|
||||
stubObject(); // Returns {}
|
||||
```
|
25
docs/zh_hans/reference/compat/util/stubString.md
Normal file
25
docs/zh_hans/reference/compat/util/stubString.md
Normal file
@ -0,0 +1,25 @@
|
||||
# stubString
|
||||
|
||||
::: info
|
||||
出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API,或者尚未完全优化。
|
||||
|
||||
从 `es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。
|
||||
:::
|
||||
|
||||
返回空字符串。
|
||||
|
||||
## 签名
|
||||
|
||||
```typescript
|
||||
function stubString(): '';
|
||||
```
|
||||
|
||||
### 返回值
|
||||
|
||||
(`''`): 空字符串。
|
||||
|
||||
## 示例
|
||||
|
||||
```typescript
|
||||
stubString(); // Returns ''
|
||||
```
|
25
docs/zh_hans/reference/compat/util/stubTrue.md
Normal file
25
docs/zh_hans/reference/compat/util/stubTrue.md
Normal 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
|
||||
```
|
@ -1,3 +0,0 @@
|
||||
export function stubArray() {
|
||||
return [];
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
export const stubFalse = function () {
|
||||
return false;
|
||||
};
|
@ -1,3 +0,0 @@
|
||||
export function stubString(): string {
|
||||
return '';
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
export const stubTrue = function () {
|
||||
return true;
|
||||
};
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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 = {
|
||||
|
@ -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';
|
||||
|
@ -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`', () => {
|
||||
|
@ -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 });
|
||||
|
@ -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', () => {
|
||||
|
@ -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`, () => {
|
||||
|
@ -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;
|
||||
|
@ -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`', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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';
|
||||
|
||||
|
8
src/compat/util/stubArray.spec.ts
Normal file
8
src/compat/util/stubArray.spec.ts
Normal 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([]);
|
||||
});
|
||||
});
|
10
src/compat/util/stubArray.ts
Normal file
10
src/compat/util/stubArray.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Returns a new empty array.
|
||||
*
|
||||
* @returns {Array} A new empty array.
|
||||
* @example
|
||||
* stubArray() // Returns []
|
||||
*/
|
||||
export function stubArray(): [] {
|
||||
return [];
|
||||
}
|
8
src/compat/util/stubFalse.spec.ts
Normal file
8
src/compat/util/stubFalse.spec.ts
Normal 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);
|
||||
});
|
||||
});
|
10
src/compat/util/stubFalse.ts
Normal file
10
src/compat/util/stubFalse.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Returns false.
|
||||
*
|
||||
* @returns {boolean} false.
|
||||
* @example
|
||||
* stubFalse() // Returns false
|
||||
*/
|
||||
export function stubFalse(): false {
|
||||
return false;
|
||||
}
|
8
src/compat/util/stubObject.spec.ts
Normal file
8
src/compat/util/stubObject.spec.ts
Normal 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({});
|
||||
});
|
||||
});
|
10
src/compat/util/stubObject.ts
Normal file
10
src/compat/util/stubObject.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Returns an empty object.
|
||||
*
|
||||
* @returns {Object} An empty object.
|
||||
* @example
|
||||
* stubObject() // Returns {}
|
||||
*/
|
||||
export function stubObject(): {} {
|
||||
return {};
|
||||
}
|
8
src/compat/util/stubString.spec.ts
Normal file
8
src/compat/util/stubString.spec.ts
Normal 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('');
|
||||
});
|
||||
});
|
10
src/compat/util/stubString.ts
Normal file
10
src/compat/util/stubString.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Returns an empty string.
|
||||
*
|
||||
* @returns {string} An empty string.
|
||||
* @example
|
||||
* stubString() // Returns ''
|
||||
*/
|
||||
export function stubString(): '' {
|
||||
return '';
|
||||
}
|
8
src/compat/util/stubTrue.spec.ts
Normal file
8
src/compat/util/stubTrue.spec.ts
Normal 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);
|
||||
});
|
||||
});
|
10
src/compat/util/stubTrue.ts
Normal file
10
src/compat/util/stubTrue.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Returns true.
|
||||
*
|
||||
* @returns {boolean} true.
|
||||
* @example
|
||||
* stubTrue() // Returns true
|
||||
*/
|
||||
export function stubTrue(): true {
|
||||
return true;
|
||||
}
|
@ -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`', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user