@whitep4nth3r/random-code

1.0.14 • Public • Published

random-code

Contributions

If you'd like to contribute to this project, check out this blog post to understand how to build and test the code locally.


Need some code for your project? We've got you covered. Choose your language. Choose how much code. BÄM! You got code.

Install package

npm install @whitep4nth3r/random-code

Get random code

There are two functions available for you to use:

import { getLanguages, generateRandomCode } from "@whitep4nth3r/random-code";

Use getLanguages() to return an Object with key/value pairs of available languages.

Use generateRandomCode() to generate some random code with two optional parameters.

  • language (a key from getLanguages())
  • lines (an integer of how many lines of code you require)

If you do not provide these parameters, your result will be random.

Here's an example request:

const myRandomCode = generateRandomCode("js", 3);

Here's an example response:

{
  "code": "const replaceObject = () => {\n    /* FIXME: For some reason this is causing the code below to error out? */\n    const property = true;\n    return 0;\n}",
  "lines": "3",
  "languageKey": "js",
  "languageValue": "JavaScript",
  "contributors": ["whitep4nth3r", "lukeocodes", "negue", "isabellabrookes"]
}

Profit

And lol.

Readme

Keywords

Package Sidebar

Install

npm i @whitep4nth3r/random-code

Weekly Downloads

0

Version

1.0.14

License

MIT

Unpacked Size

172 kB

Total Files

69

Last publish

Collaborators

  • whitep4nth3r