@tscircuit/circuit-json-util 0.0.132 → 0.0.133

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/dist/index.js CHANGED
@@ -192,7 +192,7 @@ var cju = ((circuitJsonInput, options = {}) => {
192
192
  return {
193
193
  get: (id) => circuitJson.find(
194
194
  (e) => e.type === component_type && e[`${component_type}_id`] === id
195
- ),
195
+ ) ?? null,
196
196
  getUsing: (using) => {
197
197
  const keys = Object.keys(using);
198
198
  if (keys.length !== 1) {
@@ -208,13 +208,13 @@ var cju = ((circuitJsonInput, options = {}) => {
208
208
  if (!joiner) return null;
209
209
  return circuitJson.find(
210
210
  (e) => e.type === component_type && e[`${component_type}_id`] === joiner[`${component_type}_id`]
211
- );
211
+ ) ?? null;
212
212
  },
213
213
  getWhere: (where) => {
214
214
  const keys = Object.keys(where);
215
215
  return circuitJson.find(
216
216
  (e) => e.type === component_type && keys.every((key) => e[key] === where[key])
217
- );
217
+ ) ?? null;
218
218
  },
219
219
  list: (where) => {
220
220
  const keys = !where ? [] : Object.keys(where);
@@ -260,7 +260,7 @@ var cju = ((circuitJsonInput, options = {}) => {
260
260
  if (component_type === "source_component") {
261
261
  return circuitJson.find(
262
262
  (e) => e.type === "source_component" && e.name === selector.replace(/\./g, "")
263
- );
263
+ ) ?? null;
264
264
  } else if (component_type === "pcb_port" || component_type === "source_port" || component_type === "schematic_port") {
265
265
  const [component_name, port_selector] = selector.replace(/\./g, "").split(/[\s\>]+/);
266
266
  const source_component = circuitJson.find(
@@ -275,13 +275,14 @@ var cju = ((circuitJsonInput, options = {}) => {
275
275
  if (component_type === "pcb_port") {
276
276
  return circuitJson.find(
277
277
  (e) => e.type === "pcb_port" && e.source_port_id === source_port.source_port_id
278
- );
278
+ ) ?? null;
279
279
  } else if (component_type === "schematic_port") {
280
280
  return circuitJson.find(
281
281
  (e) => e.type === "schematic_port" && e.source_port_id === source_port.source_port_id
282
- );
282
+ ) ?? null;
283
283
  }
284
284
  }
285
+ return null;
285
286
  }
286
287
  };
287
288
  }