Socket
Socket
Sign inDemoInstall

hastebin-gen

Package Overview
Dependencies
7
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

hastebin-gen

A simple hastebin client for uploading things to hastebin.com


Version published
Maintainers
1
Weekly downloads
7,800
increased by120.03%

Weekly downloads

Readme

Source

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

OptionTypeDefault Value
urlstring"https://hastebin.com"
extensionstring"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

FAQs

Last updated on 30 May 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc