Skip to content

Commit

Permalink
Simplified setAliases().
Browse files Browse the repository at this point in the history
  • Loading branch information
uhop committed Jun 7, 2024
1 parent ef59cfb commit fe89992
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions re2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

const RE2 = require('./build/Release/re2.node');

const setAliases = (object, dict, force) => {
for (let [name, aliases] of Object.entries(dict)) {
if (typeof aliases == 'string') aliases = aliases.split(/\s*,\s*/);
if (!Array.isArray(aliases)) aliases = [aliases];
for (const alias of aliases) {
const descriptor = Object.getOwnPropertyDescriptor(object, name);
if (!descriptor) continue;
if (!force && object.hasOwnProperty(alias)) continue;
Object.defineProperty(object, alias, descriptor);
}
const setAliases = (object, dict) => {
for (let [name, alias] of Object.entries(dict)) {
Object.defineProperty(
object,
alias,
Object.getOwnPropertyDescriptor(object, name)
);
}
};

Expand Down

0 comments on commit fe89992

Please sign in to comment.