Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
/*
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
Author Tobias Koppers @sokra
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Compare two arrays or strings by performing strict equality check for each value.
|
|
* @template T
|
|
* @param {ArrayLike<T>} a Array of values to be compared
|
|
* @param {ArrayLike<T>} b Array of values to be compared
|
|
* @returns {boolean} returns true if all the elements of passed arrays are strictly equal.
|
|
*/
|
|
module.exports.equals = (a, b) => {
|
|
if (a.length !== b.length) return false;
|
|
for (let i = 0; i < a.length; i++) {
|
|
if (a[i] !== b[i]) return false;
|
|
}
|
|
return true;
|
|
};
|
|
|
|
/**
|
|
* Partition an array by calling a predicate function on each value.
|
|
* @template T
|
|
* @param {T[]} arr Array of values to be partitioned
|
|
* @param {(value: T) => boolean} fn Partition function which partitions based on truthiness of result.
|
|
* @returns {[T[], T[]]} returns the values of `arr` partitioned into two new arrays based on fn predicate.
|
|
*/
|
|
module.exports.groupBy = (
|
|
// eslint-disable-next-line default-param-last
|
|
arr = [],
|
|
fn
|
|
) =>
|
|
arr.reduce(
|
|
/**
|
|
* @param {[T[], T[]]} groups An accumulator storing already partitioned values returned from previous call.
|
|
* @param {T} value The value of the current element
|
|
* @returns {[T[], T[]]} returns an array of partitioned groups accumulator resulting from calling a predicate on the current value.
|
|
*/
|
|
(groups, value) => {
|
|
groups[fn(value) ? 0 : 1].push(value);
|
|
return groups;
|
|
},
|
|
[[], []]
|
|
);
|