diff --git a/docs/conf.py b/docs/conf.py index 2041ce63b..d32fea76c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,9 +55,9 @@ author = u'hydrabolt' # built documents. # # The short X.Y version. -version = '7.0.1' +version = '8.0.0' # The full version, including alpha/beta/rc tags. -release = '7.0.1' +release = '8.0.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/docs_cache.rst b/docs/docs_cache.rst index f1d7a6a39..e46095ebd 100644 --- a/docs/docs_cache.rst +++ b/docs/docs_cache.rst @@ -25,6 +25,10 @@ get(key, value) Returns a contained object where ``object[key] == value``. Also works if value is a regex or a function. Returns the first object found that matches the criteria. +get(value) + +Returns a contained object where ``object["id"] == value``. Shorthand for ``get("id", value)``. Returns ``null`` if ID is not found. + getAll(key, value) ~~~~~~~~~~~~~~~~~~ diff --git a/lib/Util/Cache.js b/lib/Util/Cache.js index 1ed6a545f..cd11d7ced 100644 --- a/lib/Util/Cache.js +++ b/lib/Util/Cache.js @@ -25,6 +25,8 @@ var Cache = (function (_Array) { if (typeof key === 'function') { var valid = key; key = null; + } else if (key && !value) { + return this[discrimCacheS][key] || null; } else if (key === this[discrimS] && typeof value === "string") { return this[discrimCacheS][value] || null; } else if (value && value.constructor.name === 'RegExp') { diff --git a/src/Util/Cache.js b/src/Util/Cache.js index 31b98011c..a37f4c0f2 100644 --- a/src/Util/Cache.js +++ b/src/Util/Cache.js @@ -15,6 +15,8 @@ export default class Cache extends Array { if (typeof key === 'function') { var valid = key; key = null; + } else if (key && !value) { + return this[discrimCacheS][key] || null; } else if (key === this[discrimS] && typeof value === "string") { return this[discrimCacheS][value] || null; } else if (value && value.constructor.name === 'RegExp') {