html-squircle
Version:
Utilities for generating superellipse squircles in the form of SVG strings, to be used in clip-path and background inline styles.
12 lines • 565 B
JavaScript
import { fillOptions } from "./fillOptions.js";
import { isObject } from "./isObject.js";
const sortEntryByKey = ([a], [b]) => {
if (a < b) return -1;
if (a > b) return 1;
return 0;
};
const handleEntry = ([key, value]) => [key, sortAndSerializeOptions(value)].join(":");
const sortAndSerializeOptions = input => isObject(input) ? Object.entries(input).sort(sortEntryByKey).map(handleEntry).join(";") : `${input}`;
export const sortAndSerialize = input =>
// @ts-expect-error Interfaces don't have index signatures
sortAndSerializeOptions(fillOptions(input));