Skip to content

Commit

Permalink
Also test perf of Object.assign
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Feb 12, 2025
1 parent def0af5 commit ef25986
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ import { EMPTY_ARR } from './constants';

export const isArray = Array.isArray;
export const slice = EMPTY_ARR.slice;
export const assign = Object.assign;

/**
* Assign properties from `props` to `obj`
* @template O, P The obj and props types
* @param {O} obj The object to copy properties to
* @param {P} props The object to copy properties from
* @returns {O & P}
*/
export function assign(obj, props) {
// @ts-expect-error We change the type of `obj` to be `O & P`
for (let i in props) obj[i] = props[i];
return /** @type {O & P} */ (obj);
}
/**
* Remove a child node from its parent if attached. This is a workaround for
* IE11 which doesn't support `Element.prototype.remove()`. Using this function
Expand Down

0 comments on commit ef25986

Please sign in to comment.