@bbn/bbn 1.0.59 → 1.0.61

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 (463) hide show
  1. package/dist/_.js +1 -1
  2. package/dist/bundle.d.ts +3804 -242
  3. package/dist/bundle.js +4062 -501
  4. package/dist/db.js +3 -3
  5. package/dist/fn/ajax/_addLoader.d.ts +16 -0
  6. package/dist/fn/ajax/_addLoader.js +51 -0
  7. package/dist/fn/ajax/_deleteLoader.d.ts +16 -0
  8. package/dist/fn/ajax/_deleteLoader.js +39 -0
  9. package/dist/fn/ajax/abort.d.ts +24 -0
  10. package/dist/fn/ajax/abort.js +36 -0
  11. package/dist/fn/ajax/abortURL.d.ts +22 -0
  12. package/dist/fn/ajax/abortURL.js +33 -0
  13. package/dist/fn/ajax/ajax.d.ts +58 -0
  14. package/dist/fn/ajax/ajax.js +170 -0
  15. package/dist/fn/ajax/callback.d.ts +37 -0
  16. package/dist/fn/ajax/callback.js +117 -0
  17. package/dist/fn/ajax/download.d.ts +30 -0
  18. package/dist/fn/ajax/download.js +64 -0
  19. package/dist/fn/ajax/downloadContent.d.ts +28 -0
  20. package/dist/fn/ajax/downloadContent.js +74 -0
  21. package/dist/fn/ajax/getLoader.d.ts +37 -0
  22. package/dist/fn/ajax/getLoader.js +44 -0
  23. package/dist/fn/ajax/getRequestId.d.ts +50 -0
  24. package/dist/fn/ajax/getRequestId.js +62 -0
  25. package/dist/fn/ajax/link.d.ts +26 -0
  26. package/dist/fn/ajax/link.js +129 -0
  27. package/dist/fn/ajax/post.d.ts +35 -0
  28. package/dist/fn/ajax/post.js +45 -0
  29. package/dist/fn/ajax/postOut.d.ts +21 -0
  30. package/dist/fn/ajax/postOut.js +49 -0
  31. package/dist/fn/ajax/setNavigationVars.d.ts +25 -0
  32. package/dist/fn/ajax/setNavigationVars.js +80 -0
  33. package/dist/fn/ajax/treatAjaxArguments.d.ts +53 -0
  34. package/dist/fn/ajax/treatAjaxArguments.js +127 -0
  35. package/dist/fn/ajax/upload.d.ts +18 -0
  36. package/dist/fn/ajax/upload.js +52 -0
  37. package/dist/fn/browser/copy.d.ts +15 -0
  38. package/dist/fn/browser/copy.js +50 -0
  39. package/dist/fn/browser/eraseCookie.d.ts +15 -0
  40. package/dist/fn/browser/eraseCookie.js +17 -0
  41. package/dist/fn/browser/error.d.ts +14 -0
  42. package/dist/fn/browser/error.js +29 -0
  43. package/dist/fn/browser/getBrowserName.d.ts +9 -0
  44. package/dist/fn/browser/getBrowserName.js +28 -0
  45. package/dist/fn/browser/getBrowserVersion.d.ts +9 -0
  46. package/dist/fn/browser/getBrowserVersion.js +29 -0
  47. package/dist/fn/browser/getCookie.d.ts +16 -0
  48. package/dist/fn/browser/getCookie.js +32 -0
  49. package/dist/fn/browser/getDeviceType.d.ts +14 -0
  50. package/dist/fn/browser/getDeviceType.js +23 -0
  51. package/dist/fn/browser/getEventData.d.ts +16 -0
  52. package/dist/fn/browser/getEventData.js +116 -0
  53. package/dist/fn/browser/happy.d.ts +14 -0
  54. package/dist/fn/browser/happy.js +22 -0
  55. package/dist/fn/browser/history.d.ts +2 -0
  56. package/dist/fn/browser/history.js +4 -0
  57. package/dist/fn/browser/info.d.ts +10 -0
  58. package/dist/fn/browser/info.js +19 -0
  59. package/dist/fn/browser/isActiveInterface.d.ts +14 -0
  60. package/dist/fn/browser/isActiveInterface.js +20 -0
  61. package/dist/fn/browser/isDesktopDevice.d.ts +14 -0
  62. package/dist/fn/browser/isDesktopDevice.js +17 -0
  63. package/dist/fn/browser/isFocused.d.ts +21 -0
  64. package/dist/fn/browser/isFocused.js +23 -0
  65. package/dist/fn/browser/isMobile.d.ts +14 -0
  66. package/dist/fn/browser/isMobile.js +18 -0
  67. package/dist/fn/browser/isMobileDevice.d.ts +2 -0
  68. package/dist/fn/browser/isMobileDevice.js +5 -0
  69. package/dist/fn/browser/isTabletDevice.d.ts +14 -0
  70. package/dist/fn/browser/isTabletDevice.js +17 -0
  71. package/dist/fn/browser/log.d.ts +15 -0
  72. package/dist/fn/browser/log.js +46 -0
  73. package/dist/fn/browser/replaceSelection.d.ts +2 -0
  74. package/dist/fn/browser/replaceSelection.js +42 -0
  75. package/dist/fn/browser/selectElementText.d.ts +21 -0
  76. package/dist/fn/browser/selectElementText.js +42 -0
  77. package/dist/fn/browser/setCookie.d.ts +16 -0
  78. package/dist/fn/browser/setCookie.js +25 -0
  79. package/dist/fn/browser/toggleFullScreen.d.ts +2 -0
  80. package/dist/fn/browser/toggleFullScreen.js +39 -0
  81. package/dist/fn/browser/warning.d.ts +14 -0
  82. package/dist/fn/browser/warning.js +24 -0
  83. package/dist/fn/convert/arrayBuffer2String.d.ts +2 -0
  84. package/dist/fn/convert/arrayBuffer2String.js +4 -0
  85. package/dist/fn/convert/canvasToImage.d.ts +16 -0
  86. package/dist/fn/convert/canvasToImage.js +20 -0
  87. package/dist/fn/convert/colorToHex.d.ts +20 -0
  88. package/dist/fn/convert/colorToHex.js +24 -0
  89. package/dist/fn/convert/fromXml.d.ts +12 -0
  90. package/dist/fn/convert/fromXml.js +54 -0
  91. package/dist/fn/convert/hex2rgb.d.ts +24 -0
  92. package/dist/fn/convert/hex2rgb.js +29 -0
  93. package/dist/fn/convert/imageToCanvas.d.ts +15 -0
  94. package/dist/fn/convert/imageToCanvas.js +21 -0
  95. package/dist/fn/convert/imgToBase64.d.ts +2 -0
  96. package/dist/fn/convert/imgToBase64.js +7 -0
  97. package/dist/fn/convert/rgb2hex.d.ts +20 -0
  98. package/dist/fn/convert/rgb2hex.js +28 -0
  99. package/dist/fn/convert/string2ArrayBuffer.d.ts +2 -0
  100. package/dist/fn/convert/string2ArrayBuffer.js +9 -0
  101. package/dist/fn/convert/toCSV.d.ts +26 -0
  102. package/dist/fn/convert/toCSV.js +64 -0
  103. package/dist/fn/datetime/calendar.d.ts +2 -0
  104. package/dist/fn/datetime/calendar.js +23 -0
  105. package/dist/fn/datetime/chrono.d.ts +25 -0
  106. package/dist/fn/datetime/chrono.js +45 -0
  107. package/dist/fn/datetime/date.d.ts +18 -0
  108. package/dist/fn/datetime/date.js +44 -0
  109. package/dist/fn/datetime/dateSQL.d.ts +20 -0
  110. package/dist/fn/datetime/dateSQL.js +26 -0
  111. package/dist/fn/datetime/daysInMonth.d.ts +17 -0
  112. package/dist/fn/datetime/daysInMonth.js +24 -0
  113. package/dist/fn/datetime/fdate.d.ts +11 -0
  114. package/dist/fn/datetime/fdate.js +28 -0
  115. package/dist/fn/datetime/fdatetime.d.ts +9 -0
  116. package/dist/fn/datetime/fdatetime.js +30 -0
  117. package/dist/fn/datetime/formatDate.d.ts +2 -0
  118. package/dist/fn/datetime/formatDate.js +4 -0
  119. package/dist/fn/datetime/ftime.d.ts +9 -0
  120. package/dist/fn/datetime/ftime.js +21 -0
  121. package/dist/fn/datetime/getDay.d.ts +11 -0
  122. package/dist/fn/datetime/getDay.js +26 -0
  123. package/dist/fn/datetime/timestamp.d.ts +15 -0
  124. package/dist/fn/datetime/timestamp.js +18 -0
  125. package/dist/fn/default/defaultAjaxAbortFunction.d.ts +2 -0
  126. package/dist/fn/default/defaultAjaxAbortFunction.js +5 -0
  127. package/dist/fn/default/defaultAjaxErrorFunction.d.ts +2 -0
  128. package/dist/fn/default/defaultAjaxErrorFunction.js +4 -0
  129. package/dist/fn/default/defaultAlertFunction.d.ts +2 -0
  130. package/dist/fn/default/defaultAlertFunction.js +5 -0
  131. package/dist/fn/default/defaultConfirmFunction.d.ts +2 -0
  132. package/dist/fn/default/defaultConfirmFunction.js +14 -0
  133. package/dist/fn/default/defaultEndLoadingFunction.d.ts +2 -0
  134. package/dist/fn/default/defaultEndLoadingFunction.js +4 -0
  135. package/dist/fn/default/defaultErrorFunction.d.ts +2 -0
  136. package/dist/fn/default/defaultErrorFunction.js +5 -0
  137. package/dist/fn/default/defaultHistoryFunction.d.ts +2 -0
  138. package/dist/fn/default/defaultHistoryFunction.js +4 -0
  139. package/dist/fn/default/defaultLinkFunction.d.ts +2 -0
  140. package/dist/fn/default/defaultLinkFunction.js +4 -0
  141. package/dist/fn/default/defaultPostLinkFunction.d.ts +2 -0
  142. package/dist/fn/default/defaultPostLinkFunction.js +4 -0
  143. package/dist/fn/default/defaultPreLinkFunction.d.ts +2 -0
  144. package/dist/fn/default/defaultPreLinkFunction.js +4 -0
  145. package/dist/fn/default/defaultResizeFunction.d.ts +2 -0
  146. package/dist/fn/default/defaultResizeFunction.js +4 -0
  147. package/dist/fn/default/defaultStartLoadingFunction.d.ts +2 -0
  148. package/dist/fn/default/defaultStartLoadingFunction.js +4 -0
  149. package/dist/fn/form/addInputs.d.ts +43 -0
  150. package/dist/fn/form/addInputs.js +81 -0
  151. package/dist/fn/form/fieldValue.d.ts +12 -0
  152. package/dist/fn/form/fieldValue.js +34 -0
  153. package/dist/fn/form/formdata.d.ts +45 -0
  154. package/dist/fn/form/formdata.js +95 -0
  155. package/dist/fn/form/objectToFormData.d.ts +12 -0
  156. package/dist/fn/form/objectToFormData.js +45 -0
  157. package/dist/fn/form/submit.d.ts +20 -0
  158. package/dist/fn/form/submit.js +51 -0
  159. package/dist/fn/html/adjustHeight.d.ts +2 -0
  160. package/dist/fn/html/adjustHeight.js +10 -0
  161. package/dist/fn/html/adjustSize.d.ts +2 -0
  162. package/dist/fn/html/adjustSize.js +21 -0
  163. package/dist/fn/html/adjustWidth.d.ts +2 -0
  164. package/dist/fn/html/adjustWidth.js +10 -0
  165. package/dist/fn/html/getAllTags.d.ts +6 -0
  166. package/dist/fn/html/getAllTags.js +9 -0
  167. package/dist/fn/html/getAncestors.d.ts +2 -0
  168. package/dist/fn/html/getAncestors.js +25 -0
  169. package/dist/fn/html/getAttributes.d.ts +6 -0
  170. package/dist/fn/html/getAttributes.js +16 -0
  171. package/dist/fn/html/getHTMLOfSelection.d.ts +2 -0
  172. package/dist/fn/html/getHTMLOfSelection.js +18 -0
  173. package/dist/fn/html/getHtml.d.ts +2 -0
  174. package/dist/fn/html/getHtml.js +9 -0
  175. package/dist/fn/html/getPath.d.ts +10 -0
  176. package/dist/fn/html/getPath.js +50 -0
  177. package/dist/fn/html/getText.d.ts +2 -0
  178. package/dist/fn/html/getText.js +4 -0
  179. package/dist/fn/html/html2text.d.ts +17 -0
  180. package/dist/fn/html/html2text.js +22 -0
  181. package/dist/fn/html/isInside.d.ts +2 -0
  182. package/dist/fn/html/isInside.js +23 -0
  183. package/dist/fn/html/makeReactive.d.ts +2 -0
  184. package/dist/fn/html/makeReactive.js +185 -0
  185. package/dist/fn/html/selector.d.ts +10 -0
  186. package/dist/fn/html/selector.js +12 -0
  187. package/dist/fn/init.d.ts +13 -0
  188. package/dist/fn/init.js +25 -12
  189. package/dist/fn/loop/each.d.ts +33 -0
  190. package/dist/fn/loop/each.js +54 -0
  191. package/dist/fn/loop/fori.d.ts +36 -0
  192. package/dist/fn/loop/fori.js +53 -0
  193. package/dist/fn/loop/forir.d.ts +36 -0
  194. package/dist/fn/loop/forir.js +53 -0
  195. package/dist/fn/loop/iterate.d.ts +22 -0
  196. package/dist/fn/loop/iterate.js +36 -0
  197. package/dist/fn/loop/riterate.d.ts +21 -0
  198. package/dist/fn/loop/riterate.js +24 -0
  199. package/dist/fn/misc/analyzeFunction.d.ts +11 -0
  200. package/dist/fn/misc/analyzeFunction.js +141 -0
  201. package/dist/fn/misc/getTimeoff.d.ts +14 -0
  202. package/dist/fn/misc/getTimeoff.js +19 -0
  203. package/dist/fn/misc/money.d.ts +23 -0
  204. package/dist/fn/misc/money.js +122 -0
  205. package/dist/fn/misc/percent.d.ts +23 -0
  206. package/dist/fn/misc/percent.js +25 -0
  207. package/dist/fn/misc/randomInt.d.ts +22 -0
  208. package/dist/fn/misc/randomInt.js +24 -0
  209. package/dist/fn/misc/roundDecimal.d.ts +11 -0
  210. package/dist/fn/misc/roundDecimal.js +13 -0
  211. package/dist/fn/misc/translate.d.ts +2 -0
  212. package/dist/fn/misc/translate.js +8 -0
  213. package/dist/fn/object/_compareValues.d.ts +40 -0
  214. package/dist/fn/object/_compareValues.js +78 -0
  215. package/dist/fn/object/arrayFromProp.d.ts +33 -0
  216. package/dist/fn/object/arrayFromProp.js +41 -0
  217. package/dist/fn/object/autoExtend.d.ts +33 -0
  218. package/dist/fn/object/autoExtend.js +44 -0
  219. package/dist/fn/object/checkProps.d.ts +2 -0
  220. package/dist/fn/object/checkProps.js +5 -0
  221. package/dist/fn/object/checkPropsDetails.d.ts +2 -0
  222. package/dist/fn/object/checkPropsDetails.js +53 -0
  223. package/dist/fn/object/checkPropsOrDie.d.ts +2 -0
  224. package/dist/fn/object/checkPropsOrDie.js +9 -0
  225. package/dist/fn/object/circularReplacer.d.ts +7 -0
  226. package/dist/fn/object/circularReplacer.js +39 -0
  227. package/dist/fn/object/clone.d.ts +19 -0
  228. package/dist/fn/object/clone.js +33 -0
  229. package/dist/fn/object/compare.d.ts +53 -0
  230. package/dist/fn/object/compare.js +150 -0
  231. package/dist/fn/object/compareConditions.d.ts +46 -0
  232. package/dist/fn/object/compareConditions.js +86 -0
  233. package/dist/fn/object/count.d.ts +56 -0
  234. package/dist/fn/object/count.js +59 -0
  235. package/dist/fn/object/createObject.d.ts +2 -0
  236. package/dist/fn/object/createObject.js +9 -0
  237. package/dist/fn/object/deepPath.d.ts +57 -0
  238. package/dist/fn/object/deepPath.js +78 -0
  239. package/dist/fn/object/deleteProp.d.ts +8 -0
  240. package/dist/fn/object/deleteProp.js +13 -0
  241. package/dist/fn/object/diffObj.d.ts +79 -0
  242. package/dist/fn/object/diffObj.js +168 -0
  243. package/dist/fn/object/extend.d.ts +87 -0
  244. package/dist/fn/object/extend.js +158 -0
  245. package/dist/fn/object/extendOut.d.ts +18 -0
  246. package/dist/fn/object/extendOut.js +40 -0
  247. package/dist/fn/object/filter.d.ts +50 -0
  248. package/dist/fn/object/filter.js +94 -0
  249. package/dist/fn/object/filterToConditions.d.ts +48 -0
  250. package/dist/fn/object/filterToConditions.js +68 -0
  251. package/dist/fn/object/findAll.d.ts +57 -0
  252. package/dist/fn/object/findAll.js +73 -0
  253. package/dist/fn/object/getField.d.ts +30 -0
  254. package/dist/fn/object/getField.js +37 -0
  255. package/dist/fn/object/getFieldValues.d.ts +30 -0
  256. package/dist/fn/object/getFieldValues.js +41 -0
  257. package/dist/fn/object/getProp.d.ts +8 -0
  258. package/dist/fn/object/getProp.js +13 -0
  259. package/dist/fn/object/getProperty.d.ts +30 -0
  260. package/dist/fn/object/getProperty.js +39 -0
  261. package/dist/fn/object/getRow.d.ts +42 -0
  262. package/dist/fn/object/getRow.js +49 -0
  263. package/dist/fn/object/map.d.ts +74 -0
  264. package/dist/fn/object/map.js +83 -0
  265. package/dist/fn/object/move.d.ts +34 -0
  266. package/dist/fn/object/move.js +43 -0
  267. package/dist/fn/object/multiorder.d.ts +40 -0
  268. package/dist/fn/object/multiorder.js +60 -0
  269. package/dist/fn/object/numProperties.d.ts +31 -0
  270. package/dist/fn/object/numProperties.js +36 -0
  271. package/dist/fn/object/order.d.ts +28 -0
  272. package/dist/fn/object/order.js +36 -0
  273. package/dist/fn/object/pickValue.d.ts +2 -0
  274. package/dist/fn/object/pickValue.js +6 -0
  275. package/dist/fn/object/removeEmpty.d.ts +18 -0
  276. package/dist/fn/object/removeEmpty.js +47 -0
  277. package/dist/fn/object/removePrivateProp.d.ts +24 -0
  278. package/dist/fn/object/removePrivateProp.js +41 -0
  279. package/dist/fn/object/search.d.ts +101 -0
  280. package/dist/fn/object/search.js +177 -0
  281. package/dist/fn/object/setProp.d.ts +11 -0
  282. package/dist/fn/object/setProp.js +17 -0
  283. package/dist/fn/object/setProperty.d.ts +30 -0
  284. package/dist/fn/object/setProperty.js +50 -0
  285. package/dist/fn/object/shortenObj.d.ts +25 -0
  286. package/dist/fn/object/shortenObj.js +40 -0
  287. package/dist/fn/object/shuffle.d.ts +2 -0
  288. package/dist/fn/object/shuffle.js +13 -0
  289. package/dist/fn/object/stat.d.ts +2 -0
  290. package/dist/fn/object/stat.js +49 -0
  291. package/dist/fn/object/sum.d.ts +46 -0
  292. package/dist/fn/object/sum.js +57 -0
  293. package/dist/fn/object/unique.d.ts +18 -0
  294. package/dist/fn/object/unique.js +22 -0
  295. package/dist/fn/string/baseName.d.ts +24 -0
  296. package/dist/fn/string/baseName.js +39 -0
  297. package/dist/fn/string/br2nl.d.ts +19 -0
  298. package/dist/fn/string/br2nl.js +22 -0
  299. package/dist/fn/string/camelToCss.d.ts +18 -0
  300. package/dist/fn/string/camelToCss.js +26 -0
  301. package/dist/fn/string/camelize.d.ts +20 -0
  302. package/dist/fn/string/camelize.js +27 -0
  303. package/dist/fn/string/correctCase.d.ts +18 -0
  304. package/dist/fn/string/correctCase.js +20 -0
  305. package/dist/fn/string/crc32.d.ts +2 -0
  306. package/dist/fn/string/crc32.js +20 -0
  307. package/dist/fn/string/dirName.d.ts +17 -0
  308. package/dist/fn/string/dirName.js +33 -0
  309. package/dist/fn/string/escapeDquotes.d.ts +2 -0
  310. package/dist/fn/string/escapeDquotes.js +8 -0
  311. package/dist/fn/string/escapeRegExp.d.ts +19 -0
  312. package/dist/fn/string/escapeRegExp.js +21 -0
  313. package/dist/fn/string/escapeSquotes.d.ts +2 -0
  314. package/dist/fn/string/escapeSquotes.js +8 -0
  315. package/dist/fn/string/escapeTicks.d.ts +2 -0
  316. package/dist/fn/string/escapeTicks.js +8 -0
  317. package/dist/fn/string/escapeUrl.d.ts +9 -0
  318. package/dist/fn/string/escapeUrl.js +47 -0
  319. package/dist/fn/string/fileExt.d.ts +38 -0
  320. package/dist/fn/string/fileExt.js +47 -0
  321. package/dist/fn/string/format.d.ts +2 -0
  322. package/dist/fn/string/format.js +14 -0
  323. package/dist/fn/string/formatBytes.d.ts +14 -0
  324. package/dist/fn/string/formatBytes.js +20 -0
  325. package/dist/fn/string/formatSize.d.ts +2 -0
  326. package/dist/fn/string/formatSize.js +12 -0
  327. package/dist/fn/string/hash.d.ts +7 -0
  328. package/dist/fn/string/hash.js +42 -0
  329. package/dist/fn/string/md5.d.ts +22 -0
  330. package/dist/fn/string/md5.js +142 -0
  331. package/dist/fn/string/nl2br.d.ts +17 -0
  332. package/dist/fn/string/nl2br.js +20 -0
  333. package/dist/fn/string/printf.d.ts +10 -0
  334. package/dist/fn/string/printf.js +15 -0
  335. package/dist/fn/string/quotes2html.d.ts +30 -0
  336. package/dist/fn/string/quotes2html.js +39 -0
  337. package/dist/fn/string/randomString.d.ts +28 -0
  338. package/dist/fn/string/randomString.js +72 -0
  339. package/dist/fn/string/removeAccents.d.ts +17 -0
  340. package/dist/fn/string/removeAccents.js +30 -0
  341. package/dist/fn/string/removeExtraSpaces.d.ts +7 -0
  342. package/dist/fn/string/removeExtraSpaces.js +9 -0
  343. package/dist/fn/string/removeHtmlComments.d.ts +2 -0
  344. package/dist/fn/string/removeHtmlComments.js +8 -0
  345. package/dist/fn/string/removeTrailingChars.d.ts +11 -0
  346. package/dist/fn/string/removeTrailingChars.js +25 -0
  347. package/dist/fn/string/repeat.d.ts +16 -0
  348. package/dist/fn/string/repeat.js +18 -0
  349. package/dist/fn/string/replaceAll.d.ts +23 -0
  350. package/dist/fn/string/replaceAll.js +29 -0
  351. package/dist/fn/string/sanitize.d.ts +17 -0
  352. package/dist/fn/string/sanitize.js +34 -0
  353. package/dist/fn/string/shorten.d.ts +27 -0
  354. package/dist/fn/string/shorten.js +42 -0
  355. package/dist/fn/string/simpleHash.d.ts +2 -0
  356. package/dist/fn/string/simpleHash.js +8 -0
  357. package/dist/fn/string/simpleHash1.d.ts +2 -0
  358. package/dist/fn/string/simpleHash1.js +10 -0
  359. package/dist/fn/string/simpleHash2.d.ts +2 -0
  360. package/dist/fn/string/simpleHash2.js +10 -0
  361. package/dist/fn/string/substr.d.ts +23 -0
  362. package/dist/fn/string/substr.js +38 -0
  363. package/dist/fn/string/trim.d.ts +2 -0
  364. package/dist/fn/string/trim.js +20 -0
  365. package/dist/fn/string/uniqString.d.ts +18 -0
  366. package/dist/fn/string/uniqString.js +49 -0
  367. package/dist/fn/style/addColors.d.ts +17 -0
  368. package/dist/fn/style/addColors.js +76 -0
  369. package/dist/fn/style/addStyle.d.ts +12 -0
  370. package/dist/fn/style/addStyle.js +20 -0
  371. package/dist/fn/style/animateCss.d.ts +13 -0
  372. package/dist/fn/style/animateCss.js +31 -0
  373. package/dist/fn/style/center.d.ts +16 -0
  374. package/dist/fn/style/center.js +40 -0
  375. package/dist/fn/style/cssExists.d.ts +12 -0
  376. package/dist/fn/style/cssExists.js +40 -0
  377. package/dist/fn/style/getCssVar.d.ts +7 -0
  378. package/dist/fn/style/getCssVar.js +12 -0
  379. package/dist/fn/style/getScrollBarSize.d.ts +2 -0
  380. package/dist/fn/style/getScrollBarSize.js +25 -0
  381. package/dist/fn/style/lightenDarkenHex.d.ts +20 -0
  382. package/dist/fn/style/lightenDarkenHex.js +45 -0
  383. package/dist/fn/style/outerHeight.d.ts +11 -0
  384. package/dist/fn/style/outerHeight.js +19 -0
  385. package/dist/fn/style/outerWidth.d.ts +10 -0
  386. package/dist/fn/style/outerWidth.js +16 -0
  387. package/dist/fn/style/resize.d.ts +2 -0
  388. package/dist/fn/style/resize.js +39 -0
  389. package/dist/fn/style/setCssVar.d.ts +8 -0
  390. package/dist/fn/style/setCssVar.js +14 -0
  391. package/dist/fn/type/checkType.d.ts +2 -0
  392. package/dist/fn/type/checkType.js +59 -0
  393. package/dist/fn/type/isArray.d.ts +14 -0
  394. package/dist/fn/type/isArray.js +23 -0
  395. package/dist/fn/type/isBlob.d.ts +9 -0
  396. package/dist/fn/type/isBlob.js +18 -0
  397. package/dist/fn/type/isBoolean.d.ts +16 -0
  398. package/dist/fn/type/isBoolean.js +25 -0
  399. package/dist/fn/type/isCanvas.d.ts +16 -0
  400. package/dist/fn/type/isCanvas.js +25 -0
  401. package/dist/fn/type/isColor.d.ts +31 -0
  402. package/dist/fn/type/isColor.js +45 -0
  403. package/dist/fn/type/isComment.d.ts +14 -0
  404. package/dist/fn/type/isComment.js +23 -0
  405. package/dist/fn/type/isCp.d.ts +2 -0
  406. package/dist/fn/type/isCp.js +17 -0
  407. package/dist/fn/type/isDate.d.ts +20 -0
  408. package/dist/fn/type/isDate.js +29 -0
  409. package/dist/fn/type/isDimension.d.ts +11 -0
  410. package/dist/fn/type/isDimension.js +24 -0
  411. package/dist/fn/type/isDom.d.ts +14 -0
  412. package/dist/fn/type/isDom.js +23 -0
  413. package/dist/fn/type/isEmail.d.ts +23 -0
  414. package/dist/fn/type/isEmail.js +37 -0
  415. package/dist/fn/type/isEmpty.d.ts +41 -0
  416. package/dist/fn/type/isEmpty.js +57 -0
  417. package/dist/fn/type/isEvent.d.ts +9 -0
  418. package/dist/fn/type/isEvent.js +18 -0
  419. package/dist/fn/type/isFunction.d.ts +16 -0
  420. package/dist/fn/type/isFunction.js +25 -0
  421. package/dist/fn/type/isHostname.d.ts +2 -0
  422. package/dist/fn/type/isHostname.js +16 -0
  423. package/dist/fn/type/isIP.d.ts +2 -0
  424. package/dist/fn/type/isIP.js +12 -0
  425. package/dist/fn/type/isInt.d.ts +18 -0
  426. package/dist/fn/type/isInt.js +27 -0
  427. package/dist/fn/type/isIterable.d.ts +27 -0
  428. package/dist/fn/type/isIterable.js +39 -0
  429. package/dist/fn/type/isNull.d.ts +14 -0
  430. package/dist/fn/type/isNull.js +23 -0
  431. package/dist/fn/type/isNumber.d.ts +19 -0
  432. package/dist/fn/type/isNumber.js +30 -0
  433. package/dist/fn/type/isObject.d.ts +19 -0
  434. package/dist/fn/type/isObject.js +28 -0
  435. package/dist/fn/type/isPercent.d.ts +14 -0
  436. package/dist/fn/type/isPercent.js +23 -0
  437. package/dist/fn/type/isPrimitive.d.ts +18 -0
  438. package/dist/fn/type/isPrimitive.js +27 -0
  439. package/dist/fn/type/isPromise.d.ts +18 -0
  440. package/dist/fn/type/isPromise.js +27 -0
  441. package/dist/fn/type/isPropSize.d.ts +2 -0
  442. package/dist/fn/type/isPropSize.js +12 -0
  443. package/dist/fn/type/isSQLDate.d.ts +10 -0
  444. package/dist/fn/type/isSQLDate.js +20 -0
  445. package/dist/fn/type/isSame.d.ts +41 -0
  446. package/dist/fn/type/isSame.js +72 -0
  447. package/dist/fn/type/isString.d.ts +14 -0
  448. package/dist/fn/type/isString.js +23 -0
  449. package/dist/fn/type/isSymbol.d.ts +15 -0
  450. package/dist/fn/type/isSymbol.js +24 -0
  451. package/dist/fn/type/isURL.d.ts +2 -0
  452. package/dist/fn/type/isURL.js +11 -0
  453. package/dist/fn/type/isValidDimension.d.ts +11 -0
  454. package/dist/fn/type/isValidDimension.js +24 -0
  455. package/dist/fn/type/isValidName.d.ts +27 -0
  456. package/dist/fn/type/isValidName.js +38 -0
  457. package/dist/fn/type/isValue.d.ts +26 -0
  458. package/dist/fn/type/isValue.js +36 -0
  459. package/dist/fn/type/isVue.d.ts +16 -0
  460. package/dist/fn/type/isVue.js +42 -0
  461. package/dist/fn.d.ts +4 -5
  462. package/dist/fn.js +226 -228
  463. package/package.json +1 -1
@@ -0,0 +1,41 @@
1
+ import { substr } from '../string/substr';
2
+ /**
3
+ * Returns an object with the original objects' properties starting with an alphanumeric character.
4
+ *
5
+ * It is presumed that external libraries, bbn variables use prefixes such as _ or $ for
6
+ * naming private properties; this returns a new object purged from these properties.
7
+ *
8
+ * @method removePrivateProp
9
+ * @global
10
+ * @example
11
+ * ```javascript
12
+ * bbn.fn.removePrivateProp({
13
+ * _bbn_timestamp: 1587269593987,
14
+ * name: "Wonka",
15
+ * fname: "Willy"
16
+ * });
17
+ * // {name: "Wonka", fname: "Willy"}
18
+ * ```
19
+ * @memberof bbn.fn
20
+ * @param {Object} obj The original object
21
+ * @param {Boolean} deep If true the function will be reapplied on object properties
22
+ * @returns {Object} A new object without only the _public_ properties.
23
+ */
24
+ const removePrivateProp = function (obj, deep = false) {
25
+ let r = null;
26
+ if (typeof obj === 'object') {
27
+ r = {};
28
+ for (var n in obj) {
29
+ if (substr(n, 0, 1).match(/^[A-z0-9]$/) && (n in obj)) {
30
+ if (deep && typeof obj[n] === 'object') {
31
+ r[n] = removePrivateProp(obj[n], true);
32
+ }
33
+ else {
34
+ r[n] = obj[n];
35
+ }
36
+ }
37
+ }
38
+ }
39
+ return r || false;
40
+ };
41
+ export { removePrivateProp };
@@ -0,0 +1,101 @@
1
+ import { Filter } from './filterToConditions';
2
+ /**
3
+ * Retrieves the index of the array's first element corresponding to the given filter.
4
+ *
5
+ * Returns -1 if the element is not found. If the second parameter is an object or function
6
+ * for filtering as defined in bbn.fn.filter, the remaining parameters will be shifted to the
7
+ * left, i.e. val becomes operator, and operator startFrom. And if operator is a number, its value will
8
+ * be given to startFrom and operator will be undefined. The filter object can be complex with different
9
+ * operators (as seen in bbn.fn.compare) and logics (AND/OR), and infinitely nested, of this form:
10
+ * ```javascript
11
+ * {
12
+ * logic: "AND",
13
+ * conditions: [
14
+ * {
15
+ * field: "prop1",
16
+ * operator: "eq",
17
+ * value: "value1"
18
+ * }, {
19
+ * logic: "OR",
20
+ * conditions: [
21
+ * {
22
+ * field: "prop2",
23
+ * operator: "eq",
24
+ * value: 1
25
+ * }. {
26
+ * field: "prop2",
27
+ * operator: "eq",
28
+ * value: 2
29
+ * }
30
+ * ]
31
+ * }
32
+ * ]
33
+ * }
34
+ * ```
35
+ * This way of managing the arguments is used in all the filtering functions.
36
+ *
37
+ * @method search
38
+ * @global
39
+ * @example
40
+ * ```javascript
41
+ * let ar = [
42
+ * {name: "Raiders of the lost ark", director: "Steven Spielberg", year: 1981, id: 589},
43
+ * {name: "Goonies", director: "Richard Donner", year: 1985, id: 689},
44
+ * {name: "Star wars", director: "George Lucas", year: 1977, id: 256},
45
+ * {name: "Jaws", director: "Steven Spielberg", year: 1975, id: 423}
46
+ * ];
47
+ *
48
+ * bbn.fn.search(ar, "id", 256);
49
+ * // 2
50
+ *
51
+ * bbn.fn.search(ar, {director: "Steven Spielberg"});
52
+ * // 0
53
+ *
54
+ * bbn.fn.search(ar, {year: 1975, director: "Steven Spielberg"});
55
+ * // 3
56
+ *
57
+ * bbn.fn.search(ar, {director: "Steven Spielberg"}, 1);
58
+ * // 3
59
+ *
60
+ * // Complex filters
61
+ * bbn.fn.search(ar, {
62
+ * logic: "AND",
63
+ * conditions: [
64
+ * {
65
+ * field: "director",
66
+ * operator: "eq",
67
+ * value: "Steven Spielberg"
68
+ * }, {
69
+ * logic: "OR",
70
+ * conditions: [
71
+ * {
72
+ * field: "year",
73
+ * operator: "eq",
74
+ * value: 1974
75
+ * }, {
76
+ * field: "year",
77
+ * operator: "eq",
78
+ * value: 1975
79
+ * }
80
+ * ]
81
+ * }
82
+ * ]
83
+ * });
84
+ * // 3
85
+ *
86
+ * Simple array
87
+ * bbn.fn.search(['a', 'b', 'c'], null, 'b');
88
+ * // 1
89
+ *
90
+ * ```
91
+ *
92
+ * @memberof bbn.fn
93
+ * @param {Array} arr The subject array
94
+ * @param {(String|Object|Function)} prop A property's name or a filter object or function
95
+ * @param {*} val The value with which comparing the given property
96
+ * @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
97
+ * @param {Number} startFrom The index from which the search should start
98
+ * @returns {Number} The index if found, otherwise -1
99
+ */
100
+ declare const search: (arr: any[], prop: string | object | Filter | ((a: any, i: string | number | symbol) => boolean), val?: any, operator?: number | string, startFrom?: number) => number;
101
+ export { search };
@@ -0,0 +1,177 @@
1
+ import { isIterable } from '../type/isIterable';
2
+ import { compareConditions } from './compareConditions';
3
+ import { filterToConditions } from './filterToConditions';
4
+ import { isObject } from '../type/isObject';
5
+ import { numProperties } from './numProperties';
6
+ import { isNumber } from '../type/isNumber';
7
+ /**
8
+ * Retrieves the index of the array's first element corresponding to the given filter.
9
+ *
10
+ * Returns -1 if the element is not found. If the second parameter is an object or function
11
+ * for filtering as defined in bbn.fn.filter, the remaining parameters will be shifted to the
12
+ * left, i.e. val becomes operator, and operator startFrom. And if operator is a number, its value will
13
+ * be given to startFrom and operator will be undefined. The filter object can be complex with different
14
+ * operators (as seen in bbn.fn.compare) and logics (AND/OR), and infinitely nested, of this form:
15
+ * ```javascript
16
+ * {
17
+ * logic: "AND",
18
+ * conditions: [
19
+ * {
20
+ * field: "prop1",
21
+ * operator: "eq",
22
+ * value: "value1"
23
+ * }, {
24
+ * logic: "OR",
25
+ * conditions: [
26
+ * {
27
+ * field: "prop2",
28
+ * operator: "eq",
29
+ * value: 1
30
+ * }. {
31
+ * field: "prop2",
32
+ * operator: "eq",
33
+ * value: 2
34
+ * }
35
+ * ]
36
+ * }
37
+ * ]
38
+ * }
39
+ * ```
40
+ * This way of managing the arguments is used in all the filtering functions.
41
+ *
42
+ * @method search
43
+ * @global
44
+ * @example
45
+ * ```javascript
46
+ * let ar = [
47
+ * {name: "Raiders of the lost ark", director: "Steven Spielberg", year: 1981, id: 589},
48
+ * {name: "Goonies", director: "Richard Donner", year: 1985, id: 689},
49
+ * {name: "Star wars", director: "George Lucas", year: 1977, id: 256},
50
+ * {name: "Jaws", director: "Steven Spielberg", year: 1975, id: 423}
51
+ * ];
52
+ *
53
+ * bbn.fn.search(ar, "id", 256);
54
+ * // 2
55
+ *
56
+ * bbn.fn.search(ar, {director: "Steven Spielberg"});
57
+ * // 0
58
+ *
59
+ * bbn.fn.search(ar, {year: 1975, director: "Steven Spielberg"});
60
+ * // 3
61
+ *
62
+ * bbn.fn.search(ar, {director: "Steven Spielberg"}, 1);
63
+ * // 3
64
+ *
65
+ * // Complex filters
66
+ * bbn.fn.search(ar, {
67
+ * logic: "AND",
68
+ * conditions: [
69
+ * {
70
+ * field: "director",
71
+ * operator: "eq",
72
+ * value: "Steven Spielberg"
73
+ * }, {
74
+ * logic: "OR",
75
+ * conditions: [
76
+ * {
77
+ * field: "year",
78
+ * operator: "eq",
79
+ * value: 1974
80
+ * }, {
81
+ * field: "year",
82
+ * operator: "eq",
83
+ * value: 1975
84
+ * }
85
+ * ]
86
+ * }
87
+ * ]
88
+ * });
89
+ * // 3
90
+ *
91
+ * Simple array
92
+ * bbn.fn.search(['a', 'b', 'c'], null, 'b');
93
+ * // 1
94
+ *
95
+ * ```
96
+ *
97
+ * @memberof bbn.fn
98
+ * @param {Array} arr The subject array
99
+ * @param {(String|Object|Function)} prop A property's name or a filter object or function
100
+ * @param {*} val The value with which comparing the given property
101
+ * @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
102
+ * @param {Number} startFrom The index from which the search should start
103
+ * @returns {Number} The index if found, otherwise -1
104
+ */
105
+ const search = function (arr, prop, val = null, operator = '=', startFrom = 0) {
106
+ if (!isIterable(arr)) {
107
+ throw new Error(bbn._('The first argument for a search should be iterable') + ' ' + typeof arr + ' ' + bbn._('given'));
108
+ }
109
+ if (!arr.length) {
110
+ return -1;
111
+ }
112
+ let filter;
113
+ let isFn = false;
114
+ if (typeof prop === 'string') {
115
+ filter = {
116
+ conditions: [
117
+ {
118
+ field: prop,
119
+ value: val,
120
+ operator: operator || '=',
121
+ },
122
+ ]
123
+ };
124
+ }
125
+ else if (!prop) {
126
+ isFn = true;
127
+ filter = a => {
128
+ return compareConditions({ value: a }, filterToConditions({
129
+ logic: 'AND',
130
+ conditions: [
131
+ {
132
+ field: 'value',
133
+ operator: operator || '=',
134
+ value: val,
135
+ },
136
+ ],
137
+ }));
138
+ };
139
+ }
140
+ else {
141
+ startFrom = typeof (operator) === 'number' ? operator : 0;
142
+ operator = val;
143
+ if (isObject(prop)) {
144
+ filter = prop;
145
+ }
146
+ else if (typeof (prop) === 'function') {
147
+ isFn = true;
148
+ filter = prop;
149
+ }
150
+ }
151
+ if (isFn || (isObject(filter) && numProperties(filter))) {
152
+ if (isNumber(operator)) {
153
+ startFrom = typeof (operator) === 'number' ? operator : 0;
154
+ operator = undefined;
155
+ }
156
+ if (!isNumber(startFrom)) {
157
+ startFrom = 0;
158
+ }
159
+ if (typeof filter === 'function') {
160
+ for (let i = startFrom; i < arr.length; i++) {
161
+ if (filter(arr[i])) {
162
+ return i;
163
+ }
164
+ }
165
+ }
166
+ else {
167
+ filter = filterToConditions(filter);
168
+ for (let i = startFrom; i < arr.length; i++) {
169
+ if (compareConditions(arr[i], filter)) {
170
+ return i;
171
+ }
172
+ }
173
+ }
174
+ }
175
+ return -1;
176
+ };
177
+ export { search };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Sets a given property on the given object
3
+ *
4
+ * @param {Object} obj
5
+ * @param {String} prop
6
+ * @param {*} value
7
+ * @param {Boolean} writable
8
+ * @param {Boolean} configurable
9
+ */
10
+ declare const setProp: (obj: object, prop: string, value: any, writable?: boolean, configurable?: boolean) => void;
11
+ export { setProp };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Sets a given property on the given object
3
+ *
4
+ * @param {Object} obj
5
+ * @param {String} prop
6
+ * @param {*} value
7
+ * @param {Boolean} writable
8
+ * @param {Boolean} configurable
9
+ */
10
+ const setProp = function (obj, prop, value, writable = true, configurable = true) {
11
+ Object.defineProperty(obj, prop, {
12
+ value: value,
13
+ writable: writable,
14
+ configurable: configurable,
15
+ });
16
+ };
17
+ export { setProp };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Returns the value of the given property from the given object.
3
+ *
4
+ * Looks for the given property in the given object, accepting dot (.) separator
5
+ * for deep property access, and returns its value if found and undefined otherwise.
6
+ *
7
+ * @method getProperty
8
+ * @global
9
+ * @example
10
+ * ```javascript
11
+ * bbn.fn.getProperty({a: 1, b: 2}, 'b');
12
+ * // 2
13
+ * ```
14
+ * @example
15
+ * ```javascript
16
+ * bbn.fn.getProperty({a: 1, b: {o: {a: 33, h: 5}}}, 'b.o.a');
17
+ * // 33
18
+ * ```
19
+ * @example
20
+ * ```javascript
21
+ * bbn.fn.getProperty({a: 1, b: {o: {a: 33, h: 5}}}, 'b.h.a');
22
+ * // undefined
23
+ * ```
24
+ * @memberof bbn.fn
25
+ * @param {Object} obj
26
+ * @param {String} prop
27
+ * @returns {*} The property's value or undefined
28
+ */
29
+ declare const setProperty: (obj: object, prop: string, value: any, force?: boolean) => void;
30
+ export { setProperty };
@@ -0,0 +1,50 @@
1
+ import { each } from '../loop/each';
2
+ /**
3
+ * Returns the value of the given property from the given object.
4
+ *
5
+ * Looks for the given property in the given object, accepting dot (.) separator
6
+ * for deep property access, and returns its value if found and undefined otherwise.
7
+ *
8
+ * @method getProperty
9
+ * @global
10
+ * @example
11
+ * ```javascript
12
+ * bbn.fn.getProperty({a: 1, b: 2}, 'b');
13
+ * // 2
14
+ * ```
15
+ * @example
16
+ * ```javascript
17
+ * bbn.fn.getProperty({a: 1, b: {o: {a: 33, h: 5}}}, 'b.o.a');
18
+ * // 33
19
+ * ```
20
+ * @example
21
+ * ```javascript
22
+ * bbn.fn.getProperty({a: 1, b: {o: {a: 33, h: 5}}}, 'b.h.a');
23
+ * // undefined
24
+ * ```
25
+ * @memberof bbn.fn
26
+ * @param {Object} obj
27
+ * @param {String} prop
28
+ * @returns {*} The property's value or undefined
29
+ */
30
+ const setProperty = function (obj, prop, value, force) {
31
+ if (typeof obj === 'object' && typeof prop === 'string') {
32
+ let o = obj;
33
+ const bits = prop.split('.');
34
+ each(bits, (v, i) => {
35
+ if (!o) {
36
+ if (!force) {
37
+ throw new Error(bbn._('The object is invalid'));
38
+ }
39
+ o = {};
40
+ }
41
+ if (bits.length - 1 === i) {
42
+ o[v] = value;
43
+ }
44
+ else {
45
+ o = o[v];
46
+ }
47
+ });
48
+ }
49
+ };
50
+ export { setProperty };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Shortens all the strings contained in the object properties or element in a array.
3
+ *
4
+ * Modifies directly the given object by cuttin all its too long strings, and adding ellipsis (...) in this case.
5
+ *
6
+ * @method shortenObj
7
+ * @global
8
+ * @example
9
+ * ```javascript
10
+ * bbn.fn.shortenObj({
11
+ * title: "Once upon a time in the west",
12
+ * synopsis: "There's a single piece of land around Flagstone with water on it, and rail baron Morton (Gabriele Ferzetti) aims to have it, knowing the new railroad will have to stop there. He sends his henchman Frank (Henry Fonda) to scare the land's owner, McBain (Frank Wolff), but Frank kills him instead and pins it on a known bandit, Cheyenne (Jason Robards). Meanwhile, a mysterious gunslinger with a score to settle (Charles Bronson) and McBain's new wife, Jill (Claudia Cardinale), arrive in town."
13
+ * }, 50)
14
+ * // {
15
+ * // "title": "Once upon a time in the west",
16
+ * // "synopsis": "There's a single piece of land around Flagstone wi..."
17
+ * // }
18
+ * ```
19
+ * @memberof bbn.fn
20
+ * @param {(Object|Array)} obj
21
+ * @param {Number} [max=100]
22
+ * @returns {(Object|Array)} The same object, modified
23
+ */
24
+ declare const shortenObj: (obj: any, max?: number) => object;
25
+ export { shortenObj };
@@ -0,0 +1,40 @@
1
+ import { clone } from "./clone";
2
+ import { each } from "../loop/each";
3
+ import { isString } from "../type/isString";
4
+ import { shorten } from "../string/shorten";
5
+ /**
6
+ * Shortens all the strings contained in the object properties or element in a array.
7
+ *
8
+ * Modifies directly the given object by cuttin all its too long strings, and adding ellipsis (...) in this case.
9
+ *
10
+ * @method shortenObj
11
+ * @global
12
+ * @example
13
+ * ```javascript
14
+ * bbn.fn.shortenObj({
15
+ * title: "Once upon a time in the west",
16
+ * synopsis: "There's a single piece of land around Flagstone with water on it, and rail baron Morton (Gabriele Ferzetti) aims to have it, knowing the new railroad will have to stop there. He sends his henchman Frank (Henry Fonda) to scare the land's owner, McBain (Frank Wolff), but Frank kills him instead and pins it on a known bandit, Cheyenne (Jason Robards). Meanwhile, a mysterious gunslinger with a score to settle (Charles Bronson) and McBain's new wife, Jill (Claudia Cardinale), arrive in town."
17
+ * }, 50)
18
+ * // {
19
+ * // "title": "Once upon a time in the west",
20
+ * // "synopsis": "There's a single piece of land around Flagstone wi..."
21
+ * // }
22
+ * ```
23
+ * @memberof bbn.fn
24
+ * @param {(Object|Array)} obj
25
+ * @param {Number} [max=100]
26
+ * @returns {(Object|Array)} The same object, modified
27
+ */
28
+ const shortenObj = function (obj, max = 100) {
29
+ let o = clone(obj);
30
+ each(o, (a, n) => {
31
+ if (isString(a) && a.length > max) {
32
+ o[n] = shorten(a, max);
33
+ }
34
+ else if (a && typeof a === "object") {
35
+ o[n] = shortenObj(a);
36
+ }
37
+ });
38
+ return o;
39
+ };
40
+ export { shortenObj };
@@ -0,0 +1,2 @@
1
+ declare const shuffle: (array: any[]) => any[];
2
+ export { shuffle };
@@ -0,0 +1,13 @@
1
+ const shuffle = function (array) {
2
+ let currentIndex = array.length, randomIndex;
3
+ // While there remain elements to shuffle.
4
+ while (currentIndex != 0) {
5
+ // Pick a remaining element.
6
+ randomIndex = Math.floor(Math.random() * currentIndex);
7
+ currentIndex--;
8
+ // And swap it with the current element.
9
+ [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
10
+ }
11
+ return array;
12
+ };
13
+ export { shuffle };
@@ -0,0 +1,2 @@
1
+ declare const stat: (returnStat: any) => void;
2
+ export { stat };
@@ -0,0 +1,49 @@
1
+ const stat = function (returnStat) {
2
+ return;
3
+ /*
4
+ if (bbn.env.logging) {
5
+ var logs = bbn.vars.loggers;
6
+ for (var i = 0; i < arguments.length; i++) {
7
+ var a = arguments[i],
8
+ type = typeof a;
9
+ if (type === 'boolean' || type === 'undefined') {
10
+ break;
11
+ } else {
12
+ if (type === 'object') {
13
+ a = getPath(a);
14
+ } else {
15
+ a = a.toString();
16
+ }
17
+ if (!logs[a]) {
18
+ logs[a] = {
19
+ _num: 0,
20
+ };
21
+ }
22
+ logs[a]._num++;
23
+ logs = logs[a];
24
+ }
25
+ }
26
+ if (arguments[arguments.length - 1] === true) {
27
+ var treat = function (obj) {
28
+ var v = {};
29
+ for (var n in obj) {
30
+ if (n.indexOf('_') !== 0) {
31
+ v[n + '(' + obj[n]._num + ')'] = treat(obj[n]);
32
+ }
33
+ }
34
+ return v;
35
+ };
36
+ return treat(logs);
37
+ }
38
+ if (arguments[arguments.length - 1] === false) {
39
+ for (var n in logs) {
40
+ delete logs[n];
41
+ }
42
+ logs._num = 0;
43
+ return;
44
+ }
45
+ return returnStat;
46
+ }
47
+ */
48
+ };
49
+ export { stat };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Returns the sum of the given property or function for the array's elements matching the filter.
3
+ *
4
+ * The filtering arguments follow the same scheme as bbn.fn.search.
5
+ *
6
+ * @method sum
7
+ * @global
8
+ * @example
9
+ * ```javascript
10
+ * let invited = [
11
+ * {name: "Robert De Niro", attendees: 2, confirmed: true},
12
+ * {name: "Al Pacino", attendees: 1, confirmed: false},
13
+ * {name: "James Caan", attendees: 4, confirmed: false},
14
+ * {name: "Harvey Keitel", attendees: 5, confirmed: true}
15
+ * ];
16
+ * // No filter
17
+ * bbn.fn.sum(invited, "attendees");
18
+ * // 12
19
+ * // Filter
20
+ * bbn.fn.sum(invited, "attendees", {confirmed: true});
21
+ * // 7
22
+ * ```
23
+ * @example
24
+ * ```javascript
25
+ * let cart = [
26
+ * {article: "Toothpaste", price: 2.50, quantity: 1},
27
+ * {article: "Toothbrush", price: 6, quantity: 2},
28
+ * {article: "Banana", price: 0.50, quantity: 3},
29
+ * {article: "T-shirt", price: 14, quantity: 3}
30
+ * ];
31
+ * bbn.fn.sum(cart, a => a.price * a.quantity);
32
+ * // 58
33
+ * // Only the items with a quantity equal to 3
34
+ * bbn.fn.sum(cart, a => a.price * a.quantity, {quantity: 3});
35
+ * // 43.5
36
+ * ```
37
+ * @memberof bbn.fn
38
+ * @param {Array} arr The subject array
39
+ * @param {(String|Function)} numberProp The property's name for which the value should be added to the sum, or a function returning the number.
40
+ * @param {(String|Object|Function)} prop A property's name or a filter object or function
41
+ * @param {*} val The value with which comparing the given property
42
+ * @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
43
+ * @returns {Number} The sum
44
+ */
45
+ declare const sum: (arr: object[], numberProp: string | ((a: any) => any), prop: object | string, val?: any, operator?: string) => number;
46
+ export { sum };
@@ -0,0 +1,57 @@
1
+ import { each } from '../loop/each';
2
+ import { filter } from './filter';
3
+ /**
4
+ * Returns the sum of the given property or function for the array's elements matching the filter.
5
+ *
6
+ * The filtering arguments follow the same scheme as bbn.fn.search.
7
+ *
8
+ * @method sum
9
+ * @global
10
+ * @example
11
+ * ```javascript
12
+ * let invited = [
13
+ * {name: "Robert De Niro", attendees: 2, confirmed: true},
14
+ * {name: "Al Pacino", attendees: 1, confirmed: false},
15
+ * {name: "James Caan", attendees: 4, confirmed: false},
16
+ * {name: "Harvey Keitel", attendees: 5, confirmed: true}
17
+ * ];
18
+ * // No filter
19
+ * bbn.fn.sum(invited, "attendees");
20
+ * // 12
21
+ * // Filter
22
+ * bbn.fn.sum(invited, "attendees", {confirmed: true});
23
+ * // 7
24
+ * ```
25
+ * @example
26
+ * ```javascript
27
+ * let cart = [
28
+ * {article: "Toothpaste", price: 2.50, quantity: 1},
29
+ * {article: "Toothbrush", price: 6, quantity: 2},
30
+ * {article: "Banana", price: 0.50, quantity: 3},
31
+ * {article: "T-shirt", price: 14, quantity: 3}
32
+ * ];
33
+ * bbn.fn.sum(cart, a => a.price * a.quantity);
34
+ * // 58
35
+ * // Only the items with a quantity equal to 3
36
+ * bbn.fn.sum(cart, a => a.price * a.quantity, {quantity: 3});
37
+ * // 43.5
38
+ * ```
39
+ * @memberof bbn.fn
40
+ * @param {Array} arr The subject array
41
+ * @param {(String|Function)} numberProp The property's name for which the value should be added to the sum, or a function returning the number.
42
+ * @param {(String|Object|Function)} prop A property's name or a filter object or function
43
+ * @param {*} val The value with which comparing the given property
44
+ * @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
45
+ * @returns {Number} The sum
46
+ */
47
+ const sum = function (arr, numberProp, prop, val, operator) {
48
+ let r = 0;
49
+ each(filter(arr, prop, val, operator), (a) => {
50
+ let tmp = typeof numberProp === 'function' ? numberProp(a) : a[numberProp];
51
+ if (tmp) {
52
+ r += parseFloat(tmp) || 0;
53
+ }
54
+ });
55
+ return r;
56
+ };
57
+ export { sum };