From 003c11c36b09ce8cde4cd4797989bf9b60920f5a Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 10 Jan 2017 17:25:48 -0800 Subject: [PATCH] Cleanup `stringToPath`. --- .internal/memoizeCapped.js | 2 +- .internal/stringToPath.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.internal/memoizeCapped.js b/.internal/memoizeCapped.js index 01fdca2aa..9a767b0d9 100644 --- a/.internal/memoizeCapped.js +++ b/.internal/memoizeCapped.js @@ -13,13 +13,13 @@ const MAX_MEMOIZE_SIZE = 500; */ function memoizeCapped(func) { const result = memoize(func, key => { + const { cache } = result; if (cache.size === MAX_MEMOIZE_SIZE) { cache.clear(); } return key; }); - const cache = result.cache; return result; } diff --git a/.internal/stringToPath.js b/.internal/stringToPath.js index 642eb8ec9..4b5056e45 100644 --- a/.internal/stringToPath.js +++ b/.internal/stringToPath.js @@ -1,7 +1,8 @@ import memoizeCapped from './.internal/memoizeCapped.js'; /** Used to match property names within property paths. */ -const reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; +const reLeadingDot = /^\./; +const rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** Used to match backslashes in property paths. */ const reEscapeChar = /\\(\\)?/g;