Check to see if an object has a property, typescript cast as object type if it does.
(any)
Object to test
(String)
Property to check for
Boolean
:
True if found, false if not
Returns the closest day record to the current date
(Array<Day>)
Array of Master Tour Day objects
(Day | Boolean)
:
Master Tour Day object or false if no day found
Builds a simple array of phone, email, and URL info.
Array
:
Array of objects with type and url added to the contact method
String compare function for use in sorting arrays
number
:
1 if b is greater, -1 if a is greater, 0 if equal
import { compareStrings } from "@eventric/mastertour"
// -1
const formattedAddress = compareStrings("tango", "bravo");
// 0
const formattedAddress = compareStrings("racecar", "RACECAR");
Check to see if a timezone is valid with a predefined list of invalid options, and others checked from moment-timezone's database
(string)
TimeZone value to check
boolean
:
true if valid, false if not
import { isValidTimeZone } from "@eventric/mastertour"
// true
const valid = isValidTimeZone("America/Chicago");
// false
const valid = isValidTimeZone("glenn");
Convert a Master Tour XML field to a Javascript object
(string)
XML string to be converted
(string | object)
:
If valid XML, it will be a Javascript object, otherwise, the original string
import { convertFromXML } from "@eventric/mastertour"
// {dataStore: { audioPower: "200amp 3-Phase" } }
const values = convertFromXML("<dataStore><audioPower>200amp 3-Phase</audioPower></dataStore>");
// "some string that isn't XML"
const values = convertFromXML("some string that isn't XML");
Build an array of date objects beginning with the start date, ending with the end date, and include an array item for each day in-between
Array
:
Array of date objects
import { getDatesBetweenDates } from "@eventric/mastertour"
// returns [Date(2021, 0, 1), Date(2021, 0, 2), Date(2021, 0, 3)]
getDatesBetweenDates({
startDate: new Date(2021, 0, 1),
endDate: new Date(2021, 0, 3)
})
Takes in a rgb color string and determines if color hue is light for dark text or vice verse
string
:
capitalized initials of passed string
import { initials } from "@eventric/mastertour"
const data = { incomingString: "Weird Al Yankovich" };
// "WAY"
const truncatedData = initials(data);
Extract the contact records in an easier to use format from a Company or Contact record
(Object)
Object with a phoneXml field
Object
:
Object with arrays of email, phone, and url records.
getAttachmentPath will generate a standardized path for a file based on the organizationId, parentVo/id, and it's subtype.
(Attachment)
Master Tour Attachment record
string
:
Standardized path for file
import { getAttachmentPath } from "@eventric/mastertour"
const attachment = {
organizationId: "org12345",
parentVo: "day",
parentId: "day12345",
subtype: "attachment",
filename: "tech-pack.pdf"
};
// "org12345/day-day12345/attachment/tech-pack.pdf"
const pathToFile = getAttachmentPath(attachment);
Formats an address as "adressLine1, city, state zip country"
string
:
Standardized address
import { formatAddress } from "@eventric/mastertour"
const data = {
addressLine1: "123 Main st",
city: "MockCity",
country: "MockCountry"
state: "MockState",
zip: "MockZip",
};
// "123 Main st, MockCity, MockState, MockZip MockCountry"
const formattedAddress = formatAddress(data);