@player-ui/player 0.10.1 → 0.10.2-next.0

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/package.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "types"
7
7
  ],
8
8
  "name": "@player-ui/player",
9
- "version": "0.10.1",
9
+ "version": "0.10.2-next.0",
10
10
  "main": "dist/cjs/index.cjs",
11
11
  "dependencies": {
12
- "@player-ui/partial-match-registry": "0.10.1",
13
- "@player-ui/make-flow": "0.10.1",
14
- "@player-ui/types": "0.10.1",
12
+ "@player-ui/partial-match-registry": "0.10.2-next.0",
13
+ "@player-ui/make-flow": "0.10.2-next.0",
14
+ "@player-ui/types": "0.10.2-next.0",
15
15
  "@types/dlv": "^1.1.4",
16
16
  "dequal": "^2.0.2",
17
17
  "dlv": "^1.1.3",
@@ -111,3 +111,13 @@ describe("descendent binding", () => {
111
111
  ]);
112
112
  });
113
113
  });
114
+
115
+ describe("Edge cases", () => {
116
+ it("Bindings with escaped numbers", () => {
117
+ expect(new BindingInstance("foo.01.bar").asArray()).toStrictEqual([
118
+ "foo",
119
+ "01",
120
+ "bar",
121
+ ]);
122
+ });
123
+ });
@@ -1,6 +1,6 @@
1
1
  import { bench, describe } from "vitest";
2
2
  import get from "dlv";
3
- import { getBindingSegments } from "..";
3
+ import { BindingInstance, getBindingSegments } from "..";
4
4
  import { testCases, testModel } from "./resolver.test";
5
5
  import { parseCustom, ParserSuccessResult } from "../../binding-grammar";
6
6
  import { resolveBindingAST } from "../resolver";
@@ -20,3 +20,23 @@ describe("parser benchmarks", () => {
20
20
  { iterations: 10000 },
21
21
  );
22
22
  });
23
+
24
+ describe("binding creation benchmarks", () => {
25
+ testCases.map(
26
+ ([input, expectedOutput]) => {
27
+ bench(`Resolving binding: ${input}`, () => {
28
+ const parsedBinding = parseCustom(input);
29
+ const result = resolveBindingAST(
30
+ (parsedBinding as ParserSuccessResult).path,
31
+ {
32
+ getValue: (path) => get(testModel, getBindingSegments(path) as any),
33
+ convertToPath: (p) => p,
34
+ evaluate: () => undefined,
35
+ },
36
+ );
37
+ const bi = new BindingInstance(result.path);
38
+ });
39
+ },
40
+ { iterations: 10000 },
41
+ );
42
+ });
@@ -53,7 +53,9 @@ export class BindingInstance {
53
53
  }
54
54
 
55
55
  const tryNum = Number(segment);
56
- return isNaN(tryNum) ? segment : tryNum;
56
+ // test to make sure turning a numerical string to a number doesn't change
57
+ // the actual value of the string by getting rid of a leading zero
58
+ return isNaN(tryNum) || String(tryNum) !== segment ? segment : tryNum;
57
59
  });
58
60
  Object.freeze(this.split);
59
61
  this.joined = this.split.join(".");