@tscircuit/footprinter 0.0.6 → 0.0.7

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/footprinter",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "description": "",
6
6
  "main": "dist/index.cjs",
7
7
  "scripts": {
@@ -5,6 +5,7 @@ import { led } from "./fn/led"
5
5
  import { res } from "./fn/res"
6
6
  import { bga } from "./fn/bga"
7
7
  import type { AnySoupElement } from "@tscircuit/soup"
8
+ import { isNotNull } from "./helpers/is-not-null"
8
9
 
9
10
  export type FootprinterParamsBuilder<K extends string> = {
10
11
  [P in K | "params" | "soup"]: P extends "params" | "soup"
@@ -48,11 +49,15 @@ export type Footprinter = {
48
49
  export const string = (def: string): Footprinter => {
49
50
  let fp = footprinter()
50
51
 
51
- const def_parts = def.split("_").map((s) => {
52
- const m = s.match(/([a-z]+)([\(\d\.\+].*)?/)
53
- const [_, fn, v] = m ?? []
54
- return { fn: m?.[1]!, v: m?.[2]! }
55
- })
52
+ const def_parts = def
53
+ .split("_")
54
+ .map((s) => {
55
+ const m = s.match(/([a-z]+)([\(\d\.\+\?].*)?/)
56
+ const [_, fn, v] = m ?? []
57
+ if (v?.includes("?")) return null
58
+ return { fn: m?.[1]!, v: m?.[2]! }
59
+ })
60
+ .filter(isNotNull)
56
61
 
57
62
  for (const { fn, v } of def_parts) {
58
63
  fp = fp[fn](v)
@@ -0,0 +1,3 @@
1
+ export function isNotNull<T>(value: T | null): value is T {
2
+ return value !== null
3
+ }