Add array-find-index (#9151)

This commit is contained in:
Sam Verschueren
2016-05-02 00:52:48 +09:00
committed by Masahiro Wakame
parent 7b7b8af73b
commit 3063f61d0e
2 changed files with 23 additions and 0 deletions
@@ -0,0 +1,10 @@
/// <reference path="./array-find-index.d.ts" />
import * as arrayFindIndex from 'array-find-index';
arrayFindIndex(['rainbow', 'unicorn', 'pony'], x => x === 'unicorn');
const ctx = {foo: 'rainbow'};
arrayFindIndex(['rainbow', 'unicorn', 'pony'], function (x) {
return x === this.foo;
}, ctx);
+13
View File
@@ -0,0 +1,13 @@
// Type definitions for array-find-index
// Project: https://github.com/sindresorhus/array-find-index
// Definitions by: Sam Verschueren <https://github.com/samverschueren>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "array-find-index" {
type Predicate = (element: any, index: number, array: any[]) => boolean;
function arrayFindIndex(arr: any[], predicate: Predicate): number;
function arrayFindIndex(arr: any[], predicate: Predicate, ctx: any): number;
namespace arrayFindIndex {}
export = arrayFindIndex;
}