mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
Cache now returns null when using get(cacheID) with invalid ID (#441)
* Cache now returns `null` when using get(cacheID) where the ID is invalid. * Documented `get(id)` * Adjusted version in conf.py to 8.0.0
This commit is contained in:
@@ -55,9 +55,9 @@ author = u'hydrabolt'
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '7.0.1'
|
version = '8.0.0'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# 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
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|||||||
@@ -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.
|
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)
|
getAll(key, value)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ var Cache = (function (_Array) {
|
|||||||
if (typeof key === 'function') {
|
if (typeof key === 'function') {
|
||||||
var valid = key;
|
var valid = key;
|
||||||
key = null;
|
key = null;
|
||||||
|
} else if (key && !value) {
|
||||||
|
return this[discrimCacheS][key] || null;
|
||||||
} else if (key === this[discrimS] && typeof value === "string") {
|
} else if (key === this[discrimS] && typeof value === "string") {
|
||||||
return this[discrimCacheS][value] || null;
|
return this[discrimCacheS][value] || null;
|
||||||
} else if (value && value.constructor.name === 'RegExp') {
|
} else if (value && value.constructor.name === 'RegExp') {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ export default class Cache extends Array {
|
|||||||
if (typeof key === 'function') {
|
if (typeof key === 'function') {
|
||||||
var valid = key;
|
var valid = key;
|
||||||
key = null;
|
key = null;
|
||||||
|
} else if (key && !value) {
|
||||||
|
return this[discrimCacheS][key] || null;
|
||||||
} else if (key === this[discrimS] && typeof value === "string") {
|
} else if (key === this[discrimS] && typeof value === "string") {
|
||||||
return this[discrimCacheS][value] || null;
|
return this[discrimCacheS][value] || null;
|
||||||
} else if (value && value.constructor.name === 'RegExp') {
|
} else if (value && value.constructor.name === 'RegExp') {
|
||||||
|
|||||||
Reference in New Issue
Block a user