Skip to content

Commit

Permalink
Fix composition with non-value .toString descriptors (#51)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
kriskowal and sindresorhus committed Mar 14, 2024
1 parent 1105520 commit d4d3e62
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ const changeToString = (to, from, name) => {
const newToString = wrappedToString.bind(null, withName, from.toString());
// Ensure `to.toString.toString` is non-enumerable and has the same `same`
Object.defineProperty(newToString, 'name', toStringName);
Object.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});
const {writable, enumerable, configurable} = toStringDescriptor; // We destructue to avoid a potential `get` descriptor.
Object.defineProperty(to, 'toString', {value: newToString, writable, enumerable, configurable});
};

export default function mimicFunction(to, from, {ignoreNonConfigurable = false} = {}) {
Expand Down

0 comments on commit d4d3e62

Please sign in to comment.