kingjs/linq.select
@Generates a sequence of elements composed of elements of another sequence subject to a transform.
Usage
Lower the case of 'A'
, 'B'
, 'C'
like this:
var select = require('@kingjs/linq.select');
var sequence = require('@kingjs/enumerable.create');
var toArray = require('@kingjs/linq.to-array');
function selectLowerCase(x) {
return String.prototype.toLowerCase.call(x);
}
var result = select.call(sequence('A', 'B', 'C'), selectLowerCase);
toArray.call(result);
result:
['a', 'b', 'c']
API
function select(
this: Enumerable,
selector: (x, i) => any
): Enumerable
Interfaces
-
Enumerable
: See @kingjs/enumerable.define.
Parameters
-
this
: A sequence of element to transform. -
selector
: A transform applied to each element.-
x
: The element to transform. -
i
: The index of the element being transformed.
-
Return Value
A transformation of each element of the original sequence.
Install
With npm installed, run
$ npm install @kingjs/link.select
Acknowledgments
Like Enumerable.Select
License
MIT