1.3.1 • Published 5 years ago

hastebin-paste v1.3.1

Weekly downloads
433
License
MIT
Repository
github
Last release
5 years ago

npm npm downloads Open Source Love dependencies Status devDependencies Status NPM

hastebin-paste

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

change log

1.2.5Status deleted since it is not working, message after the link was added. See readme for more info

1.1.6Default Extension changed to txt file

1.1.4Status officially published

1.1.1, 1.1.2, 1.1.3Fixed Bugs

1.1.0New option: status

1.0.5error return updated: make it easier for people to debug, keyword updated

1.0.4Keyword updated

1.0.1, 1.0.2 and 1.0.3README updated

1.0.0initial publish

Installation

NPM: npm i hastebin-paste

Options

OptionTypeDefault Value
urlstring"https://hastebin.com"
extensionstring"txt"
messagestring"Powered by hastebin-paste, a npm package."
prefixstring"The link is: "

Examples

Using .then().catch()

const hastebin = require("hastebin-paste");

// 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-paste");

// 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-paste");

// 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-paste");

// 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

Using message and prefix

const hastebin = require("hastebin-paste");

// You can change the extension by setting the extension option
hastebin("code", { url: "https://paste.example.com", extention: "txt", message: "example", prefix: "example" }).then(haste => {//set message that comes after the link or set the prefix that comes before the link
    console.log(haste)// Logs the created hastebin url and message you set to the console
    //the output will be "example https://paste.example.com/someid.txt example"
}).catch(error => {
    // Handle error
    console.error(error);
});
1.3.1

5 years ago

1.3.0

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago