Skip to content

Commit 1bae115

Browse files
committed
v5.4.7
1 parent 3604f22 commit 1bae115

File tree

12 files changed

+764
-739
lines changed

12 files changed

+764
-739
lines changed

coverage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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}}
1+
{"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}}

docs/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js/home.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js/single.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/umd/tinybase/index.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
arrayForEach(objEntries(obj), ([id, value]) => cb(value, id));
117117
const objToArray = (obj, cb) =>
118118
arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
119+
const objMap = (obj, cb) =>
120+
objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
119121
const objSize = (obj) => size(objIds(obj));
120122
const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
121123
const objEnsure = (obj, id, getDefaultValue) => {
@@ -134,7 +136,7 @@
134136
onInvalidObj?.();
135137
return false;
136138
}
137-
objToArray(obj, (child, id) => {
139+
objForEach(obj, (child, id) => {
138140
if (!validateChild(child, id)) {
139141
objDel(obj, id);
140142
}
@@ -177,7 +179,7 @@
177179
return mapGet(map, key);
178180
};
179181
const mapMatch = (map, obj, set, del = mapSet) => {
180-
objToArray(obj, (value, id) => set(map, id, value));
182+
objMap(obj, (value, id) => set(map, id, value));
181183
mapForEach(map, (id) => (objHas(obj, id) ? 0 : del(map, id)));
182184
return map;
183185
};
@@ -1616,7 +1618,7 @@
16161618
destroy,
16171619
getListenerStats,
16181620
};
1619-
objToArray(
1621+
objMap(
16201622
{
16211623
[TABLE]: [1, 1],
16221624
[TABLE + CELL_IDS]: [0, 1],
@@ -2684,7 +2686,7 @@
26842686
(tableId2, rowId2) => {
26852687
if (validateRow(tableId2, rowId2, partialRow, 1)) {
26862688
const table = getOrCreateTable(tableId2);
2687-
objToArray(partialRow, (cell, cellId) =>
2689+
objMap(partialRow, (cell, cellId) =>
26882690
setCellIntoDefaultRow(tableId2, table, rowId2, cellId, cell),
26892691
);
26902692
}
@@ -2724,7 +2726,7 @@
27242726
const setPartialValues = (partialValues) =>
27252727
fluentTransaction(() =>
27262728
validateValues(partialValues, 1)
2727-
? objToArray(partialValues, (value, valueId) =>
2729+
? objMap(partialValues, (value, valueId) =>
27282730
setValidValue(valueId, value),
27292731
)
27302732
: 0,
@@ -2743,18 +2745,18 @@
27432745
);
27442746
const applyChanges = (changes) =>
27452747
fluentTransaction(() => {
2746-
objToArray(changes[0], (table, tableId) =>
2748+
objMap(changes[0], (table, tableId) =>
27472749
isUndefined(table)
27482750
? delTable(tableId)
2749-
: objToArray(table, (row, rowId) =>
2751+
: objMap(table, (row, rowId) =>
27502752
isUndefined(row)
27512753
? delRow(tableId, rowId)
2752-
: objToArray(row, (cell, cellId) =>
2754+
: objMap(row, (cell, cellId) =>
27532755
setOrDelCell(store, tableId, rowId, cellId, cell),
27542756
),
27552757
),
27562758
);
2757-
objToArray(changes[1], (value, valueId) =>
2759+
objMap(changes[1], (value, valueId) =>
27582760
setOrDelValue(store, valueId, value),
27592761
);
27602762
});
@@ -3190,7 +3192,7 @@
31903192
callListeners,
31913193
setInternalListeners,
31923194
};
3193-
objToArray(
3195+
objMap(
31943196
{
31953197
[HAS + TABLES]: [0, hasTablesListeners, [], () => [hasTables()]],
31963198
[TABLES]: [0, tablesListeners],
@@ -3801,7 +3803,7 @@
38013803
cellChanged,
38023804
valueChanged,
38033805
);
3804-
objToArray(
3806+
objMap(
38053807
store,
38063808
(method, name) =>
38073809
(mergeableStore[name] = // fluent methods

docs/umd/tinybase/store/index.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@
7575
);
7676
const objIds = object.keys;
7777
const objFreeze = object.freeze;
78+
const objNew = (entries = []) => object.fromEntries(entries);
7879
const objHas = (obj, id) => id in obj;
7980
const objDel = (obj, id) => {
8081
delete obj[id];
8182
return obj;
8283
};
84+
const objForEach = (obj, cb) =>
85+
arrayForEach(objEntries(obj), ([id, value]) => cb(value, id));
8386
const objToArray = (obj, cb) =>
8487
arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
88+
const objMap = (obj, cb) =>
89+
objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
8590
const objSize = (obj) => size(objIds(obj));
8691
const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
8792
const objValidate = (obj, validateChild, onInvalidObj, emptyIsValid = 0) => {
@@ -94,7 +99,7 @@
9499
onInvalidObj?.();
95100
return false;
96101
}
97-
objToArray(obj, (child, id) => {
102+
objForEach(obj, (child, id) => {
98103
if (!validateChild(child, id)) {
99104
objDel(obj, id);
100105
}
@@ -137,7 +142,7 @@
137142
return mapGet(map, key);
138143
};
139144
const mapMatch = (map, obj, set, del = mapSet) => {
140-
objToArray(obj, (value, id) => set(map, id, value));
145+
objMap(obj, (value, id) => set(map, id, value));
141146
mapForEach(map, (id) => (objHas(obj, id) ? 0 : del(map, id)));
142147
return map;
143148
};
@@ -1115,7 +1120,7 @@
11151120
(tableId2, rowId2) => {
11161121
if (validateRow(tableId2, rowId2, partialRow, 1)) {
11171122
const table = getOrCreateTable(tableId2);
1118-
objToArray(partialRow, (cell, cellId) =>
1123+
objMap(partialRow, (cell, cellId) =>
11191124
setCellIntoDefaultRow(tableId2, table, rowId2, cellId, cell),
11201125
);
11211126
}
@@ -1155,7 +1160,7 @@
11551160
const setPartialValues = (partialValues) =>
11561161
fluentTransaction(() =>
11571162
validateValues(partialValues, 1)
1158-
? objToArray(partialValues, (value, valueId) =>
1163+
? objMap(partialValues, (value, valueId) =>
11591164
setValidValue(valueId, value),
11601165
)
11611166
: 0,
@@ -1174,18 +1179,18 @@
11741179
);
11751180
const applyChanges = (changes) =>
11761181
fluentTransaction(() => {
1177-
objToArray(changes[0], (table, tableId) =>
1182+
objMap(changes[0], (table, tableId) =>
11781183
isUndefined(table)
11791184
? delTable(tableId)
1180-
: objToArray(table, (row, rowId) =>
1185+
: objMap(table, (row, rowId) =>
11811186
isUndefined(row)
11821187
? delRow(tableId, rowId)
1183-
: objToArray(row, (cell, cellId) =>
1188+
: objMap(row, (cell, cellId) =>
11841189
setOrDelCell(store, tableId, rowId, cellId, cell),
11851190
),
11861191
),
11871192
);
1188-
objToArray(changes[1], (value, valueId) =>
1193+
objMap(changes[1], (value, valueId) =>
11891194
setOrDelValue(store, valueId, value),
11901195
);
11911196
});
@@ -1621,7 +1626,7 @@
16211626
callListeners,
16221627
setInternalListeners,
16231628
};
1624-
objToArray(
1629+
objMap(
16251630
{
16261631
[HAS + TABLES]: [0, hasTablesListeners, [], () => [hasTables()]],
16271632
[TABLES]: [0, tablesListeners],

docs/umd/tinybase/ui-react-inspector/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@
130130
delete obj[id];
131131
return obj;
132132
};
133+
const objForEach = (obj, cb) =>
134+
arrayForEach(objEntries(obj), ([id, value]) => cb(value, id));
133135
const objToArray = (obj, cb) =>
134136
arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
135137
const objMap = (obj, cb) =>
@@ -146,7 +148,7 @@
146148
onInvalidObj?.();
147149
return false;
148150
}
149-
objToArray(obj, (child, id) => {
151+
objForEach(obj, (child, id) => {
150152
if (!validateChild(child, id)) {
151153
objDel(obj, id);
152154
}
@@ -1577,7 +1579,7 @@
15771579
return mapGet(map, key);
15781580
};
15791581
const mapMatch = (map, obj, set, del = mapSet) => {
1580-
objToArray(obj, (value, id) => set(map, id, value));
1582+
objMap(obj, (value, id) => set(map, id, value));
15811583
mapForEach(map, (id) => (objHas(obj, id) ? 0 : del(map, id)));
15821584
return map;
15831585
};
@@ -2788,7 +2790,7 @@
27882790
(tableId2, rowId2) => {
27892791
if (validateRow(tableId2, rowId2, partialRow, 1)) {
27902792
const table = getOrCreateTable(tableId2);
2791-
objToArray(partialRow, (cell, cellId) =>
2793+
objMap(partialRow, (cell, cellId) =>
27922794
setCellIntoDefaultRow(tableId2, table, rowId2, cellId, cell),
27932795
);
27942796
}
@@ -2828,7 +2830,7 @@
28282830
const setPartialValues = (partialValues) =>
28292831
fluentTransaction(() =>
28302832
validateValues(partialValues, 1)
2831-
? objToArray(partialValues, (value, valueId) =>
2833+
? objMap(partialValues, (value, valueId) =>
28322834
setValidValue(valueId, value),
28332835
)
28342836
: 0,
@@ -2847,18 +2849,18 @@
28472849
);
28482850
const applyChanges = (changes) =>
28492851
fluentTransaction(() => {
2850-
objToArray(changes[0], (table, tableId) =>
2852+
objMap(changes[0], (table, tableId) =>
28512853
isUndefined(table)
28522854
? delTable(tableId)
2853-
: objToArray(table, (row, rowId) =>
2855+
: objMap(table, (row, rowId) =>
28542856
isUndefined(row)
28552857
? delRow(tableId, rowId)
2856-
: objToArray(row, (cell, cellId) =>
2858+
: objMap(row, (cell, cellId) =>
28572859
setOrDelCell(store, tableId, rowId, cellId, cell),
28582860
),
28592861
),
28602862
);
2861-
objToArray(changes[1], (value, valueId) =>
2863+
objMap(changes[1], (value, valueId) =>
28622864
setOrDelValue(store, valueId, value),
28632865
);
28642866
});
@@ -3294,7 +3296,7 @@
32943296
callListeners,
32953297
setInternalListeners,
32963298
};
3297-
objToArray(
3299+
objMap(
32983300
{
32993301
[HAS + TABLES]: [0, hasTablesListeners, [], () => [hasTables()]],
33003302
[TABLES]: [0, tablesListeners],

0 commit comments

Comments
 (0)