curated2: !47
This commit is contained in:
commit
44fcd7ead6
17 files changed
+281
-5
No files matched your search
@@ -421,6 +421,22 @@ export function supersetUnits(items) {
|
||||
})
|
||||
return units
|
||||
}
|
||||
|
||||
// Move the selected occurrence's complete display unit by one neighbouring unit. Returning a
|
||||
// new array keeps this helper pure; the caller decides how to persist it. Index identity matters
|
||||
// here because the same exercise id may appear more than once with different setup.
|
||||
export function moveSupersetUnit(items, index, direction) {
|
||||
if (!Array.isArray(items) || (direction !== -1 && direction !== 1)) return null
|
||||
const units = supersetUnits(items)
|
||||
const source = units.findIndex(unit => unit.includes(index))
|
||||
const target = source + direction
|
||||
if (source < 0 || target < 0 || target >= units.length) return null
|
||||
const reordered = [...units]
|
||||
const selected = reordered[source]
|
||||
reordered[source] = reordered[target]
|
||||
reordered[target] = selected
|
||||
return reordered.flat().map(i => items[i])
|
||||
}
|
||||
export function unitOf(units, idx) { return units.find(u => u.includes(idx)) || [idx] }
|
||||
|
||||
export function streakWeeks(S) {
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('Brazilian Portuguese locale', () => {
|
||||
.sort(byCodeUnit)
|
||||
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
|
||||
|
||||
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(291)
|
||||
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(293)
|
||||
expect(inherited).toHaveLength(449)
|
||||
// If this fails, review the changed keys and wording before accepting a new hash. From
|
||||
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
|
||||
|
||||
Reference in new issue
Block a user