0.1.0 • Published 4 years ago

@johman/helper v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

johman-helper

Joined mini functions to help minimize duplicated coding between projects

Installation

npm install @johman/helper

Peer Dependencies

  • lodash: A modern JavaScript utility library delivering modularity, performance & extras.
  • iconv-lite: Convert character encodings in pure javascript.
  • opencc: Conversion between Traditional and Simplified Chinese.

Note: Peer dependencies are not required for general functionality.

Documentation

  • General
    • Functions
      • delay: Delay in milliseconds with promise
      • getWebsiteName: Get name of the website by checking the src
    • String.prototype
      • capitalize: Capitalize first character in the string
      • escapeRegExp: Escape all characters for regular expression
      • extractBetween: Extract the string between the start and end string. Return empty if no match found
  • Required for lodash
    • Functions
      • getHeadersCookie: Extract cookie from the headers. Using filter for specific cookie
      • getCookieExpireDate: Extract the expire date from cookie string
      • getHeadersCookieExpireDate: Extract cookie expire date from the headers. Using filter for specific cookie
      • convertToByReference: Pass in function arguments and return as pass by reference
      • convertArgumentsToByReference: Same as convertToByReference but return in Promise
      • compactObject: Compact object
  • Required for assert
    • Functions
      • handleTestError: Log the test error and assert for false
  • Required for iconv-lite
    • String.prototype/Buffer.prototype
      • encode: Encode string/buffer with charset
    • Buffer.prototype.decode: Decode buffer with charset
  • Required for opencc
    • String.prototype.toTraditional: Translate string to traditional chinese
    • String.prototype.toSimplified: Translate string to simplified chinese

License

MIT