From 85da55d9175fc54a031cd259802e59691b0bd4d0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 28 Dec 2015 20:34:17 -0600 Subject: [PATCH] Add `Stack#clear`. --- lodash.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index 35f2017d8..a19630b7a 100644 --- a/lodash.js +++ b/lodash.js @@ -1933,13 +1933,24 @@ var index = -1, length = values ? values.length : 0; - this.__data__ = { 'array': [], 'map': null }; + this.clear(); while (++index < length) { var entry = values[index]; this.set(entry[0], entry[1]); } } + /** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ + function stackClear() { + this.__data__ = { 'array': [], 'map': null }; + } + /** * Removes `key` and its value from the stack. * @@ -13802,6 +13813,7 @@ SetCache.prototype.push = cachePush; // Add functions to the `Stack` cache. + Stack.prototype.clear = stackClear; Stack.prototype['delete'] = stackDelete; Stack.prototype.get = stackGet; Stack.prototype.has = stackHas;