@wordpress/interactivity-router
Version:
Package that exposes state and actions from the `core/router` store, part of the Interactivity API.
56 lines (54 loc) • 1.89 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// packages/interactivity-router/src/assets/scs.ts
var scs_exports = {};
__export(scs_exports, {
shortestCommonSupersequence: () => shortestCommonSupersequence
});
module.exports = __toCommonJS(scs_exports);
function shortestCommonSupersequence(X, Y, isEqual = (a, b) => a === b) {
const m = X.length;
const n = Y.length;
const dp = Array.from(
{ length: m + 1 },
() => Array(n + 1).fill(null)
);
for (let i = 0; i <= m; i++) {
dp[i][0] = X.slice(0, i);
}
for (let j = 0; j <= n; j++) {
dp[0][j] = Y.slice(0, j);
}
for (let i = 1; i <= m; i++) {
for (let j = 1; j <= n; j++) {
if (isEqual(X[i - 1], Y[j - 1])) {
dp[i][j] = dp[i - 1][j - 1].concat(X[i - 1]);
} else {
const option1 = dp[i - 1][j].concat(X[i - 1]);
const option2 = dp[i][j - 1].concat(Y[j - 1]);
dp[i][j] = option1.length <= option2.length ? option1 : option2;
}
}
}
return dp[m][n];
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
shortestCommonSupersequence
});
//# sourceMappingURL=scs.cjs.map