Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// -----------------------------------------------------------------------------
// Utils
// -----------------------------------------------------------------------------
const constructError = construct(Error)
const throwError = error => {
throw error
}
const throwNewError = compose(throwError, constructError)
export const throwErrorWithMessage = compose(
throwNewError,
joinWithSpace,
appendFlipped([ERROR_PREFIX])
)
export const throwErrorWithPrefixedMessage = prefix =>
compose(throwErrorWithMessage, joinWithSpace, appendFlipped([prefix]))
// -----------------------------------------------------------------------------
// Prefixed Errors
// -----------------------------------------------------------------------------
export const throwConfigureError = compose(
throwErrorWithPrefixedMessage(CONFIGURE_PREFIX),
argumentsFailureRenderer
)
export const throwAPIMediaTypeError = compose(
throwErrorWithPrefixedMessage(API_MEDIA_TYPE_PREFIX),
const writeToString = outputString =>
compose(joinWithDoubleNewlines, compact, appendFlipped([outputString]))
const createMappingByIndex = breakpointMap => (mappings, value, idx) =>
pipe(
findBreakpointByIndex(breakpointMap),
insert(1, value),
apply(createBreakpointMapping),
appendFlipped(mappings)
)(idx)
const createMappingByName = breakpointMap => (
mappings,
{ name, range, value }
) =>
pipe(
processRange(breakpointMap),
createBreakpointMapping(name, value),
appendFlipped(mappings)
)(range)
const reducer = (propName, data, style) => (declarations, breakpointMapping) =>
pipe(processDeclaration, appendFlipped(declarations))(
propName,
data,
style,
breakpointMapping
)
const parseBreakpointToMap = (breakpoints, [name, value]) =>
pipe(parseBreakpoint, assocValue(value), appendFlipped(breakpoints))(name)
const processDeclaration = declarationProcessors => (
acc,
[processorName, args]
) => {
const property = prop(processorName, declarationProcessors)
when(isNil, () => throwAPIError(invalidPropertyError(processorName)))(
property
)
return pipe(ensureArray, apply(property), appendFlipped(acc))(args)
}
const throwPrefixedError = prefix =>
compose(throwLibError, joinWithSpace, appendFlipped([prefix]))
const appendCSS = css =>
unless(
always(isEmptyString(css)),
compose(joinWithNewline, appendFlipped([css]))
)