@bbn/bbn 1.0.426 → 1.0.428

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,18 +1,11 @@
1
- interface Structure {
2
- keys: {
3
- [key: string]: any;
4
- };
5
- fields: {
6
- [key: string]: any;
7
- };
8
- }
9
- declare const db: {
10
- _structures: {};
11
- _connections: {};
12
- _stores: {};
1
+ interface Db {
2
+ _structures: object;
3
+ _connections: object;
4
+ _stores: object;
13
5
  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
- };
6
+ updateStructure: Function;
7
+ open(name: string): Promise<object>;
8
+ add(db: string, name: string, structure: object): void;
9
+ }
10
+ declare const db: Db;
18
11
  export default db;
package/dist/db.js CHANGED
@@ -1,12 +1,3 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
1
  import _ from './_.js';
11
2
  import each from './fn/loop/each.js';
12
3
  import iterate from './fn/loop/iterate.js';
@@ -295,7 +286,7 @@ var db = {
295
286
  if (!db._structures[name]) {
296
287
  throw new Error(_("Impossible to find a structure for the database %s", name));
297
288
  }
298
- var num = Math.max.apply(Math, __spreadArray([1], Object.keys(db._structures[name]).map(function (a) { return db._structures[name][a].num || 1; }), false));
289
+ var num = Math.max.apply(_this, [1].concat(Object.keys(db._structures[name]).map(function (a) { return db._structures[name][a].num || 1; })));
299
290
  var conn_1 = idb.open(name, num);
300
291
  conn_1.onupgradeneeded = function () {
301
292
  var req = conn_1.result;
@@ -52,7 +52,6 @@ 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);
56
55
  throw new Error('Error in filter: The first argument must be an array');
57
56
  }
58
57
  var cfg = {};
package/dist/fn.d.ts CHANGED
@@ -69,7 +69,6 @@ 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';
73
72
  import extend from './fn/object/extend.js';
74
73
  import extendOut from './fn/object/extendOut.js';
75
74
  import fdate from './fn/datetime/fdate.js';
@@ -244,7 +243,6 @@ import uniqString from './fn/string/uniqString.js';
244
243
  import unique from './fn/object/unique.js';
245
244
  import upload from './fn/ajax/upload.js';
246
245
  import warning from './fn/browser/warning.js';
247
- import yieldToBrowser from './fn/browser/yieldToBrowser.js';
248
246
  declare const _default: {
249
247
  _addLoader: typeof _addLoader;
250
248
  _compareValues: typeof _compareValues;
@@ -317,7 +315,6 @@ declare const _default: {
317
315
  escapeSquotes: typeof escapeSquotes;
318
316
  escapeTicks: typeof escapeTicks;
319
317
  escapeUrl: typeof escapeUrl;
320
- executeSlowly: typeof executeSlowly;
321
318
  extend: typeof extend;
322
319
  extendOut: typeof extendOut;
323
320
  fdate: typeof fdate;
@@ -492,6 +489,5 @@ declare const _default: {
492
489
  unique: typeof unique;
493
490
  upload: typeof upload;
494
491
  warning: typeof warning;
495
- yieldToBrowser: typeof yieldToBrowser;
496
492
  };
497
493
  export default _default;
package/dist/fn.js CHANGED
@@ -69,7 +69,6 @@ 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';
73
72
  import extend from './fn/object/extend.js';
74
73
  import extendOut from './fn/object/extendOut.js';
75
74
  import fdate from './fn/datetime/fdate.js';
@@ -244,7 +243,6 @@ import uniqString from './fn/string/uniqString.js';
244
243
  import unique from './fn/object/unique.js';
245
244
  import upload from './fn/ajax/upload.js';
246
245
  import warning from './fn/browser/warning.js';
247
- import yieldToBrowser from './fn/browser/yieldToBrowser.js';
248
246
  export default {
249
247
  _addLoader: _addLoader,
250
248
  _compareValues: _compareValues,
@@ -317,7 +315,6 @@ export default {
317
315
  escapeSquotes: escapeSquotes,
318
316
  escapeTicks: escapeTicks,
319
317
  escapeUrl: escapeUrl,
320
- executeSlowly: executeSlowly,
321
318
  extend: extend,
322
319
  extendOut: extendOut,
323
320
  fdate: fdate,
@@ -492,5 +489,4 @@ export default {
492
489
  unique: unique,
493
490
  upload: upload,
494
491
  warning: warning,
495
- yieldToBrowser: yieldToBrowser
496
492
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.426",
3
+ "version": "1.0.428",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,7 +0,0 @@
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>;
@@ -1,75 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
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>;
@@ -1,69 +0,0 @@
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
- ;