* contains -- Determines if an object is contained in a list with special handling for Parse pointers.
(haystack: Array, needle: any)
| 138 | * contains -- Determines if an object is contained in a list with special handling for Parse pointers. |
| 139 | */ |
| 140 | function contains(haystack: Array, needle: any): boolean { |
| 141 | if (needle && needle.__type && needle.__type === 'Pointer') { |
| 142 | for (const i in haystack) { |
| 143 | const ptr = haystack[i]; |
| 144 | if (typeof ptr === 'string' && ptr === needle.objectId) { |
| 145 | return true; |
| 146 | } |
| 147 | if (ptr.className === needle.className && ptr.objectId === needle.objectId) { |
| 148 | return true; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | return false; |
| 153 | } |
| 154 | |
| 155 | if (Array.isArray(needle)) { |
| 156 | for (const need of needle) { |
| 157 | if (contains(haystack, need)) { |
| 158 | return true; |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | return haystack.indexOf(needle) > -1; |
| 164 | } |
| 165 | /** |
| 166 | * matchesQuery -- Determines if an object would be returned by a Parse Query |
| 167 | * It's a lightweight, where-clause only implementation of a full query engine. |
no outgoing calls
no test coverage detected