@naturalcycles/js-lib 14.211.0 → 14.212.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.
|
@@ -176,6 +176,11 @@ export declare function _last<T>(array: T[]): T;
|
|
|
176
176
|
* Returns last item of the array (or undefined if array is empty).
|
|
177
177
|
*/
|
|
178
178
|
export declare function _lastOrUndefined<T>(array: T[]): T | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* Returns the first item of non-empty array.
|
|
181
|
+
* Throws if array is empty.
|
|
182
|
+
*/
|
|
183
|
+
export declare function _first<T>(array: T[]): T;
|
|
179
184
|
export declare function _minOrUndefined<T>(array: T[]): NonNullable<T> | undefined;
|
|
180
185
|
/**
|
|
181
186
|
* Filters out nullish values (undefined and null).
|
package/dist/array/array.util.js
CHANGED
|
@@ -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._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._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._dropRightWhile = exports._dropWhile = exports._takeRightWhile = exports._takeWhile = exports._findLast = 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
|
/**
|
|
@@ -333,6 +333,16 @@ function _lastOrUndefined(array) {
|
|
|
333
333
|
return array[array.length - 1];
|
|
334
334
|
}
|
|
335
335
|
exports._lastOrUndefined = _lastOrUndefined;
|
|
336
|
+
/**
|
|
337
|
+
* Returns the first item of non-empty array.
|
|
338
|
+
* Throws if array is empty.
|
|
339
|
+
*/
|
|
340
|
+
function _first(array) {
|
|
341
|
+
if (!array.length)
|
|
342
|
+
throw new Error('_first called on empty array');
|
|
343
|
+
return array[0];
|
|
344
|
+
}
|
|
345
|
+
exports._first = _first;
|
|
336
346
|
function _minOrUndefined(array) {
|
|
337
347
|
const a = array.filter(is_util_1._isNotNullish);
|
|
338
348
|
if (!a.length)
|
|
@@ -304,6 +304,15 @@ export function _last(array) {
|
|
|
304
304
|
export function _lastOrUndefined(array) {
|
|
305
305
|
return array[array.length - 1];
|
|
306
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Returns the first item of non-empty array.
|
|
309
|
+
* Throws if array is empty.
|
|
310
|
+
*/
|
|
311
|
+
export function _first(array) {
|
|
312
|
+
if (!array.length)
|
|
313
|
+
throw new Error('_first called on empty array');
|
|
314
|
+
return array[0];
|
|
315
|
+
}
|
|
307
316
|
export function _minOrUndefined(array) {
|
|
308
317
|
const a = array.filter(_isNotNullish);
|
|
309
318
|
if (!a.length)
|
package/package.json
CHANGED
package/src/array/array.util.ts
CHANGED
|
@@ -365,6 +365,15 @@ export function _lastOrUndefined<T>(array: T[]): T | undefined {
|
|
|
365
365
|
return array[array.length - 1]
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Returns the first item of non-empty array.
|
|
370
|
+
* Throws if array is empty.
|
|
371
|
+
*/
|
|
372
|
+
export function _first<T>(array: T[]): T {
|
|
373
|
+
if (!array.length) throw new Error('_first called on empty array')
|
|
374
|
+
return array[0]!
|
|
375
|
+
}
|
|
376
|
+
|
|
368
377
|
export function _minOrUndefined<T>(array: T[]): NonNullable<T> | undefined {
|
|
369
378
|
const a = array.filter(_isNotNullish)
|
|
370
379
|
if (!a.length) return
|