@bbn/bbn 1.0.422 → 1.0.424
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/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/fn/browser/executeSlowly.d.ts +1 -0
- package/dist/fn/browser/executeSlowly.js +69 -0
- package/dist/fn/browser/yieldToBrowser.d.ts +1 -0
- package/dist/fn/browser/yieldToBrowser.js +56 -0
- package/dist/fn/init.js +6 -4
- package/dist/fn/object/filter.js +1 -1
- package/dist/fn/type/isDataURL.d.ts +16 -0
- package/dist/fn/type/isDataURL.js +31 -0
- package/dist/fn.d.ts +6 -0
- package/dist/fn.js +6 -0
- package/dist/index.js +0 -5
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function executeSlowly(arr: any[], fn: Function): 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
|
+
import yieldToBrowser from './yieldToBrowser.js';
|
|
38
|
+
export default function executeSlowly(arr, fn) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
40
|
+
var i, res;
|
|
41
|
+
return __generator(this, function (_a) {
|
|
42
|
+
switch (_a.label) {
|
|
43
|
+
case 0:
|
|
44
|
+
i = 0;
|
|
45
|
+
_a.label = 1;
|
|
46
|
+
case 1:
|
|
47
|
+
if (!(i < arr.length)) return [3 /*break*/, 6];
|
|
48
|
+
res = fn(arr[i], i);
|
|
49
|
+
if (!(res instanceof Promise)) return [3 /*break*/, 3];
|
|
50
|
+
return [4 /*yield*/, res];
|
|
51
|
+
case 2:
|
|
52
|
+
res = _a.sent();
|
|
53
|
+
_a.label = 3;
|
|
54
|
+
case 3:
|
|
55
|
+
if (res === false) {
|
|
56
|
+
return [3 /*break*/, 6];
|
|
57
|
+
}
|
|
58
|
+
return [4 /*yield*/, yieldToBrowser()];
|
|
59
|
+
case 4:
|
|
60
|
+
_a.sent();
|
|
61
|
+
_a.label = 5;
|
|
62
|
+
case 5:
|
|
63
|
+
i++;
|
|
64
|
+
return [3 /*break*/, 1];
|
|
65
|
+
case 6: return [2 /*return*/];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function yieldToBrowser(): Promise<void>;
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
export default function yieldToBrowser() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
39
|
+
return __generator(this, function (_a) {
|
|
40
|
+
switch (_a.label) {
|
|
41
|
+
case 0:
|
|
42
|
+
if (!('scheduler' in window)) return [3 /*break*/, 2];
|
|
43
|
+
return [4 /*yield*/, window.scheduler.yield()];
|
|
44
|
+
case 1:
|
|
45
|
+
_a.sent(); // cooperative yield
|
|
46
|
+
return [3 /*break*/, 4];
|
|
47
|
+
case 2: return [4 /*yield*/, new Promise(requestAnimationFrame)];
|
|
48
|
+
case 3:
|
|
49
|
+
_a.sent();
|
|
50
|
+
_a.label = 4;
|
|
51
|
+
case 4: return [2 /*return*/];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
;
|
package/dist/fn/init.js
CHANGED
|
@@ -8,6 +8,7 @@ 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';
|
|
11
12
|
import log from './browser/log.js';
|
|
12
13
|
import timestamp from './datetime/timestamp.js';
|
|
13
14
|
/**
|
|
@@ -129,10 +130,11 @@ export default function init(cfg, force) {
|
|
|
129
130
|
target = null;
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
|
-
if (target instanceof HTMLElement
|
|
133
|
-
target.hasAttribute("href")
|
|
134
|
-
!target.
|
|
135
|
-
!target.
|
|
133
|
+
if (target instanceof HTMLElement
|
|
134
|
+
&& target.hasAttribute("href")
|
|
135
|
+
&& !isDataURL(target.getAttribute("href"))
|
|
136
|
+
&& !target.hasAttribute("target")
|
|
137
|
+
&& !target.classList.contains("bbn-no")) {
|
|
136
138
|
e.preventDefault();
|
|
137
139
|
e.stopPropagation();
|
|
138
140
|
link(target.getAttribute("href"));
|
package/dist/fn/object/filter.js
CHANGED
|
@@ -61,7 +61,6 @@ export default function filter(arr, prop, val, operator) {
|
|
|
61
61
|
if (!prop || !arr.length) {
|
|
62
62
|
return arr;
|
|
63
63
|
}
|
|
64
|
-
bbn.env._enumerated.push(true);
|
|
65
64
|
if (typeof prop === 'object') {
|
|
66
65
|
operator = val;
|
|
67
66
|
cfg = prop;
|
|
@@ -72,6 +71,7 @@ export default function filter(arr, prop, val, operator) {
|
|
|
72
71
|
else if (!isFn) {
|
|
73
72
|
throw new Error('Search function error: The prop argument should be a string or an object');
|
|
74
73
|
}
|
|
74
|
+
bbn.env._enumerated.push(true);
|
|
75
75
|
if (typeof (prop) === 'function') {
|
|
76
76
|
for (var i = 0; i < arr.length; i++) {
|
|
77
77
|
if (prop(arr[i], i)) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the given argument is a date object.
|
|
3
|
+
* @method isDataURL
|
|
4
|
+
* @global
|
|
5
|
+
* @example
|
|
6
|
+
* ```javascript
|
|
7
|
+
* console.log(isDataURL("data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...")); // true
|
|
8
|
+
* console.log(isDataURL("data:text/plain,HelloWorld")); // true
|
|
9
|
+
* console.log(isDataURL("https://example.com/image.png")); // false
|
|
10
|
+
* console.log(isDataURL("data:,Hello%2C%20World!")); // true
|
|
11
|
+
* console.log(isDataURL("data:image/png;xyz,")); // false
|
|
12
|
+
* ```
|
|
13
|
+
* @memberof bbn.fn
|
|
14
|
+
* @returns {Boolean}
|
|
15
|
+
*/
|
|
16
|
+
export default function isDataURL(...args: any[]): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the given argument is a date object.
|
|
3
|
+
* @method isDataURL
|
|
4
|
+
* @global
|
|
5
|
+
* @example
|
|
6
|
+
* ```javascript
|
|
7
|
+
* console.log(isDataURL("data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...")); // true
|
|
8
|
+
* console.log(isDataURL("data:text/plain,HelloWorld")); // true
|
|
9
|
+
* console.log(isDataURL("https://example.com/image.png")); // false
|
|
10
|
+
* console.log(isDataURL("data:,Hello%2C%20World!")); // true
|
|
11
|
+
* console.log(isDataURL("data:image/png;xyz,")); // false
|
|
12
|
+
* ```
|
|
13
|
+
* @memberof bbn.fn
|
|
14
|
+
* @returns {Boolean}
|
|
15
|
+
*/
|
|
16
|
+
export default function isDataURL() {
|
|
17
|
+
var args = [];
|
|
18
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
19
|
+
args[_i] = arguments[_i];
|
|
20
|
+
}
|
|
21
|
+
if (!args.length)
|
|
22
|
+
return false;
|
|
23
|
+
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
|
24
|
+
var a = args_1[_a];
|
|
25
|
+
if (!/^data:([a-z]+\/[a-z0-9\-\+\.]+(;[a-z\-]+\=[a-z0-9\-\.]+)?)?(;base64)?,/i.test(a)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
;
|
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';
|
|
@@ -132,6 +133,7 @@ import isCanvas from './fn/type/isCanvas.js';
|
|
|
132
133
|
import isColor from './fn/type/isColor.js';
|
|
133
134
|
import isComment from './fn/type/isComment.js';
|
|
134
135
|
import isCp from './fn/type/isCp.js';
|
|
136
|
+
import isDataURL from './fn/type/isDataURL.js';
|
|
135
137
|
import isDate from './fn/type/isDate.js';
|
|
136
138
|
import isDesktopDevice from './fn/browser/isDesktopDevice.js';
|
|
137
139
|
import isDimension from './fn/type/isDimension.js';
|
|
@@ -242,6 +244,7 @@ import uniqString from './fn/string/uniqString.js';
|
|
|
242
244
|
import unique from './fn/object/unique.js';
|
|
243
245
|
import upload from './fn/ajax/upload.js';
|
|
244
246
|
import warning from './fn/browser/warning.js';
|
|
247
|
+
import yieldToBrowser from './fn/browser/yieldToBrowser.js';
|
|
245
248
|
declare const _default: {
|
|
246
249
|
_addLoader: typeof _addLoader;
|
|
247
250
|
_compareValues: typeof _compareValues;
|
|
@@ -314,6 +317,7 @@ declare const _default: {
|
|
|
314
317
|
escapeSquotes: typeof escapeSquotes;
|
|
315
318
|
escapeTicks: typeof escapeTicks;
|
|
316
319
|
escapeUrl: typeof escapeUrl;
|
|
320
|
+
executeSlowly: typeof executeSlowly;
|
|
317
321
|
extend: typeof extend;
|
|
318
322
|
extendOut: typeof extendOut;
|
|
319
323
|
fdate: typeof fdate;
|
|
@@ -377,6 +381,7 @@ declare const _default: {
|
|
|
377
381
|
isColor: typeof isColor;
|
|
378
382
|
isComment: typeof isComment;
|
|
379
383
|
isCp: typeof isCp;
|
|
384
|
+
isDataURL: typeof isDataURL;
|
|
380
385
|
isDate: typeof isDate;
|
|
381
386
|
isDesktopDevice: typeof isDesktopDevice;
|
|
382
387
|
isDimension: typeof isDimension;
|
|
@@ -487,5 +492,6 @@ declare const _default: {
|
|
|
487
492
|
unique: typeof unique;
|
|
488
493
|
upload: typeof upload;
|
|
489
494
|
warning: typeof warning;
|
|
495
|
+
yieldToBrowser: typeof yieldToBrowser;
|
|
490
496
|
};
|
|
491
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';
|
|
@@ -132,6 +133,7 @@ import isCanvas from './fn/type/isCanvas.js';
|
|
|
132
133
|
import isColor from './fn/type/isColor.js';
|
|
133
134
|
import isComment from './fn/type/isComment.js';
|
|
134
135
|
import isCp from './fn/type/isCp.js';
|
|
136
|
+
import isDataURL from './fn/type/isDataURL.js';
|
|
135
137
|
import isDate from './fn/type/isDate.js';
|
|
136
138
|
import isDesktopDevice from './fn/browser/isDesktopDevice.js';
|
|
137
139
|
import isDimension from './fn/type/isDimension.js';
|
|
@@ -242,6 +244,7 @@ import uniqString from './fn/string/uniqString.js';
|
|
|
242
244
|
import unique from './fn/object/unique.js';
|
|
243
245
|
import upload from './fn/ajax/upload.js';
|
|
244
246
|
import warning from './fn/browser/warning.js';
|
|
247
|
+
import yieldToBrowser from './fn/browser/yieldToBrowser.js';
|
|
245
248
|
export default {
|
|
246
249
|
_addLoader: _addLoader,
|
|
247
250
|
_compareValues: _compareValues,
|
|
@@ -314,6 +317,7 @@ export default {
|
|
|
314
317
|
escapeSquotes: escapeSquotes,
|
|
315
318
|
escapeTicks: escapeTicks,
|
|
316
319
|
escapeUrl: escapeUrl,
|
|
320
|
+
executeSlowly: executeSlowly,
|
|
317
321
|
extend: extend,
|
|
318
322
|
extendOut: extendOut,
|
|
319
323
|
fdate: fdate,
|
|
@@ -377,6 +381,7 @@ export default {
|
|
|
377
381
|
isColor: isColor,
|
|
378
382
|
isComment: isComment,
|
|
379
383
|
isCp: isCp,
|
|
384
|
+
isDataURL: isDataURL,
|
|
380
385
|
isDate: isDate,
|
|
381
386
|
isDesktopDevice: isDesktopDevice,
|
|
382
387
|
isDimension: isDimension,
|
|
@@ -487,4 +492,5 @@ export default {
|
|
|
487
492
|
unique: unique,
|
|
488
493
|
upload: upload,
|
|
489
494
|
warning: warning,
|
|
495
|
+
yieldToBrowser: yieldToBrowser
|
|
490
496
|
};
|
package/dist/index.js
CHANGED