Skip to content

Commit

Permalink
Rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 12, 2019
1 parent 71054e1 commit 893d474
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const changePrototype = (to, from) => {

const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;

const toStringDescriptors = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');

const changeToString = (to, from, name) => {
const withName = name === '' ? '' : `with ${name.trim()}() `;
const newToString = wrappedToString.bind(null, withName, from.toString());
Object.defineProperty(newToString, 'name', toStringName);
Object.defineProperty(to, 'toString', {...toStringDescriptors, value: newToString});
Object.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});
};

// If `to` has properties that `from` does not have, remove them
Expand Down

0 comments on commit 893d474

Please sign in to comment.