@codesnippets/codesnippets
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

CodeSnippets

Open source and free to use code snippets fueled by you! 💖

Contributing

If you would like to help with this crowd-sourced project, check out our CONTRIBUTING.md file. There you'll find how you can contribute to the project and what to contribute. Thanks!

API

npm install @codesnippets/codesnippets

Getting Languages

You can get a language with the getLanguage function provided by CodeSnippets. This will return a language from the snippets.jsonc file as an object.

const codesnippets = require('codesnippets');

const js = codesnippets.getLanguage('javascript');
console.log(js);

Alternatively, you can get a list of all languages:

const codesnippets = require('codesnippets');

const languages = codesnippets.getLanguages();
console.log(languages);

Or a list of only names of supported languages:

const codesnippets = require('codesnippets');

const names = codesnippets.getLanguageNames();
console.log(names);

Getting Snippets

Once you get a Language, you can use the getSnippet function.

const codesnippets = require('codesnippets');

const js = codesnippets.getLanguage('javascript');
const log = js.getSnippet('log');

// To get the file's contents, use the .get() function:
console.log(log.getSync());

You can also get a list of snippet names:

const snippets = js.getSnippets();
console.log(snippets);

Readme

Keywords

Package Sidebar

Install

npm i @codesnippets/codesnippets

Weekly Downloads

15

Version

0.0.4

License

MIT

Unpacked Size

22.9 kB

Total Files

28

Last publish

Collaborators

  • faztasio