@schukai/monster 1.31.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (365) hide show
  1. package/CHANGELOG +11 -0
  2. package/README.md +55 -58
  3. package/example/constraints/andoperator.mjs +17 -0
  4. package/example/constraints/invalid.mjs +6 -0
  5. package/example/constraints/isarray.mjs +11 -0
  6. package/example/constraints/isobject.mjs +12 -0
  7. package/example/constraints/oroperator.mjs +15 -0
  8. package/example/constraints/valid.mjs +6 -0
  9. package/example/data/buildmap.mjs +67 -0
  10. package/example/data/datasource.mjs +7 -0
  11. package/example/data/diff.mjs +39 -0
  12. package/example/data/pathfinder-1.mjs +23 -0
  13. package/example/data/pathfinder-2.mjs +19 -0
  14. package/example/data/pipe.mjs +14 -0
  15. package/example/data/storage/restapi.mjs +11 -0
  16. package/example/data/transformer.mjs +9 -0
  17. package/example/dom/customelement.mjs +13 -0
  18. package/example/dom/theme.mjs +5 -0
  19. package/example/dom/updater.mjs +23 -0
  20. package/example/i18n/formatter.mjs +10 -0
  21. package/example/i18n/providers/fetch.mjs +5 -0
  22. package/example/i18n/translations.mjs +20 -0
  23. package/example/types/basewithoptions.mjs +10 -0
  24. package/example/types/is-1.mjs +5 -0
  25. package/example/types/is-10.mjs +6 -0
  26. package/example/types/is-2.mjs +4 -0
  27. package/example/types/is-3.mjs +4 -0
  28. package/example/types/is-4.mjs +5 -0
  29. package/example/types/is-5.mjs +4 -0
  30. package/example/types/is-6.mjs +4 -0
  31. package/example/types/is-7.mjs +4 -0
  32. package/example/types/is-8.mjs +4 -0
  33. package/example/types/is-9.mjs +6 -0
  34. package/example/types/noderecursiveiterator.mjs +32 -0
  35. package/example/types/observer.mjs +9 -0
  36. package/example/types/proxyobserver.mjs +25 -0
  37. package/example/types/queue.mjs +20 -0
  38. package/example/types/tokenlist-1.mjs +4 -0
  39. package/example/types/tokenlist-2.mjs +7 -0
  40. package/example/types/tokenlist-3.mjs +5 -0
  41. package/example/types/tokenlist-4.mjs +5 -0
  42. package/example/types/tokenlist-5.mjs +5 -0
  43. package/example/types/typeof.mjs +9 -0
  44. package/example/types/version-1.mjs +6 -0
  45. package/example/types/version-2.mjs +3 -0
  46. package/example/util/comparator.mjs +10 -0
  47. package/example/util/deadmansswitch.mjs +9 -0
  48. package/example/util/processing.mjs +17 -0
  49. package/package.json +5 -59
  50. package/source/{constants.js → constants.mjs} +7 -10
  51. package/source/constraints/{abstract.js → abstract.mjs} +8 -9
  52. package/source/constraints/{abstractoperator.js → abstractoperator.mjs} +11 -8
  53. package/source/constraints/andoperator.mjs +38 -0
  54. package/source/constraints/invalid.mjs +38 -0
  55. package/source/constraints/isarray.mjs +41 -0
  56. package/source/constraints/isobject.mjs +41 -0
  57. package/source/constraints/{namespace.js → namespace.mjs} +3 -8
  58. package/source/constraints/{oroperator.js → oroperator.mjs} +10 -42
  59. package/source/constraints/valid.mjs +38 -0
  60. package/source/data/{buildmap.js → buildmap.mjs} +18 -104
  61. package/source/data/{buildtree.js → buildtree.mjs} +11 -31
  62. package/source/data/datasource/{namespace.js → namespace.mjs} +1 -9
  63. package/source/data/datasource/restapi/namespace.mjs +8 -0
  64. package/source/data/datasource/restapi/{writeerror.js → writeerror.mjs} +8 -9
  65. package/source/data/datasource/{restapi.js → restapi.mjs} +15 -45
  66. package/source/data/datasource/storage/localstorage.mjs +45 -0
  67. package/source/data/datasource/storage/{namespace.js → namespace.mjs} +1 -9
  68. package/source/data/datasource/storage/sessionstorage.mjs +45 -0
  69. package/source/data/datasource/{storage.js → storage.mjs} +12 -35
  70. package/source/data/{datasource.js → datasource.mjs} +17 -45
  71. package/source/data/{diff.js → diff.mjs} +10 -69
  72. package/source/data/{extend.js → extend.mjs} +10 -28
  73. package/source/data/{namespace.js → namespace.mjs} +2 -8
  74. package/source/data/{pathfinder.js → pathfinder.mjs} +18 -77
  75. package/source/data/{pipe.js → pipe.mjs} +14 -46
  76. package/source/data/{transformer.js → transformer.mjs} +18 -43
  77. package/source/dom/{assembler.js → assembler.mjs} +12 -28
  78. package/source/dom/{attributes.js → attributes.mjs} +42 -253
  79. package/source/dom/{constants.js → constants.mjs} +110 -61
  80. package/source/dom/{customcontrol.js → customcontrol.mjs} +10 -17
  81. package/source/dom/{customelement.js → customelement.mjs} +28 -52
  82. package/source/dom/{events.js → events.mjs} +15 -64
  83. package/source/dom/{focusmanager.js → focusmanager.mjs} +13 -34
  84. package/source/dom/{locale.js → locale.mjs} +11 -26
  85. package/source/dom/{namespace.js → namespace.mjs} +1 -8
  86. package/source/dom/{ready.js → ready.mjs} +12 -30
  87. package/source/dom/resource/{data.js → data.mjs} +11 -31
  88. package/source/dom/resource/link/namespace.mjs +10 -0
  89. package/source/dom/resource/link/stylesheet.mjs +35 -0
  90. package/source/dom/resource/{link.js → link.mjs} +9 -29
  91. package/source/dom/resource/namespace.mjs +8 -0
  92. package/source/dom/resource/{script.js → script.mjs} +9 -29
  93. package/source/dom/{resource.js → resource.mjs} +19 -39
  94. package/source/dom/{resourcemanager.js → resourcemanager.mjs} +17 -35
  95. package/source/dom/{template.js → template.mjs} +18 -43
  96. package/source/dom/{theme.js → theme.mjs} +14 -36
  97. package/source/dom/{updater.js → updater.mjs} +34 -68
  98. package/source/dom/{util.js → util.mjs} +17 -66
  99. package/source/dom/worker/{factory.js → factory.mjs} +13 -34
  100. package/source/dom/worker/namespace.mjs +8 -0
  101. package/source/i18n/{formatter.js → formatter.mjs} +14 -45
  102. package/source/i18n/{locale.js → locale.mjs} +15 -30
  103. package/source/i18n/{namespace.js → namespace.mjs} +1 -9
  104. package/source/i18n/provider.mjs +40 -0
  105. package/source/i18n/providers/{fetch.js → fetch.mjs} +18 -43
  106. package/source/i18n/providers/namespace.mjs +8 -0
  107. package/source/i18n/{translations.js → translations.mjs} +12 -52
  108. package/source/logging/handler/console.mjs +50 -0
  109. package/source/logging/handler/namespace.mjs +6 -0
  110. package/source/logging/{handler.js → handler.mjs} +13 -30
  111. package/source/logging/logentry.mjs +51 -0
  112. package/source/logging/{logger.js → logger.mjs} +12 -28
  113. package/source/logging/{namespace.js → namespace.mjs} +1 -9
  114. package/source/math/{namespace.js → namespace.mjs} +1 -9
  115. package/source/math/{random.js → random.mjs} +8 -34
  116. package/source/monster.mjs +114 -0
  117. package/source/text/{formatter.js → formatter.mjs} +17 -33
  118. package/source/text/{namespace.js → namespace.mjs} +1 -9
  119. package/source/types/base.mjs +31 -0
  120. package/source/types/{basewithoptions.js → basewithoptions.mjs} +17 -46
  121. package/source/types/{binary.js → binary.mjs} +10 -42
  122. package/source/types/{dataurl.js → dataurl.mjs} +12 -46
  123. package/source/types/{global.js → global.mjs} +20 -12
  124. package/source/types/{id.js → id.mjs} +10 -27
  125. package/source/types/is.mjs +225 -0
  126. package/source/types/{mediatype.js → mediatype.mjs} +13 -29
  127. package/source/types/{namespace.js → namespace.mjs} +1 -8
  128. package/source/types/{node.js → node.mjs} +11 -28
  129. package/source/types/{nodelist.js → nodelist.mjs} +17 -32
  130. package/source/types/{noderecursiveiterator.js → noderecursiveiterator.mjs} +14 -65
  131. package/source/types/{observer.js → observer.mjs} +15 -42
  132. package/source/types/{observerlist.js → observerlist.mjs} +12 -29
  133. package/source/types/{proxyobserver.js → proxyobserver.mjs} +19 -62
  134. package/source/types/{queue.js → queue.mjs} +10 -47
  135. package/source/types/randomid.mjs +45 -0
  136. package/source/types/regex.mjs +27 -0
  137. package/source/types/{stack.js → stack.mjs} +8 -24
  138. package/source/types/{tokenlist.js → tokenlist.mjs} +20 -64
  139. package/source/types/typeof.mjs +37 -0
  140. package/source/types/{uniquequeue.js → uniquequeue.mjs} +11 -27
  141. package/source/types/{uuid.js → uuid.mjs} +15 -33
  142. package/source/types/{validate.js → validate.mjs} +38 -155
  143. package/source/types/{version.js → version.mjs} +19 -62
  144. package/source/util/{clone.js → clone.mjs} +10 -28
  145. package/source/util/{comparator.js → comparator.mjs} +13 -43
  146. package/source/util/{deadmansswitch.js → deadmansswitch.mjs} +15 -40
  147. package/source/util/freeze.mjs +39 -0
  148. package/source/util/{namespace.js → namespace.mjs} +1 -9
  149. package/source/util/{processing.js → processing.mjs} +13 -51
  150. package/source/util/{trimspaces.js → trimspaces.mjs} +14 -21
  151. package/test/cases/constraint/{andoperator.js → andoperator.mjs} +3 -3
  152. package/test/cases/constraint/{invalid.js → invalid.mjs} +1 -1
  153. package/test/cases/constraint/{isarray.js → isarray.mjs} +1 -1
  154. package/test/cases/constraint/{isobject.js → isobject.mjs} +1 -1
  155. package/test/cases/constraint/{oroperator.js → oroperator.mjs} +3 -3
  156. package/test/cases/constraint/{valid.js → valid.mjs} +1 -1
  157. package/test/cases/data/{buildmap.js → buildmap.mjs} +1 -1
  158. package/test/cases/data/{buildtree.js → buildtree.mjs} +2 -2
  159. package/test/cases/data/datasource/{restapi.js → restapi.mjs} +5 -5
  160. package/test/cases/data/datasource/storage/{localstorage.js → localstorage.mjs} +5 -5
  161. package/test/cases/data/datasource/storage/{sessionstorage.js → sessionstorage.mjs} +5 -5
  162. package/test/cases/data/{datasource.js → datasource.mjs} +1 -1
  163. package/test/cases/data/{diff.js → diff.mjs} +2 -2
  164. package/test/cases/data/{extend.js → extend.mjs} +1 -1
  165. package/test/cases/data/{pathfinder.js → pathfinder.mjs} +1 -1
  166. package/test/cases/data/{pipe.js → pipe.mjs} +19 -5
  167. package/test/cases/data/{transformer.js → transformer.mjs} +14 -10
  168. package/test/cases/dom/{assembler.js → assembler.mjs} +2 -2
  169. package/test/cases/dom/{attributes.js → attributes.mjs} +2 -2
  170. package/test/cases/dom/{customcontrol.js → customcontrol.mjs} +6 -6
  171. package/test/cases/dom/{customelement.js → customelement.mjs} +6 -6
  172. package/test/cases/dom/{events.js → events.mjs} +2 -2
  173. package/test/cases/dom/{focusmanager.js → focusmanager.mjs} +3 -3
  174. package/test/cases/dom/{locale.js → locale.mjs} +2 -2
  175. package/test/cases/dom/{ready.js → ready.mjs} +2 -2
  176. package/test/cases/dom/resource/{data.js → data.mjs} +9 -9
  177. package/test/cases/dom/resource/link/{stylesheet.js → stylesheet.mjs} +6 -6
  178. package/test/cases/dom/resource/{link.js → link.mjs} +6 -6
  179. package/test/cases/dom/resource/{script.js → script.mjs} +6 -6
  180. package/test/cases/dom/{resourcemanager.js → resourcemanager.mjs} +6 -6
  181. package/test/cases/dom/{template.js → template.mjs} +3 -3
  182. package/test/cases/dom/{theme.js → theme.mjs} +3 -3
  183. package/test/cases/dom/{updater.js → updater.mjs} +6 -6
  184. package/test/cases/dom/{util.js → util.mjs} +2 -2
  185. package/test/cases/dom/worker/{factory.js → factory.mjs} +4 -4
  186. package/test/cases/i18n/{formatter.js → formatter.mjs} +2 -2
  187. package/test/cases/i18n/{locale.js → locale.mjs} +1 -1
  188. package/test/cases/i18n/{provider.js → provider.mjs} +1 -1
  189. package/test/cases/i18n/providers/{fetch.js → fetch.mjs} +3 -3
  190. package/test/cases/i18n/{translations.js → translations.mjs} +2 -2
  191. package/test/cases/logging/handler/{console.js → console.mjs} +3 -3
  192. package/test/cases/logging/{handler.js → handler.mjs} +3 -3
  193. package/test/cases/logging/{logentry.js → logentry.mjs} +1 -1
  194. package/test/cases/logging/{logger.js → logger.mjs} +1 -1
  195. package/test/cases/math/random.mjs +101 -0
  196. package/test/cases/monster.mjs +20 -0
  197. package/test/cases/text/{formatter.js → formatter.mjs} +1 -1
  198. package/test/cases/types/{base.js → base.mjs} +1 -1
  199. package/test/cases/types/{basewithoptions.js → basewithoptions.mjs} +1 -1
  200. package/test/cases/types/{binary.js → binary.mjs} +1 -1
  201. package/test/cases/types/{dataurl.js → dataurl.mjs} +1 -1
  202. package/test/cases/types/{global.js → global.mjs} +1 -1
  203. package/test/cases/types/{id.js → id.mjs} +17 -6
  204. package/test/cases/types/{is.js → is.mjs} +20 -8
  205. package/test/cases/types/{mediatype.js → mediatype.mjs} +1 -1
  206. package/test/cases/types/{node.js → node.mjs} +3 -3
  207. package/test/cases/types/{nodelist.js → nodelist.mjs} +2 -2
  208. package/test/cases/types/{noderecursiveiterator.js → noderecursiveiterator.mjs} +3 -3
  209. package/test/cases/types/{observer.js → observer.mjs} +1 -1
  210. package/test/cases/types/{observerlist.js → observerlist.mjs} +2 -2
  211. package/test/cases/types/{proxyobserver.js → proxyobserver.mjs} +4 -4
  212. package/test/cases/types/{queue.js → queue.mjs} +1 -1
  213. package/test/cases/types/randomid.mjs +39 -0
  214. package/test/cases/types/regex.mjs +46 -0
  215. package/test/cases/types/{stack.js → stack.mjs} +1 -1
  216. package/test/cases/types/{tokenlist.js → tokenlist.mjs} +1 -1
  217. package/test/cases/types/{typeof.js → typeof.mjs} +3 -4
  218. package/test/cases/types/{uniquequeue.js → uniquequeue.mjs} +1 -1
  219. package/test/cases/types/{uuid.js → uuid.mjs} +30 -10
  220. package/test/cases/types/{validate.js → validate.mjs} +3 -4
  221. package/test/cases/types/{version.js → version.mjs} +1 -2
  222. package/test/cases/util/{clone.js → clone.mjs} +1 -1
  223. package/test/cases/util/{comparator.js → comparator.mjs} +1 -1
  224. package/test/cases/util/{deadmansswitch.js → deadmansswitch.mjs} +1 -1
  225. package/test/cases/util/{freeze.js → freeze.mjs} +1 -1
  226. package/test/cases/util/{processing.js → processing.mjs} +1 -1
  227. package/test/cases/util/{trimspaces.js → trimspaces.mjs} +1 -1
  228. package/test/util/{chai-dom.js → chai-dom.mjs} +0 -0
  229. package/test/util/{cleanupdom.js → cleanupdom.mjs} +0 -0
  230. package/test/util/{jsdom.js → jsdom.mjs} +2 -2
  231. package/test/util/{localstorage.js → localstorage.mjs} +0 -0
  232. package/test/web/import.js +77 -78
  233. package/test/web/prepare.js +0 -8
  234. package/test/web/test.html +5 -4
  235. package/test/web/tests.js +25731 -587
  236. package/dist/modules/constants.js +0 -2
  237. package/dist/modules/constraints/abstract.js +0 -2
  238. package/dist/modules/constraints/abstractoperator.js +0 -2
  239. package/dist/modules/constraints/andoperator.js +0 -2
  240. package/dist/modules/constraints/invalid.js +0 -2
  241. package/dist/modules/constraints/isarray.js +0 -2
  242. package/dist/modules/constraints/isobject.js +0 -2
  243. package/dist/modules/constraints/namespace.js +0 -2
  244. package/dist/modules/constraints/oroperator.js +0 -2
  245. package/dist/modules/constraints/valid.js +0 -2
  246. package/dist/modules/data/buildmap.js +0 -2
  247. package/dist/modules/data/buildtree.js +0 -2
  248. package/dist/modules/data/datasource/namespace.js +0 -2
  249. package/dist/modules/data/datasource/restapi/writeerror.js +0 -2
  250. package/dist/modules/data/datasource/restapi.js +0 -2
  251. package/dist/modules/data/datasource/storage/localstorage.js +0 -2
  252. package/dist/modules/data/datasource/storage/namespace.js +0 -2
  253. package/dist/modules/data/datasource/storage/sessionstorage.js +0 -2
  254. package/dist/modules/data/datasource/storage.js +0 -2
  255. package/dist/modules/data/datasource.js +0 -2
  256. package/dist/modules/data/diff.js +0 -2
  257. package/dist/modules/data/extend.js +0 -2
  258. package/dist/modules/data/namespace.js +0 -2
  259. package/dist/modules/data/pathfinder.js +0 -2
  260. package/dist/modules/data/pipe.js +0 -2
  261. package/dist/modules/data/transformer.js +0 -2
  262. package/dist/modules/dom/assembler.js +0 -2
  263. package/dist/modules/dom/attributes.js +0 -2
  264. package/dist/modules/dom/constants.js +0 -2
  265. package/dist/modules/dom/customcontrol.js +0 -2
  266. package/dist/modules/dom/customelement.js +0 -2
  267. package/dist/modules/dom/events.js +0 -2
  268. package/dist/modules/dom/focusmanager.js +0 -2
  269. package/dist/modules/dom/locale.js +0 -2
  270. package/dist/modules/dom/namespace.js +0 -2
  271. package/dist/modules/dom/ready.js +0 -2
  272. package/dist/modules/dom/resource/data.js +0 -2
  273. package/dist/modules/dom/resource/link/stylesheet.js +0 -2
  274. package/dist/modules/dom/resource/link.js +0 -2
  275. package/dist/modules/dom/resource/script.js +0 -2
  276. package/dist/modules/dom/resource.js +0 -2
  277. package/dist/modules/dom/resourcemanager.js +0 -2
  278. package/dist/modules/dom/template.js +0 -2
  279. package/dist/modules/dom/theme.js +0 -2
  280. package/dist/modules/dom/updater.js +0 -2
  281. package/dist/modules/dom/util.js +0 -2
  282. package/dist/modules/dom/worker/factory.js +0 -2
  283. package/dist/modules/i18n/formatter.js +0 -2
  284. package/dist/modules/i18n/locale.js +0 -2
  285. package/dist/modules/i18n/namespace.js +0 -2
  286. package/dist/modules/i18n/provider.js +0 -2
  287. package/dist/modules/i18n/providers/fetch.js +0 -2
  288. package/dist/modules/i18n/providers/namespace.js +0 -2
  289. package/dist/modules/i18n/translations.js +0 -2
  290. package/dist/modules/logging/handler/console.js +0 -2
  291. package/dist/modules/logging/handler/namespace.js +0 -2
  292. package/dist/modules/logging/handler.js +0 -2
  293. package/dist/modules/logging/logentry.js +0 -2
  294. package/dist/modules/logging/logger.js +0 -2
  295. package/dist/modules/logging/namespace.js +0 -2
  296. package/dist/modules/math/namespace.js +0 -2
  297. package/dist/modules/math/random.js +0 -2
  298. package/dist/modules/monster.js +0 -2
  299. package/dist/modules/namespace.js +0 -2
  300. package/dist/modules/text/formatter.js +0 -2
  301. package/dist/modules/text/namespace.js +0 -2
  302. package/dist/modules/types/base.js +0 -2
  303. package/dist/modules/types/basewithoptions.js +0 -2
  304. package/dist/modules/types/binary.js +0 -2
  305. package/dist/modules/types/dataurl.js +0 -2
  306. package/dist/modules/types/global.js +0 -2
  307. package/dist/modules/types/id.js +0 -2
  308. package/dist/modules/types/is.js +0 -2
  309. package/dist/modules/types/mediatype.js +0 -2
  310. package/dist/modules/types/namespace.js +0 -2
  311. package/dist/modules/types/node.js +0 -2
  312. package/dist/modules/types/nodelist.js +0 -2
  313. package/dist/modules/types/noderecursiveiterator.js +0 -2
  314. package/dist/modules/types/observer.js +0 -2
  315. package/dist/modules/types/observerlist.js +0 -2
  316. package/dist/modules/types/proxyobserver.js +0 -2
  317. package/dist/modules/types/queue.js +0 -2
  318. package/dist/modules/types/randomid.js +0 -2
  319. package/dist/modules/types/regex.js +0 -2
  320. package/dist/modules/types/stack.js +0 -2
  321. package/dist/modules/types/tokenlist.js +0 -2
  322. package/dist/modules/types/typeof.js +0 -2
  323. package/dist/modules/types/uniquequeue.js +0 -2
  324. package/dist/modules/types/uuid.js +0 -2
  325. package/dist/modules/types/validate.js +0 -2
  326. package/dist/modules/types/version.js +0 -2
  327. package/dist/modules/util/clone.js +0 -2
  328. package/dist/modules/util/comparator.js +0 -2
  329. package/dist/modules/util/deadmansswitch.js +0 -2
  330. package/dist/modules/util/freeze.js +0 -2
  331. package/dist/modules/util/namespace.js +0 -2
  332. package/dist/modules/util/processing.js +0 -2
  333. package/dist/modules/util/trimspaces.js +0 -2
  334. package/dist/monster.dev.js +0 -15490
  335. package/dist/monster.dev.js.map +0 -1
  336. package/dist/monster.js +0 -2
  337. package/source/constraints/andoperator.js +0 -71
  338. package/source/constraints/invalid.js +0 -63
  339. package/source/constraints/isarray.js +0 -71
  340. package/source/constraints/isobject.js +0 -72
  341. package/source/constraints/valid.js +0 -63
  342. package/source/data/datasource/storage/localstorage.js +0 -64
  343. package/source/data/datasource/storage/sessionstorage.js +0 -61
  344. package/source/dom/resource/link/stylesheet.js +0 -54
  345. package/source/i18n/provider.js +0 -58
  346. package/source/i18n/providers/namespace.js +0 -16
  347. package/source/logging/handler/console.js +0 -66
  348. package/source/logging/handler/namespace.js +0 -14
  349. package/source/logging/logentry.js +0 -68
  350. package/source/monster.js +0 -80
  351. package/source/namespace.js +0 -171
  352. package/source/types/base.js +0 -50
  353. package/source/types/is.js +0 -429
  354. package/source/types/package.d.ts +0 -1
  355. package/source/types/randomid.js +0 -60
  356. package/source/types/regex.js +0 -49
  357. package/source/types/typeof.js +0 -63
  358. package/source/util/freeze.js +0 -57
  359. package/test/cases/math/random.js +0 -82
  360. package/test/cases/monster.js +0 -23
  361. package/test/cases/namespace.js +0 -93
  362. package/test/cases/types/randomid.js +0 -24
  363. package/test/cases/types/regex.js +0 -32
  364. package/test/web/monster-dev.html +0 -22
  365. package/test/web/monster.html +0 -21
@@ -1,429 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * @author schukai GmbH
5
- */
6
-
7
- import {assignToNamespace, Monster} from '../namespace.js';
8
-
9
- /**
10
- * With this function you can check if a value is iterable.
11
- *
12
- * This method is used in the library to have consistent names.
13
- *
14
- * You can call the method via the monster namespace `Monster.Types.isPrimitive()`.
15
- *
16
- * ```
17
- * <script type="module">
18
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
19
- * Monster.Types.isIterable(null) // ↦ false
20
- * Monster.Types.isIterable('hello') // ↦ true
21
- * Monster.Types.isIterable([]) // ↦ true
22
- * </script>
23
- * ```
24
- *
25
- * Alternatively, you can also integrate this function individually.
26
- *
27
- * ```
28
- * <script type="module">
29
- * import {isIterable} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/is.js';
30
- * isIterable(null) // ↦ false
31
- * isIterable('hello') // ↦ true
32
- * isIterable([]) // ↦ true
33
- * </script>
34
- * ```
35
- *
36
- * @param {*} value
37
- * @returns {boolean}
38
- * @since 1.2.0
39
- * @copyright schukai GmbH
40
- * @memberOf Monster.Types
41
- */
42
- function isIterable(value) {
43
- if (value === undefined) return false;
44
- if (value === null) return false;
45
- return typeof value?.[Symbol.iterator] === 'function';
46
- }
47
-
48
-
49
- /**
50
- * Checks whether the value passed is a primitive (string, number, boolean, NaN, undefined, null or symbol)
51
- *
52
- * This method is used in the library to have consistent names.
53
- *
54
- * You can call the method via the monster namespace `Monster.Types.isPrimitive()`.
55
- *
56
- * ```
57
- * <script type="module">
58
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
59
- * Monster.Types.isPrimitive('2') // ↦ false
60
- * Monster.Types.isPrimitive([]) // ↦ true
61
- * </script>
62
- * ```
63
- *
64
- * Alternatively, you can also integrate this function individually.
65
- *
66
- * ```
67
- * <script type="module">
68
- * import {isPrimitive} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/is.js';
69
- * isPrimitive('2')) // ↦ true
70
- * isPrimitive([])) // ↦ false
71
- * </script>
72
- * ```
73
- *
74
- * @param {*} value
75
- * @returns {boolean}
76
- * @since 1.0.0
77
- * @copyright schukai GmbH
78
- * @memberOf Monster.Types
79
- */
80
- function isPrimitive(value) {
81
- var type;
82
-
83
- if (value === undefined || value === null) {
84
- return true;
85
- }
86
-
87
- type = typeof value;
88
-
89
- if (type === 'string' || type === 'number' || type === 'boolean' || type === 'symbol') {
90
- return true;
91
- }
92
-
93
- return false;
94
- }
95
-
96
- /**
97
- * Checks whether the value passed is a symbol
98
- *
99
- * This method is used in the library to have consistent names.
100
- *
101
- * You can call the method via the monster namespace `Monster.Types.isSymbol()`.
102
- *
103
- * ```
104
- * <script type="module">
105
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
106
- * Monster.Types.isSymbol('2') // ↦ false
107
- * Monster.Types.isSymbol(Symbol('test') // ↦ true
108
- * </script>
109
- * ```
110
- *
111
- * Alternatively, you can also integrate this function individually.
112
- *
113
- * ```
114
- * <script type="module">
115
- * import {isSymbol} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/is.js';
116
- * isSymbol(Symbol('a'))) // ↦ true
117
- * isSymbol([]) // ↦ false
118
- * </script>
119
- * ```
120
- *
121
- * @param {*} value
122
- * @returns {boolean}
123
- * @since 1.9.0
124
- * @copyright schukai GmbH
125
- * @memberOf Monster.Types
126
- */
127
- function isSymbol(value) {
128
- return ('symbol' === typeof value) ? true : false;
129
- }
130
-
131
- /**
132
- * Checks whether the value passed is a boolean.
133
- *
134
- * This method is used in the library to have consistent names.
135
- *
136
- * You can call the method via the monster namespace `Monster.Types.isBoolean()`.
137
- *
138
- * ```
139
- * <script type="module">
140
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
141
- * Monster.Types.isBoolean('2') // ↦ false
142
- * Monster.Types.isBoolean([]) // ↦ false
143
- * Monster.Types.isBoolean(true) // ↦ true
144
- * </script>
145
- * ```
146
- *
147
- * Alternatively, you can also integrate this function individually.
148
- *
149
- * ```
150
- * <script type="module">
151
- * import {isBoolean} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/is.js';
152
- * isBoolean('2')) // ↦ false
153
- * isBoolean([])) // ↦ false
154
- * isBoolean(2>4)) // ↦ true
155
- * </script>
156
- * ```
157
- *
158
- * @param {*} value
159
- * @returns {boolean}
160
- * @since 1.0.0
161
- * @copyright schukai GmbH
162
- * @memberOf Monster.Types
163
- */
164
- function isBoolean(value) {
165
-
166
- if (value === true || value === false) {
167
- return true;
168
- }
169
-
170
- return false;
171
- }
172
-
173
- /**
174
- * Checks whether the value passed is a string
175
- *
176
- * This method is used in the library to have consistent names.
177
- *
178
- * You can call the method via the monster namespace `Monster.Types.isString()`.
179
- *
180
- * ```
181
- * <script type="module">
182
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
183
- * Monster.Types.isString('2') // ↦ true
184
- * Monster.Types.isString([]) // ↦ false
185
- * </script>
186
- * ```
187
- *
188
- * Alternatively, you can also integrate this function individually.
189
- *
190
- * ```
191
- * <script type="module">
192
- * import {isString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/is.js';
193
- * isString('2')) // ↦ true
194
- * isString([])) // ↦ false
195
- * </script>
196
- * ```
197
- *
198
- * @param {*} value
199
- * @returns {boolean}
200
- * @since 1.0.0
201
- * @copyright schukai GmbH
202
- * @memberOf Monster.Types
203
- */
204
- function isString(value) {
205
- if (value === undefined || typeof value !== 'string') {
206
- return false;
207
- }
208
- return true;
209
- }
210
-
211
- /**
212
- * Checks whether the value passed is a object
213
- *
214
- * This method is used in the library to have consistent names.
215
- *
216
- * You can call the method via the monster namespace `Monster.Types.isObject()`.
217
- *
218
- * ```
219
- * <script type="module">
220
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
221
- * Monster.Types.isObject('2') // ↦ false
222
- * Monster.Types.isObject([]) // ↦ false
223
- * Monster.Types.isObject({}) // ↦ true
224
- * </script>
225
- * ```
226
- *
227
- * Alternatively, you can also integrate this function individually.
228
- *
229
- * ```
230
- * <script type="module">
231
- * import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/is.js';
232
- * isObject('2')) // ↦ false
233
- * isObject([])) // ↦ false
234
- * </script>
235
- * ```
236
- *
237
- * @param {*} value
238
- * @returns {boolean}
239
- * @since 1.0.0
240
- * @copyright schukai GmbH
241
- * @memberOf Monster.Types
242
- */
243
- function isObject(value) {
244
-
245
- if (isArray(value)) return false;
246
- if (isPrimitive(value)) return false;
247
-
248
- if (typeof value === 'object') {
249
- return true;
250
- }
251
-
252
- return false;
253
- }
254
-
255
- /**
256
- * Checks whether the value passed is a object and instance of instance.
257
- *
258
- * This method is used in the library to have consistent names.
259
- *
260
- * you can call the method via the monster namespace `Monster.Types.isInstance()`.
261
- *
262
- * ```
263
- * <script type="module">
264
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
265
- * Monster.Types.isInstance('2') // ↦ false
266
- * Monster.Types.isInstance([]) // ↦ false
267
- * Monster.Types.isInstance({}) // ↦ true
268
- * </script>
269
- * ```
270
- *
271
- * Alternatively, you can also integrate this function individually.
272
- *
273
- * ```
274
- * <script type="module">
275
- * import {isInstance} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/is.js';
276
- * isInstance('2')) // ↦ false
277
- * isInstance([])) // ↦ false
278
- * </script>
279
- * ```
280
- *
281
- * @param {*} value
282
- * @param {*} instance
283
- * @returns {boolean}
284
- * @since 1.5.0
285
- * @copyright schukai GmbH
286
- * @memberOf Monster.Types
287
- */
288
- function isInstance(value, instance) {
289
-
290
- if (!isObject(value)) return false;
291
- if (!isFunction(instance)) return false;
292
- if (!instance.hasOwnProperty('prototype')) return false;
293
- return (value instanceof instance) ? true : false;
294
-
295
- }
296
-
297
- /**
298
- * Checks whether the value passed is a array
299
- *
300
- * This method is used in the library to have consistent names.
301
- *
302
- * you can call the method via the monster namespace `Monster.Types.isArray()`.
303
- *
304
- * ```
305
- * <script type="module">
306
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
307
- * Monster.Types.isArray('2') // ↦ false
308
- * Monster.Types.isArray([]) // ↦ true
309
- * </script>
310
- * ```
311
- *
312
- * Alternatively, you can also integrate this function individually.
313
- *
314
- * ```
315
- * <script type="module">
316
- * import {isArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/is.js';
317
- * isArray('2')) // ↦ false
318
- * isArray([])) // ↦ true
319
- * </script>
320
- * ```
321
- *
322
- * @param {*} value
323
- * @returns {boolean}
324
- * @since 1.0.0
325
- * @copyright schukai GmbH
326
- * @memberOf Monster.Types
327
- * @see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
328
- */
329
- function isArray(value) {
330
- return Array.isArray(value);
331
- }
332
-
333
- /**
334
- * Checks whether the value passed is a function
335
- *
336
- * This method is used in the library to have consistent names.
337
- *
338
- * you can call the method via the monster namespace `Monster.Types.isFunction()`.
339
- *
340
- * ```
341
- * <script type="module">
342
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
343
- * Monster.Types.isFunction(()=>{}) // ↦ true
344
- * Monster.Types.isFunction('2') // ↦ false
345
- * Monster.Types.isFunction([]) // ↦ false
346
- * </script>
347
- * ```
348
- *
349
- * Alternatively, you can also integrate this function individually.
350
- *
351
- * ```
352
- * <script type="module">
353
- * import {isFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/is.js';
354
- * isFunction(()=>{}) // ↦ true
355
- * isFunction('2')) // ↦ false
356
- * isFunction([])) // ↦ false
357
- * </script>
358
- * ```
359
- *
360
- * @param {*} value
361
- * @returns {boolean}
362
- * @since 1.0.0
363
- * @copyright schukai GmbH
364
- * @memberOf Monster.Types
365
- */
366
- function isFunction(value) {
367
- if (isArray(value)) return false;
368
- if (isPrimitive(value)) return false;
369
-
370
- if (typeof value === 'function') {
371
- return true;
372
- }
373
-
374
- return false;
375
-
376
- }
377
-
378
- /**
379
- * Checks whether the value passed is an integer.
380
- *
381
- * This method is used in the library to have consistent names.
382
- *
383
- * You can call the method via the monster namespace `Monster.Types.isFunction()`.
384
- *
385
- * ```
386
- * <script type="module">
387
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
388
- * Monster.Types.isInteger(()=>{}) // ↦ true
389
- * Monster.Types.isInteger('2') // ↦ false
390
- * Monster.Types.isInteger(2) // ↦ true
391
- * </script>
392
- * ```
393
- *
394
- * Alternatively, you can also integrate this function individually.
395
- *
396
- * ```
397
- * <script type="module">
398
- * import {isInteger} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/is.js';
399
- * isInteger(()=>{}) // ↦ true
400
- * isInteger('2')) // ↦ false
401
- * isInteger(2)) // ↦ true
402
- * </script>
403
- * ```
404
- *
405
- * @param {*} value
406
- * @returns {boolean}
407
- * @since 1.4.0
408
- * @copyright schukai GmbH
409
- * @memberOf Monster.Types
410
- */
411
- function isInteger(value) {
412
- return Number.isInteger(value);
413
- }
414
-
415
-
416
- assignToNamespace('Monster.Types', isPrimitive, isBoolean, isString, isObject, isArray, isFunction, isIterable, isInteger, isSymbol);
417
- export {
418
- Monster,
419
- isPrimitive,
420
- isBoolean,
421
- isString,
422
- isObject,
423
- isInstance,
424
- isArray,
425
- isFunction,
426
- isIterable,
427
- isInteger,
428
- isSymbol
429
- }
@@ -1 +0,0 @@
1
- export declare let Monster: Object;
@@ -1,60 +0,0 @@
1
- 'use strict';
2
-
3
- import {random} from "../math/random.js";
4
- /**
5
- * @author schukai GmbH
6
- */
7
- import {assignToNamespace, Monster} from '../namespace.js';
8
- import {getGlobal} from "./global.js";
9
- import {ID} from "./id.js";
10
-
11
- /**
12
- * @private
13
- * @type {number}
14
- */
15
- let internalCounter = 0;
16
-
17
- /**
18
- * You can call the method via the monster namespace `new Monster.Types.RandomID()`.
19
- *
20
- * ```
21
- * <script type="module">
22
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
23
- * console.log(new Monster.Types.RandomID())
24
- * </script>
25
- * ```
26
- *
27
- * Alternatively, you can also integrate this function individually.
28
- *
29
- * ```
30
- * <script type="module">
31
- * import {RandomID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/randomid.js';
32
- * console.log(new RandomID())
33
- * </script>
34
- * ```
35
- *
36
- * @since 1.6.0
37
- * @copyright schukai GmbH
38
- * @memberOf Monster.Types
39
- * @summary class to generate random numbers
40
- */
41
- class RandomID extends ID {
42
-
43
- /**
44
- * create new object
45
- */
46
- constructor() {
47
- super();
48
-
49
- internalCounter += 1;
50
-
51
- this.id = getGlobal().btoa(random(1, 10000))
52
- .replace(/=/g, '')
53
- /** No numbers at the beginning of the ID, because of possible problems with DOM */
54
- .replace(/^[0-9]+/, 'X') + internalCounter;
55
- }
56
-
57
- }
58
-
59
- assignToNamespace('Monster.Types', RandomID);
60
- export {Monster, RandomID}
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * @author schukai GmbH
5
- */
6
-
7
-
8
- import {assignToNamespace, Monster} from "../namespace.js";
9
- import {validateString} from "./validate.js";
10
-
11
- /**
12
- * This function prefixes all special characters that may appear in a regex with a slash.
13
- *
14
- * You can call the method via the monster namespace `Monster.Types.escapeString()`.
15
- *
16
- * ```
17
- * <script type="module">
18
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
19
- * Monster.Types.escapeString()
20
- * </script>
21
- * ```
22
- *
23
- * Alternatively, you can also integrate this function individually.
24
- *
25
- * ```
26
- * <script type="module">
27
- * import {escapeString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/validate.js';
28
- * escapeString()
29
- * </script>
30
- * ```
31
- *
32
- * @param {string} value
33
- * @return {string}
34
- * @since 1.26.0
35
- * @copyright schukai GmbH
36
- * @memberOf Monster.Types
37
- * @throws {TypeError} value is not a string
38
- */
39
- function escapeString(value) {
40
- return validateString(value)
41
- .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
42
- .replace(/-/g, '\\x2d');
43
- }
44
-
45
- assignToNamespace('Monster.Types', escapeString);
46
- export {
47
- Monster,
48
- escapeString
49
- }
@@ -1,63 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * @author schukai GmbH
5
- */
6
-
7
-
8
- import {assignToNamespace, Monster} from '../namespace.js';
9
-
10
- /**
11
- * The built-in typeof method is known to have some historical weaknesses. This function tries to provide a better and more accurate result.
12
- *
13
- * You can call the method via the monster namespace `Monster.Types.typeOf()`.
14
- *
15
- * ```
16
- * <script type="module">
17
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
18
- * console.log(Monster.Types.typeOf())
19
- * </script>
20
- * ```
21
- *
22
- * Alternatively, you can also integrate this function individually.
23
- *
24
- * ```
25
- * <script type="module">
26
- * import {typeOf} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/typeof.js';
27
- * console.log(typeOf())
28
- * </script>
29
- * ```
30
- *
31
- * @example
32
- *
33
- * import {typeOf} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/types/typeof.js';
34
- *
35
- * console.log(typeOf(undefined)); // ↦ undefined
36
- * console.log(typeOf("")); // ↦ string
37
- * console.log(typeOf(5)); // ↦ number
38
- * console.log(typeOf({})); // ↦ object
39
- * console.log(typeOf([])); // ↦ array
40
- * console.log(typeOf(new Map)); // ↦ map
41
- * console.log(typeOf(true)); // ↦ boolean
42
- *
43
- * @param {*} value
44
- * @return {string}
45
- * @since 1.7.0
46
- * @copyright schukai GmbH
47
- * @memberOf Monster.Types
48
- * @throws {TypeError} value is not a primitive
49
- */
50
- function typeOf(value) {
51
- let type = ({}).toString.call(value).match(/\s([a-zA-Z]+)/)[1];
52
- if ('Object' === type) {
53
- const results = (/^(class|function)\s+(\w+)/).exec(value.constructor.toString());
54
- type = (results && results.length > 2) ? results[2] : '';
55
- }
56
- return type.toLowerCase();
57
- }
58
-
59
- assignToNamespace('Monster.Types', typeOf);
60
- export {
61
- Monster,
62
- typeOf
63
- }
@@ -1,57 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * @author schukai GmbH
5
- */
6
-
7
- import {assignToNamespace, Monster} from '../namespace.js';
8
- import {validateObject} from '../types/validate.js';
9
-
10
- /**
11
- * Deep freeze a object
12
- *
13
- * You can call the method via the monster namespace `Monster.Util.deepFreeze()`.
14
- *
15
- * ```
16
- * <script type="module">
17
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/monster.js';
18
- * Monster.Util.deepFreeze({})
19
- * </script>
20
- * ```
21
- *
22
- * Alternatively, you can also integrate this function individually.
23
- *
24
- * ```
25
- * <script type="module">
26
- * import {deepFreeze} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.31.0/dist/modules/util/freeze.js';
27
- * deepFreeze({})
28
- * </script>
29
- * ```
30
- *
31
- * @param {object} object object to be freeze
32
- * @since 1.0.0
33
- * @returns {object}
34
- * @memberOf Monster.Util
35
- * @copyright schukai GmbH
36
- * @throws {TypeError} value is not a object
37
- */
38
- function deepFreeze(object) {
39
-
40
- validateObject(object)
41
-
42
- // Retrieve the defined property names of the object
43
- var propNames = Object.getOwnPropertyNames(object);
44
-
45
- // Freeze properties before freezing yourself
46
- for (let name of propNames) {
47
- let value = object[name];
48
-
49
- object[name] = (value && typeof value === "object") ?
50
- deepFreeze(value) : value;
51
- }
52
-
53
- return Object.freeze(object);
54
- }
55
-
56
- assignToNamespace('Monster.Util', deepFreeze);
57
- export {Monster, deepFreeze}