@bbn/bbn 2.0.237 → 2.0.238

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.
Files changed (83) hide show
  1. package/dist/$.js +1 -1
  2. package/dist/bbn.js +3 -3
  3. package/dist/bbn.js.map +1 -1
  4. package/dist/bbn.sw.js +3 -3
  5. package/dist/bbn.sw.js.map +1 -1
  6. package/dist/com.js +13 -21
  7. package/dist/{vars.d.ts → data.d.ts} +1 -0
  8. package/dist/{vars.js → data.js} +1 -0
  9. package/dist/db/classes/Object.d.ts +3 -0
  10. package/dist/db/classes/Object.js +458 -0
  11. package/dist/db/classes/ObjectProxy.d.ts +18 -0
  12. package/dist/db/classes/ObjectProxy.js +77 -0
  13. package/dist/db/classes/Proxy.d.ts +17 -0
  14. package/dist/db/classes/Proxy.js +66 -0
  15. package/dist/db/functions/fieldsFromFilter.d.ts +1 -0
  16. package/dist/db/functions/fieldsFromFilter.js +33 -0
  17. package/dist/db/functions/getPrimaryKey.d.ts +2 -0
  18. package/dist/db/functions/getPrimaryKey.js +8 -0
  19. package/dist/db/functions/requestToPromise.d.ts +1 -0
  20. package/dist/db/functions/requestToPromise.js +6 -0
  21. package/dist/db/functions/transactionDone.d.ts +1 -0
  22. package/dist/db/functions/transactionDone.js +7 -0
  23. package/dist/db/functions/transformResult.d.ts +1 -0
  24. package/dist/db/functions/transformResult.js +16 -0
  25. package/dist/db/types.d.ts +54 -0
  26. package/dist/db/types.js +1 -0
  27. package/dist/db.d.ts +1 -65
  28. package/dist/db.js +1 -557
  29. package/dist/dt/classes/{date.d.ts → Date.d.ts} +1 -1
  30. package/dist/dt/classes/{date.js → Date.js} +8 -3
  31. package/dist/dt/classes/{dateTime.d.ts → DateTime.d.ts} +1 -1
  32. package/dist/dt/classes/{dateTime.js → DateTime.js} +9 -3
  33. package/dist/dt/classes/{dt.d.ts → Dt.d.ts} +1 -1
  34. package/dist/dt/classes/{dt.js → Dt.js} +36 -48
  35. package/dist/dt/classes/Duration.js +193 -0
  36. package/dist/dt/classes/{monthDay.d.ts → MonthDay.d.ts} +1 -1
  37. package/dist/dt/classes/{monthDay.js → MonthDay.js} +2 -2
  38. package/dist/dt/classes/{time.d.ts → Time.d.ts} +1 -1
  39. package/dist/dt/classes/{time.js → Time.js} +2 -2
  40. package/dist/dt/classes/{yearMonth.d.ts → YearMonth.d.ts} +1 -1
  41. package/dist/dt/classes/{yearMonth.js → YearMonth.js} +2 -2
  42. package/dist/dt/classes/{zoned.d.ts → Zoned.d.ts} +1 -1
  43. package/dist/dt/classes/{zoned.js → Zoned.js} +9 -3
  44. package/dist/dt/functions/buildLocaleFromIntl.js +1 -1
  45. package/dist/dt/functions/guessFormat.js +1 -1
  46. package/dist/dt/functions/intl-weekinfo-polyfill.js +11 -4
  47. package/dist/dt/functions/parse.js +20 -22
  48. package/dist/dt/functions/setupIntl.js +33 -44
  49. package/dist/dt.d.ts +1 -1
  50. package/dist/dt.js +9 -7
  51. package/dist/env.d.ts +1 -1
  52. package/dist/env.js +6 -7
  53. package/dist/fn/ajax/abort.js +1 -1
  54. package/dist/fn/ajax/ajax.d.ts +1 -1
  55. package/dist/fn/ajax/ajax.js +2 -2
  56. package/dist/fn/ajax/download.js +1 -1
  57. package/dist/fn/ajax/getFileContent.js +2 -3
  58. package/dist/fn/ajax/link.js +2 -2
  59. package/dist/fn/ajax/stream.js +2 -2
  60. package/dist/fn/browser/executeSlowly.js +11 -22
  61. package/dist/fn/browser/log.js +2 -3
  62. package/dist/fn/browser/yieldToBrowser.js +7 -19
  63. package/dist/fn/html/makeReactive.js +2 -2
  64. package/dist/fn/init.d.ts +1 -1
  65. package/dist/fn/init.js +4 -5
  66. package/dist/fn/object/_filter.js +1 -1
  67. package/dist/fn/phone/fphone.js +1 -2
  68. package/dist/fn/string/cast.js +1 -2
  69. package/dist/fn/string/shorten.js +1 -1
  70. package/dist/fn/string/treatForHash.js +1 -1
  71. package/dist/fn/style/addColors.d.ts +1 -1
  72. package/dist/fn/style/addColors.js +4 -4
  73. package/dist/fn/type/checkType.js +1 -2
  74. package/dist/fn/type/isCp.js +1 -2
  75. package/dist/fn/type/isHostname.js +1 -1
  76. package/dist/fn/type/isIP.js +1 -1
  77. package/dist/fn/type/isSame.js +2 -2
  78. package/dist/fn/type/isURL.js +1 -1
  79. package/dist/index-no-dep.js +2 -2
  80. package/dist/index.js +2 -2
  81. package/package.json +1 -1
  82. package/dist/dt/classes/duration.js +0 -199
  83. /package/dist/dt/classes/{duration.d.ts → Duration.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { Temporal } from 'temporal-polyfill';
2
2
  import _ from './_.js';
3
3
  import $ from './$.js';
4
4
  import lng from './lng.js';
5
- import vars from './vars.js';
5
+ import data from './data.js';
6
6
  import env from './env.js';
7
7
  import com from './com.js';
8
8
  import db from './db.js';
@@ -17,7 +17,7 @@ const bbn = {
17
17
  _,
18
18
  $,
19
19
  lng,
20
- var: vars,
20
+ data,
21
21
  dt,
22
22
  com,
23
23
  env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.237",
3
+ "version": "2.0.238",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,199 +0,0 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _bbnDtDuration_instances, _bbnDtDuration_value, _bbnDtDuration_unit, _bbnDtDuration_getUnitValue;
13
- import { Temporal } from 'temporal-polyfill';
14
- import { units, unitsCorrespondence } from '../vars/units.js';
15
- import getRow from '../../fn/object/getRow.js';
16
- const DURATION_RELATIVE_TO = Temporal.ZonedDateTime.from('1970-01-01T00:00Z[UTC]');
17
- class bbnDtDuration {
18
- static fromUnit(value, unit) {
19
- const realUnit = unitsCorrespondence[unit] || 'ms';
20
- if (!realUnit) {
21
- throw new Error('Invalid unit for duration: ' + unit);
22
- }
23
- const ctx = [
24
- realUnit === 'y' ? value : 0,
25
- realUnit === 'm' ? value : 0,
26
- realUnit === 'w' ? value : 0,
27
- realUnit === 'd' ? value : 0,
28
- realUnit === 'h' ? value : 0,
29
- realUnit === 'i' ? value : 0,
30
- realUnit === 's' ? value : 0,
31
- ['y', 'm', 'w', 'd', 'h', 'i', 's'].includes(realUnit) ? 0 : value
32
- ];
33
- const dur = new Temporal.Duration(...ctx);
34
- return new bbnDtDuration(dur);
35
- }
36
- constructor(y, m, w, d, h, i, s, ms, unit) {
37
- _bbnDtDuration_instances.add(this);
38
- _bbnDtDuration_value.set(this, void 0);
39
- _bbnDtDuration_unit.set(this, void 0);
40
- if (y instanceof Temporal.Duration) {
41
- __classPrivateFieldSet(this, _bbnDtDuration_value, y, "f");
42
- }
43
- else if (typeof y === 'object') {
44
- __classPrivateFieldSet(this, _bbnDtDuration_value, new Temporal.Duration(y.years || 0, y.months || 0, y.weeks || 0, y.days || 0, y.hours || 0, y.minutes || 0, y.seconds || 0, y.milliseconds || 0, 0, 0), "f");
45
- }
46
- else {
47
- __classPrivateFieldSet(this, _bbnDtDuration_value, new Temporal.Duration(y || 0, m || 0, w || 0, d || 0, h || 0, i || 0, s || 0, ms || 0, 0, 0), "f");
48
- }
49
- const realUnit = unitsCorrespondence[unit || ''] || unit;
50
- __classPrivateFieldSet(this, _bbnDtDuration_unit, realUnit || 'ms', "f");
51
- const row = getRow(units, (a) => a[0] === realUnit);
52
- if (!row) {
53
- //throw new Error('Invalid unit for duration: ' + realUnit);
54
- }
55
- Object.defineProperty(this, 'isValid', {
56
- value: false,
57
- writable: false,
58
- configurable: true
59
- });
60
- }
61
- setValid(isValid) {
62
- Object.defineProperty(this, 'isValid', {
63
- value: isValid,
64
- writable: false,
65
- configurable: false
66
- });
67
- }
68
- get value() {
69
- return __classPrivateFieldGet(this, _bbnDtDuration_value, "f");
70
- }
71
- // -----------------------
72
- // Public getters
73
- // -----------------------
74
- years(remaining = false) { return __classPrivateFieldGet(this, _bbnDtDuration_instances, "m", _bbnDtDuration_getUnitValue).call(this, 'year', remaining); }
75
- months(remaining = false) { return __classPrivateFieldGet(this, _bbnDtDuration_instances, "m", _bbnDtDuration_getUnitValue).call(this, 'month', remaining); }
76
- weeks(remaining = false) { return __classPrivateFieldGet(this, _bbnDtDuration_instances, "m", _bbnDtDuration_getUnitValue).call(this, 'week', remaining); }
77
- days(remaining = false) { return __classPrivateFieldGet(this, _bbnDtDuration_instances, "m", _bbnDtDuration_getUnitValue).call(this, 'day', remaining); }
78
- hours(remaining = false) { return __classPrivateFieldGet(this, _bbnDtDuration_instances, "m", _bbnDtDuration_getUnitValue).call(this, 'hour', remaining); }
79
- minutes(remaining = false) { return __classPrivateFieldGet(this, _bbnDtDuration_instances, "m", _bbnDtDuration_getUnitValue).call(this, 'minute', remaining); }
80
- seconds(remaining = false) { return __classPrivateFieldGet(this, _bbnDtDuration_instances, "m", _bbnDtDuration_getUnitValue).call(this, 'second', remaining); }
81
- // -----------------------
82
- // Day.js style
83
- // "asX" conversions
84
- // -----------------------
85
- toJSON() {
86
- return this.value.toJSON();
87
- }
88
- /**
89
- * Returns the full duration expressed as X (float), like Day.js.
90
- */
91
- asYears() {
92
- return __classPrivateFieldGet(this, _bbnDtDuration_value, "f").total({
93
- unit: 'year',
94
- relativeTo: DURATION_RELATIVE_TO
95
- });
96
- }
97
- asMonths() {
98
- return __classPrivateFieldGet(this, _bbnDtDuration_value, "f").total({
99
- unit: 'month',
100
- relativeTo: DURATION_RELATIVE_TO
101
- });
102
- }
103
- asWeeks() {
104
- return __classPrivateFieldGet(this, _bbnDtDuration_value, "f").total({
105
- unit: 'week',
106
- relativeTo: DURATION_RELATIVE_TO
107
- });
108
- }
109
- asDays() {
110
- return __classPrivateFieldGet(this, _bbnDtDuration_value, "f").total({
111
- unit: 'day',
112
- relativeTo: DURATION_RELATIVE_TO
113
- });
114
- }
115
- asHours() {
116
- return __classPrivateFieldGet(this, _bbnDtDuration_value, "f").total({
117
- unit: 'hour',
118
- relativeTo: DURATION_RELATIVE_TO
119
- });
120
- }
121
- asMinutes() {
122
- return __classPrivateFieldGet(this, _bbnDtDuration_value, "f").total({
123
- unit: 'minute',
124
- relativeTo: DURATION_RELATIVE_TO
125
- });
126
- }
127
- asSeconds() {
128
- return __classPrivateFieldGet(this, _bbnDtDuration_value, "f").total({
129
- unit: 'second',
130
- relativeTo: DURATION_RELATIVE_TO
131
- });
132
- }
133
- /**
134
- * Add any unit (or instance default).
135
- */
136
- add(value, unit) {
137
- let targetUnit = __classPrivateFieldGet(this, _bbnDtDuration_unit, "f");
138
- if (unit) {
139
- if (unitsCorrespondence[unit]) {
140
- const realUnit = getRow(units, (a) => a[0] === unitsCorrespondence[unit]);
141
- if (realUnit) {
142
- targetUnit = realUnit[1];
143
- }
144
- }
145
- else {
146
- targetUnit = unit;
147
- }
148
- }
149
- // Map to Temporal.DurationLike field name, e.g. 'year' → 'years'
150
- const field = (targetUnit + 's');
151
- if (!['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds', 'milliseconds'].includes(field)) {
152
- throw new Error('Invalid unit for duration: ' + (unit !== null && unit !== void 0 ? unit : targetUnit));
153
- }
154
- const delta = { [field]: value };
155
- const newDuration = __classPrivateFieldGet(this, _bbnDtDuration_value, "f").add(delta);
156
- // Adapt this constructor call to however you now construct your duration:
157
- return new bbnDtDuration(newDuration, undefined, undefined, undefined, undefined, undefined, undefined, undefined, __classPrivateFieldGet(this, _bbnDtDuration_unit, "f"));
158
- }
159
- subtract(value, unit) {
160
- return this.add(-value, unit);
161
- }
162
- toMilliseconds() {
163
- const d = __classPrivateFieldGet(this, _bbnDtDuration_value, "f");
164
- // If there are no calendar units, we can let Temporal do it directly:
165
- if (!d.years && !d.months && !d.weeks && !d.days) {
166
- return d.total({ unit: 'millisecond' });
167
- }
168
- // Otherwise we must supply a relativeTo (same as in asX)
169
- return d.total({
170
- unit: 'millisecond',
171
- relativeTo: DURATION_RELATIVE_TO
172
- });
173
- }
174
- }
175
- _bbnDtDuration_value = new WeakMap(), _bbnDtDuration_unit = new WeakMap(), _bbnDtDuration_instances = new WeakSet(), _bbnDtDuration_getUnitValue = function _bbnDtDuration_getUnitValue(name, remaining) {
176
- const d = __classPrivateFieldGet(this, _bbnDtDuration_value, "f"); // Temporal.Duration
177
- if (remaining) {
178
- switch (name) {
179
- case 'year': return d.years;
180
- case 'month': return d.months;
181
- case 'week': return d.weeks;
182
- case 'day': return d.days;
183
- case 'hour': return d.hours;
184
- case 'minute': return d.minutes;
185
- case 'second':
186
- // seconds component only; sub-second parts go to milliseconds in toJSON()
187
- return d.seconds;
188
- }
189
- }
190
- // Total units: use Duration.total()
191
- const total = d.total({
192
- unit: name,
193
- relativeTo: DURATION_RELATIVE_TO
194
- });
195
- // Keep same semantics as old code (Math.floor on totals)
196
- return Math.floor(total);
197
- };
198
- export default bbnDtDuration;
199
- ;