Skip to content

My work #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

My work #4

wants to merge 10 commits into from

Conversation

Destaby
Copy link

@Destaby Destaby commented Dec 16, 2019

No description provided.

callback(new Error('obj needed'));
return;
}
for (const key in obj) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will iterate all object keys plus inherited keys from prototype chain.

const contract = (fn, ...types) => null;
const contract = (fn, ...types) => (...arr) => {
for (let i = 1; i < types.length - 1; i++) {
if (typeof fn(...arr) !== types[i].name.toLowerCase()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use intermediate variables

throw new TypeError('Types are different');
}
}
return fn(...arr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check result type

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last argument is a result type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check result type after calling fn

@tshemsedinov
Copy link
Member

Please rebase on master to activate CI

@Destaby Destaby changed the title My work My work is redone Dec 16, 2019
throw new TypeError('Types are different');
}
}
return fn(...arr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check result type after calling fn

if (argType !== neededArgType) {
throw new TypeError('Types are different');
}
if (resultType !== neededReType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you check result types in loop?

@Destaby Destaby changed the title My work is redone My work Dec 17, 2019
@Destaby
Copy link
Author

Destaby commented Dec 17, 2019 via email

@tshemsedinov
Copy link
Member

Please don't send changes in email, commit it directly to git because I need to see diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants