webpack/lib/removeAndDo.js

14 lines
321 B
JavaScript
Raw Normal View History

2014-06-25 00:53:32 +08:00
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function removeAndDo(collection, thing, action) {
var idx = this[collection].indexOf(thing);
if(idx >= 0) {
2014-06-25 00:53:32 +08:00
this[collection].splice(idx, 1);
thing[action](this);
return true;
2014-06-25 00:53:32 +08:00
}
return false;
};