tool-shack 0.0.9 → 0.0.13

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 (85) hide show
  1. package/dist/browser/index.d.ts +2 -0
  2. package/dist/browser/index.js +2 -0
  3. package/dist/browser/index.js.map +1 -1
  4. package/dist/browser/isPushNotificationSupported.d.ts +6 -0
  5. package/dist/browser/isPushNotificationSupported.js +7 -0
  6. package/dist/browser/isPushNotificationSupported.js.map +1 -0
  7. package/dist/browser/isShareSupported.d.ts +6 -0
  8. package/dist/browser/isShareSupported.js +7 -0
  9. package/dist/browser/isShareSupported.js.map +1 -0
  10. package/dist/browser/isTouchSupported.d.ts +1 -1
  11. package/dist/browser/isTouchSupported.js +4 -2
  12. package/dist/browser/isTouchSupported.js.map +1 -1
  13. package/dist/browser/preferColorScheme.js +2 -2
  14. package/dist/browser/preferColorScheme.js.map +1 -1
  15. package/dist/browser/tabFocusListener.js.map +1 -1
  16. package/dist/dateTime/dateAsIso.js.map +1 -1
  17. package/dist/dateTime/parseDuration.js.map +1 -1
  18. package/dist/dom/addAsyncEventListener.js.map +1 -1
  19. package/dist/dom/addEventListener.js +3 -3
  20. package/dist/dom/addEventListener.js.map +1 -1
  21. package/dist/dom/createElement.d.ts +1 -1
  22. package/dist/dom/createElement.js +5 -0
  23. package/dist/dom/createElement.js.map +1 -1
  24. package/dist/dom/fireEvent.js.map +1 -1
  25. package/dist/dom/interfaces/createElement.d.ts +2 -1
  26. package/dist/schedule/runAsync.js +1 -1
  27. package/dist/schedule/runAsync.js.map +1 -1
  28. package/dist/string/byteSize.d.ts +7 -0
  29. package/dist/string/byteSize.js +8 -0
  30. package/dist/string/byteSize.js.map +1 -0
  31. package/dist/string/escapeHTML.js.map +1 -1
  32. package/dist/string/index.d.ts +1 -0
  33. package/dist/string/index.js +1 -0
  34. package/dist/string/index.js.map +1 -1
  35. package/docs/assets/highlight.css +22 -22
  36. package/docs/assets/main.js +52 -52
  37. package/docs/assets/search.js +1 -1
  38. package/docs/assets/style.css +1413 -1388
  39. package/docs/interfaces/dateTime.IDuration.html +1 -1
  40. package/docs/interfaces/dom.IExtendingElementProps.html +1 -1
  41. package/docs/modules/browser.html +14 -8
  42. package/docs/modules/dateTime.html +2 -2
  43. package/docs/modules/dom.html +8 -8
  44. package/docs/modules/general.html +3 -3
  45. package/docs/modules/schedule.html +2 -2
  46. package/docs/modules/string.html +10 -5
  47. package/package.json +4 -4
  48. package/src/browser/index.ts +2 -0
  49. package/src/browser/interfaces/isTouchSupported.ts +3 -3
  50. package/src/browser/isPushNotificationSupported.ts +7 -0
  51. package/src/browser/isShareSupported.ts +7 -0
  52. package/src/browser/isTabFocused.ts +6 -6
  53. package/src/browser/isTouchSupported.ts +5 -6
  54. package/src/browser/preferColorScheme.ts +6 -3
  55. package/src/browser/tabFocusListener.ts +1 -1
  56. package/src/dateTime/dateAsIso.ts +9 -3
  57. package/src/dateTime/index.ts +4 -4
  58. package/src/dateTime/interfaces/index.ts +1 -1
  59. package/src/dateTime/interfaces/parseDuration.ts +7 -7
  60. package/src/dateTime/parseDuration.ts +1 -1
  61. package/src/dom/addAsyncEventListener.ts +15 -13
  62. package/src/dom/addClickOutsideListener.ts +16 -16
  63. package/src/dom/addEventListener.ts +12 -7
  64. package/src/dom/appendAfter.ts +9 -9
  65. package/src/dom/appendBefore.ts +9 -9
  66. package/src/dom/createElement.ts +55 -51
  67. package/src/dom/fireEvent.ts +2 -1
  68. package/src/dom/index.ts +9 -9
  69. package/src/dom/interfaces/createElement.ts +36 -35
  70. package/src/dom/interfaces/index.ts +1 -1
  71. package/src/general/index.ts +3 -3
  72. package/src/general/isEmpty.ts +21 -21
  73. package/src/general/isNil.ts +7 -7
  74. package/src/general/isValidJson.ts +15 -15
  75. package/src/index.ts +6 -6
  76. package/src/schedule/index.ts +2 -2
  77. package/src/schedule/runAnimation.ts +51 -51
  78. package/src/schedule/runAsync.ts +3 -5
  79. package/src/string/byteSize.ts +7 -0
  80. package/src/string/escapeHTML.ts +1 -1
  81. package/src/string/index.ts +1 -0
  82. package/src/string/removeDiacritics.ts +11 -11
  83. package/src/string/slugify.ts +17 -17
  84. package/src/string/truncate.ts +21 -21
  85. package/tsconfig.json +19 -19
@@ -4,10 +4,8 @@
4
4
  * @param fn Function to be run asynchronously
5
5
  * @returns Promise of expected result
6
6
  */
7
- export const runAsync = <T> (fn: () => any): Promise<T> => {
8
- const worker = new Worker(
9
- URL.createObjectURL(new Blob([`postMessage((${fn})());`])),
10
- );
7
+ export const runAsync = <T>(fn: () => any): Promise<T> => {
8
+ const worker = new Worker(URL.createObjectURL(new Blob([`postMessage((${fn})());`])));
11
9
 
12
10
  return new Promise((res, rej) => {
13
11
  worker.onmessage = ({ data }) => {
@@ -15,7 +13,7 @@ export const runAsync = <T> (fn: () => any): Promise<T> => {
15
13
  worker.terminate();
16
14
  };
17
15
 
18
- worker.onerror = err => {
16
+ worker.onerror = (err) => {
19
17
  rej(err);
20
18
  worker.terminate();
21
19
  };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Return size of string in bytes
3
+ *
4
+ * @param value String to be sized
5
+ * @returns Byte size of given string
6
+ */
7
+ export const byteSize = (value: string): number => new Blob([value]).size;
@@ -9,4 +9,4 @@ export const escapeHTML = (html: string): string => {
9
9
  tempDiv.innerText = html;
10
10
 
11
11
  return tempDiv.innerHTML;
12
- }
12
+ };
@@ -1,3 +1,4 @@
1
+ export * from './byteSize';
1
2
  export * from './escapeHTML';
2
3
  export * from './removeDiacritics';
3
4
  export * from './slugify';
@@ -1,11 +1,11 @@
1
- /**
2
- * Remove diacritics & accents from string
3
- *
4
- * @param value String from which should be removed diacritics & accents
5
- * @returns ASCII string with removed diacritics & accents
6
- */
7
- export const removeDiacritics = (value: string): string =>
8
- value
9
- .normalize('NFD')
10
- .toString()
11
- .replace(/[\u0300-\u036f]/g, '');
1
+ /**
2
+ * Remove diacritics & accents from string
3
+ *
4
+ * @param value String from which should be removed diacritics & accents
5
+ * @returns ASCII string with removed diacritics & accents
6
+ */
7
+ export const removeDiacritics = (value: string): string =>
8
+ value
9
+ .normalize('NFD')
10
+ .toString()
11
+ .replace(/[\u0300-\u036f]/g, '');
@@ -1,17 +1,17 @@
1
- import { removeDiacritics } from './removeDiacritics';
2
-
3
- /**
4
- * Create slug from given string
5
- *
6
- * @param value String to be slugified
7
- * @param separator One character to be used as separator (if provided longer than one character, will be automatically shortened), dash ('-') by default
8
- * @returns Slugified string
9
- */
10
- export const slugify = (value: string, separator: string = '-'): string => {
11
- separator = separator.trim().substring(0, 1) || '-';
12
- const removeCharsRegex = new RegExp(`[^\\\w\\\s${separator}]`, 'g');
13
-
14
- return removeDiacritics(value.trim().toLowerCase())
15
- .replace(removeCharsRegex, '')
16
- .replace(/\s+/g, separator);
17
- };
1
+ import { removeDiacritics } from './removeDiacritics';
2
+
3
+ /**
4
+ * Create slug from given string
5
+ *
6
+ * @param value String to be slugified
7
+ * @param separator One character to be used as separator (if provided longer than one character, will be automatically shortened), dash ('-') by default
8
+ * @returns Slugified string
9
+ */
10
+ export const slugify = (value: string, separator: string = '-'): string => {
11
+ separator = separator.trim().substring(0, 1) || '-';
12
+ const removeCharsRegex = new RegExp(`[^\\\w\\\s${separator}]`, 'g');
13
+
14
+ return removeDiacritics(value.trim().toLowerCase())
15
+ .replace(removeCharsRegex, '')
16
+ .replace(/\s+/g, separator);
17
+ };
@@ -1,21 +1,21 @@
1
- /**
2
- * Truncate string to maximum given length if needed and append string at the end (by default "...")
3
- *
4
- * @param value String value to be truncated
5
- * @param maxLength Maximum allowed length
6
- * @param appendedString String to append at the end, be default "..."
7
- * @returns Truncated value if needed otherwise original value
8
- */
9
- export const truncate = (
10
- value: string,
11
- maxLength: number,
12
- appendedString: string = '...',
13
- ): string => {
14
- if (maxLength < appendedString.length) {
15
- return appendedString.slice(0, maxLength);
16
- }
17
-
18
- return value.length > maxLength
19
- ? value.slice(0, maxLength - appendedString.length) + appendedString
20
- : value;
21
- };
1
+ /**
2
+ * Truncate string to maximum given length if needed and append string at the end (by default "...")
3
+ *
4
+ * @param value String value to be truncated
5
+ * @param maxLength Maximum allowed length
6
+ * @param appendedString String to append at the end, be default "..."
7
+ * @returns Truncated value if needed otherwise original value
8
+ */
9
+ export const truncate = (
10
+ value: string,
11
+ maxLength: number,
12
+ appendedString: string = '...',
13
+ ): string => {
14
+ if (maxLength < appendedString.length) {
15
+ return appendedString.slice(0, maxLength);
16
+ }
17
+
18
+ return value.length > maxLength
19
+ ? value.slice(0, maxLength - appendedString.length) + appendedString
20
+ : value;
21
+ };
package/tsconfig.json CHANGED
@@ -1,19 +1,19 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES6",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "strict": true,
7
- "noImplicitThis": true,
8
- "alwaysStrict": true,
9
- "esModuleInterop": true,
10
- "preserveConstEnums": true,
11
- "sourceMap": true,
12
- "importHelpers": true,
13
- "baseUrl": ".",
14
- "declaration": true,
15
- "outDir": "./dist",
16
- "lib": ["dom", "es2021"]
17
- },
18
- "include": ["src/**/*.ts"]
19
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES6",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "strict": true,
7
+ "noImplicitThis": true,
8
+ "alwaysStrict": true,
9
+ "esModuleInterop": true,
10
+ "preserveConstEnums": true,
11
+ "sourceMap": true,
12
+ "importHelpers": true,
13
+ "baseUrl": ".",
14
+ "declaration": true,
15
+ "outDir": "./dist",
16
+ "lib": ["dom", "es2021"]
17
+ },
18
+ "include": ["src/**/*.ts"]
19
+ }