Skip to content

Commit

Permalink
🐛 Fix name of isNill to isNil
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed May 7, 2021
1 parent bb0c941 commit 7885d81
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 41 deletions.
191 changes: 150 additions & 41 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,50 @@ Version: `Latest`

| Name | Fonction | Rambda | Ramda | Lodash |
| ------ | -------- | ------ | ------ | ------ |
| add |||||
| F |||| |
| K || | | |
| T |||| stubTrue |
| add |||||
| adjust | ||| |
| all | ||| |
| allPass | ||| |
| and |||| |
| any | ||| |
| anyPass | ||| |
| append |||| |
| applySpec | ||| |
| assoc | ||| |
| chunk || | ||
| clone | ||| cloneDeep |
| compose | ||| |
| converge | ||| |
| curry | ||| |
| dec |||| |
| defaultTo |||| |
| divide |||||
| drop | ||||
| dropLast | ||| dropRight |
| endsWith |||||
| F |||| |
| equals | ||| isEqual |
| filter | ||||
| find | ||||
| findIndex | ||||
| first || head | head ||
| flattenDeep || flatten | flatten ||
| gt || | ||
| gte || | ||
| has |||||
| head || init | init | initial |
| identity |||||
| ifElse | ||| |
| inc |||| |
| includes | ||||
| indexOf | ||||
| is | ||| |
| isArray || | ||
| isBigint || | | |
| isBoolean || | ||
| isEmpty |||||
| isFunction || | ||
| isNaN || | ||
| isNil |||||
Expand All @@ -35,66 +62,39 @@ Version: `Latest`
| isString || | ||
| isSymbol || | ||
| isUndefined || | ||
| K || | | |
| keys |||||
| last |||||
| lastIndexOf | ||||
| length |||| |
| lowerCase || toLower | toLower | toLower |
| lt || | ||
| lte || | ||
| map | ||||
| match | ||| |
| merge | ||||
| multiply |||||
| none | ||| |
| not |||| |
| omit | ||||
| or |||| |
| over | ||| |
| path | props ||| get |
| prepend |||| |
| product |||| |
| props || prop | prop | get |
| replace |||||
| replaceAll || | | |
| reverse |||||
| startsWith |||||
| subtract |||||
| sum |||||
| T |||| stubTrue |
| tail |||||
| trim |||||
| trimLeft || | | trimStart |
| trimRight || | | trimEnd |
| upperCase || toUpper | toUpper | toUpper |
| values |||||
| xor |||| |
| subtract |||||
| multiply |||||
| divide |||||
| adjust | ||| |
| all | ||| |
| allPass | ||| |
| any | ||| |
| anyPass | ||| |
| append |||| |
| applySpec | ||| |
| assoc | ||| |
| clone | ||| cloneDeep |
| compose | ||| |
| converge | ||| |
| curry | ||| |
| defaultTo |||| |
| drop | ||||
| dropLast | ||| dropRight |
| equals | ||| isEqual |
| filter | ||||
| find | ||||
| findIndex | ||||
| ifElse | ||| |
| includes | ||||
| indexOf | ||||
| is | ||| |
| isEmpty |||||
| last |||||
| lastIndexOf | ||||
| map | ||||
| match | ||| |
| merge | ||||
| none | ||| |
| omit | ||||
| over | ||| |
| path | props ||| get |
| replace |||||

</details>

Expand Down Expand Up @@ -2611,6 +2611,111 @@ Deno.test('isNaN', () => {
---
### isNil
Whatever argument is type of `undefined` or `null`.
{.desc}
**Signature:**
```ts
isNil: (val: unknown) => val is null | undefined
```
<details class="parameters-detail">
<summary>Parameters</summary>
| Parameter | Description |
| --------- | ----------- |
| `val` | Input any value |
{.table}
<code class="returns">=></code> The result of type of `val` is `undefined` or `null`
</details>
#### Example
```ts
isNil(undefined) // true
isNil(null) // true
isNil([]) // false
```
<details>
<summary>Tests</summary>
```ts
import { assertEquals } from '../deps.ts'
import { isNil } from '../src/isNil.ts'
import { isSymbol } from '../src/isSymbol.ts'
import {
BIG1,
DATE,
EMPTY_ARRAY,
EMPTY_OBJECT,
EMPTY_STRING,
MAP,
ONE,
SET,
SYMBOL,
VOID_FN,
VOID_PROMISE,
WEAK_MAP,
WEAK_SET,
ZERO
} from './index.ts'

Deno.test('isNil', () => {
const table: [unknown, boolean][] = [
[null, true],
[undefined, true],
[ZERO, false],
[ONE, false],
[EMPTY_STRING, false],
['test', false],
[false, false],
[true, false],
[BIG1, false],
[SYMBOL, false],
[EMPTY_OBJECT, false],
[{ nest: {} }, false],
[EMPTY_ARRAY, false],
[[[]], false],
[MAP, false],
[SET, false],
[WEAK_MAP, false],
[WEAK_SET, false],
[VOID_FN, false],
[VOID_PROMISE, false],
[DATE, false]
]
table.forEach(([val, expected]) => {
assertEquals(
isNil(val),
expected,
`isNil(${isSymbol(val) ? 'symbol' : val}) -> ${expected}`
)
})
})
```
</details>
[View source on GitHub](https://github.com/TomokiMiyauci/fonction/blob/main/src/isNil.ts)
---
### isNill
<small>Added from [1.0.0](./1.0.0/)</small>
Expand All @@ -2620,11 +2725,15 @@ Deno.test('isNaN', () => {
<span class="tag deprecated">deprecate</span>
Whatever argument is type of `undefined` or `null`.
{.desc}
::: danger
This function will remove next major release.
:::
**Signature:**
Expand Down
1 change: 1 addition & 0 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export { isBoolean } from './src/isBoolean.ts'
export { isEmpty } from './src/isEmpty.ts'
export { isFunction } from './src/isFunction.ts'
export { isNaN } from './src/isNaN.ts'
export { isNil } from './src/isNil.ts'
export { isNill } from './src/isNill.ts'
export { isNull } from './src/isNull.ts'
export { isNumber } from './src/isNumber.ts'
Expand Down
39 changes: 39 additions & 0 deletions src/isNil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2021-present the Fonction authors. All rights reserved. MIT license.
import type { IsNull } from './isNull.ts'
import { isNull } from './isNull.ts'
import { IsUndefined, isUndefined } from './isUndefined.ts'
import { or } from './or.ts'
/**
* Undefiled or null, or not.
*
* @typeParam T - Any value
*
* @public
*/
type IsNil<T extends unknown> = IsUndefined<T> extends true
? true
: IsNull<T> extends true
? true
: false

/**
* Whatever argument is type of `undefined` or `null`.
*
* @param val - Input any value
* @returns The result of type of `val` is `undefined` or `null`
*
* @example
* ```ts
* isNil(undefined) // true
* isNil(null) // true
* isNil([]) // false
* ```
*
* @public
*
*/
const isNil = (val: unknown): val is null | undefined =>
or(isUndefined(val), isNull(val))

export { isNil }
export type { IsNil }
5 changes: 5 additions & 0 deletions src/isNill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { or } from './or.ts'
* @typeParam T - Any value
*
* @public
* @deprecated
* This is typo. It will rename to `isNil` next major release.
*/
type IsNill<T extends unknown> = IsUndefined<T> extends true
? true
Expand All @@ -30,6 +32,9 @@ type IsNill<T extends unknown> = IsUndefined<T> extends true
*
* @public
*
* @deprecated
* This is typo. It will rename to `isNil` next major release.
*
*/
const isNill = (val: unknown): val is null | undefined =>
or(isUndefined(val), isNull(val))
Expand Down

0 comments on commit 7885d81

Please sign in to comment.