Returns the string that matches the string (if it exits). Great for matching string union types.
const methods = ['GET', 'PUT', 'POST', 'PATCH', 'DELETE'] as const;const methodStr: string = 'GET';const method = equalsOneOf(methodStr, methods);if (method) { // if method was just a string this would be a type error methods.includes(method)} Copy
const methods = ['GET', 'PUT', 'POST', 'PATCH', 'DELETE'] as const;const methodStr: string = 'GET';const method = equalsOneOf(methodStr, methods);if (method) { // if method was just a string this would be a type error methods.includes(method)}
Returns the string that matches the string (if it exits). Great for matching string union types.