@bbn/bbn 1.0.35 → 1.0.36
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/bundle.js +827 -1109
- package/dist/fn/_addLoader.js +5 -5
- package/dist/fn/_compareValues.js +2 -3
- package/dist/fn/_deleteLoader.js +11 -13
- package/dist/fn/abort.js +2 -2
- package/dist/fn/abortURL.js +2 -2
- package/dist/fn/addColors.js +12 -12
- package/dist/fn/addInputs.js +10 -12
- package/dist/fn/addStyle.js +2 -2
- package/dist/fn/adjustHeight.js +2 -2
- package/dist/fn/adjustSize.js +6 -6
- package/dist/fn/adjustWidth.js +2 -2
- package/dist/fn/ajax.js +21 -21
- package/dist/fn/analyzeFunction.js +28 -28
- package/dist/fn/animateCss.js +5 -6
- package/dist/fn/arrayBuffer2String.js +1 -1
- package/dist/fn/arrayFromProp.js +3 -3
- package/dist/fn/autoExtend.js +1 -1
- package/dist/fn/baseName.js +4 -4
- package/dist/fn/br2nl.js +1 -1
- package/dist/fn/calendar.js +2 -2
- package/dist/fn/callback.js +7 -11
- package/dist/fn/camelToCss.js +1 -1
- package/dist/fn/camelize.js +1 -1
- package/dist/fn/canvasToImage.js +2 -2
- package/dist/fn/center.js +2 -2
- package/dist/fn/checkProps.js +1 -2
- package/dist/fn/checkPropsDetails.js +8 -9
- package/dist/fn/checkPropsOrDie.js +2 -3
- package/dist/fn/checkType.js +6 -11
- package/dist/fn/chrono.js +8 -8
- package/dist/fn/circularReplacer.js +3 -3
- package/dist/fn/clone.js +3 -3
- package/dist/fn/colorToHex.js +2 -2
- package/dist/fn/compare.js +1 -1
- package/dist/fn/compareConditions.js +7 -7
- package/dist/fn/copy.js +6 -8
- package/dist/fn/correctCase.js +2 -2
- package/dist/fn/count.js +1 -3
- package/dist/fn/crc32.js +8 -8
- package/dist/fn/createObject.js +3 -16
- package/dist/fn/cssExists.js +6 -6
- package/dist/fn/date.js +2 -2
- package/dist/fn/dateSQL.js +2 -2
- package/dist/fn/daysInMonth.js +2 -2
- package/dist/fn/deepPath.js +6 -7
- package/dist/fn/defaultAjaxAbortFunction.js +1 -2
- package/dist/fn/defaultAjaxErrorFunction.js +1 -1
- package/dist/fn/defaultAlertFunction.js +1 -1
- package/dist/fn/defaultConfirmFunction.js +2 -2
- package/dist/fn/defaultEndLoadingFunction.js +1 -1
- package/dist/fn/defaultErrorFunction.js +1 -1
- package/dist/fn/defaultHistoryFunction.js +1 -1
- package/dist/fn/defaultLinkFunction.js +1 -1
- package/dist/fn/defaultPostLinkFunction.js +1 -1
- package/dist/fn/defaultPreLinkFunction.js +1 -1
- package/dist/fn/defaultResizeFunction.js +1 -1
- package/dist/fn/defaultStartLoadingFunction.js +1 -2
- package/dist/fn/deleteProp.js +1 -1
- package/dist/fn/diffObj.js +11 -13
- package/dist/fn/dirName.js +2 -2
- package/dist/fn/download.js +6 -6
- package/dist/fn/downloadContent.js +5 -5
- package/dist/fn/each.js +3 -3
- package/dist/fn/eraseCookie.js +1 -1
- package/dist/fn/error.js +3 -3
- package/dist/fn/escapeDquotes.js +1 -1
- package/dist/fn/escapeRegExp.js +1 -1
- package/dist/fn/escapeSquotes.js +1 -1
- package/dist/fn/escapeTicks.js +1 -1
- package/dist/fn/escapeUrl.js +7 -7
- package/dist/fn/extend.js +9 -13
- package/dist/fn/extendOut.js +4 -9
- package/dist/fn/fdate.js +2 -2
- package/dist/fn/fdatetime.js +2 -2
- package/dist/fn/fieldValue.js +2 -2
- package/dist/fn/fileExt.js +2 -2
- package/dist/fn/filter.js +6 -8
- package/dist/fn/filterToConditions.js +6 -7
- package/dist/fn/findAll.js +4 -5
- package/dist/fn/fori.js +3 -5
- package/dist/fn/forir.js +3 -5
- package/dist/fn/format.js +5 -5
- package/dist/fn/formatBytes.js +2 -3
- package/dist/fn/formatDate.js +1 -1
- package/dist/fn/formatSize.js +1 -1
- package/dist/fn/formdata.js +25 -25
- package/dist/fn/fromXml.js +8 -14
- package/dist/fn/ftime.js +2 -2
- package/dist/fn/getAllTags.js +2 -2
- package/dist/fn/getAncestors.js +2 -2
- package/dist/fn/getAttributes.js +3 -3
- package/dist/fn/getBrowserName.js +2 -2
- package/dist/fn/getBrowserVersion.js +2 -2
- package/dist/fn/getCookie.js +6 -6
- package/dist/fn/getCssVar.js +1 -1
- package/dist/fn/getDay.js +4 -4
- package/dist/fn/getDeviceType.js +2 -2
- package/dist/fn/getEventData.js +31 -31
- package/dist/fn/getField.js +2 -5
- package/dist/fn/getFieldValues.js +3 -3
- package/dist/fn/getHTMLOfSelection.js +5 -5
- package/dist/fn/getHtml.js +2 -3
- package/dist/fn/getLoader.js +2 -2
- package/dist/fn/getPath.js +16 -23
- package/dist/fn/getProp.js +1 -1
- package/dist/fn/getProperty.js +2 -2
- package/dist/fn/getRequestId.js +3 -3
- package/dist/fn/getRow.js +1 -3
- package/dist/fn/getScrollBarSize.js +6 -6
- package/dist/fn/getText.js +1 -1
- package/dist/fn/getTimeoff.js +1 -1
- package/dist/fn/happy.js +1 -5
- package/dist/fn/hash.js +4 -4
- package/dist/fn/hex2rgb.js +1 -1
- package/dist/fn/history.js +1 -1
- package/dist/fn/html2text.js +2 -2
- package/dist/fn/imageToCanvas.js +2 -2
- package/dist/fn/imgToBase64.js +2 -3
- package/dist/fn/info.js +1 -5
- package/dist/fn/init.js +17 -17
- package/dist/fn/isActiveInterface.js +2 -3
- package/dist/fn/isArray.js +2 -7
- package/dist/fn/isBlob.js +2 -7
- package/dist/fn/isBoolean.js +2 -7
- package/dist/fn/isCanvas.js +2 -7
- package/dist/fn/isColor.js +2 -7
- package/dist/fn/isComment.js +2 -7
- package/dist/fn/isCp.js +3 -8
- package/dist/fn/isDate.js +2 -7
- package/dist/fn/isDesktopDevice.js +1 -1
- package/dist/fn/isDimension.js +2 -7
- package/dist/fn/isDom.js +2 -7
- package/dist/fn/isEmail.js +3 -8
- package/dist/fn/isEmpty.js +1 -1
- package/dist/fn/isEvent.js +2 -7
- package/dist/fn/isFocused.js +1 -1
- package/dist/fn/isFunction.js +2 -7
- package/dist/fn/isHostname.js +2 -7
- package/dist/fn/isIP.js +2 -7
- package/dist/fn/isInside.js +6 -6
- package/dist/fn/isInt.js +2 -7
- package/dist/fn/isIterable.js +1 -1
- package/dist/fn/isMobile.js +1 -1
- package/dist/fn/isMobileDevice.js +1 -1
- package/dist/fn/isNull.js +2 -7
- package/dist/fn/isNumber.js +2 -7
- package/dist/fn/isObject.js +2 -7
- package/dist/fn/isPercent.js +2 -7
- package/dist/fn/isPrimitive.js +2 -7
- package/dist/fn/isPromise.js +2 -7
- package/dist/fn/isPropSize.js +3 -3
- package/dist/fn/isSQLDate.js +2 -7
- package/dist/fn/isSame.js +7 -7
- package/dist/fn/isString.js +2 -7
- package/dist/fn/isSymbol.js +2 -7
- package/dist/fn/isTabletDevice.js +1 -1
- package/dist/fn/isURL.js +2 -7
- package/dist/fn/isValidDimension.js +3 -3
- package/dist/fn/isValidName.js +2 -7
- package/dist/fn/isValue.js +2 -7
- package/dist/fn/isVue.js +4 -11
- package/dist/fn/iterate.js +3 -5
- package/dist/fn/lightenDarkenHex.js +3 -3
- package/dist/fn/link.js +7 -11
- package/dist/fn/log.js +6 -10
- package/dist/fn/makeReactive.js +24 -28
- package/dist/fn/map.js +2 -3
- package/dist/fn/md5.js +1 -1
- package/dist/fn/money.js +5 -5
- package/dist/fn/move.js +2 -2
- package/dist/fn/multiorder.js +6 -7
- package/dist/fn/nl2br.js +1 -1
- package/dist/fn/numProperties.js +1 -1
- package/dist/fn/objectToFormData.js +5 -7
- package/dist/fn/order.js +1 -2
- package/dist/fn/outerHeight.js +3 -3
- package/dist/fn/outerWidth.js +3 -3
- package/dist/fn/percent.js +1 -1
- package/dist/fn/pickValue.js +1 -1
- package/dist/fn/post.js +3 -7
- package/dist/fn/postOut.js +2 -2
- package/dist/fn/printf.js +1 -1
- package/dist/fn/quotes2html.js +1 -1
- package/dist/fn/randomInt.js +1 -1
- package/dist/fn/randomString.js +6 -6
- package/dist/fn/removeAccents.js +1 -1
- package/dist/fn/removeEmpty.js +3 -3
- package/dist/fn/removeExtraSpaces.js +1 -1
- package/dist/fn/removeHtmlComments.js +1 -1
- package/dist/fn/removePrivateProp.js +2 -3
- package/dist/fn/removeTrailingChars.js +1 -1
- package/dist/fn/repeat.js +1 -1
- package/dist/fn/replaceAll.js +1 -2
- package/dist/fn/replaceSelection.js +6 -6
- package/dist/fn/resize.js +15 -15
- package/dist/fn/rgb2hex.js +1 -1
- package/dist/fn/riterate.js +1 -1
- package/dist/fn/roundDecimal.js +1 -1
- package/dist/fn/sanitize.js +6 -7
- package/dist/fn/search.js +6 -9
- package/dist/fn/selectElementText.js +4 -4
- package/dist/fn/selector.js +1 -1
- package/dist/fn/setCookie.js +4 -4
- package/dist/fn/setCssVar.js +1 -1
- package/dist/fn/setNavigationVars.js +5 -5
- package/dist/fn/setProp.js +1 -3
- package/dist/fn/setProperty.js +9 -9
- package/dist/fn/shorten.js +1 -1
- package/dist/fn/shortenObj.js +3 -4
- package/dist/fn/shuffle.js +3 -4
- package/dist/fn/simpleHash.js +3 -3
- package/dist/fn/simpleHash1.js +4 -4
- package/dist/fn/simpleHash2.js +4 -4
- package/dist/fn/stat.js +1 -1
- package/dist/fn/string2ArrayBuffer.js +1 -1
- package/dist/fn/submit.js +3 -3
- package/dist/fn/substr.js +1 -1
- package/dist/fn/sum.js +4 -4
- package/dist/fn/timestamp.js +1 -1
- package/dist/fn/toCSV.js +7 -10
- package/dist/fn/toggleFullScreen.js +1 -1
- package/dist/fn/translate.js +3 -3
- package/dist/fn/treatAjaxArguments.js +4 -4
- package/dist/fn/trim.js +1 -2
- package/dist/fn/uniqString.js +7 -14
- package/dist/fn/unique.js +1 -1
- package/dist/fn/upload.js +6 -6
- package/dist/fn/warning.js +3 -3
- package/dist/index.js +237 -241
- package/package.json +1 -1
package/dist/fn/search.js
CHANGED
|
@@ -4,18 +4,15 @@ import { filterToConditions } from './filterToConditions';
|
|
|
4
4
|
import { isObject } from './isObject';
|
|
5
5
|
import { numProperties } from './numProperties';
|
|
6
6
|
import { isNumber } from './isNumber';
|
|
7
|
-
|
|
8
|
-
if (val === void 0) { val = null; }
|
|
9
|
-
if (operator === void 0) { operator = '='; }
|
|
10
|
-
if (startFrom === void 0) { startFrom = 0; }
|
|
7
|
+
const search = function (arr, prop, val = null, operator = '=', startFrom = 0) {
|
|
11
8
|
if (!isIterable(arr)) {
|
|
12
9
|
throw new Error(bbn._('The first argument for a search should be iterable') + ' ' + typeof arr + ' ' + bbn._('given'));
|
|
13
10
|
}
|
|
14
11
|
if (!arr.length) {
|
|
15
12
|
return -1;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
let filter;
|
|
15
|
+
let isFn = false;
|
|
19
16
|
if (typeof prop === 'string') {
|
|
20
17
|
filter = {
|
|
21
18
|
conditions: [
|
|
@@ -29,7 +26,7 @@ var search = function (arr, prop, val, operator, startFrom) {
|
|
|
29
26
|
}
|
|
30
27
|
else if (!prop) {
|
|
31
28
|
isFn = true;
|
|
32
|
-
filter =
|
|
29
|
+
filter = a => {
|
|
33
30
|
return compareConditions({ value: a }, filterToConditions({
|
|
34
31
|
logic: 'AND',
|
|
35
32
|
conditions: [
|
|
@@ -62,7 +59,7 @@ var search = function (arr, prop, val, operator, startFrom) {
|
|
|
62
59
|
startFrom = 0;
|
|
63
60
|
}
|
|
64
61
|
if (typeof filter === 'function') {
|
|
65
|
-
for (
|
|
62
|
+
for (let i = startFrom; i < arr.length; i++) {
|
|
66
63
|
if (filter(arr[i])) {
|
|
67
64
|
return i;
|
|
68
65
|
}
|
|
@@ -70,7 +67,7 @@ var search = function (arr, prop, val, operator, startFrom) {
|
|
|
70
67
|
}
|
|
71
68
|
else {
|
|
72
69
|
filter = filterToConditions(filter);
|
|
73
|
-
for (
|
|
70
|
+
for (let i = startFrom; i < arr.length; i++) {
|
|
74
71
|
if (compareConditions(arr[i], filter)) {
|
|
75
72
|
return i;
|
|
76
73
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
const selectElementText = function (ele, win) {
|
|
2
2
|
win = win || window;
|
|
3
3
|
if (ele instanceof HTMLInputElement) {
|
|
4
4
|
ele.select();
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
let doc = win.document;
|
|
8
|
+
let sel;
|
|
9
|
+
let range;
|
|
10
10
|
if (win.getSelection && doc.createRange) {
|
|
11
11
|
sel = win.getSelection();
|
|
12
12
|
range = doc.createRange();
|
package/dist/fn/selector.js
CHANGED
package/dist/fn/setCookie.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const setCookie = function (name, value, days) {
|
|
2
|
+
let expires = '';
|
|
3
3
|
if (days) {
|
|
4
|
-
|
|
4
|
+
let date = new Date();
|
|
5
5
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
6
6
|
expires = '; expires=' + date.toUTCString();
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
let st = escape(JSON.stringify({ value: value }));
|
|
9
9
|
document.cookie = name + '=' + st + expires + '; path=/';
|
|
10
10
|
};
|
|
11
11
|
export { setCookie };
|
package/dist/fn/setCssVar.js
CHANGED
|
@@ -2,7 +2,7 @@ import { substr } from './substr';
|
|
|
2
2
|
import { filter } from './filter';
|
|
3
3
|
import { extend } from './extend';
|
|
4
4
|
import { html2text } from './html2text';
|
|
5
|
-
|
|
5
|
+
const setNavigationVars = function (url, title, data, repl) {
|
|
6
6
|
// Current path becomes old path
|
|
7
7
|
bbn.env.old_path = bbn.env.path;
|
|
8
8
|
// URL includes the domain
|
|
@@ -10,16 +10,16 @@ var setNavigationVars = function (url, title, data, repl) {
|
|
|
10
10
|
// Path does not
|
|
11
11
|
bbn.env.path = substr(bbn.env.url, bbn.env.root.length);
|
|
12
12
|
// Params will include each part of the URL
|
|
13
|
-
bbn.env.params = filter(bbn.env.path.split('/'),
|
|
13
|
+
bbn.env.params = filter(bbn.env.path.split('/'), (v) => {
|
|
14
14
|
return v !== '';
|
|
15
15
|
});
|
|
16
16
|
// Managing history
|
|
17
|
-
|
|
17
|
+
let h = window.history;
|
|
18
18
|
if (h) {
|
|
19
19
|
// Current state
|
|
20
|
-
|
|
20
|
+
let state = h.state;
|
|
21
21
|
// Future state
|
|
22
|
-
|
|
22
|
+
let obj = {
|
|
23
23
|
url: bbn.env.path,
|
|
24
24
|
old_path: bbn.env.old_path || null,
|
|
25
25
|
data: data || {},
|
package/dist/fn/setProp.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
if (writable === void 0) { writable = true; }
|
|
3
|
-
if (configurable === void 0) { configurable = true; }
|
|
1
|
+
const setProp = function (obj, prop, value, writable = true, configurable = true) {
|
|
4
2
|
Object.defineProperty(obj, prop, {
|
|
5
3
|
value: value,
|
|
6
4
|
writable: writable,
|
package/dist/fn/setProperty.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { each } from './each';
|
|
2
|
-
|
|
2
|
+
const setProperty = function (obj, prop, value, force) {
|
|
3
3
|
if (typeof obj === 'object' && typeof prop === 'string') {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
each(
|
|
7
|
-
if (!
|
|
4
|
+
let o = obj;
|
|
5
|
+
const bits = prop.split('.');
|
|
6
|
+
each(bits, (v, i) => {
|
|
7
|
+
if (!o) {
|
|
8
8
|
if (!force) {
|
|
9
9
|
throw new Error(bbn._('The object is invalid'));
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
o = {};
|
|
12
12
|
}
|
|
13
|
-
if (
|
|
14
|
-
|
|
13
|
+
if (bits.length - 1 === i) {
|
|
14
|
+
o[v] = value;
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
|
-
|
|
17
|
+
o = o[v];
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
}
|
package/dist/fn/shorten.js
CHANGED
package/dist/fn/shortenObj.js
CHANGED
|
@@ -2,10 +2,9 @@ import { clone } from './clone';
|
|
|
2
2
|
import { each } from './each';
|
|
3
3
|
import { isString } from './isString';
|
|
4
4
|
import { shorten } from './shorten';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
each(o, function (a, n) {
|
|
5
|
+
const shortenObj = function (obj, max = 100) {
|
|
6
|
+
let o = clone(obj);
|
|
7
|
+
each(o, (a, n) => {
|
|
9
8
|
if (isString(a) && a.length > max) {
|
|
10
9
|
o[n] = shorten(a, max);
|
|
11
10
|
}
|
package/dist/fn/shuffle.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var currentIndex = array.length, randomIndex;
|
|
1
|
+
const shuffle = function (array) {
|
|
2
|
+
let currentIndex = array.length, randomIndex;
|
|
4
3
|
// While there remain elements to shuffle.
|
|
5
4
|
while (currentIndex != 0) {
|
|
6
5
|
// Pick a remaining element.
|
|
7
6
|
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
8
7
|
currentIndex--;
|
|
9
8
|
// And swap it with the current element.
|
|
10
|
-
|
|
9
|
+
[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
|
|
11
10
|
}
|
|
12
11
|
return array;
|
|
13
12
|
};
|
package/dist/fn/simpleHash.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { simpleHash1 } from './simpleHash1';
|
|
2
2
|
import { simpleHash2 } from './simpleHash2';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const simpleHash = function (str) {
|
|
4
|
+
const part1 = simpleHash1(str).toString(16).padStart(8, '0');
|
|
5
|
+
const part2 = simpleHash2(str).toString(16).padStart(8, '0');
|
|
6
6
|
return part1 + part2;
|
|
7
7
|
};
|
|
8
8
|
export { simpleHash };
|
package/dist/fn/simpleHash1.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
for (
|
|
4
|
-
|
|
1
|
+
const simpleHash1 = function (str) {
|
|
2
|
+
let hash = 0;
|
|
3
|
+
for (let i = 0; i < str.length; i++) {
|
|
4
|
+
const char = str.charCodeAt(i);
|
|
5
5
|
hash = (hash << 5) - hash + char;
|
|
6
6
|
hash |= 0; // Convert to 32-bit integer
|
|
7
7
|
}
|
package/dist/fn/simpleHash2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
for (
|
|
4
|
-
|
|
1
|
+
const simpleHash2 = function (str) {
|
|
2
|
+
let hash = 0;
|
|
3
|
+
for (let i = 0; i < str.length; i++) {
|
|
4
|
+
const char = str.charCodeAt(i);
|
|
5
5
|
hash = char + (hash << 6) + (hash << 16) - hash;
|
|
6
6
|
hash |= 0; // Convert to 32-bit integer
|
|
7
7
|
}
|
package/dist/fn/stat.js
CHANGED
package/dist/fn/submit.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { formdata } from './formdata';
|
|
2
2
|
import { post } from './post';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const submit = function (form, e, fn) {
|
|
4
|
+
let url = form.getAttribute('action') || bbn.env.path;
|
|
5
|
+
let data;
|
|
6
6
|
if (url === '') {
|
|
7
7
|
url = '.';
|
|
8
8
|
}
|
package/dist/fn/substr.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isString } from './isString';
|
|
2
2
|
import { isInt } from './isInt';
|
|
3
3
|
import { log } from './log';
|
|
4
|
-
|
|
4
|
+
const substr = function (str, from, length) {
|
|
5
5
|
if (!isString(str) || !isInt(from)) {
|
|
6
6
|
log(arguments);
|
|
7
7
|
throw new Error(bbn._('The substr function should be applied to a string and at least a `from` argument should be given'));
|
package/dist/fn/sum.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { each } from './each';
|
|
2
2
|
import { filter } from './filter';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
each(filter(arr, prop, val, operator),
|
|
6
|
-
|
|
3
|
+
const sum = function (arr, numberProp, prop, val, operator) {
|
|
4
|
+
let r = 0;
|
|
5
|
+
each(filter(arr, prop, val, operator), (a) => {
|
|
6
|
+
let tmp = typeof numberProp === 'function' ? numberProp(a) : a[numberProp];
|
|
7
7
|
if (tmp) {
|
|
8
8
|
r += parseFloat(tmp) || 0;
|
|
9
9
|
}
|
package/dist/fn/timestamp.js
CHANGED
package/dist/fn/toCSV.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { each } from './each';
|
|
2
2
|
import { isArray } from './isArray';
|
|
3
3
|
import { replaceAll } from './replaceAll';
|
|
4
|
-
|
|
5
|
-
if (valSep === void 0) { valSep = ','; }
|
|
6
|
-
if (rowSep === void 0) { rowSep = ''; }
|
|
7
|
-
if (valEsc === void 0) { valEsc = '"'; }
|
|
4
|
+
const toCSV = function (arr, valSep = ',', rowSep = '', valEsc = '"') {
|
|
8
5
|
if (!valSep) {
|
|
9
6
|
valSep = ',';
|
|
10
7
|
}
|
|
11
8
|
if (!valEsc) {
|
|
12
9
|
valEsc = '"';
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
each(arr,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
each(a,
|
|
11
|
+
let csvContent = '';
|
|
12
|
+
let total = arr.length;
|
|
13
|
+
each(arr, (a, i) => {
|
|
14
|
+
let num = isArray(a) ? a.length : Object.values(a).length;
|
|
15
|
+
let j = 0;
|
|
16
|
+
each(a, (b) => {
|
|
20
17
|
if (typeof b === 'string') {
|
|
21
18
|
csvContent += valEsc + replaceAll(valEsc, '\\' + valEsc, b) + valEsc;
|
|
22
19
|
}
|
package/dist/fn/translate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { iterate } from './iterate';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
iterate(o,
|
|
2
|
+
const translate = function (o, namespace) {
|
|
3
|
+
let lng = namespace ? bbn.lng[namespace.indexOf('_') === 0 ? namespace : '_' + namespace] : bbn.lng;
|
|
4
|
+
iterate(o, (v, k) => {
|
|
5
5
|
lng[k] = v;
|
|
6
6
|
});
|
|
7
7
|
};
|
|
@@ -2,10 +2,10 @@ import { isObject } from './isObject';
|
|
|
2
2
|
import { isFunction } from './isFunction';
|
|
3
3
|
import { substr } from './substr';
|
|
4
4
|
import { numProperties } from './numProperties';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const treatAjaxArguments = function (args) {
|
|
6
|
+
let cfg = {};
|
|
7
|
+
let t;
|
|
8
|
+
let i;
|
|
9
9
|
if (isObject(args[0]) && args.length === 1) {
|
|
10
10
|
return args[0];
|
|
11
11
|
}
|
package/dist/fn/trim.js
CHANGED
package/dist/fn/uniqString.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { isArray } from './isArray';
|
|
2
2
|
import { each } from './each';
|
|
3
3
|
import { md5 } from './md5';
|
|
4
|
-
|
|
5
|
-
var args = [];
|
|
6
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7
|
-
args[_i] = arguments[_i];
|
|
8
|
-
}
|
|
4
|
+
const uniqString = function (...args) {
|
|
9
5
|
var st = '';
|
|
10
|
-
var
|
|
6
|
+
for (var i = 0; i < args.length; i++) {
|
|
11
7
|
if (!args[i]) {
|
|
12
8
|
st += '__bbn_empty__';
|
|
13
9
|
}
|
|
@@ -17,12 +13,12 @@ var uniqString = function () {
|
|
|
17
13
|
}
|
|
18
14
|
else {
|
|
19
15
|
// An object with the same properties, even in different order, should produce the same answer
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
each(ks,
|
|
23
|
-
|
|
16
|
+
let tmp = {};
|
|
17
|
+
let ks = Object.keys(args[i]).sort();
|
|
18
|
+
each(ks, (k) => {
|
|
19
|
+
tmp[k] = args[i][k];
|
|
24
20
|
});
|
|
25
|
-
st += JSON.stringify(
|
|
21
|
+
st += JSON.stringify(tmp);
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
24
|
else if (typeof args[i] !== 'string') {
|
|
@@ -31,9 +27,6 @@ var uniqString = function () {
|
|
|
31
27
|
else {
|
|
32
28
|
st += args[i];
|
|
33
29
|
}
|
|
34
|
-
};
|
|
35
|
-
for (var i = 0; i < args.length; i++) {
|
|
36
|
-
_loop_1();
|
|
37
30
|
}
|
|
38
31
|
return md5(st);
|
|
39
32
|
};
|
package/dist/fn/unique.js
CHANGED
package/dist/fn/upload.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { objectToFormData } from './objectToFormData';
|
|
2
2
|
import { log } from './log';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const upload = function (url, file, success, failure, progress) {
|
|
4
|
+
let fn = () => {
|
|
5
5
|
return axios.post(url || bbn.env.path, objectToFormData(file), {
|
|
6
6
|
headers: {
|
|
7
7
|
'Content-Type': 'multipart/form-data',
|
|
8
8
|
},
|
|
9
|
-
onUploadProgress
|
|
9
|
+
onUploadProgress(progressEvent) {
|
|
10
10
|
if (progress) {
|
|
11
|
-
|
|
11
|
+
let percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
|
12
12
|
progress(percentCompleted, progressEvent.loaded, progressEvent.total);
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -19,13 +19,13 @@ var upload = function (url, file, success, failure, progress) {
|
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
return fn()
|
|
22
|
-
.then(
|
|
22
|
+
.then((res) => {
|
|
23
23
|
if (success) {
|
|
24
24
|
log('SUCCESS', res);
|
|
25
25
|
success(res);
|
|
26
26
|
}
|
|
27
27
|
})
|
|
28
|
-
.catch(
|
|
28
|
+
.catch((err) => {
|
|
29
29
|
if (failure) {
|
|
30
30
|
log('ERROR', err);
|
|
31
31
|
failure(err);
|
package/dist/fn/warning.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { log } from './log';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const warning = function (message) {
|
|
3
|
+
const args = ['BBN: ' + message];
|
|
4
|
+
const obj = {
|
|
5
5
|
_bbn_console_mode: 'warn',
|
|
6
6
|
_bbn_console_level: 2,
|
|
7
7
|
_bbn_console_style: 'color: #E64141; background: #F7E195; font-size: 14px',
|