value-index-pair-interface

1.0.1 • Public • Published

To include in your project:

import { IValueIndexPair } from 'value-index-pair-interface/IValueIndexPair';

This is an interface for an object representing a single array item:

export interface IValueIndexPair {
    value: any;
    index: number; // integer
}

Usage Example:

You need to extract some items from an array. But not only do you need the values,
you need their indexes too, so you write this function, specifying that it returns
an array of IValueIndexPairs:

function getValueAndIndex(  
    testFunction(item, index?, array?) => boolean,  
    array  
): IValueIndexPair[]

This lets everyone know it will return an array looking something like this:

[
	{value: 'some text', index: 5},  
	{value: 10, index: 15},  
	{value: false, index: 33}  
	...more items...
]

Package Sidebar

Install

npm i value-index-pair-interface

Weekly Downloads

1

Version

1.0.1

License

FREE

Unpacked Size

1.61 kB

Total Files

5

Last publish

Collaborators

  • writetome51