Skip to content

Commit

Permalink
v5.4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgpearce committed Jan 27, 2025
1 parent 3604f22 commit 1bae115
Show file tree
Hide file tree
Showing 12 changed files with 764 additions and 739 deletions.
2 changes: 1 addition & 1 deletion coverage.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"tests":7464,"assertions":33210,"lines":{"total":2290,"covered":2290,"skipped":0,"pct":100},"statements":{"total":2474,"covered":2474,"skipped":0,"pct":100},"functions":{"total":988,"covered":988,"skipped":0,"pct":100},"branches":{"total":856,"covered":856,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
{"tests":7464,"assertions":33196,"lines":{"total":2292,"covered":2292,"skipped":0,"pct":100},"statements":{"total":2477,"covered":2477,"skipped":0,"pct":100},"functions":{"total":990,"covered":990,"skipped":0,"pct":100},"branches":{"total":856,"covered":856,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
4 changes: 2 additions & 2 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/js/home.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/js/single.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions docs/umd/tinybase/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
arrayForEach(objEntries(obj), ([id, value]) => cb(value, id));
const objToArray = (obj, cb) =>
arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
const objMap = (obj, cb) =>
objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
const objSize = (obj) => size(objIds(obj));
const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
const objEnsure = (obj, id, getDefaultValue) => {
Expand All @@ -134,7 +136,7 @@
onInvalidObj?.();
return false;
}
objToArray(obj, (child, id) => {
objForEach(obj, (child, id) => {
if (!validateChild(child, id)) {
objDel(obj, id);
}
Expand Down Expand Up @@ -177,7 +179,7 @@
return mapGet(map, key);
};
const mapMatch = (map, obj, set, del = mapSet) => {
objToArray(obj, (value, id) => set(map, id, value));
objMap(obj, (value, id) => set(map, id, value));
mapForEach(map, (id) => (objHas(obj, id) ? 0 : del(map, id)));
return map;
};
Expand Down Expand Up @@ -1616,7 +1618,7 @@
destroy,
getListenerStats,
};
objToArray(
objMap(
{
[TABLE]: [1, 1],
[TABLE + CELL_IDS]: [0, 1],
Expand Down Expand Up @@ -2684,7 +2686,7 @@
(tableId2, rowId2) => {
if (validateRow(tableId2, rowId2, partialRow, 1)) {
const table = getOrCreateTable(tableId2);
objToArray(partialRow, (cell, cellId) =>
objMap(partialRow, (cell, cellId) =>
setCellIntoDefaultRow(tableId2, table, rowId2, cellId, cell),
);
}
Expand Down Expand Up @@ -2724,7 +2726,7 @@
const setPartialValues = (partialValues) =>
fluentTransaction(() =>
validateValues(partialValues, 1)
? objToArray(partialValues, (value, valueId) =>
? objMap(partialValues, (value, valueId) =>
setValidValue(valueId, value),
)
: 0,
Expand All @@ -2743,18 +2745,18 @@
);
const applyChanges = (changes) =>
fluentTransaction(() => {
objToArray(changes[0], (table, tableId) =>
objMap(changes[0], (table, tableId) =>
isUndefined(table)
? delTable(tableId)
: objToArray(table, (row, rowId) =>
: objMap(table, (row, rowId) =>
isUndefined(row)
? delRow(tableId, rowId)
: objToArray(row, (cell, cellId) =>
: objMap(row, (cell, cellId) =>
setOrDelCell(store, tableId, rowId, cellId, cell),
),
),
);
objToArray(changes[1], (value, valueId) =>
objMap(changes[1], (value, valueId) =>
setOrDelValue(store, valueId, value),
);
});
Expand Down Expand Up @@ -3190,7 +3192,7 @@
callListeners,
setInternalListeners,
};
objToArray(
objMap(
{
[HAS + TABLES]: [0, hasTablesListeners, [], () => [hasTables()]],
[TABLES]: [0, tablesListeners],
Expand Down Expand Up @@ -3801,7 +3803,7 @@
cellChanged,
valueChanged,
);
objToArray(
objMap(
store,
(method, name) =>
(mergeableStore[name] = // fluent methods
Expand Down
23 changes: 14 additions & 9 deletions docs/umd/tinybase/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@
);
const objIds = object.keys;
const objFreeze = object.freeze;
const objNew = (entries = []) => object.fromEntries(entries);
const objHas = (obj, id) => id in obj;
const objDel = (obj, id) => {
delete obj[id];
return obj;
};
const objForEach = (obj, cb) =>
arrayForEach(objEntries(obj), ([id, value]) => cb(value, id));
const objToArray = (obj, cb) =>
arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
const objMap = (obj, cb) =>
objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
const objSize = (obj) => size(objIds(obj));
const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
const objValidate = (obj, validateChild, onInvalidObj, emptyIsValid = 0) => {
Expand All @@ -94,7 +99,7 @@
onInvalidObj?.();
return false;
}
objToArray(obj, (child, id) => {
objForEach(obj, (child, id) => {
if (!validateChild(child, id)) {
objDel(obj, id);
}
Expand Down Expand Up @@ -137,7 +142,7 @@
return mapGet(map, key);
};
const mapMatch = (map, obj, set, del = mapSet) => {
objToArray(obj, (value, id) => set(map, id, value));
objMap(obj, (value, id) => set(map, id, value));
mapForEach(map, (id) => (objHas(obj, id) ? 0 : del(map, id)));
return map;
};
Expand Down Expand Up @@ -1115,7 +1120,7 @@
(tableId2, rowId2) => {
if (validateRow(tableId2, rowId2, partialRow, 1)) {
const table = getOrCreateTable(tableId2);
objToArray(partialRow, (cell, cellId) =>
objMap(partialRow, (cell, cellId) =>
setCellIntoDefaultRow(tableId2, table, rowId2, cellId, cell),
);
}
Expand Down Expand Up @@ -1155,7 +1160,7 @@
const setPartialValues = (partialValues) =>
fluentTransaction(() =>
validateValues(partialValues, 1)
? objToArray(partialValues, (value, valueId) =>
? objMap(partialValues, (value, valueId) =>
setValidValue(valueId, value),
)
: 0,
Expand All @@ -1174,18 +1179,18 @@
);
const applyChanges = (changes) =>
fluentTransaction(() => {
objToArray(changes[0], (table, tableId) =>
objMap(changes[0], (table, tableId) =>
isUndefined(table)
? delTable(tableId)
: objToArray(table, (row, rowId) =>
: objMap(table, (row, rowId) =>
isUndefined(row)
? delRow(tableId, rowId)
: objToArray(row, (cell, cellId) =>
: objMap(row, (cell, cellId) =>
setOrDelCell(store, tableId, rowId, cellId, cell),
),
),
);
objToArray(changes[1], (value, valueId) =>
objMap(changes[1], (value, valueId) =>
setOrDelValue(store, valueId, value),
);
});
Expand Down Expand Up @@ -1621,7 +1626,7 @@
callListeners,
setInternalListeners,
};
objToArray(
objMap(
{
[HAS + TABLES]: [0, hasTablesListeners, [], () => [hasTables()]],
[TABLES]: [0, tablesListeners],
Expand Down
20 changes: 11 additions & 9 deletions docs/umd/tinybase/ui-react-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
delete obj[id];
return obj;
};
const objForEach = (obj, cb) =>
arrayForEach(objEntries(obj), ([id, value]) => cb(value, id));
const objToArray = (obj, cb) =>
arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
const objMap = (obj, cb) =>
Expand All @@ -146,7 +148,7 @@
onInvalidObj?.();
return false;
}
objToArray(obj, (child, id) => {
objForEach(obj, (child, id) => {
if (!validateChild(child, id)) {
objDel(obj, id);
}
Expand Down Expand Up @@ -1577,7 +1579,7 @@
return mapGet(map, key);
};
const mapMatch = (map, obj, set, del = mapSet) => {
objToArray(obj, (value, id) => set(map, id, value));
objMap(obj, (value, id) => set(map, id, value));
mapForEach(map, (id) => (objHas(obj, id) ? 0 : del(map, id)));
return map;
};
Expand Down Expand Up @@ -2788,7 +2790,7 @@
(tableId2, rowId2) => {
if (validateRow(tableId2, rowId2, partialRow, 1)) {
const table = getOrCreateTable(tableId2);
objToArray(partialRow, (cell, cellId) =>
objMap(partialRow, (cell, cellId) =>
setCellIntoDefaultRow(tableId2, table, rowId2, cellId, cell),
);
}
Expand Down Expand Up @@ -2828,7 +2830,7 @@
const setPartialValues = (partialValues) =>
fluentTransaction(() =>
validateValues(partialValues, 1)
? objToArray(partialValues, (value, valueId) =>
? objMap(partialValues, (value, valueId) =>
setValidValue(valueId, value),
)
: 0,
Expand All @@ -2847,18 +2849,18 @@
);
const applyChanges = (changes) =>
fluentTransaction(() => {
objToArray(changes[0], (table, tableId) =>
objMap(changes[0], (table, tableId) =>
isUndefined(table)
? delTable(tableId)
: objToArray(table, (row, rowId) =>
: objMap(table, (row, rowId) =>
isUndefined(row)
? delRow(tableId, rowId)
: objToArray(row, (cell, cellId) =>
: objMap(row, (cell, cellId) =>
setOrDelCell(store, tableId, rowId, cellId, cell),
),
),
);
objToArray(changes[1], (value, valueId) =>
objMap(changes[1], (value, valueId) =>
setOrDelValue(store, valueId, value),
);
});
Expand Down Expand Up @@ -3294,7 +3296,7 @@
callListeners,
setInternalListeners,
};
objToArray(
objMap(
{
[HAS + TABLES]: [0, hasTablesListeners, [], () => [hasTables()]],
[TABLES]: [0, tablesListeners],
Expand Down
Loading

0 comments on commit 1bae115

Please sign in to comment.