1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-01 11:12:42 +02:00

Revert "Remove extra LEAF in memoize"

It was breaking for variable argument length methods
This reverts commit 85ebf7fffa.
This commit is contained in:
Soreine
2016-11-02 17:23:56 +01:00
parent a4460354c6
commit 77385326f0

View File

@@ -1,6 +1,16 @@
import { Map } from 'immutable'
/**
* The leaf node of a cache tree.
*
* An object, so that immutable maps will key it by reference.
*
* @type {Object}
*/
const LEAF = {}
/**
* An unique value used to detect cache misses
*
@@ -26,7 +36,7 @@ function memoize(object, properties) {
}
object[property] = function (...args) {
const keys = [property, ...args]
const keys = [property, ...args, LEAF]
this.__cache = this.__cache || new Map()
const cachedValue = this.__cache.getIn(keys, NO_SET)