1.0.14 • Published 3 years ago

@whitep4nth3r/random-code v1.0.14

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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.

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.10

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago