diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/fbjs/lib/equalsIterable.js | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/fbjs/lib/equalsIterable.js')
-rw-r--r-- | node_modules/fbjs/lib/equalsIterable.js | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/node_modules/fbjs/lib/equalsIterable.js b/node_modules/fbjs/lib/equalsIterable.js deleted file mode 100644 index 70ff48da2..000000000 --- a/node_modules/fbjs/lib/equalsIterable.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * - */ - -'use strict'; - -var enumerate = require('./enumerate'); - -/** - * Checks if two iterables are equal. A custom areEqual function may be provided - * as an optional third argument. - */ -function equalsIterable(one, two, areEqual) { - if (one === two) { - return true; - } - - // We might be able to short circuit by using the size or length fields. - var oneSize = maybeGetSize(one); - var twoSize = maybeGetSize(two); - if (oneSize != null && twoSize != null && oneSize !== twoSize) { - return false; - } - - // Otherwise use the iterators to check equality. Here we cannot use for-of - // because we need to advance the iterators at the same time. - var oneIterator = enumerate(one); - var oneItem = oneIterator.next(); - var twoIterator = enumerate(two); - var twoItem = twoIterator.next(); - var safeAreEqual = areEqual || referenceEquality; - while (!(oneItem.done || twoItem.done)) { - if (!safeAreEqual(oneItem.value, twoItem.value)) { - return false; - } - oneItem = oneIterator.next(); - twoItem = twoIterator.next(); - } - return oneItem.done === twoItem.done; -} - -function maybeGetSize(o) { - if (o == null) { - return null; - } - if (typeof o.size === 'number') { - return o.size; - } - if (typeof o.length === 'number') { - return o.length; - } - return null; -} - -function referenceEquality(one, two) { - return one === two; -} - -module.exports = equalsIterable;
\ No newline at end of file |