html-squircle
Version:
Utilities for generating superellipse squircles in the form of SVG strings, to be used in clip-path and background inline styles.
28 lines (27 loc) • 1.18 kB
JavaScript
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = /*#__PURE__*/factory(require, exports);
if (v !== undefined) module.exports = v;
} else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./fillOptions.js", "./isObject.js"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.sortAndSerialize = void 0;
const fillOptions_js_1 = require("./fillOptions.js");
const isObject_js_1 = require("./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 => (0, isObject_js_1.isObject)(input) ? Object.entries(input).sort(sortEntryByKey).map(handleEntry).join(";") : `${input}`;
const sortAndSerialize = input =>
// @ts-expect-error Interfaces don't have index signatures
sortAndSerializeOptions((0, fillOptions_js_1.fillOptions)(input));
exports.sortAndSerialize = sortAndSerialize;
});