Options
All
  • Public
  • Public/Protected
  • All
Menu

functionKit latest version | npm David GitHub Workflow Status GitHub Workflow Status GitHub commits since latest release (by date including pre-releases) Maintainability

A package with functions for example, sum 2 numbers A lodash ripoff

NOTE

I just reialized that functionKit is a lodash ripoff!

Install

npm i functionkit

or

npm install functionkit

Importing functionKit

import { sum, subtract, greet, divide } from 'functionKit';

Usage

// Greeter
console.log(greet('Shehab'));
          // Hello Shehab
// Custom Greeting
console.log(greet('Shehab', 'Welcome back,'));
                          // Welcome back, Shehab

// Math
// sum (add)
   console.log(sum([1, 1]));
   // 2
   // Same as: 1 + 1
// subtract (the opposite of sum)
   console.log(subtract(1, 3));
   // 3
   // Same as: 1 - 3
// Divide (i can't simplify it.)
   console.log(divide(55, 11));
   // 5
   // Same as: 55 / 11

For more documentation, head over to shahoob.github.io/functionKit

Index

Functions

calcPercent

  • calcPercent(current: number, max: number, mustBeString?: undefined | false | true): number | string
  • Calculates a percent

    since

    2.0.0

    Parameters

    • current: number

      The currect progress

    • max: number

      The completed progress (or the goal)

    • Optional mustBeString: undefined | false | true

      If should return a string

    Returns number | string

clean

  • clean(array: any[]): any[]
  • Cleans your array from falsy values

    since

    3.1.0

    Parameters

    • array: any[]

      Any array you want

    Returns any[]

divide

  • divide(a: number, b: number): number
  • Parameters

    • a: number
    • b: number

    Returns number

greet

  • greet(name: string, customGreeting?: undefined | string): string
  • Parameters

    • name: string
    • Optional customGreeting: undefined | string

    Returns string

half

  • half(num: number): number
  • Parameters

    • num: number

    Returns number

max

  • max(array: number[]): number
  • Get the largest number in an array

    Parameters

    • array: number[]

      A number array

    Returns number

min

  • min(array: number[]): number
  • Just like the max function, reversed.
    Get the smallest number in an array

    Parameters

    • array: number[]

      A number array

    Returns number

multiply

  • multiply(a: number, b: number): number
  • Parameters

    • a: number
    • b: number

    Returns number

random

  • random(min: number, max: number): number
  • Parameters

    • min: number
    • max: number

    Returns number

randomize

  • randomize<T>(array: T[]): T[]

range

  • range(from: number, to: number, step?: number): number[]
  • If you know python, You know what it is for.
    Creates a range of numbers

    Example

    const onetoten = range(1, 10);

    Parameters

    • from: number

      The starting number (a.k.a 'start')

    • to: number

      The ending number (a.k.a 'stop')

    • Default value step: number = 1

      How many steps to take (a.k.a 'step')

    Returns number[]

subtract

  • subtract(a: number, b: number): number
  • Parameters

    • a: number
    • b: number

    Returns number

sum

  • sum(numbers: number[]): number
  • Parameters

    • numbers: number[]

    Returns number

Legend

Generated using TypeDoc