@bbn/bbn 1.0.428 → 1.0.430

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/db.d.ts CHANGED
@@ -1,11 +1,18 @@
1
- interface Db {
2
- _structures: object;
3
- _connections: object;
4
- _stores: object;
5
- ok: boolean;
6
- updateStructure: Function;
7
- open(name: string): Promise<object>;
8
- add(db: string, name: string, structure: object): void;
1
+ interface Structure {
2
+ keys: {
3
+ [key: string]: any;
4
+ };
5
+ fields: {
6
+ [key: string]: any;
7
+ };
9
8
  }
10
- declare const db: Db;
9
+ declare const db: {
10
+ _structures: {};
11
+ _connections: {};
12
+ _stores: {};
13
+ ok: boolean;
14
+ updateStructure(storeName: any, structure: any, req: any): void;
15
+ open(name: any): Promise<unknown>;
16
+ add(database: string, name: string, structure: Structure): void;
17
+ };
11
18
  export default db;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Executes a function on each element of an array slowly, yielding to the browser in between.
3
+ * @param arr The array to iterate over.
4
+ * @param fn The function to execute on each element. If the function returns false, the iteration stops.
5
+ * @returns A promise that resolves to true if the iteration completed, or false if it was stopped early.
6
+ */
7
+ export default function executeSlowly(arr: any[], fn: Function): Promise<boolean>;
@@ -0,0 +1,75 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import yieldToBrowser from './yieldToBrowser.js';
38
+ /**
39
+ * Executes a function on each element of an array slowly, yielding to the browser in between.
40
+ * @param arr The array to iterate over.
41
+ * @param fn The function to execute on each element. If the function returns false, the iteration stops.
42
+ * @returns A promise that resolves to true if the iteration completed, or false if it was stopped early.
43
+ */
44
+ export default function executeSlowly(arr, fn) {
45
+ return __awaiter(this, void 0, void 0, function () {
46
+ var i, res;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0:
50
+ i = 0;
51
+ _a.label = 1;
52
+ case 1:
53
+ if (!(i < arr.length)) return [3 /*break*/, 6];
54
+ res = fn(arr[i], i);
55
+ if (!(res instanceof Promise)) return [3 /*break*/, 3];
56
+ return [4 /*yield*/, res];
57
+ case 2:
58
+ res = _a.sent();
59
+ _a.label = 3;
60
+ case 3:
61
+ if (res === false) {
62
+ return [2 /*return*/, false];
63
+ }
64
+ return [4 /*yield*/, yieldToBrowser()];
65
+ case 4:
66
+ _a.sent();
67
+ _a.label = 5;
68
+ case 5:
69
+ i++;
70
+ return [3 /*break*/, 1];
71
+ case 6: return [2 /*return*/, true];
72
+ }
73
+ });
74
+ });
75
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Yields execution to the browser to allow it to process pending UI updates.
3
+ * Uses `window.scheduler.yield()` if available, otherwise falls back to `requestAnimationFrame`.
4
+ * @method yieldToBrowser
5
+ * @global
6
+ * @example
7
+ * ``` javascript
8
+ * await bbn.fn.yieldToBrowser();
9
+ * ```
10
+ * @memberof bbn.fn
11
+ * @returns {Promise}
12
+ */
13
+ export default function yieldToBrowser(): Promise<void>;
@@ -0,0 +1,69 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ /**
38
+ * Yields execution to the browser to allow it to process pending UI updates.
39
+ * Uses `window.scheduler.yield()` if available, otherwise falls back to `requestAnimationFrame`.
40
+ * @method yieldToBrowser
41
+ * @global
42
+ * @example
43
+ * ``` javascript
44
+ * await bbn.fn.yieldToBrowser();
45
+ * ```
46
+ * @memberof bbn.fn
47
+ * @returns {Promise}
48
+ */
49
+ export default function yieldToBrowser() {
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ var _a;
52
+ return __generator(this, function (_b) {
53
+ switch (_b.label) {
54
+ case 0:
55
+ if (!((_a = window.scheduler) === null || _a === void 0 ? void 0 : _a.yield)) return [3 /*break*/, 2];
56
+ return [4 /*yield*/, window.scheduler.yield()];
57
+ case 1:
58
+ _b.sent(); // cooperative yield
59
+ return [3 /*break*/, 4];
60
+ case 2: return [4 /*yield*/, new Promise(requestAnimationFrame)];
61
+ case 3:
62
+ _b.sent();
63
+ _b.label = 4;
64
+ case 4: return [2 /*return*/];
65
+ }
66
+ });
67
+ });
68
+ }
69
+ ;
package/dist/fn/init.js CHANGED
@@ -8,7 +8,6 @@ import resize from './style/resize.js';
8
8
  import isMobile from './browser/isMobile.js';
9
9
  import isTabletDevice from './browser/isTabletDevice.js';
10
10
  import isFunction from './type/isFunction.js';
11
- import isDataURL from './type/isDataURL.js';
12
11
  import log from './browser/log.js';
13
12
  import timestamp from './datetime/timestamp.js';
14
13
  /**
@@ -130,11 +129,10 @@ export default function init(cfg, force) {
130
129
  target = null;
131
130
  }
132
131
  }
133
- if (target instanceof HTMLElement
134
- && target.hasAttribute("href")
135
- && !isDataURL(target.getAttribute("href"))
136
- && !target.hasAttribute("target")
137
- && !target.classList.contains("bbn-no")) {
132
+ if (target instanceof HTMLElement &&
133
+ target.hasAttribute("href") &&
134
+ !target.hasAttribute("target") &&
135
+ !target.classList.contains("bbn-no")) {
138
136
  e.preventDefault();
139
137
  e.stopPropagation();
140
138
  link(target.getAttribute("href"));
@@ -52,6 +52,7 @@ export default function filter(arr, prop, val, operator) {
52
52
  if (val === void 0) { val = null; }
53
53
  if (operator === void 0) { operator = '='; }
54
54
  if (!isArray(arr)) {
55
+ bbn.fn.log("NOT ARRAY", arr);
55
56
  throw new Error('Error in filter: The first argument must be an array');
56
57
  }
57
58
  var cfg = {};
@@ -60,6 +61,7 @@ export default function filter(arr, prop, val, operator) {
60
61
  if (!prop || !arr.length) {
61
62
  return arr;
62
63
  }
64
+ bbn.env._enumerated.push(true);
63
65
  if (typeof prop === 'object') {
64
66
  operator = val;
65
67
  cfg = prop;
@@ -70,7 +72,6 @@ export default function filter(arr, prop, val, operator) {
70
72
  else if (!isFn) {
71
73
  throw new Error('Search function error: The prop argument should be a string or an object');
72
74
  }
73
- bbn.env._enumerated.push(true);
74
75
  if (typeof (prop) === 'function') {
75
76
  for (var i = 0; i < arr.length; i++) {
76
77
  if (prop(arr[i], i)) {
package/dist/fn.d.ts CHANGED
@@ -69,6 +69,7 @@ import escapeRegExp from './fn/string/escapeRegExp.js';
69
69
  import escapeSquotes from './fn/string/escapeSquotes.js';
70
70
  import escapeTicks from './fn/string/escapeTicks.js';
71
71
  import escapeUrl from './fn/string/escapeUrl.js';
72
+ import executeSlowly from './fn/browser/executeSlowly.js';
72
73
  import extend from './fn/object/extend.js';
73
74
  import extendOut from './fn/object/extendOut.js';
74
75
  import fdate from './fn/datetime/fdate.js';
@@ -243,6 +244,7 @@ import uniqString from './fn/string/uniqString.js';
243
244
  import unique from './fn/object/unique.js';
244
245
  import upload from './fn/ajax/upload.js';
245
246
  import warning from './fn/browser/warning.js';
247
+ import yieldToBrowser from './fn/browser/yieldToBrowser.js';
246
248
  declare const _default: {
247
249
  _addLoader: typeof _addLoader;
248
250
  _compareValues: typeof _compareValues;
@@ -315,6 +317,7 @@ declare const _default: {
315
317
  escapeSquotes: typeof escapeSquotes;
316
318
  escapeTicks: typeof escapeTicks;
317
319
  escapeUrl: typeof escapeUrl;
320
+ executeSlowly: typeof executeSlowly;
318
321
  extend: typeof extend;
319
322
  extendOut: typeof extendOut;
320
323
  fdate: typeof fdate;
@@ -489,5 +492,6 @@ declare const _default: {
489
492
  unique: typeof unique;
490
493
  upload: typeof upload;
491
494
  warning: typeof warning;
495
+ yieldToBrowser: typeof yieldToBrowser;
492
496
  };
493
497
  export default _default;
package/dist/fn.js CHANGED
@@ -69,6 +69,7 @@ import escapeRegExp from './fn/string/escapeRegExp.js';
69
69
  import escapeSquotes from './fn/string/escapeSquotes.js';
70
70
  import escapeTicks from './fn/string/escapeTicks.js';
71
71
  import escapeUrl from './fn/string/escapeUrl.js';
72
+ import executeSlowly from './fn/browser/executeSlowly.js';
72
73
  import extend from './fn/object/extend.js';
73
74
  import extendOut from './fn/object/extendOut.js';
74
75
  import fdate from './fn/datetime/fdate.js';
@@ -243,6 +244,7 @@ import uniqString from './fn/string/uniqString.js';
243
244
  import unique from './fn/object/unique.js';
244
245
  import upload from './fn/ajax/upload.js';
245
246
  import warning from './fn/browser/warning.js';
247
+ import yieldToBrowser from './fn/browser/yieldToBrowser.js';
246
248
  export default {
247
249
  _addLoader: _addLoader,
248
250
  _compareValues: _compareValues,
@@ -315,6 +317,7 @@ export default {
315
317
  escapeSquotes: escapeSquotes,
316
318
  escapeTicks: escapeTicks,
317
319
  escapeUrl: escapeUrl,
320
+ executeSlowly: executeSlowly,
318
321
  extend: extend,
319
322
  extendOut: extendOut,
320
323
  fdate: fdate,
@@ -489,4 +492,5 @@ export default {
489
492
  unique: unique,
490
493
  upload: upload,
491
494
  warning: warning,
495
+ yieldToBrowser: yieldToBrowser
492
496
  };
package/dist/index.js CHANGED
@@ -123,4 +123,9 @@ var bbn = {
123
123
  }
124
124
  ]
125
125
  };
126
+ if ('undefined' !== typeof window) {
127
+ window.axios = axios;
128
+ window.dayjs = dayjs;
129
+ window.bbn = bbn;
130
+ }
126
131
  export { bbn as default, bbn, dayjs, axios };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.428",
3
+ "version": "1.0.430",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",