@suss/recognize
v0.38.2
Published
Teach suss to read a library you use, by writing a pack as data rather than code, which any language adapter can run.
Maintainers
Readme
@suss/recognize
Part of suss, which reads both sides of every call in a repository and says where the two disagree.
Write a pack as data. A pack declares where a match starts, which methods count, and what each one reads or writes. This package compiles that declaration into the recognizer hooks the adapters already call, and any adapter that implements the executor ops can run it.
import { declaredBy, pack, storageCalls } from "@suss/recognize";
const COMMANDS = {
get: { kind: "read", selector: { at: 0 } },
hset: { kind: "write", selector: { at: 0 }, fields: { at: 1 } },
} as const;
const calls = storageCalls({
system: "redis",
client: declaredBy("ioredis", "redis", "iovalkey"),
})
.methods(COMMANDS, { ignoringCase: true })
.container(namespaceOf)
.example('redis.get("user_online:42")');
export default pack("redis", [calls], {
languages: ["typescript", "javascript"],
recognizedAs: "@suss/framework-redis",
});This package never imports a syntax tree. The same declaration runs on the TypeScript adapter today, and will run on the Python and Ruby adapters once they implement the ops.
More
Apache 2.0. See LICENSE.
