@configura/web-utilities 2.0.0-alpha.2 → 2.0.0-alpha.20

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/.eslintrc.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "parser": "@typescript-eslint/parser",
3
+ "plugins": ["@typescript-eslint"],
4
+ "extends": [
5
+ "eslint:recommended",
6
+ "plugin:@typescript-eslint/recommended",
7
+ "prettier"
8
+
9
+ // TODO: Type-checking rules require a proper tsconfig-file to work,
10
+ // pointed at by the parserOption.project setting.
11
+ //
12
+ //"plugin:@typescript-eslint/recommended-requiring-type-checking"
13
+ ]
14
+ //"rules": { "@typescript-eslint/no-floating-promises": "error" }
15
+ //"parserOptions": {
16
+ // "project": "./tsconfig.json"
17
+ //}
18
+ }
@@ -1,7 +1,9 @@
1
1
  import { LogObservable } from "./LogObservable.js";
2
+ function hasLoggerProperty(object) {
3
+ return typeof object === "object" && object !== null && "logger" in object;
4
+ }
5
+ // This has to be possible to do without the helper function and the HasLoggerProperty
6
+ // but can't figure out how right now
2
7
  export function isLogProducer(object) {
3
- return (typeof object === "object" &&
4
- object !== null &&
5
- "logger" in object &&
6
- object.logger instanceof LogObservable);
8
+ return hasLoggerProperty(object) && object.logger instanceof LogObservable;
7
9
  }
@@ -5,7 +5,7 @@ export class Observable {
5
5
  this.listeners.push({ l: listener, c: context });
6
6
  };
7
7
  this.stopListen = (listener) => {
8
- let index = this.listeners.findIndex((l) => l.l === listener);
8
+ const index = this.listeners.findIndex((l) => l.l === listener);
9
9
  if (index !== -1) {
10
10
  this.listeners.splice(index, 1);
11
11
  }
package/dist/assert.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Can for example be used like a type guard in TypeScript.
5
5
  */
6
- export declare function assert(condition: any, msg?: string): asserts condition;
6
+ export declare function assert(condition: unknown, msg?: string): asserts condition;
7
7
  /**
8
8
  * @throws error with the supplied message, if the value === undefined.
9
9
  *
package/dist/filter.js CHANGED
@@ -18,7 +18,7 @@ export function validateFilter(mode, value) {
18
18
  export function match(key, filter, items) {
19
19
  const values = Array.from(new Set(items.map((p) => p[key])));
20
20
  if (filter.mode === "exact") {
21
- let { value } = filter;
21
+ const { value } = filter;
22
22
  let matching = items;
23
23
  if (value !== "-") {
24
24
  matching = items.filter((p) => p[key] === value);
@@ -9,16 +9,17 @@ export const isEqualLength = (l, r) => l.length === convertLength(r.length, r.un
9
9
  * @throws an error if the supplied string isn't a known length unit
10
10
  */
11
11
  export function toLengthUnit(unit) {
12
+ // The list below must EXACTLY match isLengthUnit(string)
12
13
  unit = unit === null || unit === void 0 ? void 0 : unit.toLowerCase();
13
14
  if (unit === "inch") {
14
15
  unit = "in";
15
16
  }
16
- if (unit === "mm" ||
17
+ if (unit === "in" ||
18
+ unit === "ft" ||
19
+ unit === "mm" ||
17
20
  unit === "cm" ||
18
21
  unit === "dm" ||
19
- unit === "m" ||
20
- unit === "in" ||
21
- unit === "ft") {
22
+ unit === "m") {
22
23
  return unit;
23
24
  }
24
25
  throw new Error(`Unknown length unit ${unit}`);
@@ -27,10 +28,15 @@ export function toLengthUnit(unit) {
27
28
  * As we accept inch as an alias for in we can't make this a typeguard
28
29
  */
29
30
  export function isLengthUnit(unit) {
30
- return (metricUnits.find((m) => m === unit) !== undefined ||
31
+ // The list below must EXACTLY match toLengthUnit(string)
32
+ unit = unit === null || unit === void 0 ? void 0 : unit.toLowerCase();
33
+ return (unit === "inch" ||
31
34
  unit === "in" ||
32
- unit === "inch" ||
33
- unit === "ft");
35
+ unit === "ft" ||
36
+ unit === "mm" ||
37
+ unit === "cm" ||
38
+ unit === "dm" ||
39
+ unit === "m");
34
40
  }
35
41
  export function convertLength(l, from, to) {
36
42
  if (from === to) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-utilities",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.20",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,5 +22,5 @@
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
- "gitHead": "70b1f8c6426c11420f00b031912e1023d3b591bf"
25
+ "gitHead": "74b8fd6c45f392b9133843b409f7662dbf93c47e"
26
26
  }