1.0.6 • Published 6 years ago

@kingjs/linq.count v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@kingjs/linq.count

Returns the number of elements in a sequence that satisfy a condition.

Usage

Count the number of elements in sequence 1, 2, 3 like this:

var count = require('@kingjs/linq.count');
var sequence = require('@kingjs/enumerable.create');

count.call(sequence(1, 2, 3));

result:

3

Count the number of odd numbers in sequence 1, 2, 3 like this:

var count = require('@kingjs/linq.count');
var sequence = require('@kingjs/enumerable.create');

var isOdd = function(o) { return o % 2 == 1; }

count.call(sequence(1, 2, 3), isOdd);

result:

2

API

declare function count(
    this: Enumerable,
    predicate?: (x) => boolean
): number

Interfaces

Parameters

  • this: The sequence to count values matching predicate.
  • predicate: To be counted, values must match this predicate.

Return Value

Returns the number of values that satisfy the predicate.

Remarks

By default, the predicate is satisfied by any value.

Install

With npm installed, run

$ npm install @kingjs/linq.count

Acknowledgments

Like Enumerable.Count.

License

MIT

Analytics

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago