@clipboard-health/util-ts 4.7.12 → 4.8.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@clipboard-health/util-ts",
3
3
  "description": "TypeScript utilities.",
4
- "version": "4.7.12",
4
+ "version": "4.8.0",
5
5
  "bugs": "https://github.com/ClipboardHealth/core-utils/issues",
6
6
  "dependencies": {
7
7
  "tslib": "2.8.1"
@@ -1,4 +1,5 @@
1
1
  export * from "./chunk";
2
2
  export * from "./forEachAsyncSequentially";
3
3
  export * from "./head";
4
+ export * from "./isNonEmptyArray";
4
5
  export * from "./nonEmptyArray";
@@ -4,5 +4,6 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./chunk"), exports);
5
5
  tslib_1.__exportStar(require("./forEachAsyncSequentially"), exports);
6
6
  tslib_1.__exportStar(require("./head"), exports);
7
+ tslib_1.__exportStar(require("./isNonEmptyArray"), exports);
7
8
  tslib_1.__exportStar(require("./nonEmptyArray"), exports);
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util-ts/src/lib/arrays/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,qEAA2C;AAC3C,iDAAuB;AACvB,0DAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util-ts/src/lib/arrays/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,qEAA2C;AAC3C,iDAAuB;AACvB,4DAAkC;AAClC,0DAAgC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Type guard that narrows an array to a non-empty tuple type.
3
+ * After this check, TypeScript knows `arr[0]` is defined.
4
+ *
5
+ * @example
6
+ * if (!isNonEmptyArray(items)) {
7
+ * return;
8
+ * }
9
+ * // items[0] is now typed as T (not T | undefined)
10
+ * const first = items[0];
11
+ */
12
+ export declare function isNonEmptyArray<T>(array: T[]): array is [T, ...T[]];
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNonEmptyArray = isNonEmptyArray;
4
+ /**
5
+ * Type guard that narrows an array to a non-empty tuple type.
6
+ * After this check, TypeScript knows `arr[0]` is defined.
7
+ *
8
+ * @example
9
+ * if (!isNonEmptyArray(items)) {
10
+ * return;
11
+ * }
12
+ * // items[0] is now typed as T (not T | undefined)
13
+ * const first = items[0];
14
+ */
15
+ function isNonEmptyArray(array) {
16
+ return array.length > 0;
17
+ }
18
+ //# sourceMappingURL=isNonEmptyArray.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNonEmptyArray.js","sourceRoot":"","sources":["../../../../../../packages/util-ts/src/lib/arrays/isNonEmptyArray.ts"],"names":[],"mappings":";;AAWA,0CAEC;AAbD;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAAI,KAAU;IAC3C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAC1B,CAAC"}