npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

abrupt

v0.2.5

Published

(Random - Strings, Numbers, Booleans, Floats, Objects, Arrays) (Crypto - Base64, AES, RSA, MD5, SHA512, Morse, Rot13)

Downloads

16

Readme

Node.js Package Utility

Require

// The separate methods of initializing are either by folder or the index of objects. 

// Library
const { crypto } = require("abrupt") // Object
const crypto = require("abrupt/crypto") // Folder

// Sub-Library
const { crypto: { base64 } } = require("abrupt") // Object
const base64 = require("abrupt/crypto/base64") // Folder

// Specific Function
const { string: { reverse } } = require("abrupt") // Object
const reverse = require("abrupt/string/reverse") // Folder

Random

const rand = require("abrupt/rand") 

// Number:
rand.int(100) // (30) 1 to 100
rand.int(50,100) // (76) 50 to 100
rand.int() // (3) 1 to 5

// Float:
rand.float(50, 100) // (64.44560214694141) 50 to 100
rand.float() // (4.552864077962543) 1 to 5

// String:
rand.str(10, true) // (afivfwveor) 10 characters [Letters]
rand.str(15) // (.]B7EU.^kF) 15 characters [All]
rand.str(true) // (dlhej) 5 characters [Letters]
rand.str() // (U)T%-) 5 characters [All]
 
// Boolean:
rand.bool() // random (true, false)

// Array
rand.array([1,2,3]) // random (1,2,3)

// Object (Choices random value, unless the second argument is true then it returns a key.)
rand.object({
    "abc": "efg",
    "hij": 123
}) // random value (efg, 123)

rand.object({
    "abc": "efg",
    "hij": 123
},true) // random key (abc, hij)

Crypto

const { base64, md5, sha256, AES, RSA, morse, rot } = require("abrupt/crypto")

// Base64
const base64_encoded = base64.encode("Hello World!")
base64_encoded // SGVsbG8gV29ybGQh
const base64_decoded = base64.decode(base64_encoded)
base64_decoded // Hello World!

// Hash
md5("Hello World!") // ed076287532e86365e841e92bfc50d8c
md5("Hello World!", "base64") // 7Qdih1MuhjZehB6Sv8UNjA==
sha256("Hello World!") // 7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069
sha256("Hello World!", "base64") // f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=


// AES 256 CBC:
// AES: Base64 (default)
const data = AES.encode("Hello World!", "key")
const [ encoded ] = data // WtbLPEWi4eu+r4bFYQR63w==
const decoded = AES.decode(...data, "key") // Hello World!
decoded 
// AES: Hex
const data = AES.encode("Hello World!", "key", "hex")
const [ encoded ] = data // a7bda69f5eaa9d208b370df02c24e606
const decoded = AES.decode(...data, "key")
decoded // Hello World!


// RSA-PSS: 
// RSA: Base64 (default)
const data = RSA.encode("Hello World!") // Default (Encoding: Base64, Key Size: 4096)
console.log(data.privateKey, data.publicKey) // Private and Public Keys
const decoded = RSA.decode(data) // Hello World!
// RSA: Hex
const data = RSA.encode("Hello World!", "hex", 4096)
console.log(data.privateKey, data.publicKey) // Private and Public Keys
const decoded = RSA.decode(data) // Hello World!


// Morse
const morse_encoded = morse.encode("Hello World!")
morse_encoded // .... . .-.. .-.. ---  / .-- --- .-. .-.. -.. -.-.--
const morse_decoded = morse.decode(morse_encoded)
morse_decoded // hello world!

// Rot
rot("Hello World!")// (Uryyb Jbeyq!) ROT 13 
rot("Hello World!", 10) // (Rovvy Gybvn!) ROT 10 

File

// File Library: seperating (file/directory)'s are handle in the function 
const file = require("abrupt/file")

// Create

file.create("Hello.txt", "Hello World!") // creates a text file containing "Hello World!"
file.create(["Hi.txt", "Welcome.txt"], ["Hello", "World!"]) // creates two text files with content corresponding to each array

file.create("Hello") // create a folder called hello
file.create(["Hello", "World"]) // creates two folders
// file.create(["Hello", "World"]) == file.create("Hello", "World") == file.create("Hello", ["World"])

// will create folders if they are missing  
file.create("this/is/three/folders.txt", "without this argument it would be a folder") 


// Exists

file.exists("this") // folder
file.exists("Hello.txt") // file
file.exists("not") // false
file.exists(["this", "Hello.txt", "not"]) // ["folder", "file", false]
// file.exists(["this", "Hello.txt", "not"]) == file.exists("this", "Hello.txt", "not")

// Read
// file.read(String Name, String Encoding)
file.read("Hello.txt") // Default Encoding: UTF8
file.read("this") // read's (file/directory) by (string/array)

// Remove

file.remove("this") // true
file.remove(["Hello.txt", "not"]) // [true, false] 
// file.remove(["Hello.txt", "not"]) == file.remove("Hello.txt", "not")

String

const { reverse, comma } = require("abrupt/string")

// String
const Hello = "Hello World!"
reverse(Hello) // !dlroW olleH
comma(10000) // 10,000
comma(10000,"$") // $10,000

Object

const { object } = require("abrupt/object")

// Object
object.merge({a:1}, {b:2}) // {a:1, b:2}
object.reverse({1:"a",2:"b"}) // {a: "1", b: "2"}
object.clean({a:null, b:undefined, c: 123}) // {c: 123}