@naturalcycles/js-lib 14.240.0 → 14.241.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -120,6 +120,18 @@ export declare function _takeWhile<T>(items: readonly T[], predicate: Predicate<
120
120
  export declare function _takeRightWhile<T>(items: readonly T[], predicate: Predicate<T>): T[];
121
121
  export declare function _dropWhile<T>(items: readonly T[], predicate: Predicate<T>): T[];
122
122
  export declare function _dropRightWhile<T>(items: readonly T[], predicate: Predicate<T>): T[];
123
+ /**
124
+ * Returns true if the _count >= limit.
125
+ * _count counts how many times the Predicate returns true, and stops
126
+ * when it reaches the limit.
127
+ */
128
+ export declare function _countAtLeast<T>(items: Iterable<T>, predicate: AbortablePredicate<T>, limit: number): boolean;
129
+ /**
130
+ * Returns true if the _count <> limit.
131
+ * _count counts how many times the Predicate returns true, and stops
132
+ * when it reaches the limit.
133
+ */
134
+ export declare function _countLessThan<T>(items: Iterable<T>, predicate: AbortablePredicate<T>, limit: number): boolean;
123
135
  /**
124
136
  * Counts how many items match the predicate.
125
137
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._zip = exports._minByOrUndefined = exports._maxByOrUndefined = exports._minBy = exports._maxBy = exports._max = exports._maxOrUndefined = exports._min = exports._minOrUndefined = exports._first = exports._lastOrUndefined = exports._last = exports._shuffle = exports._mapToObject = exports._sumBy = exports._sum = exports._difference = exports._intersectsWith = exports._intersection = exports._countBy = exports._count = exports._dropRightWhile = exports._dropWhile = exports._takeRightWhile = exports._takeWhile = exports._findLast = exports._find = exports._sortDescBy = exports._sortBy = exports._groupBy = exports._mapBy = exports._by = exports._uniqBy = exports._pushUniqBy = exports._pushUniq = exports._uniq = exports._chunk = void 0;
3
+ exports._zip = exports._minByOrUndefined = exports._maxByOrUndefined = exports._minBy = exports._maxBy = exports._max = exports._maxOrUndefined = exports._min = exports._minOrUndefined = exports._first = exports._lastOrUndefined = exports._last = exports._shuffle = exports._mapToObject = exports._sumBy = exports._sum = exports._difference = exports._intersectsWith = exports._intersection = exports._countBy = exports._count = exports._countLessThan = exports._countAtLeast = exports._dropRightWhile = exports._dropWhile = exports._takeRightWhile = exports._takeWhile = exports._findLast = exports._find = exports._sortDescBy = exports._sortBy = exports._groupBy = exports._mapBy = exports._by = exports._uniqBy = exports._pushUniqBy = exports._pushUniq = exports._uniq = exports._chunk = void 0;
4
4
  const is_util_1 = require("../is.util");
5
5
  const types_1 = require("../types");
6
6
  /**
@@ -220,6 +220,24 @@ function _dropRightWhile(items, predicate) {
220
220
  .reverse();
221
221
  }
222
222
  exports._dropRightWhile = _dropRightWhile;
223
+ /**
224
+ * Returns true if the _count >= limit.
225
+ * _count counts how many times the Predicate returns true, and stops
226
+ * when it reaches the limit.
227
+ */
228
+ function _countAtLeast(items, predicate, limit) {
229
+ return _count(items, predicate, limit) >= limit;
230
+ }
231
+ exports._countAtLeast = _countAtLeast;
232
+ /**
233
+ * Returns true if the _count <> limit.
234
+ * _count counts how many times the Predicate returns true, and stops
235
+ * when it reaches the limit.
236
+ */
237
+ function _countLessThan(items, predicate, limit) {
238
+ return _count(items, predicate, limit) < limit;
239
+ }
240
+ exports._countLessThan = _countLessThan;
223
241
  /**
224
242
  * Counts how many items match the predicate.
225
243
  *
@@ -201,6 +201,22 @@ export function _dropRightWhile(items, predicate) {
201
201
  .filter((v, index) => (proceed || (proceed = !predicate(v, index))))
202
202
  .reverse();
203
203
  }
204
+ /**
205
+ * Returns true if the _count >= limit.
206
+ * _count counts how many times the Predicate returns true, and stops
207
+ * when it reaches the limit.
208
+ */
209
+ export function _countAtLeast(items, predicate, limit) {
210
+ return _count(items, predicate, limit) >= limit;
211
+ }
212
+ /**
213
+ * Returns true if the _count <> limit.
214
+ * _count counts how many times the Predicate returns true, and stops
215
+ * when it reaches the limit.
216
+ */
217
+ export function _countLessThan(items, predicate, limit) {
218
+ return _count(items, predicate, limit) < limit;
219
+ }
204
220
  /**
205
221
  * Counts how many items match the predicate.
206
222
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.240.0",
3
+ "version": "14.241.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -241,6 +241,32 @@ export function _dropRightWhile<T>(items: readonly T[], predicate: Predicate<T>)
241
241
  .reverse()
242
242
  }
243
243
 
244
+ /**
245
+ * Returns true if the _count >= limit.
246
+ * _count counts how many times the Predicate returns true, and stops
247
+ * when it reaches the limit.
248
+ */
249
+ export function _countAtLeast<T>(
250
+ items: Iterable<T>,
251
+ predicate: AbortablePredicate<T>,
252
+ limit: number,
253
+ ): boolean {
254
+ return _count(items, predicate, limit) >= limit
255
+ }
256
+
257
+ /**
258
+ * Returns true if the _count <> limit.
259
+ * _count counts how many times the Predicate returns true, and stops
260
+ * when it reaches the limit.
261
+ */
262
+ export function _countLessThan<T>(
263
+ items: Iterable<T>,
264
+ predicate: AbortablePredicate<T>,
265
+ limit: number,
266
+ ): boolean {
267
+ return _count(items, predicate, limit) < limit
268
+ }
269
+
244
270
  /**
245
271
  * Counts how many items match the predicate.
246
272
  *