This code makes sure that the command has a key "cursor" with an array that at least has a key "batchSize" with a value. It first checks if the command is actually an array, although this test isn't strictly necessary as it would have been caught out before. Then it checks whether there is a key on the command set with the name "cursor". If it's there, it continues, if not, it creates a element with key "cursor" and an empty array. If there *was* already a key with name "cursor", if it's not an array, we bail out. We continue in the other case — which would happen if we either created the key "cursor" (with an empty array), or when it already existed as an array. And then lastly we make sure that the "cursor" array has an element "batchSize". If it has not, we create one and set its value to the batchsize. If it did exist, we don't do nothing (and leave it to the server to throw out "wrong" values). I'm pretty sure that's exactly how the codes read too.