From 67b6d3d5ea7d8ed7127f7f9129660510f9292716 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Wed, 8 Sep 2010 16:39:38 -0800 Subject: [PATCH] take out memoization since it breaks if the hash gets modified outside the fluent interface --- lib/hash.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/hash.js b/lib/hash.js index 73be18d..a2e25eb 100644 --- a/lib/hash.js +++ b/lib/hash.js @@ -80,20 +80,13 @@ function Hash (hash, xs) { items : hash }; - var memoized = {}; Object.defineProperty(self, 'keys', { get : function () { - if (memoized.keys === undefined) { - memoized.keys = Object.keys(hash); - } - return memoized.keys + return Object.keys(hash); } }); Object.defineProperty(self, 'values', { get : function () { - if (memoized.values === undefined) { - memoized.values = Object.keys(hash) - .map(function (key) { return hash[key] }); - } - return memoized.values; + return Object.keys(hash) + .map(function (key) { return hash[key] }); } }); Object.defineProperty(self, 'compact', { get : function () { @@ -109,10 +102,7 @@ function Hash (hash, xs) { } }); Object.defineProperty(self, 'length', { get : function () { - if (memoized.length === undefined) { - memoized.length = Object.keys(hash).length; - } - return memoized.length; + return Object.keys(hash).length; } }); return self;