@dxos/util 0.7.5-labs.a279d8c → 0.7.5-labs.c0e040f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +55 -48
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +51 -46
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +55 -48
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/index.d.ts +5 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/position.d.ts +15 -0
- package/dist/types/src/position.d.ts.map +1 -0
- package/dist/types/src/position.test.d.ts +2 -0
- package/dist/types/src/position.test.d.ts.map +1 -0
- package/dist/types/src/string.d.ts +5 -0
- package/dist/types/src/string.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +1 -2
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/index.ts +6 -6
- package/src/position.test.ts +98 -0
- package/src/position.ts +30 -0
- package/src/safe-parse.ts +1 -1
- package/src/string.ts +14 -0
- package/src/types.test.ts +2 -2
- package/src/types.ts +1 -6
- package/dist/types/src/disposition.d.ts +0 -15
- package/dist/types/src/disposition.d.ts.map +0 -1
- package/dist/types/src/disposition.test.d.ts +0 -2
- package/dist/types/src/disposition.test.d.ts.map +0 -1
- package/src/disposition.test.ts +0 -98
- package/src/disposition.ts +0 -30
|
@@ -61,6 +61,21 @@ var partition = (array, guard) => {
|
|
|
61
61
|
]);
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
// packages/common/util/src/array-to-hex.ts
|
|
65
|
+
var byteToHex = [];
|
|
66
|
+
for (let n = 0; n <= 255; ++n) {
|
|
67
|
+
const hexOctet = n.toString(16).padStart(2, "0");
|
|
68
|
+
byteToHex.push(hexOctet);
|
|
69
|
+
}
|
|
70
|
+
var arrayToHex = (buf) => {
|
|
71
|
+
const buff = new Uint8Array(buf);
|
|
72
|
+
const hexOctets = [];
|
|
73
|
+
for (let i = 0; i < buff.length; ++i) {
|
|
74
|
+
hexOctets.push(byteToHex[buff[i]]);
|
|
75
|
+
}
|
|
76
|
+
return hexOctets.join("");
|
|
77
|
+
};
|
|
78
|
+
|
|
64
79
|
// packages/common/util/src/binder.ts
|
|
65
80
|
import util from "@dxos/node-std/util";
|
|
66
81
|
var createBinder = (obj) => ({
|
|
@@ -569,20 +584,6 @@ var getDeep = (obj, path) => {
|
|
|
569
584
|
return parent;
|
|
570
585
|
};
|
|
571
586
|
|
|
572
|
-
// packages/common/util/src/disposition.ts
|
|
573
|
-
var byDisposition = (a, b) => {
|
|
574
|
-
const aDisposition = a.disposition ?? "static";
|
|
575
|
-
const bDisposition = b.disposition ?? "static";
|
|
576
|
-
if (aDisposition === bDisposition) {
|
|
577
|
-
return 0;
|
|
578
|
-
} else if (aDisposition === "hoist" || bDisposition === "fallback") {
|
|
579
|
-
return -1;
|
|
580
|
-
} else if (bDisposition === "hoist" || aDisposition === "fallback") {
|
|
581
|
-
return 1;
|
|
582
|
-
}
|
|
583
|
-
return 0;
|
|
584
|
-
};
|
|
585
|
-
|
|
586
587
|
// packages/common/util/src/entry.ts
|
|
587
588
|
var entry = (map, key) => new MapEntry(map, key);
|
|
588
589
|
var MapEntry = class {
|
|
@@ -1244,6 +1245,22 @@ var inferRecordOrder = (objectMap, order = []) => {
|
|
|
1244
1245
|
}, {}), objectMap);
|
|
1245
1246
|
};
|
|
1246
1247
|
|
|
1248
|
+
// packages/common/util/src/order-keys.ts
|
|
1249
|
+
var orderKeys = (obj, order) => {
|
|
1250
|
+
const ordered = {};
|
|
1251
|
+
for (const key of order) {
|
|
1252
|
+
if (key in obj) {
|
|
1253
|
+
ordered[key] = obj[key];
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
for (const key in obj) {
|
|
1257
|
+
if (!(key in ordered)) {
|
|
1258
|
+
ordered[key] = obj[key];
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
return ordered;
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1247
1264
|
// packages/common/util/src/pick.ts
|
|
1248
1265
|
var pick = (obj, keys) => {
|
|
1249
1266
|
return keys.reduce((result, key) => {
|
|
@@ -1313,6 +1330,20 @@ var getHostPlatform = () => {
|
|
|
1313
1330
|
}
|
|
1314
1331
|
};
|
|
1315
1332
|
|
|
1333
|
+
// packages/common/util/src/position.ts
|
|
1334
|
+
var byPosition = (a, b) => {
|
|
1335
|
+
const aPosition = a.position ?? "static";
|
|
1336
|
+
const bPosition = b.position ?? "static";
|
|
1337
|
+
if (aPosition === bPosition) {
|
|
1338
|
+
return 0;
|
|
1339
|
+
} else if (aPosition === "hoist" || bPosition === "fallback") {
|
|
1340
|
+
return -1;
|
|
1341
|
+
} else if (bPosition === "hoist" || aPosition === "fallback") {
|
|
1342
|
+
return 1;
|
|
1343
|
+
}
|
|
1344
|
+
return 0;
|
|
1345
|
+
};
|
|
1346
|
+
|
|
1316
1347
|
// packages/common/util/src/random.ts
|
|
1317
1348
|
var randomInt = (max, min = 0) => {
|
|
1318
1349
|
min = Math.ceil(min);
|
|
@@ -1462,7 +1493,7 @@ var safeParseFloat = (str, defaultValue) => {
|
|
|
1462
1493
|
}
|
|
1463
1494
|
};
|
|
1464
1495
|
var safeParseJson = (data, defaultValue) => {
|
|
1465
|
-
if (data) {
|
|
1496
|
+
if (data && data.length > 0) {
|
|
1466
1497
|
try {
|
|
1467
1498
|
return JSON.parse(data);
|
|
1468
1499
|
} catch (err) {
|
|
@@ -1845,8 +1876,7 @@ var stringifyTree = (node, ancestors = [], rows = []) => {
|
|
|
1845
1876
|
|
|
1846
1877
|
// packages/common/util/src/types.ts
|
|
1847
1878
|
var isNotFalsy = (value) => !!value;
|
|
1848
|
-
var
|
|
1849
|
-
var isNotNullOrUndefined = (value) => value != null;
|
|
1879
|
+
var isNonNullable = (value) => value != null;
|
|
1850
1880
|
var doAsync = async (fn) => fn();
|
|
1851
1881
|
var getProviderValue = (provider, arg) => {
|
|
1852
1882
|
return typeof provider === "function" ? provider(arg) : provider;
|
|
@@ -1971,19 +2001,12 @@ var WeakDictionary = class {
|
|
|
1971
2001
|
}
|
|
1972
2002
|
};
|
|
1973
2003
|
|
|
1974
|
-
// packages/common/util/src/
|
|
1975
|
-
var
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
byteToHex.push(hexOctet);
|
|
1979
|
-
}
|
|
1980
|
-
var arrayToHex = (buf) => {
|
|
1981
|
-
const buff = new Uint8Array(buf);
|
|
1982
|
-
const hexOctets = [];
|
|
1983
|
-
for (let i = 0; i < buff.length; ++i) {
|
|
1984
|
-
hexOctets.push(byteToHex[buff[i]]);
|
|
2004
|
+
// packages/common/util/src/string.ts
|
|
2005
|
+
var capitalize = (str) => {
|
|
2006
|
+
if (str.length === 0) {
|
|
2007
|
+
return "";
|
|
1985
2008
|
}
|
|
1986
|
-
return
|
|
2009
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1987
2010
|
};
|
|
1988
2011
|
|
|
1989
2012
|
// packages/common/util/src/remove-undefined-keys.ts
|
|
@@ -1998,22 +2021,6 @@ var removeUndefinedProperties = (object) => {
|
|
|
1998
2021
|
}
|
|
1999
2022
|
return object;
|
|
2000
2023
|
};
|
|
2001
|
-
|
|
2002
|
-
// packages/common/util/src/order-keys.ts
|
|
2003
|
-
var orderKeys = (obj, order) => {
|
|
2004
|
-
const ordered = {};
|
|
2005
|
-
for (const key of order) {
|
|
2006
|
-
if (key in obj) {
|
|
2007
|
-
ordered[key] = obj[key];
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
for (const key in obj) {
|
|
2011
|
-
if (!(key in ordered)) {
|
|
2012
|
-
ordered[key] = obj[key];
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
return ordered;
|
|
2016
|
-
};
|
|
2017
2024
|
export {
|
|
2018
2025
|
BitField,
|
|
2019
2026
|
Callback,
|
|
@@ -2033,7 +2040,8 @@ export {
|
|
|
2033
2040
|
arrayToString,
|
|
2034
2041
|
arraysEqual,
|
|
2035
2042
|
bufferToArray,
|
|
2036
|
-
|
|
2043
|
+
byPosition,
|
|
2044
|
+
capitalize,
|
|
2037
2045
|
chunkArray,
|
|
2038
2046
|
compareMulti,
|
|
2039
2047
|
compareObject,
|
|
@@ -2075,8 +2083,8 @@ export {
|
|
|
2075
2083
|
intersection,
|
|
2076
2084
|
iosCheck,
|
|
2077
2085
|
isNode,
|
|
2086
|
+
isNonNullable,
|
|
2078
2087
|
isNotFalsy,
|
|
2079
|
-
isNotNullOrUndefined,
|
|
2080
2088
|
joinTables,
|
|
2081
2089
|
jsonKeyReplacer,
|
|
2082
2090
|
jsonReplacer,
|
|
@@ -2090,7 +2098,6 @@ export {
|
|
|
2090
2098
|
mapValues,
|
|
2091
2099
|
median,
|
|
2092
2100
|
mobileAndTabletCheck,
|
|
2093
|
-
nonNullable,
|
|
2094
2101
|
numericalValues,
|
|
2095
2102
|
omit,
|
|
2096
2103
|
orderKeys,
|