type for includes

This commit is contained in:
johno
2018-12-13 11:04:02 -06:00
parent ad5afdf536
commit dc372e548b
3 changed files with 14 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
import { includes } from '../index';
export default includes;
+7
View File
@@ -269,6 +269,7 @@
/// <reference path="./es/zip.d.ts" />
/// <reference path="./es/zipObj.d.ts" />
/// <reference path="./es/zipWith.d.ts" />
/// <reference path="./es/includes.d.ts" />
declare let R: R.Static;
@@ -1129,6 +1130,12 @@ declare namespace R {
*/
inc(n: number): number;
/**
* Given a target, this function checks a list for a target and returns a boolean.
*/
includes<T>(target: T, list: ReadonlyArray<T>): boolean;
includes<T>(target: T): (list: ReadonlyArray<T>) => boolean;
/**
* Given a function that generates a key, turns a list of objects into an object indexing the objects
* by the given key.
+5
View File
@@ -971,6 +971,11 @@ interface Obj {
)(list);
});
() => {
R.includes(8, [1, 8]); // => true
R.includes(10)([1, 2, 3, 4]); // => false
};
() => {
R.indexOf(3, [1, 2, 3, 4]); // => 2
R.indexOf(10)([1, 2, 3, 4]); // => -1