Skip to content

Commit

Permalink
feat: crating assignEx
Browse files Browse the repository at this point in the history
  • Loading branch information
Farenheith committed Dec 21, 2024
1 parent 094c3f9 commit 38b7231
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/dummies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hasLength } from './guards';
import { hasLength, isObject } from './guards';
import { Lenghtable, Sizeable } from './types';

export function identity<T>(x: T) {
Expand Down Expand Up @@ -76,6 +76,12 @@ export function compareProp<K extends keyof T, T extends object = any>(
return (t: T) => comparer(t[k]);
}

export function assignEx<A, B>(a: A, b: B): unknown extends A ? B : A & B {
return (isObject(a) ? Object.assign(a, b) : { ...b }) as unknown extends A
? B
: A & B;
}

export const nodeVersion = Number(process.versions.node.split('.')[0]);

const TIMERS_PROMISE_FIRST_APPEARANCE = 16;
Expand Down

0 comments on commit 38b7231

Please sign in to comment.