Warning
We moved @scalar/snippetz
to https://github.com/scalar/scalar
A modern way to generate code examples for different languages.
npm install @scalar/snippetz
import { snippetz } from '@scalar/snippetz'
const snippet = snippetz().print('node', 'undici', {
url: 'https://example.com',
})
/* Output */
// import { request } from 'undici'
//
// const { statusCode, body } = await request(
// 'https://example.com',
// )
import { snippetz } from '@scalar/snippetz'
const snippet = snippetz().plugins()
/* Output */
// [
// {
// target: 'node',
// client: 'undici',
// }
// ]
import { snippetz } from '@scalar/snippetz'
const snippet = snippetz().hasPlugin('node', 'undici')
/* Output */
// true
You can also just use one specific plugin to keep your bundle size small.
import { undici } from '@scalar/snippetz/plugins/node/undici'
const source = undici({
url: 'https://example.com',
})
console.log(source.code)
// import { request } from 'undici'
// const { statusCode, body } = await request(
// 'url': 'https://example.com',
// )
We are API nerds. You too? Let’s chat on Discord: https://discord.gg/scalar
Contributions are welcome! Read CONTRIBUTING
.
hanspagel |
marclave |
The source code in this repository is licensed under MIT.