forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate all symbols in a single file (facebook#11629)
* Consolidate all symbols in a single file This reduces the code duplication as we have quite a few now. * Record sizes
- Loading branch information
1 parent
2d9b015
commit 77e22a2
Showing
10 changed files
with
147 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* 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. | ||
* | ||
* @flow | ||
*/ | ||
|
||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol | ||
// nor polyfill, then a plain number is used for performance. | ||
const hasSymbol = typeof Symbol === 'function' && Symbol.for; | ||
|
||
export const REACT_ELEMENT_TYPE = hasSymbol | ||
? Symbol.for('react.element') | ||
: 0xeac7; | ||
export const REACT_CALL_TYPE = hasSymbol ? Symbol.for('react.call') : 0xeac8; | ||
export const REACT_RETURN_TYPE = hasSymbol | ||
? Symbol.for('react.return') | ||
: 0xeac9; | ||
export const REACT_PORTAL_TYPE = hasSymbol | ||
? Symbol.for('react.portal') | ||
: 0xeaca; | ||
export const REACT_FRAGMENT_TYPE = hasSymbol | ||
? Symbol.for('react.fragment') | ||
: 0xeacb; | ||
|
||
const MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; | ||
const FAUX_ITERATOR_SYMBOL = '@@iterator'; | ||
|
||
export function getIteratorFn(maybeIterable: ?any): ?() => ?Iterator<*> { | ||
if (maybeIterable === null || typeof maybeIterable === 'undefined') { | ||
return null; | ||
} | ||
const maybeIterator = | ||
(MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || | ||
maybeIterable[FAUX_ITERATOR_SYMBOL]; | ||
if (typeof maybeIterator === 'function') { | ||
return maybeIterator; | ||
} | ||
return null; | ||
} |
Oops, something went wrong.