pacc 3.1.7 → 3.1.9

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2023-2024 by pacc
1
+ Copyright (c) 2023-2024 by arlac77
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
package/README.md CHANGED
@@ -38,6 +38,7 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
38
38
  * [Parameters](#parameters-2)
39
39
  * [getAttributeAndOperator](#getattributeandoperator)
40
40
  * [Parameters](#parameters-3)
41
+ * [lookup](#lookup)
41
42
  * [Token](#token)
42
43
  * [Properties](#properties-1)
43
44
  * [createToken](#createtoken)
@@ -133,6 +134,10 @@ The name may be a property path like 'a.b.c <='.
133
134
 
134
135
  Returns **\[any, [Token](#token)]** value associated with the given property name
135
136
 
137
+ ## lookup
138
+
139
+ Token lookup
140
+
136
141
  ## Token
137
142
 
138
143
  Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -19,29 +19,29 @@
19
19
  "email": "markus.felten@gmx.de"
20
20
  }
21
21
  ],
22
- "license": "BSD-2-Clause",
22
+ "license": "0BSD",
23
23
  "scripts": {
24
- "prepare": "npm run prepare:typescript",
25
- "prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule -t esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
26
- "test": "npm run test:browser-ava && npm run test:ava",
24
+ "prepare": "node --run prepare:typescript",
25
+ "prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
26
+ "test": "node --run test:browser-ava && node --run test:ava",
27
27
  "test:browser-ava": "browser-ava --headless --no-keep-open tests/*-ava.mjs tests/*-ava-browser.mjs",
28
28
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
29
29
  "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
30
30
  "docs": "documentation readme --section=API ./src/**/*.mjs",
31
- "lint": "npm run lint:docs && npm run lint:typescript",
31
+ "lint": "node --run lint:docs && node --run lint:typescript",
32
32
  "lint:docs": "documentation lint ./src/**/*.mjs",
33
- "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
33
+ "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
34
34
  },
35
35
  "devDependencies": {
36
- "ava": "^6.1.3",
37
- "browser-ava": "^2.2.13",
38
- "c8": "^9.1.0",
36
+ "ava": "^6.2.0",
37
+ "browser-ava": "^2.3.4",
38
+ "c8": "^10.1.3",
39
39
  "documentation": "^14.0.3",
40
- "semantic-release": "^23.0.8",
41
- "typescript": "^5.4.5"
40
+ "semantic-release": "^24.2.0",
41
+ "typescript": "^5.7.2"
42
42
  },
43
43
  "engines": {
44
- "node": ">=20.13.0"
44
+ "node": ">=22.12.0"
45
45
  },
46
46
  "repository": {
47
47
  "type": "git",
package/src/attribute.mjs CHANGED
@@ -118,6 +118,12 @@ export function getAttributeAndOperator(object, expression) {
118
118
  predicateTokens = undefined;
119
119
  break;
120
120
  case STAR:
121
+ if(!predicateTokens) {
122
+ const error = new Error("unexpected '*' in attribute path");
123
+ // @ts-ignore
124
+ error.expression = expression;
125
+ throw error;
126
+ }
121
127
  predicateTokens.push(token);
122
128
  break;
123
129
 
package/src/tokens.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Token lookup
3
+ */
1
4
  const lookup = {};
2
5
 
3
6
  /**
@@ -6,8 +9,8 @@ const lookup = {};
6
9
  */
7
10
 
8
11
  /**
9
- *
10
- * @param {string} str
12
+ *
13
+ * @param {string} str
11
14
  * @returns {Token}
12
15
  */
13
16
  function createToken(str) {
@@ -58,8 +61,8 @@ export function* tokens(string) {
58
61
  hex += c;
59
62
  // @ts-ignore
60
63
  if (hex.length === 4) {
61
- // @ts-ignore
62
- buffer += String.fromCharCode(parseInt(hex, 16));
64
+ // @ts-ignore
65
+ buffer += String.fromCharCode(parseInt(hex, 16));
63
66
  state = "string";
64
67
  }
65
68
  continue;
@@ -265,7 +268,10 @@ export function* tokens(string) {
265
268
  case undefined:
266
269
  break;
267
270
  case "string":
268
- throw new Error("unterminated string");
271
+ const error = new Error("unterminated string");
272
+ // @ts-ignore
273
+ error.expression = string;
274
+ throw error;
269
275
  case "number":
270
276
  case "identifier":
271
277
  yield buffer;
@@ -61,4 +61,4 @@ export type AttributeDefinition = {
61
61
  */
62
62
  env?: string[] | string;
63
63
  };
64
- export type Token = import('./tokens.mjs').Token;
64
+ export type Token = import("./tokens.mjs").Token;