@buley/dash 0.0.30 → 2.1.4

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 (116) hide show
  1. package/README.md +82 -65
  2. package/dist/src/engine/ai.d.ts +10 -0
  3. package/dist/src/engine/ai.js +47 -0
  4. package/dist/src/engine/sqlite.d.ts +31 -0
  5. package/dist/src/engine/sqlite.js +239 -0
  6. package/dist/src/engine/vec_extension.d.ts +5 -0
  7. package/dist/src/engine/vec_extension.js +10 -0
  8. package/dist/src/index.d.ts +3 -0
  9. package/dist/src/index.js +3 -0
  10. package/dist/src/mcp/server.d.ts +8 -0
  11. package/dist/src/mcp/server.js +87 -0
  12. package/dist/src/reactivity/signal.d.ts +3 -0
  13. package/dist/src/reactivity/signal.js +31 -0
  14. package/dist/src/sync/backup.d.ts +12 -0
  15. package/dist/src/sync/backup.js +44 -0
  16. package/dist/src/sync/connection.d.ts +16 -0
  17. package/dist/src/sync/connection.js +29 -0
  18. package/dist/src/sync/provider.d.ts +11 -0
  19. package/dist/src/sync/provider.js +67 -0
  20. package/dist/tsconfig.tsbuildinfo +1 -0
  21. package/package.json +33 -31
  22. package/.coveralls.yml +0 -1
  23. package/.github/workflows/opencommit.yml +0 -33
  24. package/.github/workflows/testing.yml +0 -20
  25. package/.gitmodules +0 -0
  26. package/behaviors/cache.dev.js +0 -282
  27. package/behaviors/changes.dev.js +0 -337
  28. package/behaviors/collect.dev.js +0 -40
  29. package/behaviors/examples/async.dev.js +0 -17
  30. package/behaviors/firebase.dev.js +0 -283
  31. package/behaviors/live.dev.js +0 -67
  32. package/behaviors/map.dev.js +0 -54
  33. package/behaviors/mapreduce.dev.js +0 -68
  34. package/behaviors/match.dev.js +0 -66
  35. package/behaviors/patch.dev.js +0 -69
  36. package/behaviors/rest.dev.js +0 -340
  37. package/behaviors/shorthand.dev.js +0 -59
  38. package/behaviors/stats.dev.js +0 -672
  39. package/dist/behaviors/index.js +0 -142
  40. package/dist/database/index.js +0 -76
  41. package/dist/databases/index.js +0 -121
  42. package/dist/entry/index.js +0 -166
  43. package/dist/index.js +0 -93
  44. package/dist/indexes/index.js +0 -153
  45. package/dist/store/index.js +0 -97
  46. package/dist/stores/index.js +0 -90
  47. package/dist/utilities/index.js +0 -174
  48. package/documentation/database/closing.md +0 -3
  49. package/documentation/database/getting.md +0 -1
  50. package/documentation/database/opening.md +0 -5
  51. package/documentation/database/removing.md +0 -3
  52. package/documentation/databases.md +0 -21
  53. package/documentation/entries.md +0 -13
  54. package/documentation/entry/adding.md +0 -1
  55. package/documentation/entry/getting.md +0 -4
  56. package/documentation/entry/putting.md +0 -0
  57. package/documentation/entry/removing.md +0 -3
  58. package/documentation/entry/updating.md +0 -0
  59. package/documentation/general/security.md +0 -10
  60. package/documentation/general/transaction/requests.md +0 -3
  61. package/documentation/general/transactions.md +0 -5
  62. package/documentation/index/creating.md +0 -1
  63. package/documentation/index/getting.md +0 -1
  64. package/documentation/index/iterating.md +0 -1
  65. package/documentation/index/removing.md +0 -1
  66. package/documentation/indexes.md +0 -3
  67. package/documentation/key/cursors.md +0 -5
  68. package/documentation/key/range/bounds.md +0 -11
  69. package/documentation/key/range/direction.md +0 -1
  70. package/documentation/key/ranges.md +0 -3
  71. package/documentation/keys.md +0 -12
  72. package/documentation/objectstore/clearing.md +0 -1
  73. package/documentation/objectstore/creating.md +0 -1
  74. package/documentation/objectstore/getting.md +0 -1
  75. package/documentation/objectstore/iteration.md +0 -1
  76. package/documentation/objectstore/removing.md +0 -1
  77. package/documentation/overview.md +0 -5
  78. package/documentation/stores.md +0 -13
  79. package/jest.config.js +0 -12
  80. package/src/behaviors/index.ts +0 -140
  81. package/src/database/index.ts +0 -81
  82. package/src/databases/index.ts +0 -127
  83. package/src/entry/index.ts +0 -183
  84. package/src/index/index.ts +0 -61
  85. package/src/index.ts +0 -96
  86. package/src/indexes/index.ts +0 -151
  87. package/src/store/index.ts +0 -102
  88. package/src/stores/index.ts +0 -90
  89. package/src/utilities/index.ts +0 -349
  90. package/tests/behaviors/behaviors.spec.ts +0 -123
  91. package/tests/database/database.spec.ts +0 -177
  92. package/tests/databases/databases.spec.ts +0 -199
  93. package/tests/entry/entry.spec.ts +0 -252
  94. package/tests/index/index.spec.ts +0 -94
  95. package/tests/indexes/indexes.spec.ts +0 -203
  96. package/tests/store/store.spec.ts +0 -164
  97. package/tests/stores/stores.spec.ts +0 -148
  98. package/tests/utilities/clone.spec.ts +0 -48
  99. package/tests/utilities/cloneError.spec.ts +0 -33
  100. package/tests/utilities/contains.spec.ts +0 -28
  101. package/tests/utilities/exists.spec.ts +0 -21
  102. package/tests/utilities/is.spec.ts +0 -37
  103. package/tests/utilities/isArray.spec.ts +0 -21
  104. package/tests/utilities/isBoolean.spec.ts +0 -23
  105. package/tests/utilities/isEmpty.spec.ts +0 -45
  106. package/tests/utilities/isFunction.spec.ts +0 -30
  107. package/tests/utilities/isNumber.spec.ts +0 -29
  108. package/tests/utilities/isObject.spec.ts +0 -42
  109. package/tests/utilities/isRegEx.spec.ts +0 -33
  110. package/tests/utilities/isString.spec.ts +0 -25
  111. package/tests/utilities/isnt.spec.ts +0 -50
  112. package/tests/utilities/randomId.spec.ts +0 -39
  113. package/tests/utilities/safeApply.spec.ts +0 -49
  114. package/tests/utilities/safeEach.spec.ts +0 -38
  115. package/tests/utilities/safeIterate.spec.ts +0 -47
  116. package/tsconfig.json +0 -16
@@ -1,21 +0,0 @@
1
- import { isArray } from '../../src/utilities';
2
-
3
- describe('isArray', () => {
4
- it('should return true for arrays', () => {
5
- expect(isArray([1, 2, 3])).toBe(true); // Simple array
6
- expect(isArray([])).toBe(true); // Empty array
7
- });
8
-
9
- it('should return false for non-array types', () => {
10
- expect(isArray('hello')).toBe(false); // String
11
- expect(isArray(42)).toBe(false); // Number
12
- expect(isArray({ foo: 'bar' })).toBe(false); // Object
13
- expect(isArray(null)).toBe(false); // null
14
- expect(isArray(undefined)).toBe(false); // undefined
15
- });
16
-
17
- it('should return false for array-like objects', () => {
18
- const arrayLike = { length: 2, 0: 'a', 1: 'b' };
19
- expect(isArray(arrayLike)).toBe(false); // Array-like object but not an actual array
20
- });
21
- });
@@ -1,23 +0,0 @@
1
- import { isBoolean } from '../../src/utilities';
2
-
3
- describe('isBoolean', () => {
4
- it('should return true for boolean values', () => {
5
- expect(isBoolean(true)).toBe(true); // Boolean true
6
- expect(isBoolean(false)).toBe(true); // Boolean false
7
- });
8
-
9
- it('should return false for non-boolean values', () => {
10
- expect(isBoolean('true')).toBe(false); // String
11
- expect(isBoolean(0)).toBe(false); // Number
12
- expect(isBoolean(1)).toBe(false); // Number
13
- expect(isBoolean([])).toBe(false); // Array
14
- expect(isBoolean({})).toBe(false); // Object
15
- expect(isBoolean(null)).toBe(false); // null
16
- expect(isBoolean(undefined)).toBe(false); // undefined
17
- });
18
-
19
- it('should return false for boolean-like strings', () => {
20
- expect(isBoolean('false')).toBe(false); // String "false"
21
- expect(isBoolean('true')).toBe(false); // String "true"
22
- });
23
- });
@@ -1,45 +0,0 @@
1
- import { isEmpty } from '../../src/utilities';
2
-
3
- describe('isEmpty', () => {
4
- it('should return true for empty arrays', () => {
5
- expect(isEmpty([])).toBe(true); // Empty array
6
- });
7
-
8
- it('should return false for non-empty arrays', () => {
9
- expect(isEmpty([1, 2, 3])).toBe(false); // Non-empty array
10
- });
11
-
12
- it('should return true for empty objects', () => {
13
- expect(isEmpty({})).toBe(true); // Empty object
14
- });
15
-
16
- it('should return false for non-empty objects', () => {
17
- expect(isEmpty({ foo: 'bar' })).toBe(false); // Non-empty object
18
- });
19
-
20
- it('should return true for empty strings', () => {
21
- expect(isEmpty('')).toBe(true); // Empty string
22
- });
23
-
24
- it('should return false for non-empty strings', () => {
25
- expect(isEmpty('hello')).toBe(false); // Non-empty string
26
- });
27
-
28
- it('should return true for null', () => {
29
- expect(isEmpty(null)).toBe(true); // Null value
30
- });
31
-
32
- it('should return true for undefined', () => {
33
- expect(isEmpty(undefined)).toBe(true); // Undefined value
34
- });
35
-
36
- it('should return true for numbers (as they are not considered collections)', () => {
37
- expect(isEmpty(0)).toBe(true); // Number 0
38
- expect(isEmpty(42)).toBe(true); // Non-zero number
39
- });
40
-
41
- it('should return true for booleans (as they are not considered collections)', () => {
42
- expect(isEmpty(true)).toBe(true); // Boolean true
43
- expect(isEmpty(false)).toBe(true); // Boolean false
44
- });
45
- });
@@ -1,30 +0,0 @@
1
- import { isFunction } from '../../src/utilities';
2
-
3
- describe('isFunction', () => {
4
- it('should return true for actual functions', () => {
5
- expect(isFunction(function() {})).toBe(true); // Regular function
6
- expect(isFunction(() => {})).toBe(true); // Arrow function
7
- expect(isFunction(async () => {})).toBe(true); // Async function
8
- expect(isFunction(function*() {})).toBe(true); // Generator function
9
- });
10
-
11
- it('should return false for class declarations', () => {
12
- class MyClass {}
13
- expect(isFunction(MyClass)).toBe(false); // Class declaration should return false
14
- });
15
-
16
- it('should return false for function-like objects', () => {
17
- const functionLike = { apply: () => {}, call: () => {} };
18
- expect(isFunction(functionLike)).toBe(false); // Function-like object
19
- });
20
-
21
- it('should return false for non-function values', () => {
22
- expect(isFunction('string')).toBe(false); // String
23
- expect(isFunction(42)).toBe(false); // Number
24
- expect(isFunction({})).toBe(false); // Object
25
- expect(isFunction([])).toBe(false); // Array
26
- expect(isFunction(true)).toBe(false); // Boolean
27
- expect(isFunction(null)).toBe(false); // Null
28
- expect(isFunction(undefined)).toBe(false); // Undefined
29
- });
30
- });
@@ -1,29 +0,0 @@
1
- import { isNumber } from '../../src/utilities';
2
-
3
- describe('isNumber', () => {
4
- it('should return true for valid numbers', () => {
5
- expect(isNumber(42)).toBe(true); // Integer
6
- expect(isNumber(3.14)).toBe(true); // Float
7
- expect(isNumber(0)).toBe(true); // Zero
8
- expect(isNumber(-100)).toBe(true); // Negative number
9
- });
10
-
11
- it('should return true for special number values', () => {
12
- expect(isNumber(NaN)).toBe(true); // NaN is technically a number in JavaScript
13
- expect(isNumber(Infinity)).toBe(true); // Positive infinity
14
- expect(isNumber(-Infinity)).toBe(true); // Negative infinity
15
- });
16
-
17
- it('should return false for non-number types', () => {
18
- expect(isNumber('42')).toBe(false); // String
19
- expect(isNumber(true)).toBe(false); // Boolean
20
- expect(isNumber([])).toBe(false); // Array
21
- expect(isNumber({})).toBe(false); // Object
22
- expect(isNumber(null)).toBe(false); // Null
23
- expect(isNumber(undefined)).toBe(false); // Undefined
24
- });
25
-
26
- it('should return false for number-like strings', () => {
27
- expect(isNumber('123')).toBe(false); // String that looks like a number
28
- });
29
- });
@@ -1,42 +0,0 @@
1
- import { isObject } from '../../src/utilities';
2
-
3
- describe('isObject', () => {
4
- it('should return true for plain objects', () => {
5
- expect(isObject({})).toBe(true); // Plain object
6
- expect(isObject({ foo: 'bar' })).toBe(true); // Object with properties
7
- });
8
-
9
- it('should return false for arrays', () => {
10
- expect(isObject([1, 2, 3])).toBe(false); // Array
11
- expect(isObject([])).toBe(false); // Empty array
12
- });
13
-
14
- it('should return false for functions', () => {
15
- expect(isObject(function() {})).toBe(false); // Regular function
16
- expect(isObject(() => {})).toBe(false); // Arrow function
17
- });
18
-
19
- it('should return false for special objects like Date', () => {
20
- expect(isObject(new Date())).toBe(false); // Date object
21
- });
22
-
23
- it('should return false for special objects like RegExp', () => {
24
- expect(isObject(/regex/)).toBe(false); // RegExp object
25
- });
26
-
27
- it('should return false for number objects', () => {
28
- expect(isObject(new Number(42))).toBe(false); // Number object
29
- });
30
-
31
- it('should return false for string objects', () => {
32
- expect(isObject(new String('hello'))).toBe(false); // String object
33
- });
34
-
35
- it('should return false for non-object types', () => {
36
- expect(isObject(42)).toBe(false); // Number
37
- expect(isObject('hello')).toBe(false); // String
38
- expect(isObject(true)).toBe(false); // Boolean
39
- expect(isObject(null)).toBe(false); // Null
40
- expect(isObject(undefined)).toBe(false); // Undefined
41
- });
42
- });
@@ -1,33 +0,0 @@
1
- import { isRegEx } from '../../src/utilities';
2
-
3
- describe('isRegEx', () => {
4
- it('should return true for regular expressions', () => {
5
- expect(isRegEx(/abc/)).toBe(true); // Regular expression literal
6
- expect(isRegEx(new RegExp('abc'))).toBe(true); // RegExp object
7
- });
8
-
9
- it('should return false for strings', () => {
10
- expect(isRegEx('abc')).toBe(false); // String
11
- });
12
-
13
- it('should return false for objects', () => {
14
- expect(isRegEx({ foo: 'bar' })).toBe(false); // Object
15
- });
16
-
17
- it('should return false for arrays', () => {
18
- expect(isRegEx([1, 2, 3])).toBe(false); // Array
19
- });
20
-
21
- it('should return false for numbers', () => {
22
- expect(isRegEx(123)).toBe(false); // Number
23
- });
24
-
25
- it('should return false for functions', () => {
26
- expect(isRegEx(() => {})).toBe(false); // Function
27
- });
28
-
29
- it('should return false for null and undefined', () => {
30
- expect(isRegEx(null)).toBe(false); // Null
31
- expect(isRegEx(undefined)).toBe(false); // Undefined
32
- });
33
- });
@@ -1,25 +0,0 @@
1
- import { isString } from '../../src/utilities';
2
-
3
- describe('isString', () => {
4
- it('should return true for string literals', () => {
5
- expect(isString('hello')).toBe(true); // String literal
6
- expect(isString('')).toBe(true); // Empty string
7
- });
8
-
9
- it('should return true for string objects', () => {
10
- expect(isString(new String('hello'))).toBe(true); // String object
11
- });
12
-
13
- it('should return false for non-string values', () => {
14
- expect(isString(123)).toBe(false); // Number
15
- expect(isString(true)).toBe(false); // Boolean
16
- expect(isString([])).toBe(false); // Array
17
- expect(isString({})).toBe(false); // Object
18
- expect(isString(null)).toBe(false); // Null
19
- expect(isString(undefined)).toBe(false); // Undefined
20
- });
21
-
22
- it('should return false for functions', () => {
23
- expect(isString(() => {})).toBe(false); // Function
24
- });
25
- });
@@ -1,50 +0,0 @@
1
- import { isnt } from '../../src/utilities';
2
-
3
- describe('isnt', () => {
4
- it('should return true for different primitive values', () => {
5
- expect(isnt(42, '42')).toBe(true); // Number vs string
6
- expect(isnt(42, 43)).toBe(true); // Different numbers
7
- expect(isnt('hello', 'world')).toBe(true); // Different strings
8
- expect(isnt(true, false)).toBe(true); // Different booleans
9
- });
10
-
11
- it('should return false for identical primitive values', () => {
12
- expect(isnt(42, 42)).toBe(false); // Same numbers
13
- expect(isnt('hello', 'hello')).toBe(false); // Same strings
14
- expect(isnt(true, true)).toBe(false); // Same booleans
15
- });
16
-
17
- it('should return true for different objects (reference equality)', () => {
18
- const obj1 = { foo: 'bar' };
19
- const obj2 = { foo: 'bar' };
20
- expect(isnt(obj1, obj2)).toBe(true); // Different references, even if the structure is the same
21
- });
22
-
23
- it('should return false for the same object reference', () => {
24
- const obj = { foo: 'bar' };
25
- expect(isnt(obj, obj)).toBe(false); // Same object reference
26
- });
27
-
28
- it('should return true for different arrays (reference equality)', () => {
29
- const arr1 = [1, 2, 3];
30
- const arr2 = [1, 2, 3];
31
- expect(isnt(arr1, arr2)).toBe(true); // Different array instances
32
- });
33
-
34
- it('should return false for the same array reference', () => {
35
- const arr = [1, 2, 3];
36
- expect(isnt(arr, arr)).toBe(false); // Same array reference
37
- });
38
-
39
- it('should return true for null vs undefined', () => {
40
- expect(isnt(null, undefined)).toBe(true); // Null vs undefined
41
- });
42
-
43
- it('should return false for two null values', () => {
44
- expect(isnt(null, null)).toBe(false); // Both are null
45
- });
46
-
47
- it('should return true for defined vs undefined values', () => {
48
- expect(isnt(42, undefined)).toBe(true); // Defined number vs undefined
49
- });
50
- });
@@ -1,39 +0,0 @@
1
- import { randomId } from '../../src/utilities';
2
-
3
- describe('randomId', () => {
4
- it('should return a string of default length (16)', () => {
5
- const result = randomId();
6
- expect(result).toBeDefined();
7
- expect(typeof result).toBe('string');
8
- expect(result.length).toBe(16); // Default length is 16
9
- });
10
-
11
- it('should return a string of specified length', () => {
12
- const result = randomId(8);
13
- expect(result).toBeDefined();
14
- expect(typeof result).toBe('string');
15
- expect(result.length).toBe(8); // Custom length
16
- });
17
-
18
- it('should generate different random strings for each call', () => {
19
- const result1 = randomId();
20
- const result2 = randomId();
21
- expect(result1).not.toBe(result2); // Each call should return a different string
22
- });
23
-
24
- it('should only contain characters from the specified character set', () => {
25
- const charset = 'ABCDEF123456';
26
- const result = randomId(12, charset);
27
- expect(result.length).toBe(12);
28
-
29
- // Ensure every character in the result is part of the charset
30
- for (const char of result) {
31
- expect(charset.includes(char)).toBe(true);
32
- }
33
- });
34
-
35
- it('should handle an empty charset by not generating any characters', () => {
36
- const result = randomId(10, '');
37
- expect(result.length).toBe(0); // No characters should be generated when charset is empty
38
- });
39
- });
@@ -1,49 +0,0 @@
1
- import { safeApply } from '../../src/utilities';
2
-
3
- describe('safeApply', () => {
4
- it('should invoke the provided function with given arguments', () => {
5
- const fn = jest.fn();
6
- const args = [1, 2, 3];
7
- const result = safeApply(fn, args);
8
- expect(fn).toHaveBeenCalledWith(...args); // The function should be called with the correct arguments
9
- expect(result).toBeUndefined(); // No return value, so should be undefined
10
- });
11
-
12
-
13
- it('should apply the function with a specific context', () => {
14
- interface Context {
15
- value: number;
16
- }
17
-
18
- // Use explicit typing for `this`
19
- const fn = function (this: Context) {
20
- return this.value;
21
- };
22
-
23
- const context = { value: 42 };
24
- const result = safeApply(fn, [], context);
25
- expect(result).toBe(42); // The function should use the provided context
26
- });
27
-
28
- it('should return undefined if no function is provided', () => {
29
- const result = safeApply(undefined, [1, 2, 3]);
30
- expect(result).toBeUndefined(); // Should safely return undefined when no function is provided
31
- });
32
-
33
- it('should call the error handler if the main function is undefined', () => {
34
- const errorHandler = jest.fn();
35
- safeApply(undefined, [], undefined, errorHandler);
36
- expect(errorHandler).toHaveBeenCalled(); // Error handler should be invoked
37
- });
38
-
39
- it('should return undefined if both the main function and error handler are undefined', () => {
40
- const result = safeApply(undefined, []);
41
- expect(result).toBeUndefined(); // Should return undefined in absence of both main function and error handler
42
- });
43
-
44
- it('should pass arguments to the error handler', () => {
45
- const errorHandler = jest.fn();
46
- safeApply(undefined, [], undefined, errorHandler);
47
- expect(errorHandler).toHaveBeenCalledWith(); // Error handler should be called with no arguments in this case
48
- });
49
- });
@@ -1,38 +0,0 @@
1
- import { safeEach } from '../../src/utilities';
2
-
3
- describe('safeEach', () => {
4
- it('should iterate over each element of the array and apply the callback', () => {
5
- const callback = jest.fn();
6
- const items = [1, 2, 3];
7
- safeEach(items, callback);
8
- expect(callback).toHaveBeenCalledTimes(3); // Callback should be called 3 times
9
- expect(callback).toHaveBeenCalledWith(1, 0); // First call with first element and index 0
10
- expect(callback).toHaveBeenCalledWith(2, 1); // Second call with second element and index 1
11
- expect(callback).toHaveBeenCalledWith(3, 2); // Third call with third element and index 2
12
- });
13
-
14
- it('should do nothing if the array is empty', () => {
15
- const callback = jest.fn();
16
- safeEach([], callback);
17
- expect(callback).not.toHaveBeenCalled(); // Callback should not be called for an empty array
18
- });
19
-
20
- it('should iterate using a custom increment value', () => {
21
- const callback = jest.fn();
22
- const items = [1, 2, 3, 4, 5, 6];
23
- safeEach(items, callback, 2); // Custom increment value of 2
24
- expect(callback).toHaveBeenCalledTimes(3); // Only 3 calls: [1, 3, 5]
25
- expect(callback).toHaveBeenCalledWith(1, 0); // First element and index 0
26
- expect(callback).toHaveBeenCalledWith(3, 2); // Third element and index 2
27
- expect(callback).toHaveBeenCalledWith(5, 4); // Fifth element and index 4
28
- });
29
-
30
- it('should apply the callback to every nth element based on custom increment', () => {
31
- const callback = jest.fn();
32
- const items = [10, 20, 30, 40, 50];
33
- safeEach(items, callback, 3); // Custom increment of 3
34
- expect(callback).toHaveBeenCalledTimes(2); // Callback should be called twice: [10, 40]
35
- expect(callback).toHaveBeenCalledWith(10, 0); // First element
36
- expect(callback).toHaveBeenCalledWith(40, 3); // Fourth element
37
- });
38
- });
@@ -1,47 +0,0 @@
1
- import { safeIterate } from '../../src/utilities';
2
-
3
- describe('safeIterate', () => {
4
- it('should iterate over an object’s properties and apply the callback', () => {
5
- const callback = jest.fn();
6
- const obj = { foo: 'bar', baz: 42 };
7
- safeIterate(obj, callback);
8
-
9
- expect(callback).toHaveBeenCalledTimes(2); // Callback should be called twice
10
- expect(callback).toHaveBeenCalledWith('foo', 'bar'); // First key-value pair
11
- expect(callback).toHaveBeenCalledWith('baz', 42); // Second key-value pair
12
- });
13
-
14
- it('should not call the callback for an empty object', () => {
15
- const callback = jest.fn();
16
- safeIterate({}, callback);
17
-
18
- expect(callback).not.toHaveBeenCalled(); // Callback should not be called for an empty object
19
- });
20
-
21
- it('should not iterate over properties in the prototype chain', () => {
22
- const callback = jest.fn();
23
- const proto = { inheritedProp: 'should not iterate' };
24
- const obj = Object.create(proto);
25
- obj.ownProp = 'should iterate';
26
-
27
- safeIterate(obj, callback);
28
-
29
- expect(callback).toHaveBeenCalledTimes(1); // Only own property should be iterated over
30
- expect(callback).toHaveBeenCalledWith('ownProp', 'should iterate');
31
- expect(callback).not.toHaveBeenCalledWith('inheritedProp', 'should not iterate'); // Inherited property should not be iterated over
32
- });
33
-
34
- it('should iterate over non-enumerable properties if they are explicitly defined as enumerable', () => {
35
- const callback = jest.fn();
36
- const obj = {};
37
- Object.defineProperty(obj, 'foo', {
38
- value: 'bar',
39
- enumerable: true,
40
- });
41
-
42
- safeIterate(obj, callback);
43
-
44
- expect(callback).toHaveBeenCalledTimes(1); // Non-enumerable properties should be skipped unless explicitly enumerable
45
- expect(callback).toHaveBeenCalledWith('foo', 'bar');
46
- });
47
- });
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es6",
4
- "module": "commonjs",
5
- "sourceMap": true,
6
- "outDir": "./dist",
7
- "strict": true,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true,
10
- "forceConsistentCasingInFileNames": true
11
- },
12
- "include": [
13
- "src/**/*.ts",
14
- "test/**/*.ts"
15
- ]
16
- }