moderndash 0.0.5

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 (100) hide show
  1. package/.ctiignore +3 -0
  2. package/package.json +41 -0
  3. package/src/array/chunk.ts +31 -0
  4. package/src/array/difference.ts +21 -0
  5. package/src/array/differenceBy.ts +30 -0
  6. package/src/array/differenceWith.ts +31 -0
  7. package/src/array/dropRightWhile.ts +28 -0
  8. package/src/array/dropWhile.ts +24 -0
  9. package/src/array/index.ts +24 -0
  10. package/src/array/intersection.ts +20 -0
  11. package/src/array/intersectionBy.ts +26 -0
  12. package/src/array/intersectionWith.ts +33 -0
  13. package/src/array/sample.ts +18 -0
  14. package/src/array/sampleSize.ts +31 -0
  15. package/src/array/shuffle.ts +33 -0
  16. package/src/array/takeRightWhile.ts +33 -0
  17. package/src/array/takeWhile.ts +33 -0
  18. package/src/array/union.ts +16 -0
  19. package/src/array/unionBy.ts +26 -0
  20. package/src/array/unionWith.ts +31 -0
  21. package/src/array/uniq.ts +18 -0
  22. package/src/array/uniqBy.ts +25 -0
  23. package/src/array/uniqWith.ts +20 -0
  24. package/src/array/unzip.ts +20 -0
  25. package/src/array/unzipWith.ts +26 -0
  26. package/src/array/zip.ts +17 -0
  27. package/src/array/zipWith.ts +28 -0
  28. package/src/collection/countBy.ts +38 -0
  29. package/src/collection/groupBy.ts +33 -0
  30. package/src/collection/index.ts +3 -0
  31. package/src/collection/sortBy.ts +15 -0
  32. package/src/function/after.ts +23 -0
  33. package/src/function/before.ts +27 -0
  34. package/src/function/debounce.ts +124 -0
  35. package/src/function/index.ts +6 -0
  36. package/src/function/memoize.ts +59 -0
  37. package/src/function/once.ts +19 -0
  38. package/src/function/throttle.ts +11 -0
  39. package/src/helpers/collections.ts +5 -0
  40. package/src/helpers/shortHands.ts +17 -0
  41. package/src/helpers/stringModifiers.ts +18 -0
  42. package/src/helpers/typeofChecks.ts +3 -0
  43. package/src/index.ts +7 -0
  44. package/src/lang/index.ts +4 -0
  45. package/src/lang/isEmpty.ts +23 -0
  46. package/src/lang/isEqual.ts +54 -0
  47. package/src/lang/isEqualWith.ts +5 -0
  48. package/src/lang/isPlainObject.ts +3 -0
  49. package/src/object/index.ts +1 -0
  50. package/src/object/pick.ts +22 -0
  51. package/src/string/camelCase.ts +15 -0
  52. package/src/string/capitalize.ts +3 -0
  53. package/src/string/deburr.ts +5 -0
  54. package/src/string/escape.ts +10 -0
  55. package/src/string/escapeRegExp.ts +3 -0
  56. package/src/string/index.ts +11 -0
  57. package/src/string/kebabCase.ts +10 -0
  58. package/src/string/pascalCase.ts +10 -0
  59. package/src/string/snakeCase.ts +13 -0
  60. package/src/string/startCase.ts +10 -0
  61. package/src/string/stripSpecialChars.ts +6 -0
  62. package/src/string/unescape.ts +10 -0
  63. package/src/types.ts +9 -0
  64. package/test/.eslintrc.cjs +5 -0
  65. package/test/array/chunk.test.ts +19 -0
  66. package/test/array/differenceMethods.test.ts +49 -0
  67. package/test/array/dropMethods.test.ts +30 -0
  68. package/test/array/intersectionMethods.test.ts +36 -0
  69. package/test/array/shuffle.test.ts +17 -0
  70. package/test/array/takeMethods.test.ts +41 -0
  71. package/test/array/unionMethods.test.ts +41 -0
  72. package/test/array/uniqMethods.test.ts +18 -0
  73. package/test/array/unzipMethods.test.ts +13 -0
  74. package/test/array/zipMethods.test.ts +48 -0
  75. package/test/collection/countBy.test.ts +13 -0
  76. package/test/collection/groupBy.test.ts +35 -0
  77. package/test/collection/sample.test.ts +17 -0
  78. package/test/collection/sampleSize.test.ts +33 -0
  79. package/test/collection/sortBy.test.ts +31 -0
  80. package/test/function/after.test.ts +19 -0
  81. package/test/function/before.test.ts +19 -0
  82. package/test/function/debounce.test.ts +47 -0
  83. package/test/function/memoize.test.ts +33 -0
  84. package/test/function/once.test.ts +29 -0
  85. package/test/function/throttle.test.ts +24 -0
  86. package/test/lang/isEqualMethods.test.ts +98 -0
  87. package/test/string/camelCase.test.ts +13 -0
  88. package/test/string/capitalize.test.ts +17 -0
  89. package/test/string/deburr.test.ts +16 -0
  90. package/test/string/escape.test.ts +17 -0
  91. package/test/string/escapeRegExp.test.ts +18 -0
  92. package/test/string/kebabCase.test.ts +18 -0
  93. package/test/string/pascalCase.test.ts +16 -0
  94. package/test/string/snakeCase.test.ts +23 -0
  95. package/test/string/startCase.test.ts +14 -0
  96. package/test/string/stripSpecialChars.test.ts +15 -0
  97. package/test/string/unescape.test.ts +17 -0
  98. package/tsconfig.json +112 -0
  99. package/tsup.config.js +10 -0
  100. package/vitest.config.ts +27 -0
@@ -0,0 +1,33 @@
1
+ import { test, describe, expect, vi, beforeEach } from 'vitest';
2
+
3
+ import { memoize } from '@function/memoize';
4
+
5
+ describe('memoize', () => {
6
+ const testFn = vi.fn((a: number, b: number) => a + b);
7
+
8
+ beforeEach(() => {
9
+ testFn.mockClear();
10
+ });
11
+
12
+
13
+ test('should memoize a function', () => {
14
+ const memoizedFunc = memoize(testFn);
15
+
16
+ expect(memoizedFunc(1, 2)).to.equal(3);
17
+ expect(memoizedFunc(1, 2)).to.equal(3);
18
+ expect(testFn).toHaveBeenCalledOnce();
19
+ });
20
+
21
+ test('should return different results for different arguments', () => {
22
+ const memoizedFunc = memoize(testFn);
23
+
24
+ expect(memoizedFunc(1, 2)).to.equal(3);
25
+ expect(memoizedFunc(2, 3)).to.equal(5);
26
+ expect(testFn).toHaveBeenCalledTimes(2);
27
+ });
28
+
29
+ test('should expose a cache property', () => {
30
+ const memoizedFunc = memoize(testFn);
31
+ expect(memoizedFunc.cache).to.be.an.instanceof(Map);
32
+ });
33
+ });
@@ -0,0 +1,29 @@
1
+ import { test, describe, expect, vi, afterEach } from 'vitest';
2
+
3
+ import { once } from '@function/once';
4
+
5
+ describe('once', () => {
6
+ const testFn = vi.fn((x: number) => x * 2);
7
+
8
+ afterEach(() => {
9
+ testFn.mockClear();
10
+ });
11
+
12
+ test('only calls the function once', () => {
13
+ const onceFn = once(testFn);
14
+
15
+ onceFn(1);
16
+ expect(testFn).toHaveBeenCalledTimes(1);
17
+ onceFn(1);
18
+ expect(testFn).toHaveBeenCalledTimes(1);
19
+ onceFn(1);
20
+ expect(testFn).toHaveBeenCalledTimes(1);
21
+ });
22
+
23
+ test('preserves the return value of the function', () => {
24
+ const onceFn = once(testFn);
25
+
26
+ expect(onceFn(2)).toBe(4);
27
+ expect(onceFn(3)).toBe(4);
28
+ });
29
+ });
@@ -0,0 +1,24 @@
1
+ import { describe, expect, test, vi } from 'vitest';
2
+
3
+ import { throttle } from '@function/throttle';
4
+
5
+ describe('throttle', () => {
6
+ test('only calls the function once', () => {
7
+ vi.useFakeTimers();
8
+
9
+ const callback = vi.fn();
10
+ const throttled = throttle(callback, 100);
11
+
12
+ throttled();
13
+ throttled();
14
+ throttled();
15
+
16
+ expect(callback).toHaveBeenCalledTimes(1);
17
+
18
+ vi.advanceTimersByTime(99);
19
+ expect(callback).toHaveBeenCalledTimes(1);
20
+
21
+ vi.advanceTimersByTime(1);
22
+ expect(callback).toHaveBeenCalledTimes(2);
23
+ });
24
+ });
@@ -0,0 +1,98 @@
1
+ import { describe, expect, test } from 'vitest';
2
+
3
+ import { isEqual } from '@lang/isEqual';
4
+ import { isEqualWith } from '@lang/isEqualWith';
5
+
6
+ describe('isEqual', () => {
7
+ test('numbers', () => {
8
+ expect(isEqual(1, 1)).toBe(true);
9
+ expect(isEqual(1, 2)).toBe(false);
10
+ });
11
+
12
+ test('strings', () => {
13
+ expect(isEqual('a', 'a')).toBe(true);
14
+ expect(isEqual('a', 'b')).toBe(false);
15
+ });
16
+
17
+ test('booleans', () => {
18
+ expect(isEqual(true, true)).toBe(true);
19
+ expect(isEqual(true, false)).toBe(false);
20
+ });
21
+
22
+ test('null', () => {
23
+ expect(isEqual(null, null)).toBe(true);
24
+ expect(isEqual(null, undefined)).toBe(false);
25
+ });
26
+
27
+ test('undefined', () => {
28
+ expect(isEqual(undefined, undefined)).toBe(true);
29
+ expect(isEqual(undefined, null)).toBe(false);
30
+ });
31
+
32
+ test('objects', () => {
33
+ expect(isEqual({ a: 1 }, { a: 1 })).toBe(true);
34
+ expect(isEqual({ a: 1 }, { a: 2 })).toBe(false);
35
+ });
36
+
37
+ test('arrays', () => {
38
+ expect(isEqual([1, 2, 3], [1, 2, 3])).toBe(true);
39
+ expect(isEqual([1, 2, 3], [1, 2, 4])).toBe(false);
40
+ });
41
+
42
+ test('nested objects', () => {
43
+ expect(isEqual({ a: { b: 1 } }, { a: { b: 1 } })).toBe(true);
44
+ expect(isEqual({ a: { b: 1 } }, { a: { b: 2 } })).toBe(false);
45
+ });
46
+
47
+ test('nested arrays', () => {
48
+ expect(isEqual([[1], [2], [3]], [[1], [2], [3]])).toBe(true);
49
+ expect(isEqual([[1], [2], [3]], [[1], [2], [4]])).toBe(false);
50
+ });
51
+
52
+ test('nested objects and arrays', () => {
53
+ expect(isEqual({ a: { b: [1] } }, { a: { b: [1] } })).toBe(true);
54
+ expect(isEqual({ a: { b: [1] } }, { a: { b: [2] } })).toBe(false);
55
+ });
56
+
57
+ test('objects with different keys', () => {
58
+ expect(isEqual({ a: 1 }, { b: 1 })).toBe(false);
59
+ });
60
+
61
+ test('arrays with different lengths', () => {
62
+ expect(isEqual([1, 2, 3], [1, 2])).toBe(false);
63
+ });
64
+
65
+ // eslint-disable-next-line unicorn/consistent-function-scoping
66
+ const testFunction = () => { return 1 };
67
+ test('functions', () => {
68
+ expect(isEqual(() => { return 1 }, () => { return 2 })).toBe(false);
69
+ expect(isEqual(testFunction, testFunction)).toBe(true);
70
+ });
71
+
72
+ test('objects with functions', () => {
73
+ expect(isEqual({ a: () => { return 1 } }, { a: () => { return 1 } })).toBe(false);
74
+ expect(isEqual({ a: testFunction }, { a: testFunction })).toBe(true);
75
+ });
76
+
77
+ test('regExp', () => {
78
+ expect(isEqual(/a(.*)/, /a(.*)/)).toBe(true);
79
+ expect(isEqual(/a/, /b.*/)).toBe(false);
80
+ });
81
+ });
82
+
83
+
84
+ describe('isEqualWith', () => {
85
+ test('should return true if the customizer function returns equal values for both inputs', () => {
86
+ expect(isEqualWith(Math.floor, 1.3, 1.8)).toBe(true);
87
+ });
88
+
89
+ test('should return false if the customizer function returns different values for both inputs', () => {
90
+ const customizer = (value: number) => value * 2;
91
+ expect(isEqualWith(customizer, 2, 5)).toBe(false);
92
+ });
93
+
94
+ test('should work with objects as input', () => {
95
+ const customizer = (value: { a: number, b: number }) => value.a + value.b;
96
+ expect(isEqualWith(customizer, { a: 2, b: 3 }, { a: 1, b: 4 })).toBe(true);
97
+ });
98
+ });
@@ -0,0 +1,13 @@
1
+ import { describe, expect, test } from 'vitest';
2
+
3
+ import { camelCase } from '@string/camelCase';
4
+
5
+ describe('camelCase', () => {
6
+ test('should convert a string to camel case', () => {
7
+ expect(camelCase('Foo Bar')).toBe('fooBar');
8
+ expect(camelCase('fooBar')).toBe('fooBar');
9
+ expect(camelCase('FooBar')).toBe('fooBar');
10
+ expect(camelCase('--foo-bar--')).toBe('fooBar');
11
+ expect(camelCase('__FOO_BAR__')).toBe('fooBar');
12
+ });
13
+ });
@@ -0,0 +1,17 @@
1
+ import { expect, test, describe } from 'vitest';
2
+
3
+ import { capitalize } from '@string/capitalize';
4
+
5
+ describe('capitalize', () => {
6
+ test('capitalizes the first letter of a string', () => {
7
+ expect(capitalize('hello world')).toBe('Hello world');
8
+ });
9
+
10
+ test('returns an empty string for an empty input', () => {
11
+ expect(capitalize('')).toBe('');
12
+ });
13
+
14
+ test('returns the original string for a single-character string', () => {
15
+ expect(capitalize('a')).toBe('A');
16
+ });
17
+ });
@@ -0,0 +1,16 @@
1
+ import { describe, expect, test } from 'vitest';
2
+
3
+ import { deburr } from '@string/deburr';
4
+
5
+ describe('deburr', () => {
6
+ test('removes diacritics from a string', () => {
7
+ expect(deburr('Mëtàl Hëàd')).toEqual('Metal Head');
8
+ expect(deburr('Pokémón')).toEqual('Pokemon');
9
+ expect(deburr('résumé')).toEqual('resume');
10
+ });
11
+
12
+ test('returns the input string if it has no diacritics', () => {
13
+ expect(deburr('hello')).toEqual('hello');
14
+ expect(deburr('world')).toEqual('world');
15
+ });
16
+ });
@@ -0,0 +1,17 @@
1
+ import { expect, test, describe } from 'vitest';
2
+
3
+ import { escape } from '@string/escape';
4
+
5
+ describe('escapeToHTML', () => {
6
+ test('should escape special characters to HTML entities', () => {
7
+ const str = '<p>Hello, World!</p>';
8
+ const html = escape(str);
9
+ expect(html).toBe('&lt;p&gt;Hello, World!&lt;/p&gt;');
10
+ });
11
+
12
+ test('should return the original string if it does not contain special characters', () => {
13
+ const str = 'Hello, World!';
14
+ const html = escape(str);
15
+ expect(html).toBe(str);
16
+ });
17
+ });
@@ -0,0 +1,18 @@
1
+ import { expect, test, describe } from 'vitest';
2
+
3
+ import { escapeRegExp } from '@string/escapeRegExp';
4
+
5
+ describe('escapeRegExp', () => {
6
+ test('escapes special characters in a string', () => {
7
+ expect(escapeRegExp('hello.world*')).toBe('hello\\.world\\*');
8
+ expect(escapeRegExp('[lodash](https://lodash.com/)')).toBe('\\[lodash\\]\\(https://lodash\\.com/\\)');
9
+ });
10
+
11
+ test('returns an empty string for an empty input', () => {
12
+ expect(escapeRegExp('')).toBe('');
13
+ });
14
+
15
+ test('returns the original string for a string without special characters', () => {
16
+ expect(escapeRegExp('hello world')).toBe('hello world');
17
+ });
18
+ });
@@ -0,0 +1,18 @@
1
+ import { describe, expect, test } from 'vitest';
2
+
3
+ import { kebabCase } from '@string/kebabCase';
4
+
5
+ describe('kebabCase', () => {
6
+ test('converts a string to kebab case', () => {
7
+ expect(kebabCase('helloWorld')).toBe('hello-world');
8
+ expect(kebabCase('helloCRUELWorld')).toBe('hello-cruel-world');
9
+ });
10
+
11
+ test('returns an empty string for an empty input', () => {
12
+ expect(kebabCase('')).toBe('');
13
+ });
14
+
15
+ test('returns the original string for a single-word string', () => {
16
+ expect(kebabCase('hello')).toBe('hello');
17
+ });
18
+ });
@@ -0,0 +1,16 @@
1
+ import { describe, expect, test } from 'vitest';
2
+
3
+ import { pascalCase } from '@string/pascalCase';
4
+
5
+ describe('toPascalCase', () => {
6
+ test('converts a string to PascalCase', () => {
7
+ expect(pascalCase('hello world')).toEqual('HelloWorld');
8
+ expect(pascalCase('this is a.test')).toEqual('ThisIsATest');
9
+ expect(pascalCase('CamelCase')).toEqual('CamelCase');
10
+ });
11
+
12
+ test('handles empty strings and single words correctly', () => {
13
+ expect(pascalCase('')).toEqual('');
14
+ expect(pascalCase('hello')).toEqual('Hello');
15
+ });
16
+ });
@@ -0,0 +1,23 @@
1
+ import { describe, expect, test } from 'vitest';
2
+
3
+ import { snakeCase } from '@string/snakeCase';
4
+
5
+ describe('snakeCase', () => {
6
+ test('converts a string to snake_case', () => {
7
+ expect(snakeCase('someString')).toBe('some_string');
8
+ expect(snakeCase('someOtherString')).toBe('some_other_string');
9
+ expect(snakeCase('someStringWithCamelCase')).toBe('some_string_with_camel_case');
10
+ });
11
+
12
+ test('converts a string with multiple uppercase letters to snake_case', () => {
13
+ expect(snakeCase('someStringWithMultipleUppercaseLetters')).toBe('some_string_with_multiple_uppercase_letters');
14
+ });
15
+
16
+ test('handles strings that are already in snake_case', () => {
17
+ expect(snakeCase('some_string')).toBe('some_string');
18
+ });
19
+
20
+ test('handles empty strings', () => {
21
+ expect(snakeCase('')).toBe('');
22
+ });
23
+ });
@@ -0,0 +1,14 @@
1
+ import { expect, test, describe } from 'vitest';
2
+
3
+ import { startCase } from '@string/startCase';
4
+
5
+ describe('startCase', () => {
6
+ test('should convert a string to start case', () => {
7
+ expect(startCase('hello world')).toBe('Hello World');
8
+ expect(startCase('HELLO WORLD')).toBe('Hello World');
9
+ expect(startCase('Hello World')).toBe('Hello World');
10
+ expect(startCase('hello-world')).toBe('Hello World');
11
+ expect(startCase('hello_world')).toBe('Hello World');
12
+ expect(startCase('hello world')).toBe('Hello World');
13
+ });
14
+ });
@@ -0,0 +1,15 @@
1
+ import { describe, test, expect } from 'vitest';
2
+
3
+ import { stripSpecialChars } from '@string/stripSpecialChars';
4
+
5
+ describe('stripSpecialChars', () => {
6
+ test('removes special characters from a string', () => {
7
+ expect(stripSpecialChars('Héllo, world!')).toEqual('Hello world');
8
+ expect(stripSpecialChars('This string has #$%&*!')).toEqual('This string has ');
9
+ expect(stripSpecialChars('Testing 123')).toEqual('Testing 123');
10
+ });
11
+
12
+ test('returns an empty string if given an empty string', () => {
13
+ expect(stripSpecialChars('')).toEqual('');
14
+ });
15
+ });
@@ -0,0 +1,17 @@
1
+ import { test, expect, describe } from 'vitest';
2
+
3
+ import { unescapeHTML } from '@string/unescape';
4
+
5
+ describe('unescapeHTML', () => {
6
+ test('should unescape HTML entities', () => {
7
+ const html = '&lt;p&gt;Hello, World!&lt;/p&gt;';
8
+ const str = unescapeHTML(html);
9
+ expect(str).toBe('<p>Hello, World!</p>');
10
+ });
11
+
12
+ test('should return the original string if it does not contain HTML entities', () => {
13
+ const html = 'Hello, World!';
14
+ const str = unescapeHTML(html);
15
+ expect(str).toBe(html);
16
+ });
17
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,112 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ "lib": ["ESNext", "DOM"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ "types": [],
17
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
18
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
19
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
20
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
21
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
23
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
24
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
27
+
28
+ /* Modules */
29
+ "module": "esnext", /* Specify what module code is generated. */
30
+ "rootDir": "./", /* Specify the root folder within your source files. */
31
+ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
32
+ "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
36
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
37
+ // "resolveJsonModule": true, /* Enable importing .json files. */
38
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
39
+
40
+ /* JavaScript Support */
41
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
42
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
43
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
44
+
45
+ /* Emit */
46
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
47
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
48
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
49
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
50
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
51
+ "outDir": "./dist", /* Specify an output folder for all emitted files. */
52
+ // "removeComments": true, /* Disable emitting comments. */
53
+ // "noEmit": true, /* Disable emitting files from a compilation. */
54
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
55
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
56
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
57
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
58
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
59
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
60
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
61
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
62
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
63
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
64
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
65
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
66
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
67
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
68
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
69
+
70
+ /* Interop Constraints */
71
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
72
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
73
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
74
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
75
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
76
+
77
+ /* Type Checking */
78
+ "strict": true, /* Enable all strict type-checking options. */
79
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
80
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
81
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
82
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
83
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
84
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
85
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
86
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
87
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
88
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
89
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
90
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
91
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
92
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
93
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
94
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
95
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
96
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
97
+
98
+ /* Completeness */
99
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
100
+ "skipLibCheck": true,
101
+ "paths": {
102
+ "@array/*": ["src/array/*"],
103
+ "@lang/*": ["src/lang/*"],
104
+ "@function/*": ["src/function/*"],
105
+ "@object/*": ["src/object/*"],
106
+ "@string/*": ["src/string/*"],
107
+ "@collection/*": ["src/collection/*"],
108
+ "@helpers/*": ["src/helpers/*"]
109
+ }
110
+ },
111
+ "include": ["./**/*.ts", "./**/*.js"]
112
+ }
package/tsup.config.js ADDED
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts'],
5
+ format: ['esm'],
6
+ sourcemap: true,
7
+ clean: true,
8
+ outDir: 'dist',
9
+ dts: true
10
+ });
@@ -0,0 +1,27 @@
1
+ /// <reference types="vitest" />
2
+ // Configure Vitest (https://vitest.dev/config/)
3
+
4
+ import { fileURLToPath, URL } from 'url';
5
+
6
+ import { defineConfig } from 'vite';
7
+
8
+ const getPath = (path: string) => fileURLToPath(new URL(path, import.meta.url));
9
+
10
+ export default defineConfig({
11
+ test: {
12
+ /* for example, use global to avoid globals imports (describe, test, expect): */
13
+ // globals: true,
14
+ },
15
+ resolve: {
16
+ alias: {
17
+ '@array': getPath('src/array'),
18
+ '@lang': getPath('src/lang'),
19
+ '@object': getPath('src/object'),
20
+ '@function': getPath('src/function'),
21
+ '@collection': getPath('src/collection'),
22
+ '@string': getPath('src/string'),
23
+ '@number': getPath('src/number'),
24
+ '@helpers': getPath('src/helpers')
25
+ }
26
+ }
27
+ });