@oscarpalmer/atoms 0.89.0 → 0.90.0

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.
@@ -43,8 +43,7 @@ function getDiffs(first, second, prefix) {
43
43
  if (Array.isArray(first) && Array.isArray(second)) {
44
44
  const maximumLength = Math.max(first.length, second.length);
45
45
  const minimumLength = Math.min(first.length, second.length);
46
- let index = minimumLength;
47
- for (; index < maximumLength; index += 1) {
46
+ for (let index = minimumLength; index < maximumLength; index += 1) {
48
47
  const key = string_index.join([prefix, index], ".");
49
48
  changes.push({
50
49
  key,
@@ -72,7 +71,11 @@ function getDiffs(first, second, prefix) {
72
71
  key: prefixed
73
72
  };
74
73
  const nested = is.isArrayOrPlainObject(from) || is.isArrayOrPlainObject(to);
75
- const diffs = nested ? getDiffs(from, to, prefixed) : [];
74
+ const diffs = nested ? getDiffs(
75
+ from ?? {},
76
+ to ?? {},
77
+ prefixed
78
+ ) : [];
76
79
  if (!nested || nested && diffs.length > 0) {
77
80
  changes.push(change);
78
81
  }
@@ -41,8 +41,7 @@ function getDiffs(first, second, prefix) {
41
41
  if (Array.isArray(first) && Array.isArray(second)) {
42
42
  const maximumLength = Math.max(first.length, second.length);
43
43
  const minimumLength = Math.min(first.length, second.length);
44
- let index = minimumLength;
45
- for (; index < maximumLength; index += 1) {
44
+ for (let index = minimumLength; index < maximumLength; index += 1) {
46
45
  const key = join([prefix, index], ".");
47
46
  changes.push({
48
47
  key,
@@ -70,7 +69,11 @@ function getDiffs(first, second, prefix) {
70
69
  key: prefixed
71
70
  };
72
71
  const nested = isArrayOrPlainObject(from) || isArrayOrPlainObject(to);
73
- const diffs = nested ? getDiffs(from, to, prefixed) : [];
72
+ const diffs = nested ? getDiffs(
73
+ from ?? {},
74
+ to ?? {},
75
+ prefixed
76
+ ) : [];
74
77
  if (!nested || nested && diffs.length > 0) {
75
78
  changes.push(change);
76
79
  }
package/package.json CHANGED
@@ -4,19 +4,19 @@
4
4
  "url": "https://oscarpalmer.se"
5
5
  },
6
6
  "dependencies": {
7
- "type-fest": "^4.36"
7
+ "type-fest": "^4.38"
8
8
  },
9
9
  "description": "Atomic utilities for making your JavaScript better.",
10
10
  "devDependencies": {
11
11
  "@biomejs/biome": "^1.9",
12
12
  "@types/node": "^22.13",
13
- "@vitest/coverage-istanbul": "^3",
13
+ "@vitest/coverage-istanbul": "^3.1",
14
14
  "dts-bundle-generator": "^9.5",
15
15
  "glob": "^11",
16
16
  "happy-dom": "^17.4",
17
17
  "typescript": "^5.8",
18
18
  "vite": "^6.2",
19
- "vitest": "^3"
19
+ "vitest": "^3.1"
20
20
  },
21
21
  "exports": {
22
22
  "./package.json": "./package.json",
@@ -208,5 +208,5 @@
208
208
  },
209
209
  "type": "module",
210
210
  "types": "./types/index.d.cts",
211
- "version": "0.89.0"
211
+ "version": "0.90.0"
212
212
  }
package/src/models.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type {Get, Paths} from 'type-fest';
1
+ import type {Get, Paths, Primitive} from 'type-fest';
2
2
 
3
3
  export type ArrayOrPlainObject = unknown[] | Record<PropertyKey, unknown>;
4
4
 
@@ -23,15 +23,6 @@ export type Key = number | string;
23
23
 
24
24
  export type PlainObject = Record<PropertyKey, unknown>;
25
25
 
26
- export type Primitive =
27
- | bigint
28
- | boolean
29
- | null
30
- | number
31
- | string
32
- | symbol
33
- | undefined;
34
-
35
26
  export type TypedArray =
36
27
  | Int8Array
37
28
  | Uint8Array
@@ -45,4 +36,4 @@ export type TypedArray =
45
36
  | BigInt64Array
46
37
  | BigUint64Array;
47
38
 
48
- export type {Get, Paths};
39
+ export type {Get, Paths, Primitive};
package/src/value/diff.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {isArrayOrPlainObject} from '../is';
2
- import type {ArrayOrPlainObject, Key, PlainObject} from '../models';
2
+ import type {ArrayOrPlainObject, PlainObject} from '../models';
3
3
  import {join} from '../string/index';
4
4
  import {equal} from '../value/equal';
5
5
 
@@ -92,9 +92,7 @@ function getDiffs(
92
92
  const maximumLength = Math.max(first.length, second.length);
93
93
  const minimumLength = Math.min(first.length, second.length);
94
94
 
95
- let index = minimumLength;
96
-
97
- for (; index < maximumLength; index += 1) {
95
+ for (let index = minimumLength; index < maximumLength; index += 1) {
98
96
  const key = join([prefix, index], '.');
99
97
 
100
98
  changes.push({
@@ -133,7 +131,11 @@ function getDiffs(
133
131
  const nested = isArrayOrPlainObject(from) || isArrayOrPlainObject(to);
134
132
 
135
133
  const diffs = nested
136
- ? getDiffs(from as PlainObject, to as PlainObject, prefixed)
134
+ ? getDiffs(
135
+ (from ?? {}) as PlainObject,
136
+ (to ?? {}) as PlainObject,
137
+ prefixed,
138
+ )
137
139
  : [];
138
140
 
139
141
  if (!nested || (nested && diffs.length > 0)) {