helperfunc

A collection of useful helper functions, able to be used in any circumstance.


Keywords
typescript, helper-functions, npm
License
MIT
Install
npm install helperfunc@1.4.2

Documentation

helperfunc | functions that can help

npm-package-version travis-ci-build fossa-license-status npm

A collection of handy helper functions.

Some of these functions are:

  • A function that generates a random string based on a given length (randomString(lengthOfString: number))
  • A function that gets the last element of a given array (lastArrayElement(array))
  • A function that generates a random true/false bool, based on a given single digit probability (randomBool(singleDigitProbability: number))
  • ...and more to come!

Because this is all built in Typescript, you'll get useful intellisense and IDE documentation! (if you use an IDE that has those) However, this will still work in Javascript.

Installation

You can run this:

npm install helperfunc

Or you can run:

yarn add helperfunc

Depending on whether you use yarn or npm.

Examples of usage:

Javascript Example:

// Get a random true or false value, then return a integer based upon that.

// Import the NEEDED function
const { randomBool } = require("helperfunc"); // CommonJS syntax
// import { randomBool } from "helperfunc" // ES6 import/export syntax

const randomBoolean = randomBool(5); // 5 is the given probability.

const kewlInteger = randomBoolean ? 1 : 0; // If randomBoolean is true, make kewlInteger 1, otherwise, make it 0.

console.log(kewlInteger); // Log it!

Typescript Example:

// Get a random string, then log it.

// Import the NEEDED function
import { randomString } from "helperfunc"; // ES6 import/export syntax
// const { randomBool } = require("helperfunc") // CommonJS syntax

const EpicRandomString: string = randomString(10); // Call the function

console.log(EpicRandomString); // Log it

Official Documentation:

Documentation can be found here.

Status of functions:

The roadmap of stuff to add can be found here

License

FOSSA Status


Hope you all like it! More stuff is coming soon!