hastebin-gen
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

Discord npm npm downloads NPM version Build Status Open Source Love dependencies Status devDependencies Status NPM

hastebin-gen

A npm module for generating hastebin links. https://www.npmjs.com/package/hastebin-gen

Installation

NPM: npm i hastebin-gen

Yarn: yarn add hastebin-gen

Options

Option Type Default Value
url string "https://hastebin.com"
extension string "js"

Examples

Using .then().catch()

const hastebin = require("hastebin-gen");
 
// You can change the extension by setting the extension option
hastebin("code", { extension: "txt" }).then(haste => {
    // Logs the created hastebin url to the console
    console.log(haste); // https://hastebin.com/someid.txt
}).catch(error => {
    // Handle error
    console.error(error);
});

Using async/await

This is assuming that you are in a asynchronous scope

Understanding Async/Await

const hastebin = require("hastebin-gen");
 
// You can change the extension by setting the extension option
const haste = await hastebin("code", { extension: "txt" });
 
// Logs the created hastebin url to the console
console.log(haste); // https://hastebin.com/someid.txt

Example with a custom haste-server instance

Using .then().catch()

const hastebin = require("hastebin-gen");
 
// You can change the extension by setting the extension option
hastebin("code", { url: "https://paste.example.com", extension: "txt" }).then(haste => {
    // Logs the created hastebin url to the console
    console.log(haste); // https://paste.example.com/someid.txt
}).catch(error => {
    // Handle error
    console.error(error);
});

Using async/await

This is assuming that you are in a asynchronous scope

Understanding Async/Await

const hastebin = require("hastebin-gen");
 
// You can change the extension by setting the extension option
const haste = await hastebin("code", { url: "https://paste.example.com", extension: "txt" });
 
// Logs the created hastebin url to the console
console.log(haste); // https://paste.example.com/someid.txt

Readme

Keywords

none

Package Sidebar

Install

npm i hastebin-gen

Weekly Downloads

1,359

Version

2.0.5

License

MIT

Unpacked Size

6.2 kB

Total Files

8

Last publish

Collaborators

  • jacz