@oscarpalmer/atoms 0.138.0 → 0.139.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.
- package/dist/atoms.full.js +1 -97
- package/dist/index.js +1 -3
- package/dist/value/index.js +1 -2
- package/package.json +5 -1
- package/src/value/index.ts +0 -1
- package/types/value/index.d.ts +0 -1
package/dist/atoms.full.js
CHANGED
|
@@ -3091,102 +3091,6 @@ const cloneHandlers = getSelfHandlers(clone, {
|
|
|
3091
3091
|
});
|
|
3092
3092
|
const MAX_CLONE_DEPTH = 100;
|
|
3093
3093
|
/**
|
|
3094
|
-
* Find the differences between two values
|
|
3095
|
-
* @param first First value
|
|
3096
|
-
* @param second Second value
|
|
3097
|
-
* @param options Comparison options
|
|
3098
|
-
* @returns Difference result
|
|
3099
|
-
*/
|
|
3100
|
-
function diff(first, second, options) {
|
|
3101
|
-
const relaxedNullish = typeof options === "object" && options?.relaxedNullish === true;
|
|
3102
|
-
const diffResult = {
|
|
3103
|
-
original: {
|
|
3104
|
-
from: first,
|
|
3105
|
-
to: second
|
|
3106
|
-
},
|
|
3107
|
-
type: "partial",
|
|
3108
|
-
values: {}
|
|
3109
|
-
};
|
|
3110
|
-
const same = relaxedNullish && first == null && second == null || Object.is(first, second);
|
|
3111
|
-
const firstIsArrayOrObject = isArrayOrPlainObject(first);
|
|
3112
|
-
const secondIsArrayOrObject = isArrayOrPlainObject(second);
|
|
3113
|
-
if (same || !(firstIsArrayOrObject || secondIsArrayOrObject)) {
|
|
3114
|
-
diffResult.type = same ? "none" : "full";
|
|
3115
|
-
return diffResult;
|
|
3116
|
-
}
|
|
3117
|
-
if (firstIsArrayOrObject !== secondIsArrayOrObject) {
|
|
3118
|
-
diffResult.type = "full";
|
|
3119
|
-
return diffResult;
|
|
3120
|
-
}
|
|
3121
|
-
const diffs = getDiffs(first, second, relaxedNullish);
|
|
3122
|
-
const { length } = diffs;
|
|
3123
|
-
if (length === 0) diffResult.type = "none";
|
|
3124
|
-
for (let index = 0; index < length; index += 1) {
|
|
3125
|
-
const differences = diffs[index];
|
|
3126
|
-
diffResult.values[differences.key] = {
|
|
3127
|
-
from: differences.from,
|
|
3128
|
-
to: differences.to
|
|
3129
|
-
};
|
|
3130
|
-
}
|
|
3131
|
-
return diffResult;
|
|
3132
|
-
}
|
|
3133
|
-
function getChanges(changes, first, second, relaxedNullish, prefix) {
|
|
3134
|
-
const checked = /* @__PURE__ */ new Set();
|
|
3135
|
-
for (let outerIndex = 0; outerIndex < 2; outerIndex += 1) {
|
|
3136
|
-
const value = (outerIndex === 0 ? first : second) ?? {};
|
|
3137
|
-
const keys = [...Object.keys(value), ...Object.getOwnPropertySymbols(value)];
|
|
3138
|
-
const { length } = keys;
|
|
3139
|
-
for (let innerIndex = 0; innerIndex < length; innerIndex += 1) {
|
|
3140
|
-
const key = keys[innerIndex];
|
|
3141
|
-
if (checked.has(key)) continue;
|
|
3142
|
-
checked.add(key);
|
|
3143
|
-
setChanges({
|
|
3144
|
-
changes,
|
|
3145
|
-
key,
|
|
3146
|
-
relaxedNullish,
|
|
3147
|
-
prefix,
|
|
3148
|
-
values: {
|
|
3149
|
-
first,
|
|
3150
|
-
second
|
|
3151
|
-
}
|
|
3152
|
-
});
|
|
3153
|
-
}
|
|
3154
|
-
}
|
|
3155
|
-
return changes;
|
|
3156
|
-
}
|
|
3157
|
-
function getDiffs(first, second, relaxedNullish, prefix) {
|
|
3158
|
-
const changes = [];
|
|
3159
|
-
if (Array.isArray(first) && Array.isArray(second)) {
|
|
3160
|
-
const maximumLength = Math.max(first.length, second.length);
|
|
3161
|
-
const minimumLength = Math.min(first.length, second.length);
|
|
3162
|
-
for (let index = minimumLength; index < maximumLength; index += 1) {
|
|
3163
|
-
const key = join([prefix, index], ".");
|
|
3164
|
-
changes.push({
|
|
3165
|
-
key,
|
|
3166
|
-
from: index >= first.length ? void 0 : first[index],
|
|
3167
|
-
to: index >= first.length ? second[index] : void 0
|
|
3168
|
-
});
|
|
3169
|
-
}
|
|
3170
|
-
}
|
|
3171
|
-
return getChanges(changes, first, second, relaxedNullish, prefix);
|
|
3172
|
-
}
|
|
3173
|
-
function setChanges(parameters) {
|
|
3174
|
-
const { changes, key, prefix, relaxedNullish, values } = parameters;
|
|
3175
|
-
const from = values.first?.[key];
|
|
3176
|
-
const to = values.second?.[key];
|
|
3177
|
-
if (equal(from, to, { relaxedNullish })) return;
|
|
3178
|
-
const prefixed = join([prefix, key], ".");
|
|
3179
|
-
const change = {
|
|
3180
|
-
from,
|
|
3181
|
-
to,
|
|
3182
|
-
key: prefixed
|
|
3183
|
-
};
|
|
3184
|
-
const diffs = isArrayOrPlainObject(from) || isArrayOrPlainObject(to) ? getDiffs(from, to, relaxedNullish, prefixed) : [];
|
|
3185
|
-
changes.push(change);
|
|
3186
|
-
const diffsLength = diffs.length;
|
|
3187
|
-
for (let diffIndex = 0; diffIndex < diffsLength; diffIndex += 1) changes.push(diffs[diffIndex]);
|
|
3188
|
-
}
|
|
3189
|
-
/**
|
|
3190
3094
|
* Create a new object with only the specified keys
|
|
3191
3095
|
* @param value Original object
|
|
3192
3096
|
* @param keys Keys to use
|
|
@@ -3326,4 +3230,4 @@ function mergeValues(values, options, validate, prefix) {
|
|
|
3326
3230
|
const actual = validate ? values.filter(isArrayOrPlainObject) : values;
|
|
3327
3231
|
return actual.length > 1 ? mergeObjects(actual, options, prefix) : actual[0] ?? {};
|
|
3328
3232
|
}
|
|
3329
|
-
export { frame_rate_default as FRAME_RATE_MS, PromiseTimeoutError, QueueError, SizedMap, SizedSet, asyncResult, average, beacon, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, debounce, delay,
|
|
3233
|
+
export { frame_rate_default as FRAME_RATE_MS, PromiseTimeoutError, QueueError, SizedMap, SizedSet, asyncResult, average, beacon, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, debounce, delay, endsWith, equal, error, exists, filter, find, flatten, fromQuery, getArray, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupArraysBy, groupBy, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, includes, indexOf, initializeEqualizer, initializeMerger, initializeTemplater, insert, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, memoize, merge, min, noop, ok, parse, partial, pascalCase, promises, push, queue, registerCloner, registerComparator, registerEqualizer, result, rgbToHex, rgbToHsl, rgbToHsla, round, setValue, shuffle, smush, snakeCase, sort, splice, startsWith, sum, template, throttle, timed, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toSet, trim, truncate, unique, unregisterCloner, unregisterComparator, unregisterEqualizer, unsmush, unwrap, upperCase, words };
|
package/dist/index.js
CHANGED
|
@@ -50,10 +50,8 @@ import "./string/index.js";
|
|
|
50
50
|
import { getValue } from "./internal/value/get.js";
|
|
51
51
|
import { initializeTemplater, template } from "./string/template.js";
|
|
52
52
|
import { clone, registerCloner, unregisterCloner } from "./value/clone.js";
|
|
53
|
-
import { diff } from "./value/diff.js";
|
|
54
53
|
import { partial } from "./value/partial.js";
|
|
55
54
|
import { smush } from "./value/smush.js";
|
|
56
55
|
import { unsmush } from "./value/unsmush.js";
|
|
57
|
-
import "./value/index.js";
|
|
58
56
|
import { initializeMerger, merge } from "./value/merge.js";
|
|
59
|
-
export { frame_rate_default as FRAME_RATE_MS, PromiseTimeoutError, QueueError, SizedMap, SizedSet, asyncResult, average, beacon, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, debounce, delay,
|
|
57
|
+
export { frame_rate_default as FRAME_RATE_MS, PromiseTimeoutError, QueueError, SizedMap, SizedSet, asyncResult, average, beacon, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, debounce, delay, endsWith, equal, error, exists, filter, find, flatten, fromQuery, getArray, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupArraysBy, groupBy, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, includes, indexOf, initializeEqualizer, initializeMerger, initializeTemplater, insert, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, memoize, merge, min, noop, ok, parse, partial, pascalCase, promises, push, queue, registerCloner, registerComparator, registerEqualizer, result, rgbToHex, rgbToHsl, rgbToHsla, round, setValue, shuffle, smush, snakeCase, sort, splice, startsWith, sum, template, throttle, timed, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toSet, trim, truncate, unique, unregisterCloner, unregisterComparator, unregisterEqualizer, unsmush, unwrap, upperCase, words };
|
package/dist/value/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { setValue } from "../internal/value/set.js";
|
|
2
2
|
import { getValue } from "../internal/value/get.js";
|
|
3
|
-
import { diff } from "./diff.js";
|
|
4
3
|
import { partial } from "./partial.js";
|
|
5
4
|
import { smush } from "./smush.js";
|
|
6
5
|
import { unsmush } from "./unsmush.js";
|
|
7
|
-
export {
|
|
6
|
+
export { getValue, partial, setValue, smush, unsmush };
|
package/package.json
CHANGED
|
@@ -105,6 +105,10 @@
|
|
|
105
105
|
"types": "./types/internal/value/compare.d.ts",
|
|
106
106
|
"default": "./dist/internal/value/compare.js"
|
|
107
107
|
},
|
|
108
|
+
"./value/diff": {
|
|
109
|
+
"types": "./types/value/diff.d.ts",
|
|
110
|
+
"default": "./dist/value/diff.js"
|
|
111
|
+
},
|
|
108
112
|
"./value/equal": {
|
|
109
113
|
"types": "./types/internal/value/equal.d.ts",
|
|
110
114
|
"default": "./dist/internal/value/equal.js"
|
|
@@ -140,5 +144,5 @@
|
|
|
140
144
|
},
|
|
141
145
|
"type": "module",
|
|
142
146
|
"types": "./types/index.d.ts",
|
|
143
|
-
"version": "0.
|
|
147
|
+
"version": "0.139.0"
|
|
144
148
|
}
|
package/src/value/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export {getValue} from '../internal/value/get';
|
|
2
2
|
export {setValue} from '../internal/value/set';
|
|
3
3
|
export type {ArrayOrPlainObject, NestedPartial, PlainObject} from '../models';
|
|
4
|
-
export {diff, type DiffOptions, type DiffResult, type DiffValue} from './diff';
|
|
5
4
|
export {partial} from './partial';
|
|
6
5
|
export {smush} from './smush';
|
|
7
6
|
export {unsmush} from './unsmush';
|
package/types/value/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { getValue } from '../internal/value/get';
|
|
2
2
|
export { setValue } from '../internal/value/set';
|
|
3
3
|
export type { ArrayOrPlainObject, NestedPartial, PlainObject } from '../models';
|
|
4
|
-
export { diff, type DiffOptions, type DiffResult, type DiffValue } from './diff';
|
|
5
4
|
export { partial } from './partial';
|
|
6
5
|
export { smush } from './smush';
|
|
7
6
|
export { unsmush } from './unsmush';
|