@bbn/bbn 1.0.117 → 1.0.119
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/$.js +1 -1
- package/dist/_.js +11 -7
- package/dist/bundle-webpack.js +77 -0
- package/dist/bundle-webpack.js.map +1 -0
- package/dist/bundle.js +13374 -9875
- package/dist/bundle.js.map +1 -0
- package/dist/db.js +82 -81
- package/dist/env.js +1 -1
- package/dist/fn/ajax/_addLoader.js +6 -6
- package/dist/fn/ajax/_deleteLoader.js +16 -14
- package/dist/fn/ajax/abort.js +3 -3
- package/dist/fn/ajax/abortURL.js +4 -4
- package/dist/fn/ajax/ajax.js +36 -31
- package/dist/fn/ajax/callback.js +14 -10
- package/dist/fn/ajax/download.js +15 -13
- package/dist/fn/ajax/downloadContent.js +10 -9
- package/dist/fn/ajax/getLoader.js +3 -3
- package/dist/fn/ajax/getRequestId.js +5 -5
- package/dist/fn/ajax/link.js +20 -16
- package/dist/fn/ajax/post.js +10 -6
- package/dist/fn/ajax/postOut.js +7 -5
- package/dist/fn/ajax/setNavigationVars.js +11 -9
- package/dist/fn/ajax/treatAjaxArguments.js +8 -8
- package/dist/fn/ajax/upload.js +11 -8
- package/dist/fn/browser/copy.js +10 -8
- package/dist/fn/browser/eraseCookie.js +1 -1
- package/dist/fn/browser/error.js +4 -4
- package/dist/fn/browser/getBrowserName.js +2 -2
- package/dist/fn/browser/getBrowserVersion.js +2 -2
- package/dist/fn/browser/getCookie.js +6 -6
- package/dist/fn/browser/getDeviceType.js +2 -2
- package/dist/fn/browser/getEventData.js +33 -33
- package/dist/fn/browser/happy.js +6 -2
- package/dist/fn/browser/history.js +1 -1
- package/dist/fn/browser/info.js +6 -2
- package/dist/fn/browser/isActiveInterface.js +3 -2
- package/dist/fn/browser/isDesktopDevice.js +2 -2
- package/dist/fn/browser/isFocused.js +2 -1
- package/dist/fn/browser/isMobile.js +3 -3
- package/dist/fn/browser/isMobileDevice.js +2 -2
- package/dist/fn/browser/isTabletDevice.js +2 -2
- package/dist/fn/browser/log.js +13 -9
- package/dist/fn/browser/replaceSelection.js +6 -6
- package/dist/fn/browser/selectElementText.js +5 -4
- package/dist/fn/browser/setCookie.js +4 -4
- package/dist/fn/browser/toggleFullScreen.js +2 -2
- package/dist/fn/browser/warning.js +4 -4
- package/dist/fn/convert/arrayBuffer2String.js +1 -1
- package/dist/fn/convert/canvasToImage.js +2 -2
- package/dist/fn/convert/colorToHex.js +2 -2
- package/dist/fn/convert/fromXml.js +14 -8
- package/dist/fn/convert/hex2rgb.js +1 -1
- package/dist/fn/convert/imageToCanvas.js +2 -2
- package/dist/fn/convert/imgToBase64.js +4 -3
- package/dist/fn/convert/rgb2hex.js +1 -1
- package/dist/fn/convert/string2ArrayBuffer.js +1 -1
- package/dist/fn/convert/toCSV.js +13 -10
- package/dist/fn/datetime/calendar.js +11 -10
- package/dist/fn/datetime/chrono.js +9 -9
- package/dist/fn/datetime/date.js +5 -5
- package/dist/fn/datetime/dateSQL.d.ts +1 -1
- package/dist/fn/datetime/dateSQL.js +4 -4
- package/dist/fn/datetime/daysInMonth.js +3 -3
- package/dist/fn/datetime/fdate.js +7 -6
- package/dist/fn/datetime/fdatetime.js +6 -5
- package/dist/fn/datetime/formatDate.js +1 -1
- package/dist/fn/datetime/ftime.js +5 -5
- package/dist/fn/datetime/getDay.js +5 -5
- package/dist/fn/datetime/timestamp.js +3 -2
- package/dist/fn/default/defaultAjaxAbortFunction.js +3 -2
- package/dist/fn/default/defaultAjaxErrorFunction.js +4 -2
- package/dist/fn/default/defaultAlertFunction.js +2 -1
- package/dist/fn/default/defaultConfirmFunction.js +4 -3
- package/dist/fn/default/defaultEndLoadingFunction.js +3 -1
- package/dist/fn/default/defaultErrorFunction.js +2 -2
- package/dist/fn/default/defaultHistoryFunction.js +1 -1
- package/dist/fn/default/defaultLinkFunction.js +1 -1
- package/dist/fn/default/defaultPostLinkFunction.js +2 -1
- package/dist/fn/default/defaultPreLinkFunction.js +4 -2
- package/dist/fn/default/defaultResizeFunction.js +1 -1
- package/dist/fn/default/defaultStartLoadingFunction.js +3 -1
- package/dist/fn/form/addInputs.js +13 -11
- package/dist/fn/form/fieldValue.js +2 -2
- package/dist/fn/form/formdata.js +29 -29
- package/dist/fn/form/objectToFormData.js +13 -10
- package/dist/fn/form/submit.js +5 -5
- package/dist/fn/html/adjustHeight.js +4 -4
- package/dist/fn/html/adjustSize.js +7 -7
- package/dist/fn/html/adjustWidth.js +4 -4
- package/dist/fn/html/getAllTags.js +3 -3
- package/dist/fn/html/getAncestors.js +3 -2
- package/dist/fn/html/getAttributes.js +4 -4
- package/dist/fn/html/getHTMLOfSelection.js +6 -6
- package/dist/fn/html/getHtml.js +4 -3
- package/dist/fn/html/getPath.js +24 -17
- package/dist/fn/html/getText.js +1 -1
- package/dist/fn/html/html2text.js +2 -2
- package/dist/fn/html/isInside.js +9 -9
- package/dist/fn/html/makeReactive.js +35 -31
- package/dist/fn/html/selector.js +1 -1
- package/dist/fn/init.js +28 -28
- package/dist/fn/loop/each.js +6 -6
- package/dist/fn/loop/fori.js +7 -5
- package/dist/fn/loop/forir.js +7 -5
- package/dist/fn/loop/iterate.js +7 -4
- package/dist/fn/loop/riterate.js +3 -2
- package/dist/fn/misc/analyzeFunction.js +30 -30
- package/dist/fn/misc/getTimeoff.js +1 -1
- package/dist/fn/misc/money.js +6 -6
- package/dist/fn/misc/percent.js +1 -1
- package/dist/fn/misc/randomInt.js +1 -1
- package/dist/fn/misc/roundDecimal.js +1 -1
- package/dist/fn/misc/translate.js +4 -4
- package/dist/fn/object/_compareValues.js +7 -6
- package/dist/fn/object/arrayFromProp.js +5 -5
- package/dist/fn/object/autoExtend.js +2 -2
- package/dist/fn/object/checkProps.js +3 -2
- package/dist/fn/object/checkPropsDetails.js +13 -12
- package/dist/fn/object/checkPropsOrDie.js +4 -3
- package/dist/fn/object/circularReplacer.js +6 -6
- package/dist/fn/object/clone.js +6 -6
- package/dist/fn/object/compare.js +6 -6
- package/dist/fn/object/compareConditions.js +11 -11
- package/dist/fn/object/count.js +4 -2
- package/dist/fn/object/createObject.js +17 -4
- package/dist/fn/object/deepPath.js +10 -9
- package/dist/fn/object/deleteProp.js +2 -2
- package/dist/fn/object/diffObj.js +19 -17
- package/dist/fn/object/extend.js +17 -13
- package/dist/fn/object/extendOut.js +10 -5
- package/dist/fn/object/filter.d.ts +1 -1
- package/dist/fn/object/filter.js +12 -10
- package/dist/fn/object/filterToConditions.js +10 -9
- package/dist/fn/object/findAll.js +8 -7
- package/dist/fn/object/getField.js +6 -3
- package/dist/fn/object/getFieldValues.js +6 -6
- package/dist/fn/object/getProp.js +2 -2
- package/dist/fn/object/getProperty.js +2 -2
- package/dist/fn/object/getRow.js +4 -2
- package/dist/fn/object/map.js +4 -3
- package/dist/fn/object/move.js +2 -2
- package/dist/fn/object/multiorder.js +8 -7
- package/dist/fn/object/numProperties.js +1 -1
- package/dist/fn/object/order.js +3 -2
- package/dist/fn/object/pickValue.js +1 -1
- package/dist/fn/object/removeEmpty.js +6 -6
- package/dist/fn/object/removePrivateProp.js +4 -3
- package/dist/fn/object/search.d.ts +1 -1
- package/dist/fn/object/search.js +15 -12
- package/dist/fn/object/setProp.js +3 -1
- package/dist/fn/object/setProperty.js +10 -10
- package/dist/fn/object/shortenObj.js +8 -7
- package/dist/fn/object/shuffle.js +4 -3
- package/dist/fn/object/sum.js +6 -6
- package/dist/fn/object/unique.js +1 -1
- package/dist/fn/string/baseName.js +6 -6
- package/dist/fn/string/br2nl.js +2 -2
- package/dist/fn/string/camelToCss.js +1 -1
- package/dist/fn/string/camelize.js +1 -1
- package/dist/fn/string/correctCase.js +2 -2
- package/dist/fn/string/crc32.js +8 -8
- package/dist/fn/string/dirName.js +4 -4
- package/dist/fn/string/escapeDquotes.js +2 -2
- package/dist/fn/string/escapeRegExp.js +1 -1
- package/dist/fn/string/escapeSquotes.js +2 -2
- package/dist/fn/string/escapeTicks.js +2 -2
- package/dist/fn/string/escapeUrl.js +11 -11
- package/dist/fn/string/fileExt.js +3 -3
- package/dist/fn/string/format.js +6 -6
- package/dist/fn/string/formatBytes.js +3 -2
- package/dist/fn/string/formatSize.js +3 -3
- package/dist/fn/string/hash.js +9 -9
- package/dist/fn/string/md5.js +1 -1
- package/dist/fn/string/nl2br.js +2 -2
- package/dist/fn/string/printf.js +1 -1
- package/dist/fn/string/quotes2html.js +2 -2
- package/dist/fn/string/randomString.js +7 -7
- package/dist/fn/string/removeAccents.js +3 -3
- package/dist/fn/string/removeExtraSpaces.js +1 -1
- package/dist/fn/string/removeHtmlComments.js +2 -2
- package/dist/fn/string/removeTrailingChars.js +2 -2
- package/dist/fn/string/repeat.js +1 -1
- package/dist/fn/string/replaceAll.js +4 -3
- package/dist/fn/string/sanitize.js +9 -8
- package/dist/fn/string/shorten.js +3 -3
- package/dist/fn/string/simpleHash.js +5 -5
- package/dist/fn/string/simpleHash1.js +4 -4
- package/dist/fn/string/simpleHash2.js +4 -4
- package/dist/fn/string/substr.js +4 -4
- package/dist/fn/string/trim.js +3 -2
- package/dist/fn/string/uniqString.js +17 -10
- package/dist/fn/style/addColors.js +17 -17
- package/dist/fn/style/addStyle.js +4 -4
- package/dist/fn/style/animateCss.js +4 -4
- package/dist/fn/style/center.js +2 -2
- package/dist/fn/style/cssExists.js +8 -8
- package/dist/fn/style/getCssVar.js +1 -1
- package/dist/fn/style/getScrollBarSize.js +6 -6
- package/dist/fn/style/lightenDarkenHex.js +3 -3
- package/dist/fn/style/outerHeight.js +4 -4
- package/dist/fn/style/outerWidth.js +4 -4
- package/dist/fn/style/resize.js +17 -17
- package/dist/fn/style/setCssVar.js +1 -1
- package/dist/fn/type/checkType.js +16 -12
- package/dist/fn/type/isArray.js +7 -2
- package/dist/fn/type/isBlob.js +7 -2
- package/dist/fn/type/isBoolean.js +7 -2
- package/dist/fn/type/isCanvas.js +7 -2
- package/dist/fn/type/isColor.js +8 -3
- package/dist/fn/type/isComment.js +7 -2
- package/dist/fn/type/isCp.js +9 -4
- package/dist/fn/type/isDate.js +7 -2
- package/dist/fn/type/isDimension.js +8 -3
- package/dist/fn/type/isDom.js +7 -2
- package/dist/fn/type/isEmail.js +9 -4
- package/dist/fn/type/isEmpty.js +3 -3
- package/dist/fn/type/isEvent.js +7 -2
- package/dist/fn/type/isFunction.js +7 -2
- package/dist/fn/type/isHostname.js +9 -4
- package/dist/fn/type/isIP.js +8 -3
- package/dist/fn/type/isInt.js +7 -2
- package/dist/fn/type/isIterable.js +7 -2
- package/dist/fn/type/isNull.js +7 -2
- package/dist/fn/type/isNumber.js +7 -2
- package/dist/fn/type/isObject.js +7 -2
- package/dist/fn/type/isPercent.js +7 -2
- package/dist/fn/type/isPrimitive.js +7 -2
- package/dist/fn/type/isPromise.js +7 -2
- package/dist/fn/type/isPropSize.js +4 -4
- package/dist/fn/type/isSQLDate.js +7 -2
- package/dist/fn/type/isSame.js +9 -9
- package/dist/fn/type/isString.js +7 -2
- package/dist/fn/type/isSymbol.js +7 -2
- package/dist/fn/type/isURL.js +7 -2
- package/dist/fn/type/isValidDimension.js +5 -5
- package/dist/fn/type/isValidName.js +8 -3
- package/dist/fn/type/isValue.js +8 -3
- package/dist/fn/type/isVue.js +11 -4
- package/dist/fn.d.ts +1 -1
- package/dist/fn.js +456 -456
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1241 -920
- package/dist/lng.js +1 -1
- package/dist/vars.js +1 -1
- package/package.json +8 -5
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { isArray } from
|
|
2
|
-
import { isObject } from
|
|
3
|
-
import { each } from
|
|
4
|
-
import { substr } from
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { isArray } from '../type/isArray.js';
|
|
2
|
+
import { isObject } from '../type/isObject.js';
|
|
3
|
+
import { each } from '../loop/each.js';
|
|
4
|
+
import { substr } from '../string/substr.js';
|
|
5
|
+
var checkPropsDetails = function (obj, props, checkEmpty) {
|
|
6
|
+
if (checkEmpty === void 0) { checkEmpty = false; }
|
|
7
|
+
var res = {
|
|
7
8
|
error: false,
|
|
8
9
|
result: true,
|
|
9
10
|
};
|
|
@@ -17,23 +18,23 @@ const checkPropsDetails = function (obj, props, checkEmpty = false) {
|
|
|
17
18
|
res.error = bbn._("checkProps must receive an object as obj argument");
|
|
18
19
|
}
|
|
19
20
|
if (!res.error) {
|
|
20
|
-
|
|
21
|
-
each(props, (varName)
|
|
21
|
+
var check_1;
|
|
22
|
+
each(props, function (varName) {
|
|
22
23
|
varName = varName.trim().split(":");
|
|
23
|
-
|
|
24
|
+
var type = varName[1] || false;
|
|
24
25
|
varName = varName[0];
|
|
25
26
|
if (obj[varName] === undefined) {
|
|
26
27
|
res.error = varName + " " + bbn._("is not defined");
|
|
27
28
|
}
|
|
28
29
|
else if (type) {
|
|
29
|
-
|
|
30
|
+
check_1 =
|
|
30
31
|
"is" +
|
|
31
32
|
substr(type, 0, 1).toUpperCase() +
|
|
32
33
|
substr(type, 1).toLowerCase();
|
|
33
|
-
if (bbn.fn[
|
|
34
|
+
if (bbn.fn[check_1] === undefined) {
|
|
34
35
|
res.error = type + " " + bbn._("is not a valid type");
|
|
35
36
|
}
|
|
36
|
-
else if (!bbn.fn[
|
|
37
|
+
else if (!bbn.fn[check_1](obj[varName])) {
|
|
37
38
|
res.error = varName + " " + bbn._("is not a") + " " + type;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { checkPropsDetails } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { checkPropsDetails } from './checkPropsDetails.js';
|
|
2
|
+
var checkPropsOrDie = function (obj, props, checkEmpty) {
|
|
3
|
+
if (checkEmpty === void 0) { checkEmpty = false; }
|
|
4
|
+
var res = checkPropsDetails(obj, props, checkEmpty);
|
|
4
5
|
if (res.error) {
|
|
5
6
|
throw new Error(res.error);
|
|
6
7
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { isDom } from
|
|
2
|
-
import { isCp } from
|
|
3
|
-
import { log } from
|
|
1
|
+
import { isDom } from '../type/isDom.js';
|
|
2
|
+
import { isCp } from '../type/isCp.js';
|
|
3
|
+
import { log } from '../browser/log.js';
|
|
4
4
|
/**
|
|
5
5
|
* Returns a function to give to JSON.stringify in order to avoid circular values.
|
|
6
6
|
*
|
|
7
7
|
* @returns Function
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return (key, value)
|
|
9
|
+
var circularReplacer = function () {
|
|
10
|
+
var visited = new WeakSet();
|
|
11
|
+
return function (key, value) {
|
|
12
12
|
if (typeof value === "object" && value !== null) {
|
|
13
13
|
if (visited.has(value)) {
|
|
14
14
|
return;
|
package/dist/fn/object/clone.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isArray } from
|
|
2
|
-
import { isObject } from
|
|
3
|
-
import { extend } from
|
|
1
|
+
import { isArray } from '../type/isArray.js';
|
|
2
|
+
import { isObject } from '../type/isObject.js';
|
|
3
|
+
import { extend } from './extend.js';
|
|
4
4
|
/**
|
|
5
5
|
* Creates and returns a perfect clone - but different - from the given object.
|
|
6
6
|
*
|
|
@@ -18,14 +18,14 @@ import { extend } from "./extend.js";
|
|
|
18
18
|
* @param {Object} obj The source object
|
|
19
19
|
* @returns {Object} A new object
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
var clone = function (obj) {
|
|
22
22
|
if (isArray(obj)) {
|
|
23
|
-
return obj.slice().map((a)
|
|
23
|
+
return obj.slice().map(function (a) {
|
|
24
24
|
return typeof a === "object" ? clone(a) : a;
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
if (isObject(obj)) {
|
|
28
|
-
|
|
28
|
+
var o = Object.create(Object.getPrototypeOf(obj));
|
|
29
29
|
return extend(true, o, obj);
|
|
30
30
|
}
|
|
31
31
|
return obj;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { isEmpty } from
|
|
2
|
-
import { removeAccents } from
|
|
3
|
-
import { isNull } from
|
|
4
|
-
import { isObject } from
|
|
5
|
-
import { isSame } from
|
|
1
|
+
import { isEmpty } from '../type/isEmpty.js';
|
|
2
|
+
import { removeAccents } from '../string/removeAccents.js';
|
|
3
|
+
import { isNull } from '../type/isNull.js';
|
|
4
|
+
import { isObject } from '../type/isObject.js';
|
|
5
|
+
import { isSame } from '../type/isSame.js';
|
|
6
6
|
/**
|
|
7
7
|
* Performs a comparison between two values based on the given operator and returns a boolean.
|
|
8
8
|
*
|
|
@@ -54,7 +54,7 @@ import { isSame } from "../type/isSame.js";
|
|
|
54
54
|
* @param {String} operator
|
|
55
55
|
* @returns {Boolean} True if the values' comparison complies with the operator, false otherwise
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
var compare = function (v1, v2, operator) {
|
|
58
58
|
switch (operator) {
|
|
59
59
|
case '===':
|
|
60
60
|
case '=':
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isArray } from
|
|
2
|
-
import { each } from
|
|
3
|
-
import { compare } from
|
|
4
|
-
import { getProperty } from
|
|
1
|
+
import { isArray } from '../type/isArray.js';
|
|
2
|
+
import { each } from '../loop/each.js';
|
|
3
|
+
import { compare } from './compare.js';
|
|
4
|
+
import { getProperty } from './getProperty.js';
|
|
5
5
|
/**
|
|
6
6
|
* Checks whether the given data object complies or not with the given filter.
|
|
7
7
|
*
|
|
@@ -46,23 +46,23 @@ import { getProperty } from "./getProperty.js";
|
|
|
46
46
|
* @param {Object} filter
|
|
47
47
|
* @returns {Boolean}
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
var compareConditions = function (data, filter) {
|
|
50
50
|
if (!filter.conditions || !filter.logic || !isArray(filter.conditions)) {
|
|
51
51
|
throw new Error("Error in compareConditions: the filter should an abject with conditions and logic properties and conditions should be an array of objects");
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
each(filter.conditions, (a)
|
|
55
|
-
|
|
53
|
+
var ok = filter.logic === "AND" ? true : false;
|
|
54
|
+
each(filter.conditions, function (a) {
|
|
55
|
+
var comparator;
|
|
56
56
|
if (a.conditions && isArray(a.conditions)) {
|
|
57
57
|
comparator = compareConditions(data, a);
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
60
|
comparator = compare(getProperty(data, a.field), a.value, a.operator);
|
|
61
61
|
if (comparator) {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
var bits = a.field.split(".");
|
|
63
|
+
var prop = bits.pop();
|
|
64
64
|
if (bits.length) {
|
|
65
|
-
each(bits, (b)
|
|
65
|
+
each(bits, function (b) { return (data = data[b]); });
|
|
66
66
|
}
|
|
67
67
|
// Case where both are undefined: value and prop which doesn't exist; they are not the same!
|
|
68
68
|
if (getProperty(data, prop) === undefined && a.value !== undefined) {
|
package/dist/fn/object/count.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { filter } from
|
|
1
|
+
import { filter } from './filter.js';
|
|
2
2
|
/**
|
|
3
3
|
* Counts the number of objects matching the given filter in the given array.
|
|
4
4
|
*
|
|
@@ -53,7 +53,9 @@ import { filter } from "./filter.js";
|
|
|
53
53
|
* @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
|
|
54
54
|
* @returns {Number} The number of items
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
var count = function (arr, prop, val, operator) {
|
|
57
|
+
if (val === void 0) { val = null; }
|
|
58
|
+
if (operator === void 0) { operator = '='; }
|
|
57
59
|
return filter(arr, prop, val, operator).length || 0;
|
|
58
60
|
};
|
|
59
61
|
export { count };
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
import { extend } from './extend.js';
|
|
11
|
+
var createObject = function () {
|
|
12
|
+
var args = [];
|
|
13
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
14
|
+
args[_i] = arguments[_i];
|
|
15
|
+
}
|
|
16
|
+
var obj = Object.create(null);
|
|
4
17
|
if (args.length) {
|
|
5
|
-
extend(obj,
|
|
18
|
+
extend.apply(void 0, __spreadArray([obj], args, false));
|
|
6
19
|
}
|
|
7
20
|
return obj;
|
|
8
21
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { search } from
|
|
2
|
-
import { each } from
|
|
3
|
-
import { isArray } from
|
|
1
|
+
import { search } from './search.js';
|
|
2
|
+
import { each } from '../loop/each.js';
|
|
3
|
+
import { isArray } from '../type/isArray.js';
|
|
4
4
|
/**
|
|
5
5
|
* Retrieves all elements of a hierarchical array corresponding to the filter.
|
|
6
6
|
*
|
|
@@ -56,18 +56,19 @@ import { isArray } from "../type/isArray.js";
|
|
|
56
56
|
* @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
|
|
57
57
|
* @returns {Number} The number of items
|
|
58
58
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
var deepPath = function (arr, filter, deepProperty, res) {
|
|
60
|
+
if (res === void 0) { res = []; }
|
|
61
|
+
var idx;
|
|
62
|
+
var start = 0;
|
|
62
63
|
if ((idx = search(arr, filter, start)) > -1) {
|
|
63
64
|
res.push(idx);
|
|
64
65
|
return res;
|
|
65
66
|
}
|
|
66
|
-
each(arr, (it, i)
|
|
67
|
+
each(arr, function (it, i) {
|
|
67
68
|
if (isArray(it[deepProperty])) {
|
|
68
|
-
|
|
69
|
+
var r = res.slice();
|
|
69
70
|
r.push(i);
|
|
70
|
-
|
|
71
|
+
var tmp = deepPath(it[deepProperty], filter, deepProperty, r);
|
|
71
72
|
if (tmp !== false) {
|
|
72
73
|
return tmp;
|
|
73
74
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { checkType } from
|
|
1
|
+
import { checkType } from '../type/checkType.js';
|
|
2
2
|
/**
|
|
3
3
|
* Gets the given property from the given object
|
|
4
4
|
* @param {Object} obj
|
|
5
5
|
* @param {String} prop
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
var deleteProp = function (obj, prop) {
|
|
9
9
|
checkType(obj, "object", bbn._("The obj must be an object in setProp"));
|
|
10
10
|
checkType(prop, "string", bbn._("The prop must be a string in setProp"));
|
|
11
11
|
delete obj[prop];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { isDate } from
|
|
2
|
-
import { createObject } from
|
|
3
|
-
import { isFunction } from
|
|
4
|
-
import { isValue } from
|
|
5
|
-
import { isDom } from
|
|
6
|
-
import { numProperties } from
|
|
7
|
-
|
|
1
|
+
import { isDate } from '../type/isDate.js';
|
|
2
|
+
import { createObject } from './createObject.js';
|
|
3
|
+
import { isFunction } from '../type/isFunction.js';
|
|
4
|
+
import { isValue } from '../type/isValue.js';
|
|
5
|
+
import { isDom } from '../type/isDom.js';
|
|
6
|
+
import { numProperties } from './numProperties.js';
|
|
7
|
+
var diffObjProcessed = [];
|
|
8
8
|
/**
|
|
9
9
|
* Returns an object describing the differences for transforming the first given object into the second.
|
|
10
10
|
*
|
|
@@ -82,11 +82,13 @@ let diffObjProcessed = [];
|
|
|
82
82
|
* @param {Boolean} notRoot
|
|
83
83
|
* @returns {Object}
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
var diffObj = function (obj1, obj2, unchanged, notRoot) {
|
|
86
|
+
if (unchanged === void 0) { unchanged = false; }
|
|
87
|
+
if (notRoot === void 0) { notRoot = false; }
|
|
86
88
|
if (!notRoot) {
|
|
87
89
|
diffObjProcessed = [];
|
|
88
90
|
}
|
|
89
|
-
|
|
91
|
+
var VALUE_CREATED = 'created', VALUE_UPDATED = 'updated', VALUE_DELETED = 'deleted', VALUE_UNCHANGED = 'unchanged', _compareValues = function (value1, value2) {
|
|
90
92
|
if (value1 === value2) {
|
|
91
93
|
return VALUE_UNCHANGED;
|
|
92
94
|
}
|
|
@@ -104,12 +106,12 @@ const diffObj = function (obj1, obj2, unchanged = false, notRoot = false) {
|
|
|
104
106
|
if (notRoot === undefined) {
|
|
105
107
|
notRoot = false;
|
|
106
108
|
}
|
|
107
|
-
|
|
109
|
+
var diff = createObject();
|
|
108
110
|
if (!isFunction(obj1) && !isFunction(obj2)) {
|
|
109
111
|
if (isValue(obj1) || isValue(obj2)) {
|
|
110
|
-
|
|
112
|
+
var res = _compareValues(obj1, obj2);
|
|
111
113
|
if (unchanged || res !== VALUE_UNCHANGED) {
|
|
112
|
-
|
|
114
|
+
var ret = createObject();
|
|
113
115
|
Object.defineProperty(ret, 'type', {
|
|
114
116
|
value: res,
|
|
115
117
|
enumerable: false,
|
|
@@ -140,24 +142,24 @@ const diffObj = function (obj1, obj2, unchanged = false, notRoot = false) {
|
|
|
140
142
|
return false;
|
|
141
143
|
}
|
|
142
144
|
diffObjProcessed.push(obj1, obj2);
|
|
143
|
-
for (
|
|
145
|
+
for (var key in obj1) {
|
|
144
146
|
if (isFunction(obj1[key])) {
|
|
145
147
|
continue;
|
|
146
148
|
}
|
|
147
|
-
|
|
149
|
+
var value2 = undefined;
|
|
148
150
|
if ('undefined' != typeof obj2[key]) {
|
|
149
151
|
value2 = obj2[key];
|
|
150
152
|
}
|
|
151
|
-
|
|
153
|
+
var res = diffObj(obj1[key], value2, unchanged, true);
|
|
152
154
|
if (res) {
|
|
153
155
|
diff[key] = res;
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
|
-
for (
|
|
158
|
+
for (var key in obj2) {
|
|
157
159
|
if (isFunction(obj2[key]) || 'undefined' != typeof obj1[key]) {
|
|
158
160
|
continue;
|
|
159
161
|
}
|
|
160
|
-
|
|
162
|
+
var res = diffObj(undefined, obj2[key], unchanged, true);
|
|
161
163
|
if (res) {
|
|
162
164
|
diff[key] = res;
|
|
163
165
|
}
|
package/dist/fn/object/extend.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { iterate } from
|
|
2
|
-
import { isArray } from
|
|
3
|
-
import { each } from
|
|
4
|
-
import { isObject } from
|
|
1
|
+
import { iterate } from '../loop/iterate.js';
|
|
2
|
+
import { isArray } from '../type/isArray.js';
|
|
3
|
+
import { each } from '../loop/each.js';
|
|
4
|
+
import { isObject } from '../type/isObject.js';
|
|
5
5
|
/**
|
|
6
6
|
* Merges the contents of two or more objects together into the first object.
|
|
7
7
|
*
|
|
@@ -87,10 +87,14 @@ import { isObject } from "../type/isObject.js";
|
|
|
87
87
|
* @memberof bbn.fn
|
|
88
88
|
* @returns {Object} The first object argument, merged with the other objects given
|
|
89
89
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
var extend = function () {
|
|
91
|
+
var originalArgs = [];
|
|
92
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
93
|
+
originalArgs[_i] = arguments[_i];
|
|
94
|
+
}
|
|
95
|
+
var deep = false;
|
|
96
|
+
var args = [];
|
|
97
|
+
for (var i = 0; i < originalArgs.length; i++) {
|
|
94
98
|
if (originalArgs[i] === true) {
|
|
95
99
|
deep = true;
|
|
96
100
|
}
|
|
@@ -107,15 +111,15 @@ const extend = function (...originalArgs) {
|
|
|
107
111
|
if (!args.length) {
|
|
108
112
|
throw new Error("No argument given");
|
|
109
113
|
}
|
|
110
|
-
|
|
111
|
-
for (
|
|
112
|
-
iterate(args[i], (a, key)
|
|
114
|
+
var out = args[0];
|
|
115
|
+
for (var i = 1; i < args.length; i++) {
|
|
116
|
+
iterate(args[i], function (a, key) {
|
|
113
117
|
if (deep) {
|
|
114
118
|
if (isArray(a)) {
|
|
115
119
|
out[key] = isArray(out[key]) ? out[key] : [];
|
|
116
|
-
each(a, (b, i)
|
|
120
|
+
each(a, function (b, i) {
|
|
117
121
|
if (b && typeof b === "object") {
|
|
118
|
-
|
|
122
|
+
var tmp = out[key][i];
|
|
119
123
|
if (isArray(b)) {
|
|
120
124
|
if (!isArray(tmp)) {
|
|
121
125
|
tmp = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isObject } from
|
|
1
|
+
import { isObject } from '../type/isObject.js';
|
|
2
2
|
/**
|
|
3
3
|
* Returns a new object made of the properties from all the given objects.
|
|
4
4
|
*
|
|
@@ -15,9 +15,14 @@ import { isObject } from "../type/isObject.js";
|
|
|
15
15
|
* @memberof bbn.fn
|
|
16
16
|
* @returns {Object}
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for (
|
|
18
|
+
var extendOut = function () {
|
|
19
|
+
var args = [];
|
|
20
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
21
|
+
args[_i] = arguments[_i];
|
|
22
|
+
}
|
|
23
|
+
var r = null;
|
|
24
|
+
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
|
25
|
+
var a = args_1[_a];
|
|
21
26
|
if (!isObject(a)) {
|
|
22
27
|
throw new Error("Each argument for extendOut must be an object, " + typeof a + " given");
|
|
23
28
|
}
|
|
@@ -25,7 +30,7 @@ const extendOut = function (...args) {
|
|
|
25
30
|
r = a;
|
|
26
31
|
}
|
|
27
32
|
else {
|
|
28
|
-
for (
|
|
33
|
+
for (var n in a) {
|
|
29
34
|
if (isObject(r[n], a[n])) {
|
|
30
35
|
extendOut(r[n], a[n]);
|
|
31
36
|
}
|
package/dist/fn/object/filter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isArray } from
|
|
2
|
-
import { each } from
|
|
3
|
-
import { filterToConditions } from
|
|
4
|
-
import { compareConditions } from
|
|
1
|
+
import { isArray } from '../type/isArray.js';
|
|
2
|
+
import { each } from '../loop/each.js';
|
|
3
|
+
import { filterToConditions } from './filterToConditions.js';
|
|
4
|
+
import { compareConditions } from './compareConditions.js';
|
|
5
5
|
/**
|
|
6
6
|
* Returns a new array with only the data matching the given filter.
|
|
7
7
|
*
|
|
@@ -49,14 +49,16 @@ import { compareConditions } from "./compareConditions.js";
|
|
|
49
49
|
* @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
|
|
50
50
|
* @returns {Array} A new filtered array
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
var filter = function (arr, prop, val, operator) {
|
|
53
|
+
if (val === void 0) { val = null; }
|
|
54
|
+
if (operator === void 0) { operator = '='; }
|
|
53
55
|
if (!isArray(arr)) {
|
|
54
56
|
bbn.fn.log("NOT ARRAY", arr);
|
|
55
57
|
throw new Error('Error in filter: The first argument must be an array');
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
var cfg = {};
|
|
60
|
+
var res = [];
|
|
61
|
+
var isFn = typeof (prop) === 'function';
|
|
60
62
|
if (!prop || !arr.length) {
|
|
61
63
|
return arr;
|
|
62
64
|
}
|
|
@@ -72,7 +74,7 @@ const filter = function (arr, prop, val = null, operator = '=') {
|
|
|
72
74
|
throw new Error('Search function error: The prop argument should be a string or an object');
|
|
73
75
|
}
|
|
74
76
|
if (typeof (prop) === 'function') {
|
|
75
|
-
each(arr, (a, i)
|
|
77
|
+
each(arr, function (a, i) {
|
|
76
78
|
if (prop(a, i)) {
|
|
77
79
|
res.push(a);
|
|
78
80
|
}
|
|
@@ -81,7 +83,7 @@ const filter = function (arr, prop, val = null, operator = '=') {
|
|
|
81
83
|
else {
|
|
82
84
|
cfg = filterToConditions(cfg, operator);
|
|
83
85
|
if (cfg.conditions && cfg.logic) {
|
|
84
|
-
each(arr, (a)
|
|
86
|
+
each(arr, function (a) {
|
|
85
87
|
if (compareConditions(a, cfg)) {
|
|
86
88
|
res.push(a);
|
|
87
89
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isObject } from
|
|
2
|
-
import { isArray } from
|
|
3
|
-
import { iterate } from
|
|
1
|
+
import { isObject } from '../type/isObject.js';
|
|
2
|
+
import { isArray } from '../type/isArray.js';
|
|
3
|
+
import { iterate } from '../loop/iterate.js';
|
|
4
4
|
/**
|
|
5
5
|
* Converts the given object 'filter' to a valid format of condition.
|
|
6
6
|
*
|
|
@@ -38,18 +38,19 @@ import { iterate } from "../loop/iterate.js";
|
|
|
38
38
|
* @param {String} operator
|
|
39
39
|
* @returns {Object}
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
var filterToConditions = function (filter, operator) {
|
|
42
|
+
if (operator === void 0) { operator = "="; }
|
|
42
43
|
if (!isObject(filter)) {
|
|
43
44
|
throw new Error("Error in filterToCondition: filter must be an object");
|
|
44
45
|
}
|
|
45
46
|
if (!filter.conditions || !isArray(filter.conditions)) {
|
|
46
|
-
|
|
47
|
-
iterate(filter, (a, n)
|
|
47
|
+
var tmp_1 = [];
|
|
48
|
+
iterate(filter, function (a, n) {
|
|
48
49
|
if (isObject(a) && typeof a.conditions === "object") {
|
|
49
|
-
|
|
50
|
+
tmp_1.push(filterToConditions(a));
|
|
50
51
|
}
|
|
51
52
|
else {
|
|
52
|
-
|
|
53
|
+
tmp_1.push({
|
|
53
54
|
field: n,
|
|
54
55
|
operator: operator,
|
|
55
56
|
value: a,
|
|
@@ -57,7 +58,7 @@ const filterToConditions = function (filter, operator = "=") {
|
|
|
57
58
|
}
|
|
58
59
|
});
|
|
59
60
|
filter = {
|
|
60
|
-
conditions:
|
|
61
|
+
conditions: tmp_1,
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
if (!filter.logic) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { search } from
|
|
2
|
-
import { each } from
|
|
3
|
-
import { isArray } from
|
|
1
|
+
import { search } from './search.js';
|
|
2
|
+
import { each } from '../loop/each.js';
|
|
3
|
+
import { isArray } from '../type/isArray.js';
|
|
4
4
|
/**
|
|
5
5
|
* Retrieves all elements of a hierarchical array corresponding to the filter.
|
|
6
6
|
*
|
|
@@ -56,14 +56,15 @@ import { isArray } from "../type/isArray.js";
|
|
|
56
56
|
* @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
|
|
57
57
|
* @returns {Number} The number of items
|
|
58
58
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
var findAll = function (arr, filter, deepProperty, res) {
|
|
60
|
+
if (res === void 0) { res = []; }
|
|
61
|
+
var idx;
|
|
62
|
+
var start = 0;
|
|
62
63
|
while ((idx = search(arr, filter, start)) > -1) {
|
|
63
64
|
res.push(arr[idx]);
|
|
64
65
|
start = idx + 1;
|
|
65
66
|
}
|
|
66
|
-
each(arr, (it)
|
|
67
|
+
each(arr, function (it) {
|
|
67
68
|
if (isArray(it[deepProperty])) {
|
|
68
69
|
findAll(it[deepProperty], filter, deepProperty, res);
|
|
69
70
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRow } from
|
|
1
|
+
import { getRow } from './getRow.js';
|
|
2
2
|
/**
|
|
3
3
|
* Returns the value of the given field (property) from the first object matching the given filter in an array of objects.
|
|
4
4
|
*
|
|
@@ -27,8 +27,11 @@ import { getRow } from "./getRow.js";
|
|
|
27
27
|
* @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
|
|
28
28
|
* @returns {*}
|
|
29
29
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
var getField = function (arr, field, prop, val, operator) {
|
|
31
|
+
if (prop === void 0) { prop = ''; }
|
|
32
|
+
if (val === void 0) { val = null; }
|
|
33
|
+
if (operator === void 0) { operator = '='; }
|
|
34
|
+
var r;
|
|
32
35
|
if (field && (r = getRow(arr, prop, val, operator))) {
|
|
33
36
|
return r[field];
|
|
34
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { checkType } from
|
|
2
|
-
import { filter } from
|
|
3
|
-
import { each } from
|
|
1
|
+
import { checkType } from '../type/checkType.js';
|
|
2
|
+
import { filter } from './filter.js';
|
|
3
|
+
import { each } from '../loop/each.js';
|
|
4
4
|
/**
|
|
5
5
|
* Returns all the unique values of the given field (property) from the first object matching the given filter in an array.
|
|
6
6
|
*
|
|
@@ -29,13 +29,13 @@ import { each } from "../loop/each.js";
|
|
|
29
29
|
* @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
|
|
30
30
|
* @returns {*}
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
var getFieldValues = function (arr, field, prop, val, operator) {
|
|
33
33
|
checkType(field, 'string');
|
|
34
34
|
if (prop) {
|
|
35
35
|
arr = filter(arr, prop, val, operator);
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
each(arr, (a)
|
|
37
|
+
var res = [];
|
|
38
|
+
each(arr, function (a) { return (res.indexOf(a[field]) === -1 ? res.push(a[field]) : null); });
|
|
39
39
|
return res;
|
|
40
40
|
};
|
|
41
41
|
export { getFieldValues };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { checkType } from
|
|
1
|
+
import { checkType } from '../type/checkType.js';
|
|
2
2
|
/**
|
|
3
3
|
* Gets the given property from the given object
|
|
4
4
|
* @param {Object} obj
|
|
5
5
|
* @param {String} prop
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
var getProp = function (obj, prop) {
|
|
9
9
|
checkType(obj, "object", bbn._("The obj must be an object in setProp"));
|
|
10
10
|
checkType(prop, "string", bbn._("The prop must be a string in setProp"));
|
|
11
11
|
return obj[prop];
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
* @param {String} prop
|
|
27
27
|
* @returns {*} The property's value or undefined
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
var getProperty = function (obj, prop) {
|
|
30
30
|
if (typeof obj === 'object' && typeof prop === 'string') {
|
|
31
|
-
return prop.split('.').reduce((o, i)
|
|
31
|
+
return prop.split('.').reduce(function (o, i) {
|
|
32
32
|
if (o) {
|
|
33
33
|
return o[i];
|
|
34
34
|
}
|