Skip to content

Contains JavaScript cool ready to use helper functions

License

Notifications You must be signed in to change notification settings

mudssrali/js-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 

Repository files navigation

JavaScript Helpers

Some hand-crafted ES6 based JavaScript (type guarded - TypeScript based) utility functions:

  • Convert blob to base64 string

     canvasToBlob( canvas: HTMLCanvasElement, options: Options = {})

    View Code

  • Convert blob to base64 string

     blobToBase64(blob: Blob)

    View Code

  • String utils

      isValidLength(str: string, minLength: number)
      isValidEmail(email: string)
      removeFileExtension(filename: string)

    View Code

  • Split Array into Chunks

     chunkify(kvArray = [], chunkSize = 10, reverse = false): Array<[]>

    View Code

  • Split Array into Chunks - V2

     chunkify(kvArray = [], chunkSize = 10): Array<[]>

    View Code

  • Split Array into Chunks - V3

     chunkify(kvArray: T[], chunkSize: number): Array<T[]>

    View Code

  • Check number

      isDecimalNumber(number: any): boolean
      isFloat(value: any): boolean

    View Code

  • Convert text to Titled-Case

      toTitleCase(text: string,  delimiter = ' '): string

    e.g. toTitleCase("mUdAssaAr lOves OpEn SouRCe") ===========> Mudassar Loves Open Source

    View Code

  • Prettify Number

    Description: Prettify a number for use in the application. Use toLocaleString, but also force a standard number of decimal places if it's a float.

      prettifyNumber(number): string

    View Code

  • Random Color Code Generator

      randomColorGenerator(): string

    View Code

  • Bump Array Sort Description: Return a new sorted array, except with one value bumped to the front. This function does not sort an array in place; a new array is returned.

      bumpSort(kvArray: Array, bumpValue: any): Array

    View Code

  • Sort Year Months

      sortYearMonths(kvSet: Set<string>): Array
      sortYearMonths(kvArray: Array<string>): Array

    View Code

  • Array Utils

      isEqual(array1: Array<any>, array2: Array<any>): boolean
      takeRight(array: Array<any>, n: number): Array<any>

    View Code

  • Format File Size

      formatFileSize(bytes: number, suffixIndex = 0): string

    View Code

  • Kebab Case to Title Case

      kebabToTitleCase(str: string): string

    View Code

Contributions

Contributions of any kind are welcome.

MIT-LICENSE

Releases

No releases published

Packages

No packages published