@bbn/bbn 1.0.25 → 1.0.26

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.
Files changed (276) hide show
  1. package/dist/bundle.d.ts +224 -238
  2. package/dist/bundle.js +939 -906
  3. package/dist/fn/_addLoader.js +1 -1
  4. package/dist/fn/_deleteLoader.d.ts +1 -1
  5. package/dist/fn/_deleteLoader.js +2 -2
  6. package/dist/fn/abort.js +4 -4
  7. package/dist/fn/abortURL.js +2 -2
  8. package/dist/fn/addColors.d.ts +1 -1
  9. package/dist/fn/addColors.js +23 -6
  10. package/dist/fn/addInputs.d.ts +1 -2
  11. package/dist/fn/addInputs.js +4 -5
  12. package/dist/fn/adjustHeight.js +1 -1
  13. package/dist/fn/adjustSize.js +1 -1
  14. package/dist/fn/adjustWidth.js +1 -1
  15. package/dist/fn/ajax.d.ts +1 -1
  16. package/dist/fn/ajax.js +8 -7
  17. package/dist/fn/analyzeFunction.js +5 -5
  18. package/dist/fn/animateCss.js +8 -7
  19. package/dist/fn/baseName.d.ts +1 -1
  20. package/dist/fn/baseName.js +1 -1
  21. package/dist/fn/br2nl.d.ts +1 -1
  22. package/dist/fn/br2nl.js +1 -1
  23. package/dist/fn/calendar.js +1 -1
  24. package/dist/fn/callback.d.ts +1 -1
  25. package/dist/fn/callback.js +5 -5
  26. package/dist/fn/camelToCss.js +4 -2
  27. package/dist/fn/canvasToImage.js +1 -1
  28. package/dist/fn/center.js +3 -5
  29. package/dist/fn/checkProps.d.ts +1 -1
  30. package/dist/fn/checkProps.js +1 -1
  31. package/dist/fn/checkPropsDetails.d.ts +1 -4
  32. package/dist/fn/checkPropsDetails.js +10 -11
  33. package/dist/fn/checkPropsOrDie.d.ts +1 -1
  34. package/dist/fn/checkPropsOrDie.js +1 -1
  35. package/dist/fn/checkType.d.ts +1 -1
  36. package/dist/fn/checkType.js +3 -3
  37. package/dist/fn/chrono.d.ts +3 -0
  38. package/dist/fn/chrono.js +23 -0
  39. package/dist/fn/circularReplacer.js +2 -2
  40. package/dist/fn/clone.d.ts +0 -1
  41. package/dist/fn/clone.js +1 -1
  42. package/dist/fn/colorToHex.js +1 -1
  43. package/dist/fn/compare.js +44 -44
  44. package/dist/fn/compareConditions.d.ts +0 -1
  45. package/dist/fn/compareConditions.js +3 -3
  46. package/dist/fn/copy.js +9 -9
  47. package/dist/fn/correctCase.js +1 -1
  48. package/dist/fn/count.d.ts +1 -1
  49. package/dist/fn/count.js +2 -2
  50. package/dist/fn/crc32.js +11 -3
  51. package/dist/fn/createObject.d.ts +1 -1
  52. package/dist/fn/createObject.js +3 -3
  53. package/dist/fn/cssExists.js +7 -4
  54. package/dist/fn/date.js +5 -5
  55. package/dist/fn/dateSQL.js +4 -3
  56. package/dist/fn/deepPath.d.ts +1 -2
  57. package/dist/fn/defaultAjaxAbortFunction.d.ts +1 -1
  58. package/dist/fn/defaultAjaxAbortFunction.js +1 -1
  59. package/dist/fn/defaultAjaxErrorFunction.d.ts +1 -1
  60. package/dist/fn/defaultAjaxErrorFunction.js +0 -12
  61. package/dist/fn/defaultAlertFunction.d.ts +1 -1
  62. package/dist/fn/defaultAlertFunction.js +2 -3
  63. package/dist/fn/defaultConfirmFunction.d.ts +1 -1
  64. package/dist/fn/defaultEndLoadingFunction.d.ts +1 -1
  65. package/dist/fn/defaultEndLoadingFunction.js +1 -17
  66. package/dist/fn/defaultPostLinkFunction.d.ts +1 -1
  67. package/dist/fn/defaultPostLinkFunction.js +1 -1
  68. package/dist/fn/defaultPreLinkFunction.d.ts +1 -1
  69. package/dist/fn/defaultPreLinkFunction.js +2 -10
  70. package/dist/fn/defaultStartLoadingFunction.d.ts +1 -1
  71. package/dist/fn/defaultStartLoadingFunction.js +2 -13
  72. package/dist/fn/deleteProp.d.ts +1 -1
  73. package/dist/fn/deleteProp.js +3 -2
  74. package/dist/fn/diffObj.d.ts +1 -2
  75. package/dist/fn/diffObj.js +13 -14
  76. package/dist/fn/dirName.d.ts +1 -1
  77. package/dist/fn/download.d.ts +1 -1
  78. package/dist/fn/download.js +3 -5
  79. package/dist/fn/downloadContent.d.ts +1 -1
  80. package/dist/fn/each.js +1 -1
  81. package/dist/fn/error.js +2 -2
  82. package/dist/fn/escapeRegExp.js +1 -1
  83. package/dist/fn/escapeTicks.js +1 -1
  84. package/dist/fn/escapeUrl.js +1 -1
  85. package/dist/fn/extend.d.ts +1 -2
  86. package/dist/fn/extend.js +11 -11
  87. package/dist/fn/extendOut.d.ts +1 -2
  88. package/dist/fn/extendOut.js +3 -3
  89. package/dist/fn/fdate.d.ts +1 -1
  90. package/dist/fn/fdatetime.d.ts +1 -1
  91. package/dist/fn/fdatetime.js +1 -1
  92. package/dist/fn/fieldValue.js +2 -2
  93. package/dist/fn/fileExt.js +1 -1
  94. package/dist/fn/filter.d.ts +1 -2
  95. package/dist/fn/filter.js +13 -12
  96. package/dist/fn/filterToConditions.d.ts +11 -3
  97. package/dist/fn/filterToConditions.js +6 -6
  98. package/dist/fn/findAll.d.ts +0 -1
  99. package/dist/fn/findAll.js +1 -1
  100. package/dist/fn/fori.d.ts +1 -1
  101. package/dist/fn/fori.js +2 -2
  102. package/dist/fn/forir.d.ts +1 -1
  103. package/dist/fn/forir.js +2 -2
  104. package/dist/fn/formdata.d.ts +1 -1
  105. package/dist/fn/formdata.js +12 -13
  106. package/dist/fn/fromXml.js +6 -6
  107. package/dist/fn/ftime.js +1 -1
  108. package/dist/fn/getAllTags.d.ts +1 -1
  109. package/dist/fn/getAllTags.js +1 -1
  110. package/dist/fn/getAncestors.d.ts +1 -1
  111. package/dist/fn/getAncestors.js +7 -8
  112. package/dist/fn/getAttributes.js +2 -2
  113. package/dist/fn/getBrowserName.js +9 -9
  114. package/dist/fn/getBrowserVersion.js +2 -2
  115. package/dist/fn/getCookie.js +1 -1
  116. package/dist/fn/getDeviceType.js +3 -3
  117. package/dist/fn/getEventData.js +11 -8
  118. package/dist/fn/getField.d.ts +1 -1
  119. package/dist/fn/getField.js +4 -3
  120. package/dist/fn/getFieldValues.d.ts +1 -1
  121. package/dist/fn/getFieldValues.js +2 -2
  122. package/dist/fn/getHTMLOfSelection.d.ts +1 -1
  123. package/dist/fn/getHTMLOfSelection.js +9 -19
  124. package/dist/fn/getLoader.d.ts +1 -1
  125. package/dist/fn/getPath.d.ts +1 -1
  126. package/dist/fn/getPath.js +4 -4
  127. package/dist/fn/getProp.js +3 -2
  128. package/dist/fn/getProperty.js +1 -1
  129. package/dist/fn/getRow.d.ts +1 -1
  130. package/dist/fn/getRow.js +1 -1
  131. package/dist/fn/getScrollBarSize.js +9 -7
  132. package/dist/fn/getText.d.ts +1 -1
  133. package/dist/fn/getTimeoff.js +1 -1
  134. package/dist/fn/happy.js +1 -1
  135. package/dist/fn/hash.d.ts +1 -1
  136. package/dist/fn/hash.js +1 -1
  137. package/dist/fn/hex2rgb.js +7 -5
  138. package/dist/fn/html2text.d.ts +1 -1
  139. package/dist/fn/imageToCanvas.js +2 -2
  140. package/dist/fn/imgToBase64.d.ts +1 -1
  141. package/dist/fn/imgToBase64.js +3 -3
  142. package/dist/fn/info.js +1 -1
  143. package/dist/fn/init.js +29 -29
  144. package/dist/fn/isActiveInterface.js +2 -2
  145. package/dist/fn/isColor.d.ts +1 -1
  146. package/dist/fn/isColor.js +11 -4
  147. package/dist/fn/isCp.js +7 -7
  148. package/dist/fn/isDimension.d.ts +1 -1
  149. package/dist/fn/isDimension.js +11 -4
  150. package/dist/fn/isEmail.d.ts +1 -1
  151. package/dist/fn/isEmail.js +11 -4
  152. package/dist/fn/isEmpty.js +1 -1
  153. package/dist/fn/isFocused.d.ts +1 -1
  154. package/dist/fn/isFocused.js +1 -1
  155. package/dist/fn/isHostname.js +1 -1
  156. package/dist/fn/isIP.js +1 -1
  157. package/dist/fn/isInside.js +1 -1
  158. package/dist/fn/isIterable.js +1 -1
  159. package/dist/fn/isNumber.js +1 -1
  160. package/dist/fn/isPercent.js +1 -1
  161. package/dist/fn/isPrimitive.js +1 -1
  162. package/dist/fn/isPropSize.js +1 -1
  163. package/dist/fn/isSQLDate.js +1 -1
  164. package/dist/fn/isSame.d.ts +1 -2
  165. package/dist/fn/isSame.js +3 -3
  166. package/dist/fn/isURL.js +1 -1
  167. package/dist/fn/isValidDimension.js +2 -3
  168. package/dist/fn/isValue.js +1 -1
  169. package/dist/fn/isVue.d.ts +1 -1
  170. package/dist/fn/isVue.js +5 -5
  171. package/dist/fn/iterate.d.ts +1 -1
  172. package/dist/fn/iterate.js +3 -3
  173. package/dist/fn/lightenDarkenHex.js +2 -2
  174. package/dist/fn/link.d.ts +1 -2
  175. package/dist/fn/link.js +17 -19
  176. package/dist/fn/log.js +4 -4
  177. package/dist/fn/makeReactive.d.ts +0 -1
  178. package/dist/fn/makeReactive.js +35 -23
  179. package/dist/fn/map.d.ts +0 -1
  180. package/dist/fn/md5.js +30 -10
  181. package/dist/fn/money.d.ts +1 -1
  182. package/dist/fn/money.js +47 -34
  183. package/dist/fn/move.d.ts +1 -1
  184. package/dist/fn/move.js +1 -1
  185. package/dist/fn/multiorder.d.ts +1 -1
  186. package/dist/fn/multiorder.js +5 -5
  187. package/dist/fn/nl2br.d.ts +1 -1
  188. package/dist/fn/nl2br.js +1 -1
  189. package/dist/fn/numProperties.d.ts +1 -1
  190. package/dist/fn/numProperties.js +1 -1
  191. package/dist/fn/objectToFormData.d.ts +1 -1
  192. package/dist/fn/objectToFormData.js +3 -3
  193. package/dist/fn/outerHeight.d.ts +1 -1
  194. package/dist/fn/outerHeight.js +5 -4
  195. package/dist/fn/outerWidth.d.ts +1 -1
  196. package/dist/fn/outerWidth.js +1 -2
  197. package/dist/fn/pickValue.d.ts +1 -1
  198. package/dist/fn/post.d.ts +1 -1
  199. package/dist/fn/post.js +3 -3
  200. package/dist/fn/postOut.d.ts +1 -1
  201. package/dist/fn/postOut.js +2 -2
  202. package/dist/fn/printf.js +1 -3
  203. package/dist/fn/quotes2html.d.ts +1 -1
  204. package/dist/fn/quotes2html.js +3 -3
  205. package/dist/fn/randomInt.d.ts +1 -1
  206. package/dist/fn/randomString.d.ts +1 -1
  207. package/dist/fn/randomString.js +9 -8
  208. package/dist/fn/removeAccents.d.ts +1 -1
  209. package/dist/fn/removeAccents.js +1 -1
  210. package/dist/fn/removeEmpty.d.ts +1 -1
  211. package/dist/fn/removeExtraSpaces.d.ts +1 -1
  212. package/dist/fn/removeHtmlComments.d.ts +1 -1
  213. package/dist/fn/removePrivateProp.d.ts +1 -2
  214. package/dist/fn/removePrivateProp.js +6 -6
  215. package/dist/fn/removeTrailingChars.d.ts +1 -1
  216. package/dist/fn/repeat.d.ts +1 -1
  217. package/dist/fn/repeat.js +1 -6
  218. package/dist/fn/replaceAll.d.ts +1 -1
  219. package/dist/fn/replaceAll.js +1 -4
  220. package/dist/fn/replaceSelection.js +1 -1
  221. package/dist/fn/resize.js +9 -7
  222. package/dist/fn/rgb2hex.js +6 -4
  223. package/dist/fn/riterate.d.ts +1 -1
  224. package/dist/fn/roundDecimal.d.ts +1 -1
  225. package/dist/fn/roundDecimal.js +1 -1
  226. package/dist/fn/sanitize.js +3 -1
  227. package/dist/fn/search.d.ts +2 -1
  228. package/dist/fn/search.js +24 -21
  229. package/dist/fn/selectElementText.d.ts +1 -1
  230. package/dist/fn/selectElementText.js +1 -1
  231. package/dist/fn/selector.d.ts +1 -1
  232. package/dist/fn/selector.js +1 -1
  233. package/dist/fn/setCookie.js +4 -4
  234. package/dist/fn/setCssVar.js +2 -1
  235. package/dist/fn/setNavigationVars.d.ts +1 -1
  236. package/dist/fn/setNavigationVars.js +6 -5
  237. package/dist/fn/setProp.d.ts +1 -1
  238. package/dist/fn/setProp.js +1 -3
  239. package/dist/fn/setProperty.d.ts +1 -1
  240. package/dist/fn/setProperty.js +2 -2
  241. package/dist/fn/shorten.d.ts +1 -1
  242. package/dist/fn/shorten.js +3 -3
  243. package/dist/fn/shortenObj.d.ts +1 -2
  244. package/dist/fn/shortenObj.js +2 -2
  245. package/dist/fn/shuffle.d.ts +1 -1
  246. package/dist/fn/shuffle.js +1 -3
  247. package/dist/fn/simpleHash.d.ts +1 -1
  248. package/dist/fn/simpleHash1.d.ts +1 -1
  249. package/dist/fn/simpleHash1.js +1 -1
  250. package/dist/fn/simpleHash2.d.ts +1 -1
  251. package/dist/fn/stat.d.ts +1 -1
  252. package/dist/fn/stat.js +8 -8
  253. package/dist/fn/string2ArrayBuffer.d.ts +1 -1
  254. package/dist/fn/submit.d.ts +1 -1
  255. package/dist/fn/submit.js +6 -21
  256. package/dist/fn/substr.d.ts +1 -1
  257. package/dist/fn/substr.js +1 -1
  258. package/dist/fn/sum.d.ts +1 -1
  259. package/dist/fn/sum.js +2 -3
  260. package/dist/fn/timestamp.d.ts +1 -1
  261. package/dist/fn/timestamp.js +1 -1
  262. package/dist/fn/toCSV.d.ts +1 -1
  263. package/dist/fn/toCSV.js +1 -1
  264. package/dist/fn/toggleFullScreen.js +13 -13
  265. package/dist/fn/translate.d.ts +1 -1
  266. package/dist/fn/treatAjaxArguments.d.ts +1 -1
  267. package/dist/fn/treatAjaxArguments.js +16 -14
  268. package/dist/fn/uniqString.js +3 -3
  269. package/dist/fn/unique.d.ts +1 -1
  270. package/dist/fn/upload.d.ts +1 -1
  271. package/dist/fn/upload.js +6 -6
  272. package/dist/fn/warning.d.ts +1 -1
  273. package/dist/fn/warning.js +6 -6
  274. package/dist/index.d.ts +106 -108
  275. package/dist/index.js +5 -6
  276. package/package.json +3 -1
package/dist/fn/search.js CHANGED
@@ -1,28 +1,31 @@
1
1
  import { isIterable } from './isIterable';
2
- import { isString } from './isString';
3
2
  import { compareConditions } from './compareConditions';
4
3
  import { filterToConditions } from './filterToConditions';
5
4
  import { isObject } from './isObject';
6
5
  import { numProperties } from './numProperties';
7
6
  import { isNumber } from './isNumber';
8
- const search = function (arr, prop, val, operator, startFrom) {
7
+ const search = function (arr, prop, val = null, operator = '=', startFrom = 0) {
9
8
  if (!isIterable(arr)) {
10
- throw new Error(bbn._("The first argument for a search should be iterable") + " " + (typeof arr) + " " + bbn._("given"));
9
+ throw new Error(bbn._('The first argument for a search should be iterable') + ' ' + typeof arr + ' ' + bbn._('given'));
11
10
  }
12
11
  if (!arr.length) {
13
12
  return -1;
14
13
  }
15
- let filter = {};
16
- let isFunction = false;
17
- if (isString(prop)) {
18
- filter.conditions = [{
19
- field: prop,
20
- value: val,
21
- operator: operator || '='
22
- }];
14
+ let filter;
15
+ let isFn = false;
16
+ if (typeof prop === 'string') {
17
+ filter = {
18
+ conditions: [
19
+ {
20
+ field: prop,
21
+ value: val,
22
+ operator: operator || '=',
23
+ },
24
+ ]
25
+ };
23
26
  }
24
27
  else if (!prop) {
25
- isFunction = true;
28
+ isFn = true;
26
29
  filter = a => {
27
30
  return compareConditions({ value: a }, filterToConditions({
28
31
  logic: 'AND',
@@ -30,32 +33,32 @@ const search = function (arr, prop, val, operator, startFrom) {
30
33
  {
31
34
  field: 'value',
32
35
  operator: operator || '=',
33
- value: val
34
- }
35
- ]
36
+ value: val,
37
+ },
38
+ ],
36
39
  }));
37
40
  };
38
41
  }
39
42
  else {
40
- startFrom = operator;
43
+ startFrom = typeof (operator) === 'number' ? operator : 0;
41
44
  operator = val;
42
45
  if (isObject(prop)) {
43
46
  filter = prop;
44
47
  }
45
- else if (isFunction(prop)) {
46
- isFunction = true;
48
+ else if (typeof (prop) === 'function') {
49
+ isFn = true;
47
50
  filter = prop;
48
51
  }
49
52
  }
50
- if (isFunction || (isObject(filter) && numProperties(filter))) {
53
+ if (isFn || (isObject(filter) && numProperties(filter))) {
51
54
  if (isNumber(operator)) {
52
- startFrom = operator;
55
+ startFrom = typeof (operator) === 'number' ? operator : 0;
53
56
  operator = undefined;
54
57
  }
55
58
  if (!isNumber(startFrom)) {
56
59
  startFrom = 0;
57
60
  }
58
- if (isFunction) {
61
+ if (typeof filter === 'function') {
59
62
  for (let i = startFrom; i < arr.length; i++) {
60
63
  if (filter(arr[i])) {
61
64
  return i;
@@ -1,2 +1,2 @@
1
- declare const selectElementText: (ele: any, win: any) => void;
1
+ declare const selectElementText: (ele: HTMLElement, win?: Window) => void;
2
2
  export { selectElementText };
@@ -14,7 +14,7 @@ const selectElementText = function (ele, win) {
14
14
  sel.removeAllRanges();
15
15
  sel.addRange(range);
16
16
  }
17
- else if (doc.body.createTextRange) {
17
+ else if (('createTextRange' in doc.body) && (typeof doc.body.createTextRange === 'function')) {
18
18
  range = doc.body.createTextRange();
19
19
  range.moveToElementText(ele);
20
20
  range.select();
@@ -1,2 +1,2 @@
1
- declare const selector: (ele: any) => any;
1
+ declare const selector: (ele: string | HTMLElement) => HTMLElement | undefined;
2
2
  export { selector };
@@ -1,4 +1,4 @@
1
1
  const selector = function (ele) {
2
- return (typeof el === 'string') ? document.querySelector(ele) : ele;
2
+ return typeof ele === 'string' ? document.querySelector(ele) : ele;
3
3
  };
4
4
  export { selector };
@@ -1,11 +1,11 @@
1
1
  const setCookie = function (name, value, days) {
2
- let expires = "";
2
+ let expires = '';
3
3
  if (days) {
4
4
  let date = new Date();
5
- date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
6
- expires = "; expires=" + date.toUTCString();
5
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
6
+ expires = '; expires=' + date.toUTCString();
7
7
  }
8
8
  let st = escape(JSON.stringify({ value: value }));
9
- document.cookie = name + "=" + st + expires + "; path=/";
9
+ document.cookie = name + '=' + st + expires + '; path=/';
10
10
  };
11
11
  export { setCookie };
@@ -2,6 +2,7 @@ const setCssVar = function (varname, value) {
2
2
  if (varname.indexOf('--') !== 0) {
3
3
  varname = '--' + varname;
4
4
  }
5
- document.documentElement.setProperty(varname, value);
5
+ /** @todo To Fix */
6
+ //document.documentElement.setProperty(varname, value);
6
7
  };
7
8
  export { setCssVar };
@@ -1,2 +1,2 @@
1
- declare const setNavigationVars: (url: any, title: any, data: any, repl: any) => void;
1
+ declare const setNavigationVars: (url: any, title: any, data?: object, repl?: boolean) => void;
2
2
  export { setNavigationVars };
@@ -10,7 +10,7 @@ const 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("/"), (v) => {
13
+ bbn.env.params = filter(bbn.env.path.split('/'), (v) => {
14
14
  return v !== '';
15
15
  });
16
16
  // Managing history
@@ -22,17 +22,18 @@ const setNavigationVars = function (url, title, data, repl) {
22
22
  let obj = {
23
23
  url: bbn.env.path,
24
24
  old_path: bbn.env.old_path || null,
25
- data: data || {}
25
+ data: data || {},
26
+ reload: false
26
27
  };
27
28
  // If same URL we replace
28
- if (state && (state.url === bbn.env.path)) {
29
+ if (state && state.url === bbn.env.path) {
29
30
  if (state.data) {
30
31
  extend(obj.data, state.data);
31
32
  }
32
33
  if (state.title && !title) {
33
34
  title = state.title;
34
35
  }
35
- repl = 1;
36
+ repl = true;
36
37
  }
37
38
  // If no title the global title
38
39
  if (!title) {
@@ -44,7 +45,7 @@ const setNavigationVars = function (url, title, data, repl) {
44
45
  }
45
46
  // Replacing state
46
47
  if (repl) {
47
- obj.reload = 1;
48
+ obj.reload = true;
48
49
  h.replaceState(obj, title, bbn.env.url);
49
50
  }
50
51
  // Adding state
@@ -1,2 +1,2 @@
1
- declare const setProp: (obj: any, prop: any, value: any, writable?: boolean, configurable?: boolean) => void;
1
+ declare const setProp: (obj: object, prop: string, value: any, writable?: boolean, configurable?: boolean) => void;
2
2
  export { setProp };
@@ -1,10 +1,8 @@
1
1
  const setProp = function (obj, prop, value, writable = true, configurable = true) {
2
- checkType(prop, "string", bbn._("The prop must be a string in setProp"));
3
- checkType(obj, "object", bbn._("The obj must be an object in setProp"));
4
2
  Object.defineProperty(obj, prop, {
5
3
  value: value,
6
4
  writable: writable,
7
- configurable: configurable
5
+ configurable: configurable,
8
6
  });
9
7
  };
10
8
  export { setProp };
@@ -1,2 +1,2 @@
1
- declare const setProperty: (obj: any, prop: any, value: any, force: any) => void;
1
+ declare const setProperty: (obj: object, prop: string, value: any, force?: boolean) => void;
2
2
  export { setProperty };
@@ -1,12 +1,12 @@
1
1
  import { each } from './each';
2
2
  const setProperty = function (obj, prop, value, force) {
3
- if ((typeof obj === 'object') && (typeof prop === 'string')) {
3
+ if (typeof obj === 'object' && typeof prop === 'string') {
4
4
  let o = obj;
5
5
  const bits = prop.split('.');
6
6
  each(bits, (v, i) => {
7
7
  if (!o) {
8
8
  if (!force) {
9
- throw new Error(bbn._("The object is invalid"));
9
+ throw new Error(bbn._('The object is invalid'));
10
10
  }
11
11
  o = {};
12
12
  }
@@ -1,2 +1,2 @@
1
- declare const shorten: (st: any, len: any, adj: any) => any;
1
+ declare const shorten: (st: string, len?: number, adj?: string) => string;
2
2
  export { shorten };
@@ -1,11 +1,11 @@
1
1
  import { isString } from './isString';
2
2
  import { substr } from './substr';
3
3
  const shorten = function (st, len, adj) {
4
- if (typeof (st).toLowerCase() === 'string') {
4
+ if (typeof st.toLowerCase() === 'string') {
5
5
  if (!len) {
6
- len = bbn.var.shortenLen;
6
+ len = bbn.vars.shortenLen;
7
7
  }
8
- if ((adj === undefined) || !isString(adj)) {
8
+ if (adj === undefined || !isString(adj)) {
9
9
  adj = '...';
10
10
  }
11
11
  if (st.length > len) {
@@ -1,3 +1,2 @@
1
- import { shortenObj } from './shortenObj';
2
- declare const shortenObj: (obj: any, max?: number) => any;
1
+ declare const shortenObj: (obj: any, max?: number) => object;
3
2
  export { shortenObj };
@@ -5,10 +5,10 @@ import { shorten } from './shorten';
5
5
  const shortenObj = function (obj, max = 100) {
6
6
  let o = clone(obj);
7
7
  each(o, (a, n) => {
8
- if (isString(a) && (a.length > max)) {
8
+ if (isString(a) && a.length > max) {
9
9
  o[n] = shorten(a, max);
10
10
  }
11
- else if (a && (typeof a === 'object')) {
11
+ else if (a && typeof a === 'object') {
12
12
  o[n] = shortenObj(a);
13
13
  }
14
14
  });
@@ -1,2 +1,2 @@
1
- declare const shuffle: (array: any) => any;
1
+ declare const shuffle: (array: any[]) => any[];
2
2
  export { shuffle };
@@ -6,9 +6,7 @@ const shuffle = function (array) {
6
6
  randomIndex = Math.floor(Math.random() * currentIndex);
7
7
  currentIndex--;
8
8
  // And swap it with the current element.
9
- [array[currentIndex], array[randomIndex]] = [
10
- array[randomIndex], array[currentIndex]
11
- ];
9
+ [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
12
10
  }
13
11
  return array;
14
12
  };
@@ -1,2 +1,2 @@
1
- declare const simpleHash: (str: any) => any;
1
+ declare const simpleHash: (str: any) => string;
2
2
  export { simpleHash };
@@ -1,2 +1,2 @@
1
- declare const simpleHash1: (str: any) => number;
1
+ declare const simpleHash1: (str: string) => number;
2
2
  export { simpleHash1 };
@@ -2,7 +2,7 @@ const simpleHash1 = function (str) {
2
2
  let hash = 0;
3
3
  for (let i = 0; i < str.length; i++) {
4
4
  const char = str.charCodeAt(i);
5
- hash = ((hash << 5) - hash) + char;
5
+ hash = (hash << 5) - hash + char;
6
6
  hash |= 0; // Convert to 32-bit integer
7
7
  }
8
8
  return hash;
@@ -1,2 +1,2 @@
1
- declare const simpleHash2: (str: any) => number;
1
+ declare const simpleHash2: (str: string) => number;
2
2
  export { simpleHash2 };
package/dist/fn/stat.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const stat: (returnStat: any) => any;
1
+ declare const stat: (returnStat: any) => void;
2
2
  export { stat };
package/dist/fn/stat.js CHANGED
@@ -1,18 +1,17 @@
1
- import { getPath } from './getPath';
2
1
  const stat = function (returnStat) {
3
2
  return;
3
+ /*
4
4
  if (bbn.env.logging) {
5
- var logs = bbn.var.loggers;
5
+ var logs = bbn.vars.loggers;
6
6
  for (var i = 0; i < arguments.length; i++) {
7
- var a = arguments[i], type = typeof (a);
8
- if ((type === 'boolean') || (type === 'undefined')) {
7
+ var a = arguments[i],
8
+ type = typeof a;
9
+ if (type === 'boolean' || type === 'undefined') {
9
10
  break;
10
- }
11
- else {
11
+ } else {
12
12
  if (type === 'object') {
13
13
  a = getPath(a);
14
- }
15
- else {
14
+ } else {
16
15
  a = a.toString();
17
16
  }
18
17
  if (!logs[a]) {
@@ -45,5 +44,6 @@ const stat = function (returnStat) {
45
44
  }
46
45
  return returnStat;
47
46
  }
47
+ */
48
48
  };
49
49
  export { stat };
@@ -1,2 +1,2 @@
1
- declare const string2ArrayBuffer: (str: any) => ArrayBuffer;
1
+ declare const string2ArrayBuffer: (str: string) => ArrayBuffer;
2
2
  export { string2ArrayBuffer };
@@ -1,2 +1,2 @@
1
- declare const submit: (form: any, e: any, fn: any) => void;
1
+ declare const submit: (form: HTMLFormElement, e?: Event, fn?: Function) => void;
2
2
  export { submit };
package/dist/fn/submit.js CHANGED
@@ -1,14 +1,15 @@
1
1
  import { formdata } from './formdata';
2
- import { isFunction } from './isFunction';
3
- import { isString } from './isString';
4
2
  import { post } from './post';
5
3
  const submit = function (form, e, fn) {
6
- let url = form.getAttribute("action") || bbn.env.path, data;
4
+ let url = form.getAttribute('action') || bbn.env.path;
5
+ let data;
7
6
  if (url === '') {
8
7
  url = '.';
9
8
  }
10
9
  //if ( (typeof(url) === 'string') && (url.indexOf("http") !== 0 || url.indexOf(window.document.location.hostname) !== -1) && !form.is("[target]") ){
11
- if ((typeof (url) === 'string') && (url.indexOf("http") !== 0 || url.indexOf(window.document.location.hostname) !== -1) && !form.getAttribute("target")) {
10
+ if (typeof url === 'string' &&
11
+ (url.indexOf('http') !== 0 || url.indexOf(window.document.location.hostname) !== -1) &&
12
+ !form.getAttribute('target')) {
12
13
  if (e) {
13
14
  e.preventDefault();
14
15
  }
@@ -17,26 +18,10 @@ const submit = function (form, e, fn) {
17
18
  //$form.attr("action", null);
18
19
  form.setAttribute('action', null);
19
20
  //$form.data("bbnSubmit", 1);
20
- form.dataset.bbnSubmit = 1;
21
- //var script = $form.data("script");
22
- let script = form.dataset.script;
23
- if (isFunction(script)) {
24
- /*$form.data("script", function(d){
25
- $form.attr("action", url);
26
- script(d);
27
- })*/
28
- form.dataset.script = d => {
29
- form.setAttribute("action", url);
30
- script(d);
31
- };
32
- }
33
21
  if (!fn) {
34
- fn = form.getAttribute("data-script");
22
+ fn = form.getAttribute('data-script') ? eval(form.getAttribute('data-script')) : null;
35
23
  }
36
24
  if (fn) {
37
- if (isString(fn)) {
38
- fn = eval(fn);
39
- }
40
25
  post(url, data, fn);
41
26
  }
42
27
  else {
@@ -1,2 +1,2 @@
1
- declare const substr: (str: any, from: any, length: any) => any;
1
+ declare const substr: (str: string, from: number, length?: number) => string;
2
2
  export { substr };
package/dist/fn/substr.js CHANGED
@@ -4,7 +4,7 @@ import { log } from './log';
4
4
  const substr = function (str, from, length) {
5
5
  if (!isString(str) || !isInt(from)) {
6
6
  log(arguments);
7
- throw new Error(bbn._("The substr function should be applied to a string and at least a `from` argument should be given"));
7
+ throw new Error(bbn._('The substr function should be applied to a string and at least a `from` argument should be given'));
8
8
  }
9
9
  if (from < 0) {
10
10
  from = str.length + from;
package/dist/fn/sum.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const sum: (arr: any, numberProp: any, prop: any, val: any, operator: any) => number;
1
+ declare const sum: (arr: object[], numberProp: string | ((a: any) => any), prop: object | string, val?: any, operator?: string) => number;
2
2
  export { sum };
package/dist/fn/sum.js CHANGED
@@ -2,11 +2,10 @@ import { each } from './each';
2
2
  import { filter } from './filter';
3
3
  const sum = function (arr, numberProp, prop, val, operator) {
4
4
  let r = 0;
5
- let isFunction = isFunction(numberProp);
6
5
  each(filter(arr, prop, val, operator), (a) => {
7
- let tmp = isFunction ? numberProp(a) : a[numberProp];
6
+ let tmp = typeof numberProp === 'function' ? numberProp(a) : a[numberProp];
8
7
  if (tmp) {
9
- r += (parseFloat(tmp) || 0);
8
+ r += parseFloat(tmp) || 0;
10
9
  }
11
10
  });
12
11
  return r;
@@ -1,2 +1,2 @@
1
- declare const timestamp: (seconds: any) => number;
1
+ declare const timestamp: (seconds?: boolean) => number;
2
2
  export { timestamp };
@@ -1,5 +1,5 @@
1
1
  const timestamp = function (seconds) {
2
- var r = (new Date()).getTime();
2
+ var r = new Date().getTime();
3
3
  return seconds ? Math.round(r / 1000) : r;
4
4
  };
5
5
  export { timestamp };
@@ -1,2 +1,2 @@
1
- declare const toCSV: (arr: any, valSep?: string, rowSep?: string, valEsc?: string) => string;
1
+ declare const toCSV: (arr: any[], valSep?: string, rowSep?: string, valEsc?: string) => string;
2
2
  export { toCSV };
package/dist/fn/toCSV.js CHANGED
@@ -32,7 +32,7 @@ const toCSV = function (arr, valSep = ',', rowSep = '', valEsc = '"') {
32
32
  }
33
33
  });
34
34
  if (i < total - 1) {
35
- csvContent += rowSep + "\n";
35
+ csvContent += rowSep + '\n';
36
36
  }
37
37
  });
38
38
  return csvContent;
@@ -1,30 +1,30 @@
1
1
  import { resize } from './resize';
2
2
  const toggleFullScreen = function () {
3
- if (window.document.documentElement.mozRequestFullScreen) {
4
- if (window.document.mozFullScreen) {
5
- window.document.mozCancelFullScreen();
3
+ if ('mozRequestFullScreen' in window.document.documentElement) {
4
+ if (window.document['mozFullScreen']) {
5
+ window.document['mozCancelFullScreen']();
6
6
  }
7
- else {
7
+ else if (typeof window.document.documentElement.mozRequestFullScreen === 'function') {
8
8
  window.document.documentElement.mozRequestFullScreen();
9
9
  }
10
10
  }
11
- else if (window.document.documentElement.webkitRequestFullScreen) {
12
- if (window.document.webkitIsFullScreen) {
13
- window.document.webkitCancelFullScreen();
11
+ else if ('webkitRequestFullScreen' in window.document.documentElement) {
12
+ if (window.document['webkitIsFullScreen']) {
13
+ window.document['webkitCancelFullScreen']();
14
14
  }
15
- else {
15
+ else if (typeof window.document.documentElement.webkitRequestFullScreen === 'function') {
16
16
  window.document.documentElement.webkitRequestFullScreen();
17
17
  }
18
18
  }
19
- else if (window.document.msRequestFullScreen) {
20
- if (window.document.msFullscreenEnabled) {
21
- window.document.msExitFullscreen();
19
+ else if ('msRequestFullScreen' in window.document.documentElement) {
20
+ if (window.document['msFullscreenEnabled']) {
21
+ window.document['msExitFullscreen']();
22
22
  }
23
- else {
23
+ else if (typeof window.document.documentElement.msRequestFullScreen === 'function') {
24
24
  window.document.documentElement.msRequestFullScreen();
25
25
  }
26
26
  }
27
- else if (window.document.requestFullscreen) {
27
+ else if ('requestFullscreen' in window.document) {
28
28
  if (window.document.fullscreenEnabled) {
29
29
  window.document.exitFullscreen();
30
30
  }
@@ -1,2 +1,2 @@
1
- declare const translate: (o: any, namespace: any) => void;
1
+ declare const translate: (o: object, namespace?: string) => void;
2
2
  export { translate };
@@ -1,2 +1,2 @@
1
- declare const treatAjaxArguments: (args: any) => any;
1
+ declare const treatAjaxArguments: (args: any) => BbnAjaxCfg;
2
2
  export { treatAjaxArguments };
@@ -3,12 +3,14 @@ import { isFunction } from './isFunction';
3
3
  import { substr } from './substr';
4
4
  import { numProperties } from './numProperties';
5
5
  const treatAjaxArguments = function (args) {
6
- let cfg = {}, t, i;
7
- if (isObject(args[0]) && (args.length === 1)) {
6
+ let cfg = {};
7
+ let t;
8
+ let i;
9
+ if (isObject(args[0]) && args.length === 1) {
8
10
  return args[0];
9
11
  }
10
12
  for (i = 0; i < args.length; i++) {
11
- t = typeof (args[i]);
13
+ t = typeof args[i];
12
14
  t = t.toLowerCase();
13
15
  /* Callbacks */
14
16
  if (isFunction(args[i])) {
@@ -22,8 +24,8 @@ const treatAjaxArguments = function (args) {
22
24
  cfg.successFn = args[i];
23
25
  }
24
26
  }
25
- /* Force */
26
- else if ((args[i] === 1) || (args[i] === true)) {
27
+ else if (args[i] === 1 || args[i] === true) {
28
+ /* Force */
27
29
  cfg.force = true;
28
30
  }
29
31
  else if (t === 'string') {
@@ -32,30 +34,30 @@ const treatAjaxArguments = function (args) {
32
34
  if (args[i].indexOf('#') === 0 || args[i].indexOf(bbn.env.root + '#') === 0) {
33
35
  cfg.url = substr(args[i], bbn.env.root.length);
34
36
  }
35
- /* Link */
36
37
  else {
38
+ /* Link */
37
39
  cfg.url = args[i];
38
40
  if (cfg.url.indexOf(bbn.env.root) === 0) {
39
41
  cfg.url = substr(cfg.url, bbn.env.root.length);
40
42
  }
41
43
  }
42
44
  }
43
- /* Ajax datatype */
44
45
  else {
46
+ /* Ajax datatype */
45
47
  cfg.datatype = args[i];
46
48
  }
47
49
  }
48
- /* Event */
49
- else if (args[i] && (t === 'object')) {
50
+ else if (args[i] && t === 'object') {
51
+ /* Event */
50
52
  if (args[i] instanceof Event) {
51
53
  cfg.e = args[i];
52
54
  }
53
- /* HTML Element */
54
- else if (!cfg.ele && (args[i].nodeType === 1)) {
55
+ else if (!cfg.ele && args[i].nodeType === 1) {
56
+ /* HTML Element */
55
57
  cfg.ele = args[i];
56
58
  }
57
- /* An object to post */
58
59
  else if (t.toLowerCase() === 'object') {
60
+ /* An object to post */
59
61
  cfg.obj = args[i];
60
62
  }
61
63
  }
@@ -64,10 +66,10 @@ const treatAjaxArguments = function (args) {
64
66
  cfg.url = bbn.env.path;
65
67
  }
66
68
  if (cfg.obj === undefined) {
67
- cfg.obj = { _bbn: "public" };
69
+ cfg.obj = { _bbn: 'public' };
68
70
  }
69
71
  if (!cfg.datatype) {
70
- cfg.datatype = "json";
72
+ cfg.datatype = 'json';
71
73
  }
72
74
  return cfg;
73
75
  };
@@ -7,7 +7,7 @@ const uniqString = function (...args) {
7
7
  if (!args[i]) {
8
8
  st += '__bbn_empty__';
9
9
  }
10
- else if (typeof (args[i]) === 'object') {
10
+ else if (typeof args[i] === 'object') {
11
11
  if (isArray(args[i])) {
12
12
  st += JSON.stringify(args[i]);
13
13
  }
@@ -15,13 +15,13 @@ const uniqString = function (...args) {
15
15
  // An object with the same properties, even in different order, should produce the same answer
16
16
  let tmp = {};
17
17
  let ks = Object.keys(args[i]).sort();
18
- each(ks, k => {
18
+ each(ks, (k) => {
19
19
  tmp[k] = args[i][k];
20
20
  });
21
21
  st += JSON.stringify(tmp);
22
22
  }
23
23
  }
24
- else if (typeof (args[i]) !== 'string') {
24
+ else if (typeof args[i] !== 'string') {
25
25
  st += args[i].toString();
26
26
  }
27
27
  else {
@@ -1,2 +1,2 @@
1
- declare const unique: (arr: any) => any;
1
+ declare const unique: (arr: any[]) => any[];
2
2
  export { unique };