Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

Wingman 🐝

This module contains tools that help you program efficiently and keep your code tidy.

Library

LibraryFunction NameDescription
ArraysRandomIndexThis gives you a random index/element from the array.
ArraysFilterExactThis returns the total amount (int) of appearances of a given string.
ArraysLoopFunctionThis runs the given function maxLoops amount of time.
ArraysArrayToObjectThis converts an array into an object
ObjectsReverseObjectKeyValueThis returns an object where the value is the key.
ObjectsGetValueFromPathThis fetches value from object using Dot Notation.

Arrays

  • <Library/arrays>.RandomIndex(array Any[]) This gives you a random index/element from the array.

    import*asWingmanfrom"wingman/arrays";Wingman.RandomIndex(["test","project","42"]);// Returns any (could be "project" for example)
  • <Library/arrays>.FilterExact(array Any[], filter Any) This returns the total amount (int) of appearances of a given string.

    import*asWingmanfrom"wingman/arrays";Wingman.FilterExact([1,5,55,12,9,2,2,2,4],2);// Returns 3
  • <Library/arrays>.LoopFunction(maxLoops Number, givenFunc Function) This runs the given function maxLoops amount of time.

    import*asWingmanfrom"wingman/arrays";letStr="";Wingman.LoopFunction(4,()=>(Str+="a"));Str;// aaaa
  • <Library/arrays>.ArrayToObject(object Object) This converts an array into an object.

    import*asWingmanfrom"wingman/arrays";Wingman.ArrayToObject(["cool",5,false]);// { 0: "cool", 1: "5", 2: false }

Objects

  • <Library/objects>.ReverseObjectKeyValue(obj Object{string | number: string | number}) This returns an object where the value is the key.

    import*asWingmanfrom"wingman/objects";Wingman.ReverseObjectKeyValue({cool: "bye",12: 12,lol: 62,1: "lol"});// { '12': '12', '62': 'lol', lol: '1', bye: 'cool' }
  • <Library/objects>.GetValueFromPath(obj Object, path String) This fetches value from object using Dot Notation.

    import*asWingmanfrom"wingman/objects";Wingman.GetValueFromPath({cool: "bye",12: {"isCool?": true}},"12.isCool");// true

About

🐝 Typescript Coding Tool

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages