@koine/utils 1.0.91 → 1.0.93

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.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Ensure an array contains all deisred values
3
+ *
4
+ * @category array
5
+ * @borrows [SO comment by `CertainPerformance`](https://stackoverflow.com/a/60132060/1938970)
6
+ *
7
+ * @usage
8
+ *
9
+ * ```
10
+ * import { arrayOfAll } from "@koine/utils";
11
+ *
12
+ * type Fruit = "pear" | "apple" | "orange";
13
+ *
14
+ * const arrayOfAllFruits = arrayOfAll<Fruit>();
15
+ *
16
+ * const allFruits = arrayOfAllFruits([
17
+ * "pear",
18
+ * "apple",
19
+ * "orange"
20
+ * ]); // ts compiler ok
21
+ *
22
+ * const allFruits = arrayOfAllFruits([
23
+ * "pear",
24
+ * "apple",
25
+ * ]); // ts compiler fails
26
+ * ```
27
+ *
28
+ */
29
+ export declare const arrayOfAll: <T>() => <U extends T[]>(array: U & ([T] extends [U[number]] ? unknown : "Invalid")) => U & ([T] extends [U[number]] ? unknown : "Invalid");
30
+ export default arrayOfAll;
package/arrayOfAll.js ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Ensure an array contains all deisred values
3
+ *
4
+ * @category array
5
+ * @borrows [SO comment by `CertainPerformance`](https://stackoverflow.com/a/60132060/1938970)
6
+ *
7
+ * @usage
8
+ *
9
+ * ```
10
+ * import { arrayOfAll } from "@koine/utils";
11
+ *
12
+ * type Fruit = "pear" | "apple" | "orange";
13
+ *
14
+ * const arrayOfAllFruits = arrayOfAll<Fruit>();
15
+ *
16
+ * const allFruits = arrayOfAllFruits([
17
+ * "pear",
18
+ * "apple",
19
+ * "orange"
20
+ * ]); // ts compiler ok
21
+ *
22
+ * const allFruits = arrayOfAllFruits([
23
+ * "pear",
24
+ * "apple",
25
+ * ]); // ts compiler fails
26
+ * ```
27
+ *
28
+ */
29
+ export var arrayOfAll = function () {
30
+ return function (array) {
31
+ return array;
32
+ };
33
+ };
34
+ export default arrayOfAll;
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./accentSets";
2
2
  export * from "./addOrReplaceAtIdx";
3
+ export * from "./arrayOfAll";
3
4
  export * from "./arrayToLookup";
4
5
  export * from "./buildUrlQueryString";
5
6
  export * from "./capitalize";
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./accentSets";
2
2
  export * from "./addOrReplaceAtIdx";
3
+ export * from "./arrayOfAll";
3
4
  export * from "./arrayToLookup";
4
5
  export * from "./buildUrlQueryString";
5
6
  export * from "./capitalize";
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.arrayOfAll = void 0;
4
+ /**
5
+ * Ensure an array contains all deisred values
6
+ *
7
+ * @category array
8
+ * @borrows [SO comment by `CertainPerformance`](https://stackoverflow.com/a/60132060/1938970)
9
+ *
10
+ * @usage
11
+ *
12
+ * ```
13
+ * import { arrayOfAll } from "@koine/utils";
14
+ *
15
+ * type Fruit = "pear" | "apple" | "orange";
16
+ *
17
+ * const arrayOfAllFruits = arrayOfAll<Fruit>();
18
+ *
19
+ * const allFruits = arrayOfAllFruits([
20
+ * "pear",
21
+ * "apple",
22
+ * "orange"
23
+ * ]); // ts compiler ok
24
+ *
25
+ * const allFruits = arrayOfAllFruits([
26
+ * "pear",
27
+ * "apple",
28
+ * ]); // ts compiler fails
29
+ * ```
30
+ *
31
+ */
32
+ var arrayOfAll = function () {
33
+ return function (array) {
34
+ return array;
35
+ };
36
+ };
37
+ exports.arrayOfAll = arrayOfAll;
38
+ exports.default = exports.arrayOfAll;
package/node/index.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./accentSets"), exports);
5
5
  tslib_1.__exportStar(require("./addOrReplaceAtIdx"), exports);
6
+ tslib_1.__exportStar(require("./arrayOfAll"), exports);
6
7
  tslib_1.__exportStar(require("./arrayToLookup"), exports);
7
8
  tslib_1.__exportStar(require("./buildUrlQueryString"), exports);
8
9
  tslib_1.__exportStar(require("./capitalize"), exports);
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "tslib": "^2.4.0"
9
9
  },
10
10
  "peerDependencies": {},
11
- "version": "1.0.91",
11
+ "version": "1.0.93",
12
12
  "module": "./index.js",
13
13
  "types": "./index.d.ts"
14
14
  }