0.4.1 • Published 4 years ago

@techstars/utils v0.4.1

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

@techstars/utils

A handy utilities collection to be used as-needed across the monorepo. Before adding a new abstraction for your code, it's a good idea to check here for what you need.

Code Coverage

Coverage:branches

Coverage:functions

Coverage:lines

Coverage:statements

Available Methods

  • momentLib: Collection of common moment.js functions. It's useful to leave calls to moment in this package, that way we only have to think about it as a dependency stemming from one location.

    • .today(): Get today's date formatted using the monorepo's convention
    • .format(:string || :object): Format a string or date object using our convention
    • .daysLeft(:string || :object): Determine the days left before a passed date
    • .isPast(:string): Determine if a date is in the past
    • .isFuture(:string): Determine if a date is in the future
    • .isNowOrPast(:string): Determine if a date is current or in the past
    • .isNowOrFuture(:string): Determine if a date is current or in the future
    • .daysAgo(:integer): Return the date from X days ago, where X is a valid integer
    • .daysFromNow(:integer): Return the date X days from now, where X is a valid integer
  • .prefixHttp(:string): Convert an https url to an insecure http one

  • .nameToSlug(:string): Convert a passed name object to a slug, eg. Techstars New York Accelerator to techstars-new-york-accelerator
  • .slugToName(:string): Convert a passed slug to a human-readable name, eg. techstars-new-york-accelerator to Techstars New York Accelerator

Adding new methods

Feel free to add new methods to the collection as you see fit. Make sure to namespace grouped methods to a single object, as in momentLib. Please also add new methods to our specs at ../test.