node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org ยป



This module contains utility functions that are common in UW Foster applications.


npm install uwfoster-util --save


import uwutil from 'uwsoster-util';

let outputString = uwutil.strFormat.padAndTruncate('A string goes here.', 50);

// outputstring = "A string goes here.                               "


The strFormat functions are used to format data for output and return strings.


The days of week function takes a comma-separated string or an array of day objects ({ Name: "Monday" }) and returns a 7-character string representing the days passed in. Days not passed in are represented as spaces in their respective position. For example if "Monday, Wednesday, Friday" is passed in, " M W F " is returned.


The pad and trim function ensures that the passed in string is returned with a specified length. The string is either padded with spaces or trimmed to length.


The truncate on last comma function takes a comma separated string and trims it at the last comma-separated item to ensure it is shorter than the specified length. The function also adds ellipsis to the end of the string to indicate the list has been truncated.


  • Kevin Coleman