Skip to content

feat: improvements#136

Merged
bameyrick merged 3 commits into
mainfrom
improvements
Jun 27, 2026
Merged

feat: improvements#136
bameyrick merged 3 commits into
mainfrom
improvements

Conversation

@bameyrick

Copy link
Copy Markdown
Owner

New utilities:

  • sortBy(): comparator factory with dotted paths, descending, case-insensitive, tie-breaking, mapping functions
  • SortMappingFunction type
  • pascalToKebab(): PascalCase → kebab-case conversion
  • isArray(): typed array predicate

Breaking changes:

  • ValueType enum members renamed to PascalCase (e.g. ValueType.String, ValueType.Array)
  • difference() now returns a copy of the first array when values is empty (previously returned [])

isEqual rewrite:

  • Removed Moment.js dependency
  • Added cycle detection (WeakMap<object, WeakSet>)
  • Uses Reflect.ownKeys + propertyIsEnumerable for property comparison
  • Added bigint and symbol to IndividualEqualityType
  • More accurate ArrayBuffer.isView byte-level comparison
  • Other improvements:

    • typeOf: removed isMoment, value: any → unknown, improved constructorName null safety
    • isEmpty: uses Reflect.ownKeys for object empty check, cleaner types (no namespace)
    • isPlainObject: uses Object.getPrototypeOf for null-prototype check
    • isMergeableObject: fixed filename typo (isMergable → isMergeable), added Map/Set/WeakMap/WeakSet/ArrayBuffer checks
    • merge: readonly MergeOptions, function overloads, prototype pollution guards (proto/prototype/constructor), symbol key support
    • randomNumberBetweenRange: validation for non-finite, non-safe-integer, and empty ranges
    • All simple predicates (isArguments, isBuffer, isDate, isError, isGeneratorObject, isRegExp, isBoolean, isNumber, isString, isObject, isNullOrUndefined, isNaNStrict): value: any → value: unknown
    • package.json exports: added types condition for import and require
    • README: documented new functions, fixed isMergableObject typo, updated ValueType note

New utilities:
- sortBy(): comparator factory with dotted paths, descending, case-insensitive, tie-breaking, mapping functions
- SortMappingFunction type
- pascalToKebab(): PascalCase → kebab-case conversion
- isArray(): typed array predicate

Breaking changes:
- ValueType enum members renamed to PascalCase (e.g. ValueType.String, ValueType.Array)
- difference() now returns a copy of the first array when values is empty (previously returned [])

isEqual rewrite:
- Removed Moment.js dependency
- Added cycle detection (WeakMap<object, WeakSet<object>>)
- Uses Reflect.ownKeys + propertyIsEnumerable for property comparison
- Added bigint and symbol to IndividualEqualityType
- More accurate ArrayBuffer.isView byte-level comparison

Other improvements:
- typeOf: removed isMoment, value: any → unknown, improved constructorName null safety
- isEmpty: uses Reflect.ownKeys for object empty check, cleaner types (no namespace)
- isPlainObject: uses Object.getPrototypeOf for null-prototype check
- isMergeableObject: fixed filename typo (isMergable → isMergeable), added Map/Set/WeakMap/WeakSet/ArrayBuffer checks
- merge: readonly MergeOptions, function overloads, prototype pollution guards (__proto__/prototype/constructor), symbol key support
- randomNumberBetweenRange: validation for non-finite, non-safe-integer, and empty ranges
- All simple predicates (isArguments, isBuffer, isDate, isError, isGeneratorObject, isRegExp, isBoolean, isNumber, isString, isObject, isNullOrUndefined, isNaNStrict): value: any → value: unknown
- package.json exports: added types condition for import and require
- README: documented new functions, fixed isMergableObject typo, updated ValueType note
BREAKING
- ValueType enum members renamed to PascalCase throughout
  (ValueType.String, ValueType.Array, etc. — string values unchanged)
- All src/ filenames converted from camelCase to kebab-case
- Moment.js removed from typeOf, isEqual, and clone

New utilities
- sortBy: comparator factory for Array.prototype.sort with dot-notation,
  descending (-), case-insensitive (^), null-first, and mapping function support
- pascalToKebab: converts PascalCase strings to kebab-case
- isArray: type predicate returning value is unknown[]
- isMergeableObject: corrected spelling (was isMergableObject)

API improvements
- typeOf: value parameter typed as unknown; all enum members PascalCase
- isEqual: cycle detection (WeakMap); bigint and symbol added to
  IndividualEqualityType; Reflect.ownKeys → Object.keys (58% perf gain);
  lazy WeakMap creation eliminates allocation cost on primitive comparisons
- isEmpty: Reflect.ownKeys for object empty-check; flat type aliases
- isPlainObject: typed unknown; Object.getPrototypeOf(value) === null fast path
- isMergeableObject: Map, Set, WeakMap, WeakSet, ArrayBuffer, ArrayBuffer.isView
  added to isSpecial()
- merge: readonly MergeOptions; function overloads; prototype pollution
  protection (__proto__, prototype, constructor); symbol key support
- difference: readonly params; returns array.slice() when values is empty
- randomNumberBetweenRange: validates Number.isFinite, Number.isSafeInteger,
  range > 0
- clone: removed Moment.js; proto-first instanceof check order; for..in
  instead of Object.keys in object clone hot path; fast/slow path split
  eliminating instanceClone parameter threading overhead

Testing
- Migrate from Karma/Playwright browser mode to Vitest with jsdom environment
- isVisible.spec.ts excluded (requires real browser layout engine)
- is-equal.spec.ts rewritten as data-driven from isEqualTestDefinitions
- Additional isEqual test cases added to definitions (null/false, bool/null,
  bool/undefined, bool/)

Build
- tsconfig.mjs.json and tsconfig.cjs.json: add rootDir (TypeScript 6 required)
- tsconfig.cjs.json: override types to ["node"] to avoid vitest/vite resolution
  errors under node10 moduleResolution
- tsconfig.json: add vitest/globals, benchmark.ts, eslint.config.mts,
  vitest.setup.ts to include
- benchmark.ts: fix CJS imports (clone-deep, deepmerge, fast-deep-equal);
  switch library imports to pre-built dist/mjs

README
- Remove Moment.js references from clone and isEqual docs
- Add bigint and symbol to IndividualEqualityType list
- Fix benchmark link paths to renamed spec files
- Fix capitaliseFirst/capitaliseLast heading levels and ToC nesting
Comment thread src/math/random-number-between-range.ts Fixed
@sonarqubecloud

Copy link
Copy Markdown

@bameyrick bameyrick merged commit 0867053 into main Jun 27, 2026
7 checks passed
@bameyrick bameyrick deleted the improvements branch June 27, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants