thaj

1.1.1 • Public • Published

thaj npm

as in "Thanos JS", just (the exceptionally perfect) half of it

This package allows you to use the powers of evil people with mythical golden gauntlets to erase half of pretty much whatever* you want.

* as long as it is divisible (it keeps fractions intact)

Installation

npm i thaj

Usage

In scripts

Note: Results may vary.

const { Thanos } = require('thaj')
const thanos = new Thanos()
 
thanos.snap('Stan Lee') // 'tnee'
thanos.snap(Buffer.from('New York')) // <Buffer 77 20 6f 6b> => 'w ok'
 
thanos.snap(42) // 21
thanos.snap(21) // 10 or 11
thanos.snap(Math.PI) // 1.1415926535897931 or 2.141592653589793
 
thanos.snap([2, 5]) // [2] or [5]
 
// you can also pass in multiple values:
thanos.snap('I am inevitable', 3000, [2, 5])

You can also optionally apply a custom RNG for your own grain of randomness (GeneratorFunctions are also supported)!

Just make sure that its values range from 0 to 1 (excluding 1) like in Math.random.

// change the default for all instances
Thanos.DEFAULT_RNG = myCustomRNG
 
// change it for once instance
thanos.rng = myCustomRNG

On the command line

The CLI variant thanos essentially works like the unix command cat, just half as good.

echo "Stark Tower" > /tmp/starktower.txt
$ thanos /tmp/starktower.txt
takToe
 
$ thanos -
Captain America
panmerca

License

Click to read: NPM

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i thaj

      Weekly Downloads

      6

      Version

      1.1.1

      License

      MIT

      Unpacked Size

      15.8 kB

      Total Files

      7

      Last publish

      Collaborators

      • metaa