Skip to content
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

Added yank function #35

Merged
merged 2 commits into from
Sep 26, 2018
Merged

Conversation

decarbonite
Copy link
Contributor

Fixes #29

this.remove(value);
return value;
} else{
throw "Value not in the array";

Choose a reason for hiding this comment

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

I think it'd be better to just return a null if there is nothing found in the yank. That way if it was going to be used in a if statement, or a tertiary statement it could be used like if(foo.yank(2)). Here it'd just throw a crazy uncaught error.

@@ -50,6 +50,30 @@ extensionArray.remove = function remove(selector) {
return this;
};

/**
* Remove all instances of a value within the array and return the removed value
* @param {*} value - The value trying to match against

Choose a reason for hiding this comment

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

Return value in JSDoc :)

@@ -68,6 +68,22 @@ describe('array prototype', () => {
})
})

describe('Array yank prototype', () => {
it('should return removed values and mutate the array ', () => {

Choose a reason for hiding this comment

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

Maybe test for the not found instance as well 👍

@El-Dringo-Brannde
Copy link
Owner

El-Dringo-Brannde commented Sep 25, 2018

Oops! @decarbonite Been distracted by real life, I'll try and get to this later tonight 🤞

@El-Dringo-Brannde El-Dringo-Brannde merged commit abd9fff into El-Dringo-Brannde:master Sep 26, 2018
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