pacc 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -21,13 +21,13 @@ propetty path utils
21
21
 
22
22
  * [AttributeDefinition](#attributedefinition)
23
23
  * [Properties](#properties)
24
- * [tokens](#tokens)
25
- * [Parameters](#parameters)
26
24
  * [setAttribute](#setattribute)
27
- * [Parameters](#parameters-1)
25
+ * [Parameters](#parameters)
28
26
  * [getAttribute](#getattribute)
29
- * [Parameters](#parameters-2)
27
+ * [Parameters](#parameters-1)
30
28
  * [getAttributeAndOperator](#getattributeandoperator)
29
+ * [Parameters](#parameters-2)
30
+ * [tokens](#tokens)
31
31
  * [Parameters](#parameters-3)
32
32
 
33
33
  ## AttributeDefinition
@@ -47,14 +47,6 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
47
47
  * `get` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** get the value can be used to calculate default values
48
48
  * `env` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))?** environment variable use to provide the value
49
49
 
50
- ## tokens
51
-
52
- Split property path into tokens
53
-
54
- ### Parameters
55
-
56
- * `string` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
57
-
58
50
  ## setAttribute
59
51
 
60
52
  Set Object attribute.
@@ -91,6 +83,14 @@ The name may be a property path like 'a.b.c <='.
91
83
 
92
84
  Returns **\[any, [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)]** value associated with the given property name
93
85
 
86
+ ## tokens
87
+
88
+ Split property path into tokens
89
+
90
+ ### Parameters
91
+
92
+ * `string` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
93
+
94
94
  # install
95
95
 
96
96
  With [npm](http://npmjs.org) do:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/attribute.mjs CHANGED
@@ -30,8 +30,6 @@ export function setAttribute(object, expression, value) {
30
30
 
31
31
  for (const token of tokens(expression)) {
32
32
  switch (token) {
33
- case ">":
34
- case "<":
35
33
  case ".":
36
34
  case "[":
37
35
  case "]":
package/src/tokens.mjs CHANGED
@@ -5,21 +5,32 @@
5
5
  * @yields {string}
6
6
  */
7
7
  export function* tokens(string) {
8
- let state, buffer;
8
+ let state, buffer, hex;
9
9
 
10
10
  for (const c of string) {
11
11
  switch (state) {
12
+ case "string-escaping-hex":
13
+ hex += c;
14
+ if (hex.length === 4) {
15
+ buffer += String.fromCharCode(parseInt(hex, 16));
16
+ state = "string";
17
+ }
18
+ continue;
12
19
  case "string-escaping":
13
- const esc = {
14
- "\\": "\\",
15
- b: "\b",
16
- f: "\f",
17
- n: "\n",
18
- r: "\r",
19
- t: "\t"
20
- };
21
- buffer += esc[c];
22
- state = "string";
20
+ if (c === "u") {
21
+ state = "string-escaping-hex";
22
+ hex = "";
23
+ } else {
24
+ const esc = {
25
+ b: "\b",
26
+ f: "\f",
27
+ n: "\n",
28
+ r: "\r",
29
+ t: "\t"
30
+ };
31
+ buffer += esc[c] || c;
32
+ state = "string";
33
+ }
23
34
  continue;
24
35
  }
25
36
 
@@ -78,17 +89,16 @@ export function* tokens(string) {
78
89
  case "&":
79
90
  case "|":
80
91
  switch (state) {
81
- case '&':
82
- case '|':
83
- if(state === c) {
92
+ case "&":
93
+ case "|":
94
+ if (state === c) {
84
95
  yield state + c;
85
96
  state = undefined;
86
- }
87
- else {
97
+ } else {
88
98
  yield state;
89
99
  state = c;
90
100
  }
91
- break;
101
+ break;
92
102
  case undefined:
93
103
  state = c;
94
104
  break;
@@ -121,6 +131,9 @@ export function* tokens(string) {
121
131
  state += c;
122
132
  }
123
133
  break;
134
+ case ":":
135
+ case ";":
136
+ case ",":
124
137
  case ".":
125
138
  case "+":
126
139
  case "-":