Skip to content

Commit 1e36016

Browse files
committed
v5.2.2
1 parent 6b6e322 commit 1e36016

File tree

10 files changed

+84
-73
lines changed

10 files changed

+84
-73
lines changed

coverage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"tests":7339,"assertions":32979,"lines":{"total":2224,"covered":2224,"skipped":0,"pct":100},"statements":{"total":2400,"covered":2400,"skipped":0,"pct":100},"functions":{"total":958,"covered":958,"skipped":0,"pct":100},"branches":{"total":858,"covered":858,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
1+
{"tests":7339,"assertions":32954,"lines":{"total":2231,"covered":2231,"skipped":0,"pct":100},"statements":{"total":2409,"covered":2409,"skipped":0,"pct":100},"functions":{"total":961,"covered":961,"skipped":0,"pct":100},"branches":{"total":860,"covered":859,"skipped":0,"pct":99.88},"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/ui-react/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
'use strict';
1111

1212
const getTypeOf = (thing) => typeof thing;
13+
const TINYBASE = 'tinybase';
1314
const EMPTY_STRING = '';
1415
const STRING = getTypeOf(EMPTY_STRING);
1516
const FUNCTION = getTypeOf(getTypeOf);
@@ -33,6 +34,7 @@
3334
const VALUES = VALUE + 's';
3435
const VALUE_IDS = VALUE + IDS;
3536

37+
const GLOBAL = globalThis;
3638
const isUndefined = (thing) => thing == void 0;
3739
const ifNotUndefined = (value, then, otherwise) =>
3840
isUndefined(value) ? otherwise?.() : then(value);
@@ -66,6 +68,7 @@
6668
);
6769
const objIds = object.keys;
6870
const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
71+
const objHas = (obj, id) => id in obj;
6972
const objDel = (obj, id) => {
7073
delete obj[id];
7174
return obj;
@@ -84,13 +87,21 @@
8487
)
8588
);
8689
};
90+
const objEnsure = (obj, id, getDefaultValue) => {
91+
if (!objHas(obj, id)) {
92+
obj[id] = getDefaultValue();
93+
}
94+
return obj[id];
95+
};
8796

8897
const {
8998
createContext,
9099
useContext: useContext$1,
91100
useEffect: useEffect$1,
92101
} = React;
93-
const Context = createContext([]);
102+
const Context = objEnsure(GLOBAL, TINYBASE + '_uirc', () =>
103+
createContext([]),
104+
);
94105
const useThing = (id, offset) => {
95106
const contextValue = useContext$1(Context);
96107
return isUndefined(id)

0 commit comments

Comments
 (0)