|
| 1 | +import type { ToolMetadata } from "@stackables/bridge-types"; |
| 2 | + |
| 3 | +const syncUtility = { |
| 4 | + sync: true, |
| 5 | + trace: false, |
| 6 | +} satisfies ToolMetadata; |
| 7 | + |
1 | 8 | /** Add two numbers. Returns `a + b`. */ |
2 | 9 | export function add(opts: { a: number; b: number }): number { |
3 | 10 | return Number(opts.a) + Number(opts.b); |
4 | 11 | } |
| 12 | +add.bridge = syncUtility; |
| 13 | + |
5 | 14 | /** Subtract two numbers. Returns `a - b`. */ |
6 | 15 | export function subtract(opts: { a: number; b: number }): number { |
7 | 16 | return Number(opts.a) - Number(opts.b); |
8 | 17 | } |
| 18 | +subtract.bridge = syncUtility; |
| 19 | + |
9 | 20 | /** Multiply two numbers. Returns `a * b`. */ |
10 | 21 | export function multiply(opts: { a: number; b: number }): number { |
11 | 22 | return Number(opts.a) * Number(opts.b); |
12 | 23 | } |
| 24 | +multiply.bridge = syncUtility; |
| 25 | + |
13 | 26 | /** Divide two numbers. Returns `a / b`. */ |
14 | 27 | export function divide(opts: { a: number; b: number }): number { |
15 | 28 | return Number(opts.a) / Number(opts.b); |
16 | 29 | } |
| 30 | +divide.bridge = syncUtility; |
| 31 | + |
17 | 32 | /** Strict equality. Returns `true` if `a === b`, `false` otherwise. */ |
18 | 33 | export function eq(opts: { a: any; b: any }): boolean { |
19 | 34 | return opts.a === opts.b; |
20 | 35 | } |
| 36 | +eq.bridge = syncUtility; |
| 37 | + |
21 | 38 | /** Strict inequality. Returns `true` if `a !== b`, `false` otherwise. */ |
22 | 39 | export function neq(opts: { a: any; b: any }): boolean { |
23 | 40 | return opts.a !== opts.b; |
24 | 41 | } |
| 42 | +neq.bridge = syncUtility; |
| 43 | + |
25 | 44 | /** Greater than. Returns `true` if `a > b`, `false` otherwise. */ |
26 | 45 | export function gt(opts: { a: number; b: number }): boolean { |
27 | 46 | return Number(opts.a) > Number(opts.b); |
28 | 47 | } |
| 48 | +gt.bridge = syncUtility; |
| 49 | + |
29 | 50 | /** Greater than or equal. Returns `true` if `a >= b`, `false` otherwise. */ |
30 | 51 | export function gte(opts: { a: number; b: number }): boolean { |
31 | 52 | return Number(opts.a) >= Number(opts.b); |
32 | 53 | } |
| 54 | +gte.bridge = syncUtility; |
| 55 | + |
33 | 56 | /** Less than. Returns `true` if `a < b`, `false` otherwise. */ |
34 | 57 | export function lt(opts: { a: number; b: number }): boolean { |
35 | 58 | return Number(opts.a) < Number(opts.b); |
36 | 59 | } |
| 60 | +lt.bridge = syncUtility; |
| 61 | + |
37 | 62 | /** Less than or equal. Returns `true` if `a <= b`, `false` otherwise. */ |
38 | 63 | export function lte(opts: { a: number; b: number }): boolean { |
39 | 64 | return Number(opts.a) <= Number(opts.b); |
40 | 65 | } |
| 66 | +lte.bridge = syncUtility; |
| 67 | + |
41 | 68 | /** Logical NOT. Returns `true` if `a` is falsy. */ |
42 | 69 | export function not(opts: { a: any }): boolean { |
43 | 70 | return !opts.a; |
44 | 71 | } |
| 72 | +not.bridge = syncUtility; |
| 73 | + |
45 | 74 | /** Logical AND. Returns `true` if both `a` and `b` are truthy. */ |
46 | 75 | export function and(opts: { a: any; b: any }): boolean { |
47 | 76 | return Boolean(opts.a) && Boolean(opts.b); |
48 | 77 | } |
| 78 | +and.bridge = syncUtility; |
| 79 | + |
49 | 80 | /** Logical OR. Returns `true` if either `a` or `b` is truthy. */ |
50 | 81 | export function or(opts: { a: any; b: any }): boolean { |
51 | 82 | return Boolean(opts.a) || Boolean(opts.b); |
52 | 83 | } |
| 84 | +or.bridge = syncUtility; |
| 85 | + |
53 | 86 | /** String concatenation. Joins all parts into a single string. */ |
54 | 87 | export function concat(opts: { parts: unknown[] }): { value: string } { |
55 | 88 | const result = (opts.parts ?? []) |
56 | 89 | .map((v) => (v == null ? "" : String(v))) |
57 | 90 | .join(""); |
58 | 91 | return { value: result }; |
59 | 92 | } |
| 93 | +concat.bridge = syncUtility; |
0 commit comments