@utiliread/primitives 1.0.0-124 → 1.0.0-125
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/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types/medium.d.ts +3 -0
- package/dist/types/medium.spec.d.ts +1 -0
- package/dist/types/repository.d.ts +1 -0
- package/package.json +1 -1
- package/src/medium.spec.ts +12 -0
- package/src/medium.ts +19 -0
- package/src/repository.spec.ts +9 -0
- package/src/repository.ts +10 -5
- package/asdasd/index.js +0 -2
- package/asdasd/index.js.map +0 -1
package/dist/types/medium.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,6 +2,7 @@ export type Repository = "some/repo";
|
|
|
2
2
|
export declare function Repository(repo: string): Repository;
|
|
3
3
|
export declare function Repository(team: string, name: string): Repository;
|
|
4
4
|
export declare namespace Repository {
|
|
5
|
+
function isRepository(input: string): input is Repository;
|
|
5
6
|
function split(repo: Repository): {
|
|
6
7
|
team: string;
|
|
7
8
|
name: string;
|
package/package.json
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Medium } from "./medium";
|
|
2
|
+
import { expect } from "chai";
|
|
3
|
+
|
|
4
|
+
describe("isMedium", () => {
|
|
5
|
+
it("should correctly determine if input is a medium", () => {
|
|
6
|
+
expect(Medium.isMedium("heat")).to.equal(true);
|
|
7
|
+
expect(Medium.isMedium("water")).to.equal(true);
|
|
8
|
+
expect(Medium.isMedium("heat,water")).to.equal(true);
|
|
9
|
+
expect(Medium.isMedium(["heat","water"])).to.equal(true);
|
|
10
|
+
expect(Medium.isMedium("notamedium")).to.equal(false);
|
|
11
|
+
});
|
|
12
|
+
});
|
package/src/medium.ts
CHANGED
|
@@ -6,3 +6,22 @@ export type Medium =
|
|
|
6
6
|
| "electricity"
|
|
7
7
|
| "infrastructure"
|
|
8
8
|
| "all";
|
|
9
|
+
|
|
10
|
+
export namespace Medium {
|
|
11
|
+
export function isMedium(
|
|
12
|
+
input: string | string[],
|
|
13
|
+
): input is Medium | Medium[] {
|
|
14
|
+
if (input === "none" || input === "all") {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
const parts = Array.isArray(input) ? input : input.split(",");
|
|
18
|
+
const ALL_MEDIUMS: Medium[] = [
|
|
19
|
+
"heat",
|
|
20
|
+
"water",
|
|
21
|
+
"cooling",
|
|
22
|
+
"electricity",
|
|
23
|
+
"infrastructure",
|
|
24
|
+
];
|
|
25
|
+
return !parts.some((x) => !ALL_MEDIUMS.includes(<Medium>x));
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/repository.spec.ts
CHANGED
|
@@ -11,6 +11,15 @@ describe("ctor", () => {
|
|
|
11
11
|
});
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
+
describe("isRepository", () => {
|
|
15
|
+
it("should correctly determine if input is a Repository", () => {
|
|
16
|
+
expect(Repository.isRepository("some/test")).to.equal(true);
|
|
17
|
+
expect(Repository.isRepository("so-me/te-st")).to.equal(true);
|
|
18
|
+
expect(Repository.isRepository("NOT/REPO")).to.equal(false);
|
|
19
|
+
expect(Repository.isRepository("notarepo")).to.equal(false);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
14
23
|
describe("split", () => {
|
|
15
24
|
it("splits into correct parts", () => {
|
|
16
25
|
const { team, name } = Repository.split(Repository("gpkv", "gjoel"));
|
package/src/repository.ts
CHANGED
|
@@ -4,16 +4,21 @@ export type Repository = "some/repo";
|
|
|
4
4
|
export function Repository(repo: string): Repository;
|
|
5
5
|
export function Repository(team: string, name: string): Repository;
|
|
6
6
|
export function Repository(repoOrTeam: string, name?: string): Repository {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} else if (repoOrTeam.indexOf("/") > 0) {
|
|
10
|
-
return <Repository>repoOrTeam;
|
|
11
|
-
} else {
|
|
7
|
+
const repo = name ? `${repoOrTeam}/${name}` : repoOrTeam;
|
|
8
|
+
if (!Repository.isRepository(repo)) {
|
|
12
9
|
throw new TypeError("Invalid repository format");
|
|
13
10
|
}
|
|
11
|
+
return repo;
|
|
14
12
|
}
|
|
15
13
|
|
|
14
|
+
const PART_REGEX = new RegExp(/[a-z][a-z0-9-]*/);
|
|
15
|
+
|
|
16
16
|
export namespace Repository {
|
|
17
|
+
export function isRepository(input: string): input is Repository {
|
|
18
|
+
const parts = input.split("/");
|
|
19
|
+
return parts.length === 2 && !parts.some((x) => !PART_REGEX.test(x));
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
export function split(repo: Repository) {
|
|
18
23
|
const parts = repo.split("/");
|
|
19
24
|
return {
|
package/asdasd/index.js
DELETED
package/asdasd/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"","sources":["src/registers/index.ts"],"sourcesContent":["export * from \"./acoustic-noise\";\nexport * from \"./ambient-temperature\";\nexport * from \"./consumer\";\nexport * from \"./cooling-energy-inlet\";\nexport * from \"./cooling-energy-outlet\";\nexport * from \"./cooling-energy\";\nexport * from \"./cooling\";\nexport * from \"./device-addresses-kamdraft\";\nexport * from \"./device-addresses-msisdn\";\nexport * from \"./device-addresses-tchlr\";\nexport * from \"./device-addresses-wmbus\";\nexport * from \"./device-date-time\";\nexport * from \"./device-date\";\nexport * from \"./device-nominal-diameter\";\nexport * from \"./device-permanent-volume-flow\";\nexport * from \"./device-registers\";\nexport * from \"./device-software-version\";\nexport * from \"./device-time\";\nexport * from \"./device\";\nexport * from \"./diehl-infocode\";\nexport * from \"./electrical-energy\";\nexport * from \"./energy-inlet\";\nexport * from \"./energy-outlet\";\nexport * from \"./error-operating-time\";\nexport * from \"./flow-temperature-aux\";\nexport * from \"./flow-temperature-inlet\";\nexport * from \"./flow-temperature-outlet\";\nexport * from \"./flow-temperature\";\nexport * from \"./heat-energy-inlet\";\nexport * from \"./heat-energy-outlet\";\nexport * from \"./heat-energy\";\nexport * from \"./infocode\";\nexport * from \"./kamstrup-module-type\";\nexport * from \"./kamstrup-multical-infocode\";\nexport * from \"./landis-gyr-infocode\";\nexport * from \"./landis-gyr-mbus-status\";\nexport * from \"./device-samples\";\nexport * from \"./mass-flow-inlet\";\nexport * from \"./mass-flow-outlet\";\nexport * from \"./mass-flow\";\nexport * from \"./mass-inlet\";\nexport * from \"./mass-outlet\";\nexport * from \"./mass\";\nexport * from \"./mbus-format-string-signature\";\nexport * from \"./none\";\nexport * from \"./operating-time\";\nexport * from \"./place\";\nexport * from \"./power-inlet\";\nexport * from \"./power-outlet\";\nexport * from \"./power\";\nexport * from \"./pressure-inlet\";\nexport * from \"./pressure-outlet\";\nexport * from \"./pressure\";\nexport * from \"./radiator-temperature\";\nexport * from \"./reactive-energy\";\nexport * from \"./relative-humidity\";\nexport * from \"./remaining-battery-time\";\nexport * from \"./time-last-exact-overhearing-arrived\";\nexport * from \"./time-last-installation-mounted\";\nexport * from \"./time-last-possible-candidate-overhearing-arrived\";\nexport * from \"./time-last-sampled\";\nexport * from \"./time\";\nexport * from \"./volume-flow-inlet\";\nexport * from \"./volume-flow-outlet\";\nexport * from \"./volume-flow\";\nexport * from \"./volume-inlet\";\nexport * from \"./volume-outlet\";\nexport * from \"./volume-pulse-input-a\";\nexport * from \"./volume-pulse-input-b\";\nexport * from \"./volume\";\n"],"names":[],"version":3,"file":"index.js.map"}
|