@jnagra/dwim
v0.1.0
Published
Library that implements every API you need hallucinated.
Maintainers
Readme
DWIM
Library that implements every API you need hallucinated.
Do what I mean. The largest library of functions in the world in practically a tiny number of bytes. Ask for a function and Gemini Nano writes it on your device. The next call reuses the implementation. No server, API key, or runtime dependencies.
Use it
npm install @jnagra/dwimimport DWIM, { randomIntInRange } from '@jnagra/dwim';
const { mergeSort } = DWIM;
console.log(await mergeSort([3, 1, 4, 1, 5]));
console.log(await randomIntInRange(0, 10));
console.log(await DWIM.math.PI);Run this in a browser app with Chrome's Prompt API,
on HTTPS or localhost. Nano doesn't run in Node. If the model download needs a
click, call await DWIM.$init() from a click handler.
Calls and property values need await; arguments must be JSON data.
Invented names work through DWIM.anything or destructuring. The playground also
accepts arbitrary named imports; the npm module's named exports are fixed.
Curious what it wrote? await DWIM.$source('mergeSort') shows the code.
await DWIM.$destroy() clears the cache and releases the model.
This is a joke that runs real, unsandboxed JavaScript. It can be wrong.
If your app sets a Content Security Policy, it must allow unsafe-eval.
Please definitely do not do that - this is a joke library!
Run the demo locally
With Node.js 20+:
git clone https://github.com/jasvir/dwim.git
cd dwim
npm ci
npm run demoOpen the printed URL in Chrome. Pick an example or write your own code; the second tab shows the functions DWIM came up with.
MIT licensed. Publishing and Pages setup.
