1
0
Fork 0
Code Issues Pull requests Projects Releases 2 Packages Wiki Activity Actions Pages

Add JavaScript and TypeScript reference adapter

This commit is contained in:
Andraxion 2026-07-29 14:39:53 -04:00
parent cb52bf8ae6
commit 58c0196be5
11 changed files with 1341 additions and 0 deletions

View file

@ -0,0 +1,8 @@
import { Service } from "./service.mjs";
export { clamp } from "./shared.js";
throw new Error("The reference adapter must never execute project code");
export function applicationName() {
return Service.name;
}

View file

@ -0,0 +1,14 @@
import { clamp } from "./shared.js";
export class Service {
run(value) {
return clamp(value);
}
}
export const buildService = (enabled) => {
if (enabled) {
return new Service();
}
return null;
};

View file

@ -0,0 +1,11 @@
export const DEFAULT_LIMIT = 3;
export function clamp(value, limit = DEFAULT_LIMIT) {
if (value < 0) {
return 0;
}
if (value > limit) {
return limit;
}
return value;
}

View file

@ -0,0 +1,5 @@
export { Service } from "./service.mjs";
export function execute(worker, value) {
return worker.run(value);
}

View file

@ -0,0 +1,8 @@
import { Service } from "./service";
export type { Choice } from "./types";
throw new Error("The reference adapter must never execute project code");
export function applicationName(): string {
return Service.name;
}

View file

@ -0,0 +1,17 @@
import type { Choice } from "./types";
export class Service {
run(choice: Choice): number {
if (choice.enabled) {
return choice.value;
}
return 0;
}
}
export const buildService = (choice: Choice): Service | null => {
if (choice.enabled) {
return new Service();
}
return null;
};

View file

@ -0,0 +1,6 @@
export interface Choice {
enabled: boolean;
value: number;
}
export const DEFAULT_LIMIT: number = 3;

View file

@ -0,0 +1,6 @@
import { Service } from "./service";
import type { Choice } from "./types";
export function execute(worker: Service, choice: Choice): number {
return worker.run(choice);
}