source: imaps-frontend/node_modules/webpack/lib/util/IterableHelpers.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 958 bytes
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8/**
9 * @template T
10 * @param {Iterable<T>} set a set
11 * @returns {T | undefined} last item
12 */
13const last = set => {
14 let last;
15 for (const item of set) last = item;
16 return last;
17};
18
19/**
20 * @template T
21 * @param {Iterable<T>} iterable iterable
22 * @param {function(T): boolean | null | undefined} filter predicate
23 * @returns {boolean} true, if some items match the filter predicate
24 */
25const someInIterable = (iterable, filter) => {
26 for (const item of iterable) {
27 if (filter(item)) return true;
28 }
29 return false;
30};
31
32/**
33 * @template T
34 * @param {Iterable<T>} iterable an iterable
35 * @returns {number} count of items
36 */
37const countIterable = iterable => {
38 let i = 0;
39 for (const _ of iterable) i++;
40 return i;
41};
42
43module.exports.last = last;
44module.exports.someInIterable = someInIterable;
45module.exports.countIterable = countIterable;
Note: See TracBrowser for help on using the repository browser.