Skip to content

Commit

Permalink
add eqStrict, closes #965
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Feb 13, 2020
1 parent 69f9067 commit 7937019
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -23,6 +23,8 @@ high state of flux, you're at risk of it changing without notice.
- add `ReadonlyMap` module (@gcanti)
- add `ReadonlyRecord` module (@gcanti)
- add `ReadonlyTuple` module (@gcanti)
- `Eq`
- add `eqStrict`, closes #965 (@gcanti)
- `NonEmptyArray`
- add `fold` (@vicrac)
- `Semigroup`
Expand Down
17 changes: 15 additions & 2 deletions docs/modules/Eq.ts.md
Expand Up @@ -28,11 +28,12 @@ Added in v2.0.0
- [eqBoolean](#eqboolean)
- [eqDate](#eqdate)
- [eqNumber](#eqnumber)
- [eqStrict](#eqstrict)
- [eqString](#eqstring)
- [fromEquals](#fromequals)
- [getStructEq](#getstructeq)
- [getTupleEq](#gettupleeq)
- [strictEqual](#strictequal)
- [~~strictEqual~~](#strictequal)

---

Expand Down Expand Up @@ -118,6 +119,16 @@ export const eqNumber: Eq<number> = ...

Added in v2.0.0

# eqStrict

**Signature**

```ts
export const eqStrict: Eq<unknown> = ...
```

Added in v2.5.0

# eqString

**Signature**
Expand Down Expand Up @@ -174,7 +185,9 @@ assert.strictEqual(E.equals(['a', 1, true], ['a', 1, false]), false)

Added in v2.0.0

# strictEqual
# ~~strictEqual~~

Use `eqStrict` instead

**Signature**

Expand Down
13 changes: 11 additions & 2 deletions src/Eq.ts
Expand Up @@ -46,14 +46,23 @@ export function fromEquals<A>(equals: (x: A, y: A) => boolean): Eq<A> {
}

/**
* @since 2.5.0
*/
export const eqStrict: Eq<unknown> = {
// tslint:disable-next-line: deprecation
equals: strictEqual
}

/**
* Use `eqStrict` instead
*
* @since 2.0.0
* @deprecated
*/
export function strictEqual<A>(a: A, b: A): boolean {
return a === b
}

const eqStrict = { equals: strictEqual }

/**
* @since 2.0.0
*/
Expand Down
7 changes: 6 additions & 1 deletion test/Eq.ts
@@ -1,5 +1,5 @@
import * as assert from 'assert'
import { eq, eqDate, eqNumber, eqString, fromEquals, getTupleEq, eqBoolean, getStructEq } from '../src/Eq'
import { eq, eqDate, eqNumber, eqString, fromEquals, getTupleEq, eqBoolean, getStructEq, eqStrict } from '../src/Eq'

describe('Eq', () => {
it('getTupleEq', () => {
Expand Down Expand Up @@ -54,4 +54,9 @@ describe('Eq', () => {
assert.deepStrictEqual(S.equals({ name: 'a', age: 1 }, { name: 'a', age: 2 }), false)
assert.deepStrictEqual(S.equals({ name: 'a', age: 1 }, { name: 'b', age: 1 }), false)
})

it('eqStrict', () => {
assert.deepStrictEqual(eqStrict.equals(1, 1), true)
assert.deepStrictEqual(eqStrict.equals(1, 'a'), false)
})
})

0 comments on commit 7937019

Please sign in to comment.