@bbn/bbn 1.0.437 → 1.0.438

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 (206) hide show
  1. package/dist/_.js +7 -11
  2. package/dist/bbn.js +1 -1
  3. package/dist/bbn.js.map +1 -1
  4. package/dist/date.d.ts +26 -0
  5. package/dist/date.js +190 -0
  6. package/dist/db.js +107 -124
  7. package/dist/fn/ajax/_addLoader.js +6 -6
  8. package/dist/fn/ajax/_deleteLoader.js +11 -13
  9. package/dist/fn/ajax/abort.js +1 -1
  10. package/dist/fn/ajax/abortURL.js +1 -1
  11. package/dist/fn/ajax/ajax.js +25 -30
  12. package/dist/fn/ajax/callback.js +10 -14
  13. package/dist/fn/ajax/download.js +7 -9
  14. package/dist/fn/ajax/downloadContent.js +5 -6
  15. package/dist/fn/ajax/getLoader.js +1 -1
  16. package/dist/fn/ajax/getRequestId.js +2 -2
  17. package/dist/fn/ajax/link.js +9 -13
  18. package/dist/fn/ajax/post.js +3 -7
  19. package/dist/fn/ajax/postOut.js +2 -4
  20. package/dist/fn/ajax/setNavigationVars.js +5 -7
  21. package/dist/fn/ajax/stream.js +21 -22
  22. package/dist/fn/ajax/treatAjaxArguments.js +3 -3
  23. package/dist/fn/ajax/upload.js +6 -9
  24. package/dist/fn/browser/copy.js +9 -12
  25. package/dist/fn/browser/error.js +2 -2
  26. package/dist/fn/browser/executeSlowly.js +11 -55
  27. package/dist/fn/browser/getBrowserName.js +1 -1
  28. package/dist/fn/browser/getBrowserVersion.js +1 -1
  29. package/dist/fn/browser/getCookie.js +5 -5
  30. package/dist/fn/browser/getDeviceType.js +1 -1
  31. package/dist/fn/browser/getEventData.js +30 -30
  32. package/dist/fn/browser/happy.js +1 -5
  33. package/dist/fn/browser/info.js +1 -5
  34. package/dist/fn/browser/isActiveInterface.js +2 -3
  35. package/dist/fn/browser/isFocused.js +1 -2
  36. package/dist/fn/browser/log.js +8 -12
  37. package/dist/fn/browser/replaceSelection.js +5 -5
  38. package/dist/fn/browser/selectElementText.js +4 -5
  39. package/dist/fn/browser/setCookie.js +3 -3
  40. package/dist/fn/browser/warning.js +2 -2
  41. package/dist/fn/browser/yieldToBrowser.js +7 -43
  42. package/dist/fn/convert/arrayBuffer2String.js +1 -1
  43. package/dist/fn/convert/canvasToImage.js +1 -1
  44. package/dist/fn/convert/colorToHex.js +1 -1
  45. package/dist/fn/convert/fromXml.js +7 -13
  46. package/dist/fn/convert/hex2rgb.js +1 -1
  47. package/dist/fn/convert/imageToCanvas.js +1 -1
  48. package/dist/fn/convert/imgToBase64.js +2 -3
  49. package/dist/fn/convert/toCSV.js +7 -10
  50. package/dist/fn/datetime/calendar.js +4 -5
  51. package/dist/fn/datetime/date.js +1 -1
  52. package/dist/fn/datetime/dateSQL.js +1 -1
  53. package/dist/fn/datetime/daysInMonth.js +1 -1
  54. package/dist/fn/datetime/fdate.js +2 -3
  55. package/dist/fn/datetime/fdatetime.js +2 -3
  56. package/dist/fn/datetime/ftime.js +1 -1
  57. package/dist/fn/datetime/getChrono.js +2 -3
  58. package/dist/fn/datetime/getDay.js +3 -3
  59. package/dist/fn/datetime/startChrono.js +1 -1
  60. package/dist/fn/datetime/stopChrono.js +2 -2
  61. package/dist/fn/datetime/timestamp.js +2 -3
  62. package/dist/fn/default/defaultAjaxAbortFunction.js +1 -2
  63. package/dist/fn/default/defaultAjaxErrorFunction.js +1 -3
  64. package/dist/fn/default/defaultAlertFunction.js +1 -2
  65. package/dist/fn/default/defaultConfirmFunction.js +2 -3
  66. package/dist/fn/default/defaultEndLoadingFunction.js +1 -3
  67. package/dist/fn/default/defaultPostLinkFunction.js +1 -2
  68. package/dist/fn/default/defaultPreLinkFunction.js +1 -3
  69. package/dist/fn/form/addInputs.js +10 -12
  70. package/dist/fn/form/fieldValue.js +1 -1
  71. package/dist/fn/form/formdata.js +24 -24
  72. package/dist/fn/form/objectToFormData.js +5 -8
  73. package/dist/fn/form/submit.js +4 -4
  74. package/dist/fn/html/adjustHeight.js +1 -1
  75. package/dist/fn/html/adjustSize.js +5 -5
  76. package/dist/fn/html/adjustWidth.js +1 -1
  77. package/dist/fn/html/getAllTags.js +1 -1
  78. package/dist/fn/html/getAncestors.js +2 -3
  79. package/dist/fn/html/getAttributes.js +2 -2
  80. package/dist/fn/html/getHTMLOfSelection.js +4 -4
  81. package/dist/fn/html/getHtml.js +2 -3
  82. package/dist/fn/html/getIndex.js +3 -4
  83. package/dist/fn/html/getPath.js +12 -17
  84. package/dist/fn/html/html2text.js +1 -1
  85. package/dist/fn/html/isInViewport.js +4 -5
  86. package/dist/fn/html/isInside.js +5 -5
  87. package/dist/fn/html/makeReactive.js +22 -26
  88. package/dist/fn/init.js +18 -18
  89. package/dist/fn/loop/each.js +2 -2
  90. package/dist/fn/loop/fori.js +3 -5
  91. package/dist/fn/loop/forir.js +3 -5
  92. package/dist/fn/loop/iterate.js +3 -6
  93. package/dist/fn/loop/riterate.js +1 -2
  94. package/dist/fn/misc/analyzeFunction.js +36 -36
  95. package/dist/fn/misc/money.js +4 -4
  96. package/dist/fn/misc/translate.js +2 -2
  97. package/dist/fn/object/_compareValues.js +2 -3
  98. package/dist/fn/object/_filter.js +7 -10
  99. package/dist/fn/object/arrayFromProp.js +2 -2
  100. package/dist/fn/object/checkProps.js +1 -2
  101. package/dist/fn/object/checkPropsDetails.js +8 -9
  102. package/dist/fn/object/checkPropsOrDie.js +2 -3
  103. package/dist/fn/object/circularReplacer.js +2 -2
  104. package/dist/fn/object/clone.js +2 -2
  105. package/dist/fn/object/compareConditions.js +6 -6
  106. package/dist/fn/object/count.js +1 -3
  107. package/dist/fn/object/createObject.js +3 -16
  108. package/dist/fn/object/deepPath.js +6 -7
  109. package/dist/fn/object/diffObj.js +11 -13
  110. package/dist/fn/object/extend.js +10 -14
  111. package/dist/fn/object/extendOut.js +4 -9
  112. package/dist/fn/object/filter.js +6 -8
  113. package/dist/fn/object/filterToConditions.js +6 -7
  114. package/dist/fn/object/findAll.js +4 -5
  115. package/dist/fn/object/getField.js +2 -8
  116. package/dist/fn/object/getFieldValues.js +2 -2
  117. package/dist/fn/object/getProperty.js +5 -9
  118. package/dist/fn/object/getRow.js +2 -7
  119. package/dist/fn/object/getSortingMoves.js +28 -28
  120. package/dist/fn/object/isWritable.js +1 -1
  121. package/dist/fn/object/map.js +2 -3
  122. package/dist/fn/object/move.js +1 -1
  123. package/dist/fn/object/multiorder.js +5 -6
  124. package/dist/fn/object/mutateArray.js +8 -9
  125. package/dist/fn/object/mutateObject.js +3 -3
  126. package/dist/fn/object/order.js +1 -2
  127. package/dist/fn/object/removeEmpty.js +2 -2
  128. package/dist/fn/object/removePrivateProp.js +2 -3
  129. package/dist/fn/object/search.js +13 -17
  130. package/dist/fn/object/setProp.js +1 -3
  131. package/dist/fn/object/setProperty.js +8 -8
  132. package/dist/fn/object/shortenObj.js +3 -4
  133. package/dist/fn/object/shuffle.js +2 -3
  134. package/dist/fn/object/sum.js +3 -3
  135. package/dist/fn/object/unique.js +1 -1
  136. package/dist/fn/phone/fphone.js +22 -22
  137. package/dist/fn/string/baseName.js +3 -3
  138. package/dist/fn/string/correctCase.js +1 -1
  139. package/dist/fn/string/crc32.js +7 -7
  140. package/dist/fn/string/data2Html.js +4 -5
  141. package/dist/fn/string/dirName.js +1 -1
  142. package/dist/fn/string/escapeUrl.js +6 -6
  143. package/dist/fn/string/fileExt.js +1 -1
  144. package/dist/fn/string/firstVarElement.js +2 -2
  145. package/dist/fn/string/format.js +4 -4
  146. package/dist/fn/string/formatBytes.js +2 -3
  147. package/dist/fn/string/hash.js +4 -8
  148. package/dist/fn/string/randomString.js +5 -5
  149. package/dist/fn/string/replaceAll.js +1 -2
  150. package/dist/fn/string/sanitize.js +6 -7
  151. package/dist/fn/string/simpleHash.js +2 -2
  152. package/dist/fn/string/simpleHash1.js +3 -3
  153. package/dist/fn/string/simpleHash2.js +3 -3
  154. package/dist/fn/string/treatForHash.js +6 -10
  155. package/dist/fn/string/trim.js +1 -2
  156. package/dist/fn/string/uniqString.js +7 -14
  157. package/dist/fn/style/addColors.js +14 -14
  158. package/dist/fn/style/addStyle.js +1 -1
  159. package/dist/fn/style/animateCss.js +1 -1
  160. package/dist/fn/style/center.js +1 -1
  161. package/dist/fn/style/cssExists.js +5 -5
  162. package/dist/fn/style/getCssVar.js +1 -1
  163. package/dist/fn/style/getScrollBarSize.js +5 -5
  164. package/dist/fn/style/lightenDarkenHex.js +2 -2
  165. package/dist/fn/style/outerHeight.js +2 -2
  166. package/dist/fn/style/outerWidth.js +2 -2
  167. package/dist/fn/style/resize.js +14 -14
  168. package/dist/fn/type/checkType.js +5 -9
  169. package/dist/fn/type/isArray.js +2 -7
  170. package/dist/fn/type/isBlob.js +2 -7
  171. package/dist/fn/type/isBoolean.js +2 -7
  172. package/dist/fn/type/isCanvas.js +2 -7
  173. package/dist/fn/type/isColor.js +2 -7
  174. package/dist/fn/type/isComment.js +2 -7
  175. package/dist/fn/type/isCp.js +3 -8
  176. package/dist/fn/type/isDataURL.js +2 -7
  177. package/dist/fn/type/isDate.js +2 -7
  178. package/dist/fn/type/isDimension.js +2 -7
  179. package/dist/fn/type/isDom.js +2 -7
  180. package/dist/fn/type/isEmail.js +3 -8
  181. package/dist/fn/type/isEvent.js +2 -7
  182. package/dist/fn/type/isFunction.js +2 -7
  183. package/dist/fn/type/isHostname.js +2 -7
  184. package/dist/fn/type/isIP.js +2 -7
  185. package/dist/fn/type/isInt.js +2 -7
  186. package/dist/fn/type/isIterable.js +2 -7
  187. package/dist/fn/type/isNotObject.js +2 -7
  188. package/dist/fn/type/isNull.js +2 -7
  189. package/dist/fn/type/isNumber.js +2 -7
  190. package/dist/fn/type/isObject.js +2 -7
  191. package/dist/fn/type/isPercent.js +2 -7
  192. package/dist/fn/type/isPrimitive.js +2 -7
  193. package/dist/fn/type/isPromise.js +2 -7
  194. package/dist/fn/type/isPropSize.js +2 -2
  195. package/dist/fn/type/isSQLDate.js +2 -7
  196. package/dist/fn/type/isSame.js +12 -12
  197. package/dist/fn/type/isString.js +2 -7
  198. package/dist/fn/type/isSymbol.js +2 -7
  199. package/dist/fn/type/isURL.js +2 -7
  200. package/dist/fn/type/isUid.js +2 -7
  201. package/dist/fn/type/isValidDimension.js +2 -2
  202. package/dist/fn/type/isValidName.js +2 -7
  203. package/dist/fn/type/isVue.js +4 -11
  204. package/dist/fn.js +247 -247
  205. package/dist/index.js +9 -7
  206. package/package.json +1 -1
package/dist/date.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ declare class bbnDateTool {
2
+ #private;
3
+ constructor(value: any, inputFormat?: null | String);
4
+ get year(): Number;
5
+ get month(): number;
6
+ get day(): number;
7
+ get hours(): number;
8
+ get minutes(): number;
9
+ get seconds(): number;
10
+ get YYYY(): string;
11
+ get YY(): string;
12
+ get MM(): string;
13
+ get DD(): string;
14
+ add(value: number, unit: string | null): bbnDateTool;
15
+ sub(value: number, unit: string | null): bbnDateTool;
16
+ dateFromFormat(value: string, unit: string | null): Date;
17
+ format(format: string): string;
18
+ unix(ms?: boolean): number;
19
+ isBefore(date: any, unit?: string): Boolean;
20
+ isAfter(date: any, unit?: string): Boolean;
21
+ isSame(date: any, unit?: string): Boolean;
22
+ calendar(format: string): string;
23
+ get daysInMonth(): Number | 0;
24
+ }
25
+ declare function generatorFunction(value: any, inputFormat?: null | String): bbnDateTool;
26
+ export default generatorFunction;
package/dist/date.js ADDED
@@ -0,0 +1,190 @@
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 _bbnDateTool_value, _bbnDateTool_daysInMonth, _bbnDateTool_parts;
13
+ import each from './fn/loop/each.js';
14
+ import substr from './fn/string/substr.js';
15
+ import isNumber from './fn/type/isNumber.js';
16
+ import isDate from './fn/type/isDate.js';
17
+ import getProperty from './fn/object/getProperty.js';
18
+ class bbnDateTool {
19
+ constructor(value, inputFormat = null) {
20
+ _bbnDateTool_value.set(this, void 0);
21
+ _bbnDateTool_daysInMonth.set(this, undefined);
22
+ _bbnDateTool_parts.set(this, undefined);
23
+ if (inputFormat) {
24
+ }
25
+ else {
26
+ let t = typeof value;
27
+ if (value === undefined) {
28
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(), "f");
29
+ }
30
+ if (t === 'number' || (isNumber(value) && value !== '')) {
31
+ if ((value < 5000) && isNumber(inputFormat)) {
32
+ value = Array.from(arguments);
33
+ }
34
+ else if (value < 10000000000) {
35
+ value = value * 1000;
36
+ }
37
+ if (!Array.isArray(value)) {
38
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(value), "f");
39
+ }
40
+ }
41
+ if (t === 'string') {
42
+ if (value.length === 10) {
43
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(parseInt(substr(value, 0, 4)), parseInt(substr(value, 5, 2)) - 1, parseInt(substr(value, 8, 2)), 12), "f");
44
+ }
45
+ else if (value.length === 19) {
46
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(parseInt(substr(value, 0, 4)), parseInt(substr(value, 5, 2)) - 1, parseInt(substr(value, 8, 2)), parseInt(substr(value, 11, 2)), parseInt(substr(value, 14, 2)), parseInt(substr(value, 17, 2))), "f");
47
+ }
48
+ }
49
+ else if (isDate(value)) {
50
+ __classPrivateFieldSet(this, _bbnDateTool_value, value, "f");
51
+ }
52
+ else if (Array.isArray(value)) {
53
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(...value), "f");
54
+ }
55
+ }
56
+ if (__classPrivateFieldGet(this, _bbnDateTool_value, "f") === undefined) {
57
+ const obj = {};
58
+ return new Proxy(this, {
59
+ get: (target, prop) => {
60
+ return undefined;
61
+ }
62
+ });
63
+ }
64
+ }
65
+ get year() {
66
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getFullYear();
67
+ }
68
+ get month() {
69
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getMonth() + 1;
70
+ }
71
+ get day() {
72
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getDate();
73
+ }
74
+ get hours() {
75
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getHours();
76
+ }
77
+ get minutes() {
78
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getMinutes();
79
+ }
80
+ get seconds() {
81
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getSeconds();
82
+ }
83
+ get YYYY() {
84
+ return this.year.toString();
85
+ }
86
+ get YY() {
87
+ return substr(this.year.toString(), 2, 2);
88
+ }
89
+ get MM() {
90
+ return this.month < 10 ? '0' + this.month.toString() : this.month.toString();
91
+ }
92
+ get DD() {
93
+ return this.day < 10 ? '0' + this.day.toString() : this.day.toString();
94
+ }
95
+ add(value, unit) {
96
+ let newValue;
97
+ return new bbnDateTool(newValue);
98
+ }
99
+ sub(value, unit) {
100
+ let newValue;
101
+ return new bbnDateTool(newValue);
102
+ }
103
+ dateFromFormat(value, unit) {
104
+ const d = new Date();
105
+ return d;
106
+ }
107
+ format(format) {
108
+ let str = '';
109
+ if (format) {
110
+ const parts = format.split(/(YYYY|YY|MM|DD|HH|mm|ss)/);
111
+ each(parts, (part) => {
112
+ if (part in this) {
113
+ str += getProperty(this, part);
114
+ }
115
+ else {
116
+ str += part;
117
+ }
118
+ });
119
+ }
120
+ return str;
121
+ }
122
+ unix(ms = false) {
123
+ if (__classPrivateFieldGet(this, _bbnDateTool_value, "f")) {
124
+ if (ms) {
125
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime();
126
+ }
127
+ else {
128
+ return Math.floor(__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime() / 1000);
129
+ }
130
+ }
131
+ return 0;
132
+ }
133
+ isBefore(date, unit = '') {
134
+ const d = new bbnDateTool(date);
135
+ if (unit === 'd') {
136
+ }
137
+ return false;
138
+ }
139
+ isAfter(date, unit = '') {
140
+ const d = new bbnDateTool(date);
141
+ if (unit === 'd') {
142
+ }
143
+ return false;
144
+ }
145
+ isSame(date, unit = '') {
146
+ const d = new bbnDateTool(date);
147
+ if (unit === 'd') {
148
+ }
149
+ return false;
150
+ }
151
+ calendar(format) {
152
+ let str = '';
153
+ if (format) {
154
+ }
155
+ return str;
156
+ }
157
+ get daysInMonth() {
158
+ if (!__classPrivateFieldGet(this, _bbnDateTool_value, "f")) {
159
+ return 0;
160
+ }
161
+ if (!__classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f")) {
162
+ switch (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getMonth()) {
163
+ case 1:
164
+ if (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getFullYear() % 4 === 0) {
165
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 29, "f");
166
+ }
167
+ else {
168
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 28, "f");
169
+ }
170
+ break;
171
+ case 0:
172
+ case 3:
173
+ case 5:
174
+ case 8:
175
+ case 10:
176
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 30, "f");
177
+ break;
178
+ default:
179
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 31, "f");
180
+ break;
181
+ }
182
+ }
183
+ return __classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f");
184
+ }
185
+ }
186
+ _bbnDateTool_value = new WeakMap(), _bbnDateTool_daysInMonth = new WeakMap(), _bbnDateTool_parts = new WeakMap();
187
+ function generatorFunction(value, inputFormat = null) {
188
+ return new bbnDateTool(value, inputFormat);
189
+ }
190
+ export default generatorFunction;
package/dist/db.js CHANGED
@@ -5,24 +5,23 @@ import log from './fn/browser/log.js';
5
5
  import isObject from './fn/type/isObject.js';
6
6
  import isArray from './fn/type/isArray.js';
7
7
  import extend from './fn/object/extend.js';
8
- var idb = window['indexedDB'] || window['webkitIndexedDB'] || window['mozIndexedDB'] || window['OIndexedDB'] || window['msIndexedDB'];
9
- var transformResult = function (obj, fields) {
8
+ const idb = window['indexedDB'] || window['webkitIndexedDB'] || window['mozIndexedDB'] || window['OIndexedDB'] || window['msIndexedDB'];
9
+ const transformResult = (obj, fields) => {
10
10
  if (fields === null || fields === void 0 ? void 0 : fields.length) {
11
- var res_1 = {};
12
- iterate(obj, function (v, n) {
11
+ let res = {};
12
+ iterate(obj, (v, n) => {
13
13
  if (fields.indexOf(n) > -1) {
14
- res_1[n] = v;
14
+ res[n] = v;
15
15
  }
16
16
  });
17
- return res_1;
17
+ return res;
18
18
  }
19
19
  return obj;
20
20
  };
21
- var fieldsFromFilter = function (filter, fields) {
21
+ const fieldsFromFilter = (filter, fields = []) => {
22
22
  var _a;
23
- if (fields === void 0) { fields = []; }
24
23
  if ((_a = filter === null || filter === void 0 ? void 0 : filter.conditions) === null || _a === void 0 ? void 0 : _a.length) {
25
- filter.conditions.forEach(function (cond) {
24
+ filter.conditions.forEach(cond => {
26
25
  if (cond.field && !fields.includes(cond.field)) {
27
26
  fields.push(cond.field);
28
27
  }
@@ -32,14 +31,14 @@ var fieldsFromFilter = function (filter, fields) {
32
31
  });
33
32
  }
34
33
  else if (isObject(filter)) {
35
- iterate(filter, function (v, n) {
34
+ iterate(filter, (v, n) => {
36
35
  if (!fields.includes(n)) {
37
36
  fields.push(n);
38
37
  }
39
38
  });
40
39
  }
41
40
  else if (isArray(filter)) {
42
- filter.forEach(function (cond) {
41
+ filter.forEach(cond => {
43
42
  if (cond.field && !fields.includes(cond.field)) {
44
43
  fields.push(cond.field);
45
44
  }
@@ -50,162 +49,152 @@ var fieldsFromFilter = function (filter, fields) {
50
49
  }
51
50
  return fields;
52
51
  };
53
- var dbObject = function (dbName) {
54
- var _this = this;
55
- var conn = db._connections[dbName];
56
- var structure = db._structures[dbName];
57
- var lastError = null;
58
- var onError = function (req, resolve) {
59
- req.onerror = function () {
52
+ const dbObject = function (dbName) {
53
+ const conn = db._connections[dbName];
54
+ const structure = db._structures[dbName];
55
+ let lastError = null;
56
+ const onError = (req, resolve) => {
57
+ req.onerror = () => {
60
58
  lastError = req.error;
61
59
  log(req.error);
62
60
  resolve(req.error);
63
61
  };
64
62
  };
65
- var getStore = function (table, mode) {
66
- var tx = conn.transaction([table], mode.toLowerCase().indexOf('r') === 0 ? "readonly" : "readwrite");
67
- tx.onabort = function () {
63
+ const getStore = (table, mode) => {
64
+ const tx = conn.transaction([table], mode.toLowerCase().indexOf('r') === 0 ? "readonly" : "readwrite");
65
+ tx.onabort = () => {
68
66
  lastError = tx.error;
69
67
  throw new Error(tx.error);
70
68
  };
71
69
  return [tx, tx.objectStore(table)];
72
70
  };
73
- this.lastError = function () { return lastError; };
74
- this.insert = function (table, data) {
71
+ this.lastError = () => lastError;
72
+ this.insert = (table, data) => {
75
73
  if (!Array.isArray(data)) {
76
74
  data = [data];
77
75
  }
78
- return new Promise(function (resolve) {
79
- var _a = getStore(table, 'w'), tx = _a[0], store = _a[1];
80
- var res = data.length;
81
- each(data, function (a) {
82
- var request = store.put(a);
83
- request.onerror = function () {
76
+ return new Promise(resolve => {
77
+ const [tx, store] = getStore(table, 'w');
78
+ let res = data.length;
79
+ each(data, a => {
80
+ const request = store.put(a);
81
+ request.onerror = () => {
84
82
  log(request.error);
85
83
  res--;
86
84
  };
87
85
  });
88
- tx.oncomplete = function () {
86
+ tx.oncomplete = () => {
89
87
  resolve(res);
90
88
  };
91
89
  });
92
90
  };
93
- this.update = function (table, data, where, replace) {
94
- return new Promise(function (resolve) {
95
- _this.selectAll(table, [], where).then(function (rows) {
96
- var _a;
91
+ this.update = (table, data, where, replace) => {
92
+ return new Promise(resolve => {
93
+ this.selectAll(table, [], where).then(rows => {
97
94
  if (!rows.length) {
98
95
  resolve(0);
99
96
  return;
100
97
  }
101
- var _b = getStore(table, 'w'), tx = _b[0], store = _b[1];
102
- var arch = structure[table];
103
- var primary = arch.keys.PRIMARY.columns.length > 1 ? arch.keys.PRIMARY.columns : arch.keys.PRIMARY.columns[0];
104
- var res = 0;
105
- for (var i = 0; i < rows.length; i++) {
106
- var newData = extend({}, replace ? (_a = {}, _a[primary] = rows[i][primary], _a) : rows[i], data);
98
+ const [tx, store] = getStore(table, 'w');
99
+ const arch = structure[table];
100
+ const primary = arch.keys.PRIMARY.columns.length > 1 ? arch.keys.PRIMARY.columns : arch.keys.PRIMARY.columns[0];
101
+ let res = 0;
102
+ for (let i = 0; i < rows.length; i++) {
103
+ const newData = extend({}, replace ? { [primary]: rows[i][primary] } : rows[i], data);
107
104
  if (!newData[primary]) {
108
105
  throw new Error(_("No primary key in the data"));
109
106
  }
110
- var req = store.put(newData);
107
+ const req = store.put(newData);
111
108
  onError(req, resolve);
112
- req.onsuccess = function () {
109
+ req.onsuccess = () => {
113
110
  res++;
114
111
  };
115
112
  }
116
- tx.oncomplete = function () {
113
+ tx.oncomplete = () => {
117
114
  resolve(res);
118
115
  };
119
116
  });
120
117
  });
121
118
  };
122
- this.delete = function (table, where) {
123
- return new Promise(function (resolve) {
124
- var _a = getStore(table, 'w'), tx = _a[0], store = _a[1];
125
- var arch = structure[table];
126
- var primary = arch.keys.PRIMARY.columns.length > 1 ? arch.keys.PRIMARY.columns : arch.keys.PRIMARY.columns[0];
119
+ this.delete = (table, where) => {
120
+ return new Promise(resolve => {
121
+ const [tx, store] = getStore(table, 'w');
122
+ const arch = structure[table];
123
+ const primary = arch.keys.PRIMARY.columns.length > 1 ? arch.keys.PRIMARY.columns : arch.keys.PRIMARY.columns[0];
127
124
  if (!where[primary]) {
128
125
  throw new Error(_("No "));
129
126
  }
130
- var res = 1;
131
- var req = store.delete(where[primary]);
127
+ let res = 1;
128
+ const req = store.delete(where[primary]);
132
129
  onError(req, resolve);
133
- tx.oncomplete = function () {
130
+ tx.oncomplete = () => {
134
131
  resolve(res);
135
132
  };
136
133
  });
137
134
  };
138
- this.selectOne = function (table, field, where, order, start, limit) {
139
- return new Promise(function (resolve) {
140
- _this.selectAll(table, [field], where, order, start, 1).then(function (d) {
135
+ this.selectOne = (table, field, where, order, start, limit) => {
136
+ return new Promise(resolve => {
137
+ this.selectAll(table, [field], where, order, start, 1).then(d => {
141
138
  var _a, _b;
142
139
  resolve((_b = (_a = d === null || d === void 0 ? void 0 : d[0]) === null || _a === void 0 ? void 0 : _a[field]) !== null && _b !== void 0 ? _b : undefined);
143
140
  });
144
141
  });
145
142
  };
146
- this.select = function (table, fields, where, order, start) {
147
- return new Promise(function (resolve) {
148
- _this.selectAll(table, fields, where, order, start, 1).then(function (d) {
143
+ this.select = (table, fields, where, order, start) => {
144
+ return new Promise(resolve => {
145
+ this.selectAll(table, fields, where, order, start, 1).then(d => {
149
146
  resolve(d.length ? d[0] : null);
150
147
  });
151
148
  });
152
149
  };
153
- this.selectAll = function (table, fields, where, order, start, limit) {
154
- if (fields === void 0) { fields = []; }
155
- if (where === void 0) { where = null; }
156
- if (order === void 0) { order = null; }
157
- if (start === void 0) { start = 0; }
158
- if (limit === void 0) { limit = null; }
159
- return new Promise(function (resolve) {
160
- var _a = getStore(table, 'r'), tx = _a[0], store = _a[1];
161
- var arch = structure[table];
162
- var primary = arch.keys.PRIMARY.columns.length > 1 ? arch.keys.PRIMARY.columns : arch.keys.PRIMARY.columns[0];
163
- var search = isObject(where) ? Object.keys(where)[0] : (!where || isArray(where) ? null : primary);
164
- var results = [];
150
+ this.selectAll = (table, fields = [], where = null, order = null, start = 0, limit = null) => {
151
+ return new Promise(resolve => {
152
+ const [tx, store] = getStore(table, 'r');
153
+ const arch = structure[table];
154
+ const primary = arch.keys.PRIMARY.columns.length > 1 ? arch.keys.PRIMARY.columns : arch.keys.PRIMARY.columns[0];
155
+ const search = isObject(where) ? Object.keys(where)[0] : (!where || isArray(where) ? null : primary);
156
+ const results = [];
165
157
  if (search === primary) {
166
158
  if (bbn.fn.isArray(where === null || where === void 0 ? void 0 : where[primary])) {
167
- var req = [];
168
- var max_1 = Math.min(where[primary].length, limit || 9999999);
169
- var _loop_1 = function (i) {
170
- var getter = store.get(where[primary][i]);
171
- getter.onsuccess = function () {
172
- var obj = getter.result;
159
+ let req = [];
160
+ const max = Math.min(where[primary].length, limit || 9999999);
161
+ for (let i = start || 0; i < max; i++) {
162
+ let getter = store.get(where[primary][i]);
163
+ getter.onsuccess = () => {
164
+ let obj = getter.result;
173
165
  results.push(transformResult(obj, fields));
174
- if (results.length === max_1) {
166
+ if (results.length === max) {
175
167
  resolve(results);
176
168
  }
177
169
  };
178
170
  onError(getter, resolve);
179
171
  req.push(getter);
180
- };
181
- for (var i = start || 0; i < max_1; i++) {
182
- _loop_1(i);
183
172
  }
184
173
  }
185
174
  else {
186
- var req_1 = store.get((where === null || where === void 0 ? void 0 : where[primary]) || where);
187
- req_1.onsuccess = function () {
188
- var obj = req_1.result;
175
+ let req = store.get((where === null || where === void 0 ? void 0 : where[primary]) || where);
176
+ req.onsuccess = () => {
177
+ let obj = req.result;
189
178
  results.push(transformResult(obj, fields));
190
179
  resolve(results);
191
180
  };
192
- onError(req_1, resolve);
181
+ onError(req, resolve);
193
182
  }
194
183
  }
195
184
  else {
196
- var req = store.openCursor();
197
- var i_1 = 0;
198
- req.onsuccess = function (e) {
199
- var cursor = e.target.result;
185
+ const req = store.openCursor();
186
+ let i = 0;
187
+ req.onsuccess = (e) => {
188
+ const cursor = e.target.result;
200
189
  if (cursor) {
201
190
  if (!where || !bbn.fn.search([cursor.value], where)) {
202
- if (i_1 >= start) {
191
+ if (i >= start) {
203
192
  results.push(transformResult(cursor.value, fields));
204
193
  if (results.length === limit) {
205
194
  resolve(results);
206
195
  }
207
196
  }
208
- i_1++;
197
+ i++;
209
198
  }
210
199
  cursor.continue();
211
200
  }
@@ -217,19 +206,14 @@ var dbObject = function (dbName) {
217
206
  }
218
207
  });
219
208
  };
220
- this.getColumnValues = function (table, field, where, order, start, limit) {
221
- return new Promise(function (resolve) {
222
- var tx = conn.transaction([table], "read");
223
- var store = tx.objectStore(table);
209
+ this.getColumnValues = (table, field, where, order, start, limit) => {
210
+ return new Promise(resolve => {
211
+ const tx = conn.transaction([table], "read");
212
+ const store = tx.objectStore(table);
224
213
  });
225
214
  };
226
- this.copyTable = function (target, table, fields, where, order, start, limit) {
227
- if (fields === void 0) { fields = []; }
228
- if (where === void 0) { where = null; }
229
- if (order === void 0) { order = null; }
230
- if (start === void 0) { start = 0; }
231
- if (limit === void 0) { limit = null; }
232
- return new Promise(function (resolve) {
215
+ this.copyTable = (target, table, fields = [], where = null, order = null, start = 0, limit = null) => {
216
+ return new Promise(resolve => {
233
217
  if (!conn.objectStoreNames.contains(target)) {
234
218
  db.add(dbName, target, structure[table]);
235
219
  }
@@ -237,9 +221,9 @@ var dbObject = function (dbName) {
237
221
  resolve(0);
238
222
  throw new Error(_("The target table %s does not exist", target));
239
223
  }
240
- _this.selectAll(table, fields, where, order, start, limit).then(function (d) {
224
+ this.selectAll(table, fields, where, order, start, limit).then(d => {
241
225
  if (d.length) {
242
- _this.insert(target, d).then(function (res) {
226
+ this.insert(target, d).then(res => {
243
227
  resolve(res);
244
228
  });
245
229
  }
@@ -249,28 +233,28 @@ var dbObject = function (dbName) {
249
233
  });
250
234
  });
251
235
  };
252
- this.deleteTable = function (table) {
253
- return new Promise(function (resolve) {
236
+ this.deleteTable = table => {
237
+ return new Promise(resolve => {
254
238
  conn.deleteObjectStore(table);
255
239
  resolve(true);
256
240
  });
257
241
  };
258
242
  };
259
- var db = {
243
+ const db = {
260
244
  _structures: {},
261
245
  /* This variable should be set to true in debugging mode only */
262
246
  _connections: {},
263
247
  /* Address of the CDN (where this file should be hosted) */
264
248
  _stores: {},
265
249
  ok: idb !== undefined,
266
- updateStructure: function (storeName, structure, req) {
267
- var primary = structure.keys.PRIMARY.columns.length > 1 ? structure.keys.PRIMARY.columns : structure.keys.PRIMARY.columns[0];
268
- var stores = req.objectStoreNames;
250
+ updateStructure(storeName, structure, req) {
251
+ const primary = structure.keys.PRIMARY.columns.length > 1 ? structure.keys.PRIMARY.columns : structure.keys.PRIMARY.columns[0];
252
+ const stores = req.objectStoreNames;
269
253
  if (!stores.contains(storeName)) {
270
- var store_1 = req.createObjectStore(storeName, { keyPath: primary });
271
- iterate(structure.keys, function (a, n) {
254
+ const store = req.createObjectStore(storeName, { keyPath: primary });
255
+ iterate(structure.keys, (a, n) => {
272
256
  if (n !== 'PRIMARY') {
273
- store_1.createIndex(n, a.columns.length > 1 ? a.columns : a.columns[0], {
257
+ store.createIndex(n, a.columns.length > 1 ? a.columns : a.columns[0], {
274
258
  unique: !!a.unique
275
259
  });
276
260
  }
@@ -279,24 +263,23 @@ var db = {
279
263
  else {
280
264
  }
281
265
  },
282
- open: function (name) {
283
- var _this = this;
284
- return new Promise(function (resolve) {
266
+ open(name) {
267
+ return new Promise((resolve) => {
285
268
  if (!db._connections[name]) {
286
269
  if (!db._structures[name]) {
287
270
  throw new Error(_("Impossible to find a structure for the database %s", name));
288
271
  }
289
- var num = Math.max.apply(_this, [1].concat(Object.keys(db._structures[name]).map(function (a) { return db._structures[name][a].num || 1; })));
290
- var conn_1 = idb.open(name, num);
291
- conn_1.onupgradeneeded = function () {
292
- var req = conn_1.result;
293
- iterate(db._structures[name], function (structure, storeName) {
294
- _this.updateStructure(storeName, structure, req);
272
+ let num = Math.max.apply(this, [1].concat(Object.keys(db._structures[name]).map(a => db._structures[name][a].num || 1)));
273
+ const conn = idb.open(name, num);
274
+ conn.onupgradeneeded = () => {
275
+ const req = conn.result;
276
+ iterate(db._structures[name], (structure, storeName) => {
277
+ this.updateStructure(storeName, structure, req);
295
278
  });
296
279
  };
297
- conn_1.onsuccess = function () {
298
- db._connections[name] = conn_1.result;
299
- var obj = new dbObject(name);
280
+ conn.onsuccess = () => {
281
+ db._connections[name] = conn.result;
282
+ let obj = new dbObject(name);
300
283
  resolve(obj);
301
284
  };
302
285
  }
@@ -305,7 +288,7 @@ var db = {
305
288
  }
306
289
  });
307
290
  },
308
- add: function (database, name, structure) {
291
+ add(database, name, structure) {
309
292
  var _a;
310
293
  if (((_a = structure === null || structure === void 0 ? void 0 : structure.keys) === null || _a === void 0 ? void 0 : _a.PRIMARY) && (structure === null || structure === void 0 ? void 0 : structure.fields)) {
311
294
  if (!db._structures[database]) {
@@ -15,15 +15,15 @@ import substr from '../string/substr.js';
15
15
  */
16
16
  export default function _addLoader(requestId, prom, aborter) {
17
17
  /** @var {Number} tst Current timestamp */
18
- var tst = new Date().getTime();
18
+ let tst = new Date().getTime();
19
19
  /** @var {String} url The original URL (part of requestId before : and md5) */
20
- var url = substr(requestId, 0, requestId.length - 33);
20
+ let url = substr(requestId, 0, requestId.length - 33);
21
21
  /** @var {Object} loader The loader object */
22
- var loader = {
22
+ let loader = {
23
23
  key: requestId,
24
- url: url,
24
+ url,
25
25
  loader: prom,
26
- aborter: aborter,
26
+ aborter,
27
27
  loading: true,
28
28
  error: false,
29
29
  abort: false,
@@ -36,7 +36,7 @@ export default function _addLoader(requestId, prom, aborter) {
36
36
  // Adding an object with this loader info in bbn.env.loadersHistory
37
37
  bbn.env.loadersHistory.unshift(loader);
38
38
  /** @var {Number} idx A pointer starting at the end of array loadersHistory */
39
- var idx = bbn.env.loadersHistory.length;
39
+ let idx = bbn.env.loadersHistory.length;
40
40
  // Removing elements from the loadersHistory object if their number is higher
41
41
  // than bbn.env.maxLoadersHistory
42
42
  while (idx && bbn.env.loadersHistory.length > bbn.env.maxLoadersHistory) {