Skip to content

Commit

Permalink
Merge pull request #85 from rwjblue/fix-ie11
Browse files Browse the repository at this point in the history
Fix IE11 compatibility (avoid Object.entries).
  • Loading branch information
maxfierke authored Dec 4, 2020
2 parents ecdda67 + acebac3 commit a1be780
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions addon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,28 +156,30 @@ function applyOptions(
options: TaskGroupOptions | TaskOptions,
task: TaskGroupProperty | TaskProperty
): (TaskGroupProperty | TaskProperty) & Decorator {
return Object.entries(options).reduce(
(
taskProperty,
[key, value]: [
keyof typeof options,
ObjectValues<Required<typeof options>>
]
) => {
assert(
`ember-concurrency-decorators: Option '${key}' is not a valid function`,
typeof taskProperty[key] === 'function'
);
if (value === true) {
return (taskProperty[key] as () => typeof taskProperty)();
}
return (taskProperty[key] as (o: typeof value) => typeof taskProperty)(
value
);
},
task
// The CP decorator gets executed in `createDecorator`
) as typeof task & Decorator;
const keys = Object.keys(options) as Array<keyof typeof options>;

for (const key of keys) {
const value: ObjectValues<Required<typeof options>> | undefined =
options[key];

assert(
`ember-concurrency-decorators: Option '${key}' is not a valid value`,
value !== undefined
);
assert(
`ember-concurrency-decorators: Option '${key}' is not a valid function`,
typeof task[key] === 'function'
);

if (value === true) {
(task[key] as () => typeof task)();
}

(task[key] as (o: typeof value) => typeof task)(value);
}

// The CP decorator gets executed in `createDecorator`
return task as typeof task & Decorator;
}

type MethodOrPropertyDecoratorWithParams<
Expand Down

0 comments on commit a1be780

Please sign in to comment.