-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat@important deprecate contains in favour of includes
- Loading branch information
1 parent
5b77179
commit d916411
Showing
8 changed files
with
36 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,7 @@ https://unpkg.com/[email protected]/dist/rambda.umd.js | |
|
||
- Rambda's **partialCurry** is not part of Ramda API. | ||
|
||
- Rambda's **includes** acts as curried Javascript `includes`, while **Ramda** version uses `R.equals` to check if a list contains certain value. Also **Ramda** version will throw an error if input is neither `string` nor `array`, while **Rambda** version will return `false`. | ||
- Ramda's **includes** will throw an error if input is neither `string` nor `array`, while **Rambda** version will return `false`. | ||
|
||
> If you need more **Ramda** methods in **Rambda**, you may either submit a `PR` or check the extended version of **Rambda** - [Rambdax](https://github.com/selfrefactor/rambdax). In case of the former, you may want to consult with [Rambda contribution guidelines.](CONTRIBUTING.md) | ||
|
@@ -322,21 +322,6 @@ R.concat('foo')('bar') // => 'foobar' | |
|
||
[Source](https://github.com/selfrefactor/rambda/tree/master/src/concat.js) | ||
|
||
#### contains | ||
|
||
> contains(valueToFind: T, arr: T[]): boolean | ||
It returns `true`, if `valueToFind` is part of `arr`. | ||
|
||
Note that while new versions of `Ramda` depricate this method, `contains` will remain in this library. | ||
|
||
``` | ||
R.contains(2, [1, 2]) // => true | ||
R.contains(3, [1, 2]) // => false | ||
``` | ||
|
||
[Source](https://github.com/selfrefactor/rambda/tree/master/src/contains.js) | ||
|
||
#### curry | ||
|
||
> curry(fn: Function): Function | ||
|
@@ -736,19 +721,16 @@ R.inc(1) // => 2 | |
|
||
#### includes | ||
|
||
If `input` is neither `string` nor `array`, then this method will return `false`. | ||
> includes(valueToFind: T|string, input: T[]|string): boolean | ||
> includes(target: any, input: any): boolean | ||
If `input` is string, then this method work as native `includes`. | ||
If `input` is array, then `R.equals` is used to define if `valueToFind` belongs to the list. | ||
|
||
``` | ||
R.includes(1, [1, 2]) // => true | ||
R.includes('oo', 'foo') // => true | ||
R.includes('z', 'foo') // => false | ||
R.includes('z', null) // => false | ||
R.includes({a: 1}, [{a: 1}]) // => true | ||
``` | ||
|
||
!! Note that this method is not part of `Ramda` API. | ||
|
||
[Source](https://github.com/selfrefactor/rambda/tree/master/src/includes.js) | ||
|
||
#### indexBy | ||
|
@@ -1709,6 +1691,8 @@ import omit from 'rambda/lib/omit' | |
## Changelog | ||
|
||
- 3.0.0 Deprecate `R.contains`, while `R.includes` is now following Ramda API(it uses `R.equals` for comparision) | ||
|
||
- 2.14.5 `R.without` needs currying | ||
|
||
- 2.14.4 Close [issue #227](https://github.com/selfrefactor/rambda/issues/227) - add index as third argument of `R.reduce` typings | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import { includes } from './includes' | ||
import R from 'ramda' | ||
|
||
test('includes with string', () => { | ||
const str = 'more is less' | ||
|
||
expect(includes('less')(str)).toBeTruthy() | ||
|
||
expect(R.includes('less')(str)).toBeTruthy() | ||
expect(includes('never', str)).toBeFalsy() | ||
expect(R.includes('never', str)).toBeFalsy() | ||
}) | ||
|
||
test('includes with array', () => { | ||
const arr = [ 1, 2, 3 ] | ||
|
||
expect(includes(2)(arr)).toBeTruthy() | ||
expect(R.includes(2)(arr)).toBeTruthy() | ||
|
||
expect(includes(4, arr)).toBeFalsy() | ||
expect(R.includes(4, arr)).toBeFalsy() | ||
}) | ||
|
||
test('return false if input is falsy', () => { | ||
expect(includes(2, null)).toBeFalsy() | ||
expect(() => R.includes(2, null)).toThrow() | ||
expect(includes(4, undefined)).toBeFalsy() | ||
expect(() => R.includes(4, undefined)).toThrow() | ||
}) |