-
Notifications
You must be signed in to change notification settings - Fork 1
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
Added yank function #35
Conversation
src/Array/extensions.js
Outdated
this.remove(value); | ||
return value; | ||
} else{ | ||
throw "Value not in the array"; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 ', () => { |
There was a problem hiding this comment.
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 👍
Oops! @decarbonite Been distracted by real life, I'll try and get to this later tonight 🤞 |
Fixes #29