code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
getChildren(rootID: string = DEFAULT_ROOT_ID) { throw new Error( 'No longer supported due to bad performance when used with `expect()`. ' + 'Use `ReactNoop.getChildrenAsJSX()` instead or, if you really need to, `dangerouslyGetChildren` after you carefully considered the warning in its JSDOC.', ...
This is a renderer of React that doesn't have a render target output. It is useful to demonstrate the internals of the reconciler in isolation and for testing semantics of reconciliation separate from the host environment.
getChildren
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
getPendingChildren(rootID: string = DEFAULT_ROOT_ID) { throw new Error( 'No longer supported due to bad performance when used with `expect()`. ' + 'Use `ReactNoop.getPendingChildrenAsJSX()` instead or, if you really need to, `dangerouslyGetPendingChildren` after you carefully considered the warn...
This is a renderer of React that doesn't have a render target output. It is useful to demonstrate the internals of the reconciler in isolation and for testing semantics of reconciliation separate from the host environment.
getPendingChildren
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
dangerouslyGetChildren(rootID: string = DEFAULT_ROOT_ID) { const container = rootContainers.get(rootID); return getChildren(container); }
Prefer using `getChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
dangerouslyGetChildren
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
dangerouslyGetPendingChildren(rootID: string = DEFAULT_ROOT_ID) { const container = rootContainers.get(rootID); return getPendingChildren(container); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
dangerouslyGetPendingChildren
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
render(children: ReactNodeList) { NoopRenderer.updateContainer(children, fiberRoot, null, null); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
render
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
getChildren() { return getChildren(container); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
getChildren
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
getChildrenAsJSX() { return getChildrenAsJSX(container); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
getChildrenAsJSX
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
if (disableLegacyMode) { throw new Error('createLegacyRoot: Unsupported Legacy Mode API.'); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
if
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
render(children: ReactNodeList) { NoopRenderer.updateContainer(children, fiberRoot, null, null); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
render
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
getChildren() { return getChildren(container); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
getChildren
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
getChildrenAsJSX() { return getChildrenAsJSX(container); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
getChildrenAsJSX
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
if (suspenseyThingCache === null) { return null; }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
if
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
if (suspenseyThingCache === null) { suspenseyThingCache = new Map(); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
if
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
if (disableLegacyMode) { throw new Error('createLegacyRoot: Unsupported Legacy Mode API.'); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
if
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
setCurrentUpdatePriority(priority); return fn(); } finally { setCurrentUpdatePriority(previousPriority); }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
setCurrentUpdatePriority
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
fn(); } finally { currentEventPriority = prevEventPriority; }
Prefer using `getPendingChildrenAsJSX`. Using the returned children in `.toEqual` has very poor performance on mismatch due to deep equality checking of fiber structures. Make sure you deeply remove enumerable properties before passing it to `.toEqual`, or, better, use `getChildrenAsJSX` or `toMatchRenderedOutput`.
fn
javascript
facebook/react
packages/react-noop-renderer/src/createReactNoop.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/createReactNoop.js
MIT
createStringDecoder() { return new TextDecoder(); }
This is a renderer of React that doesn't have a render target output. It is useful to demonstrate the internals of the reconciler in isolation and for testing semantics of reconciliation separate from the host environment.
createStringDecoder
javascript
facebook/react
packages/react-noop-renderer/src/ReactNoopFlightClient.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/ReactNoopFlightClient.js
MIT
function write(destination: Destination, buffer: Uint8Array): void { const stack = destination.stack; if (buffer === POP) { stack.pop(); return; } // We assume one chunk is one instance. const instance = JSON.parse(Buffer.from((buffer: any)).toString('utf8')); if (stack.length === 0) { destinati...
This is a renderer of React that doesn't have a render target output. It is useful to demonstrate the internals of the reconciler in isolation and for testing semantics of reconciliation separate from the host environment.
write
javascript
facebook/react
packages/react-noop-renderer/src/ReactNoopServer.js
https://github.com/facebook/react/blob/master/packages/react-noop-renderer/src/ReactNoopServer.js
MIT
function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) { if (newChild.$$typeof === REACT_LEGACY_ELEMENT_TYPE) { throw new Error( 'A React Element from an older version of React was rendered. ' + 'This is not supported. It can happen if:\n' + '- Multiple copies of the "react"...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
throwOnInvalidObjectType
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function warnOnFunctionType(returnFiber: Fiber, invalidChild: Function) { if (__DEV__) { const parentName = getComponentNameFromFiber(returnFiber) || 'Component'; if (ownerHasFunctionTypeWarning[parentName]) { return; } ownerHasFunctionTypeWarning[parentName] = true; const name = invalidCh...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
warnOnFunctionType
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function warnOnSymbolType(returnFiber: Fiber, invalidChild: symbol) { if (__DEV__) { const parentName = getComponentNameFromFiber(returnFiber) || 'Component'; if (ownerHasSymbolTypeWarning[parentName]) { return; } ownerHasSymbolTypeWarning[parentName] = true; // eslint-disable-next-line re...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
warnOnSymbolType
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function resolveLazy(lazyType: any) { if (__DEV__) { return callLazyInitInDEV(lazyType); } const payload = lazyType._payload; const init = lazyType._init; return init(payload); }
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
resolveLazy
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function deleteChild(returnFiber: Fiber, childToDelete: Fiber): void { if (!shouldTrackSideEffects) { // Noop. return; } const deletions = returnFiber.deletions; if (deletions === null) { returnFiber.deletions = [childToDelete]; returnFiber.flags |= ChildDeletion; } else { ...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
deleteChild
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function deleteRemainingChildren( returnFiber: Fiber, currentFirstChild: Fiber | null, ): null { if (!shouldTrackSideEffects) { // Noop. return null; } // TODO: For the shouldClone case, this could be micro-optimized a bit by // assuming that after the first child we've already ad...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
deleteRemainingChildren
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function mapRemainingChildren( currentFirstChild: Fiber, ): Map<string | number, Fiber> { // Add the remaining children to a temporary map so that we can find them by // keys quickly. Implicit (null) keys get added to this set with their index // instead. const existingChildren: Map<string | numbe...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
mapRemainingChildren
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function useFiber(fiber: Fiber, pendingProps: mixed): Fiber { // We currently set sibling to null and index to 0 here because it is easy // to forget to do before returning it. E.g. for the single child case. const clone = createWorkInProgress(fiber, pendingProps); clone.index = 0; clone.sibling = n...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
useFiber
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function placeChild( newFiber: Fiber, lastPlacedIndex: number, newIndex: number, ): number { newFiber.index = newIndex; if (!shouldTrackSideEffects) { // During hydration, the useId algorithm needs to know which fibers are // part of a list of children (arrays, iterators). newFib...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
placeChild
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function placeSingleChild(newFiber: Fiber): Fiber { // This is simpler for the single child case. We only need to do a // placement for inserting new children. if (shouldTrackSideEffects && newFiber.alternate === null) { newFiber.flags |= Placement | PlacementDEV; } return newFiber; }
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
placeSingleChild
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function updateTextNode( returnFiber: Fiber, current: Fiber | null, textContent: string, lanes: Lanes, ) { if (current === null || current.tag !== HostText) { // Insert const created = createFiberFromText(textContent, returnFiber.mode, lanes); created.return = returnFiber; ...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
updateTextNode
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function updateElement( returnFiber: Fiber, current: Fiber | null, element: ReactElement, lanes: Lanes, ): Fiber { const elementType = element.type; if (elementType === REACT_FRAGMENT_TYPE) { const updated = updateFragment( returnFiber, current, element.props.chil...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
updateElement
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function updatePortal( returnFiber: Fiber, current: Fiber | null, portal: ReactPortal, lanes: Lanes, ): Fiber { if ( current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.imp...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
updatePortal
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function reconcileChildrenArray( returnFiber: Fiber, currentFirstChild: Fiber | null, newChildren: Array<any>, lanes: Lanes, ): Fiber | null { // This algorithm can't optimize by searching from both ends since we // don't have backpointers on fibers. I'm trying to see how far we can get //...
Warns if there is a duplicate or missing key
reconcileChildrenArray
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function reconcileChildrenIteratable( returnFiber: Fiber, currentFirstChild: Fiber | null, newChildrenIterable: Iterable<mixed>, lanes: Lanes, ): Fiber | null { // This is the same implementation as reconcileChildrenArray(), // but using the iterator instead. const iteratorFn = getIterato...
Warns if there is a duplicate or missing key
reconcileChildrenIteratable
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
if (__DEV__) { knownKeys = warnOnInvalidKey( returnFiber, newFiber, step.value, knownKeys, ); }
Warns if there is a duplicate or missing key
if
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
if (shouldTrackSideEffects) { if (newFiber.alternate !== null) { // The new fiber is a work in progress, but if there exists a // current, that means that we reused the fiber. We need to delete // it from the child list so that we don't add it to the deletion //...
Warns if there is a duplicate or missing key
if
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
if (child.key === key) { const elementType = element.type; if (elementType === REACT_FRAGMENT_TYPE) { if (child.tag === Fragment) { deleteRemainingChildren(returnFiber, child.sibling); const existing = useFiber(child, element.props.children); if (enableFragm...
Warns if there is a duplicate or missing key
if
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
coerceRef(created, element); } created.return = returnFiber; if (__DEV__) { // We treat the parent as the owner for stack purposes. created._debugOwner = returnFiber; created._debugTask = returnFiber._debugTask; created._debugInfo = currentDebugInfo; }
Warns if there is a duplicate or missing key
coerceRef
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
if (child.key === key) { if ( child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation ) { deleteRemainingChildren(returnFiber, child.sibling); const existing = useFibe...
Warns if there is a duplicate or missing key
if
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
if ( x === SuspenseException || x === SuspenseActionException || (!disableLegacyMode && (returnFiber.mode & ConcurrentMode) === NoMode && typeof x === 'object' && x !== null && typeof x.then === 'function') ) { // Suspense exceptions need to ...
Warns if there is a duplicate or missing key
if
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
for (let i = debugInfo.length - 1; i >= 0; i--) { if (typeof debugInfo[i].stack === 'string') { throwFiber._debugOwner = (debugInfo[i]: any); throwFiber._debugTask = debugInfo[i].debugTask; break; } }
Warns if there is a duplicate or missing key
for
javascript
facebook/react
packages/react-reconciler/src/ReactChildFiber.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactChildFiber.js
MIT
function markUpdate(workInProgress: Fiber) { workInProgress.flags |= Update; }
Tag the fiber with an update effect. This turns a Placement into a PlacementAndUpdate.
markUpdate
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function markCloned(workInProgress: Fiber) { if (supportsPersistence && enablePersistedModeClonedFlag) { workInProgress.flags |= Cloned; } }
Tag the fiber with Cloned in persistent mode to signal that it received an update that requires a clone of the tree above.
markCloned
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function doesRequireClone(current: null | Fiber, completedWork: Fiber) { const didBailout = current !== null && current.child === completedWork.child; if (didBailout) { return false; } if ((completedWork.flags & ChildDeletion) !== NoFlags) { return true; } // TODO: If we move the `doesRequireClone...
In persistent mode, return whether this update needs to clone the subtree.
doesRequireClone
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function appendAllChildren( parent: Instance, workInProgress: Fiber, needsVisibilityToggle: boolean, isHidden: boolean, ) { if (supportsMutation) { // We only have the top Fiber that was created but we need recurse down its // children to find all the terminal nodes. let node = workInProgress.chil...
In persistent mode, return whether this update needs to clone the subtree.
appendAllChildren
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function appendAllChildrenToContainer( containerChildSet: ChildSet, workInProgress: Fiber, needsVisibilityToggle: boolean, isHidden: boolean, ): boolean { // Host components that have their visibility toggled by an OffscreenComponent // do not support passChildrenWhenCloningPersistedNodes. To inform the cal...
In persistent mode, return whether this update needs to clone the subtree.
appendAllChildrenToContainer
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function updateHostContainer(current: null | Fiber, workInProgress: Fiber) { if (supportsPersistence) { if (doesRequireClone(current, workInProgress)) { const portalOrRoot: { containerInfo: Container, pendingChildren: ChildSet, ... } = workInProgress.stateNode; const cont...
In persistent mode, return whether this update needs to clone the subtree.
updateHostContainer
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function updateHostComponent( current: Fiber, workInProgress: Fiber, type: Type, newProps: Props, renderLanes: Lanes, ) { if (supportsMutation) { // If we have an alternate, that means this is an update and we need to // schedule a side-effect to do the updates. const oldProps = current.memoized...
In persistent mode, return whether this update needs to clone the subtree.
updateHostComponent
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function preloadInstanceAndSuspendIfNeeded( workInProgress: Fiber, type: Type, oldProps: null | Props, newProps: Props, renderLanes: Lanes, ) { const maySuspend = (enableSuspenseyImages || (workInProgress.mode & SuspenseyImagesMode) !== NoMode) && (oldProps === null ? maySuspendCommit(ty...
In persistent mode, return whether this update needs to clone the subtree.
preloadInstanceAndSuspendIfNeeded
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function preloadResourceAndSuspendIfNeeded( workInProgress: Fiber, resource: Resource, type: Type, props: Props, renderLanes: Lanes, ) { // This is a fork of preloadInstanceAndSuspendIfNeeded, but for resources. if (!mayResourceSuspendCommit(resource)) { workInProgress.flags &= ~MaySuspendCommit; ...
In persistent mode, return whether this update needs to clone the subtree.
preloadResourceAndSuspendIfNeeded
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function scheduleRetryEffect( workInProgress: Fiber, retryQueue: RetryQueue | null, ) { const wakeables = retryQueue; if (wakeables !== null) { // Schedule an effect to attach a retry listener to the promise. // TODO: Move to passive phase workInProgress.flags |= Update; } // Check if we need t...
In persistent mode, return whether this update needs to clone the subtree.
scheduleRetryEffect
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function updateHostText( current: Fiber, workInProgress: Fiber, oldText: string, newText: string, ) { if (supportsMutation) { // If the text differs, mark it as an update. All the work in done in commitWork. if (oldText !== newText) { markUpdate(workInProgress); } } else if (supportsPersis...
In persistent mode, return whether this update needs to clone the subtree.
updateHostText
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function cutOffTailIfNeeded( renderState: SuspenseListRenderState, hasRenderedATailFallback: boolean, ) { if (getIsHydrating()) { // If we're hydrating, we should consume as many items as we can // so we don't leave any behind. return; } switch (renderState.tailMode) { case 'hidden': { /...
In persistent mode, return whether this update needs to clone the subtree.
cutOffTailIfNeeded
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function bubbleProperties(completedWork: Fiber) { const didBailout = completedWork.alternate !== null && completedWork.alternate.child === completedWork.child; let newChildLanes: Lanes = NoLanes; let subtreeFlags = NoFlags; if (!didBailout) { // Bubble up the earliest expiration time. if (enab...
In persistent mode, return whether this update needs to clone the subtree.
bubbleProperties
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function completeDehydratedActivityBoundary( current: Fiber | null, workInProgress: Fiber, nextState: ActivityState | null, ): boolean { const wasHydrated = popHydrationState(workInProgress); if (nextState !== null) { // We might be inside a hydration state the first time we're picking up this // Act...
In persistent mode, return whether this update needs to clone the subtree.
completeDehydratedActivityBoundary
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function completeDehydratedSuspenseBoundary( current: Fiber | null, workInProgress: Fiber, nextState: SuspenseState | null, ): boolean { const wasHydrated = popHydrationState(workInProgress); if (nextState !== null && nextState.dehydrated !== null) { // We might be inside a hydration state the first time...
In persistent mode, return whether this update needs to clone the subtree.
completeDehydratedSuspenseBoundary
javascript
facebook/react
packages/react-reconciler/src/ReactFiberCompleteWork.js
https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberCompleteWork.js
MIT
function describeNativeComponentFrame( fn: Function, construct: boolean, ): string { // If something asked for a stack inside a fake render, it should get ignored. if (!fn || reentry) { return ''; } if (__DEV__) { const frame = componentFrameCache.get(fn); if (frame !== undefined) { retur...
Leverages native browser/VM stack frames to get proper details (e.g. filename, line + col number) for a single component in a component stack. We do this by: (1) throwing and catching an error in the function - this will be our control error. (2) calling the component which will eventually throw an error that...
describeNativeComponentFrame
javascript
facebook/react
packages/shared/ReactComponentStackFrame.js
https://github.com/facebook/react/blob/master/packages/shared/ReactComponentStackFrame.js
MIT
function describeClassComponentFrame(ctor: Function): string { return describeNativeComponentFrame(ctor, true); }
Finding a common stack frame between sample and control errors can be tricky given the different types and levels of stack trace truncation from different JS VMs. So instead we'll attempt to control what that common frame should be through this object method: Having both the sample and control errors be in the function...
describeClassComponentFrame
javascript
facebook/react
packages/shared/ReactComponentStackFrame.js
https://github.com/facebook/react/blob/master/packages/shared/ReactComponentStackFrame.js
MIT
function describeFunctionComponentFrame(fn: Function): string { return describeNativeComponentFrame(fn, false); }
Finding a common stack frame between sample and control errors can be tricky given the different types and levels of stack trace truncation from different JS VMs. So instead we'll attempt to control what that common frame should be through this object method: Having both the sample and control errors be in the function...
describeFunctionComponentFrame
javascript
facebook/react
packages/shared/ReactComponentStackFrame.js
https://github.com/facebook/react/blob/master/packages/shared/ReactComponentStackFrame.js
MIT
function get(key) { return key._reactInternals; }
`ReactInstanceMap` maintains a mapping from a public facing stateful instance (key) and the internal representation (value). This allows public methods to accept the user facing instance as an argument and map them back to internal methods. Note that this module is currently shared and assumed to be stateless. If this...
get
javascript
facebook/react
packages/shared/ReactInstanceMap.js
https://github.com/facebook/react/blob/master/packages/shared/ReactInstanceMap.js
MIT
function set(key, value) { key._reactInternals = value; }
`ReactInstanceMap` maintains a mapping from a public facing stateful instance (key) and the internal representation (value). This allows public methods to accept the user facing instance as an argument and map them back to internal methods. Note that this module is currently shared and assumed to be stateless. If this...
set
javascript
facebook/react
packages/shared/ReactInstanceMap.js
https://github.com/facebook/react/blob/master/packages/shared/ReactInstanceMap.js
MIT
function shallowEqual(objA: mixed, objB: mixed): boolean { if (is(objA, objB)) { return true; } if ( typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null ) { return false; } const keysA = Object.keys(objA); const keysB = Object.keys(objB); if ...
Performs equality by iterating through keys on an object and returning false when any key has values which are not strictly equal between the arguments. Returns true when the values of all keys are strictly equal.
shallowEqual
javascript
facebook/react
packages/shared/shallowEqual.js
https://github.com/facebook/react/blob/master/packages/shared/shallowEqual.js
MIT
function invertObject(targetObj) { const result = {}; const mapKeys = Object.keys(targetObj); // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (const originalKey of mapKeys) { const originalVal = targetObj[originalKey]; result[originalVal] = originalKey; } return result; }
turns { 'MUCH ERROR': '0', 'SUCH WRONG': '1' } into { 0: 'MUCH ERROR', 1: 'SUCH WRONG' }
invertObject
javascript
facebook/react
scripts/error-codes/invertObject.js
https://github.com/facebook/react/blob/master/scripts/error-codes/invertObject.js
MIT
function isEquivalentCode(node1, node2) { return ( JSON.stringify(node1, astReplacer) === JSON.stringify(node2, astReplacer) ); }
Simplistic comparison between AST node. Only the following patterns are supported because that's almost all (all?) usage in React: - Identifiers, e.g. `foo` - Member access, e.g. `foo.bar` - Array access with numeric literal, e.g. `foo[0]`
isEquivalentCode
javascript
facebook/react
scripts/eslint-rules/safe-string-coercion.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/safe-string-coercion.js
MIT
function isDescendant(node, maybeParentNode) { let parent = node.parent; while (parent) { if (!parent) { return false; } if (parent === maybeParentNode) { return true; } parent = parent.parent; } return false; }
Simplistic comparison between AST node. Only the following patterns are supported because that's almost all (all?) usage in React: - Identifiers, e.g. `foo` - Member access, e.g. `foo.bar` - Array access with numeric literal, e.g. `foo[0]`
isDescendant
javascript
facebook/react
scripts/eslint-rules/safe-string-coercion.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/safe-string-coercion.js
MIT
function isSafeTypeofExpression(originalValueNode, node) { if (node.type === 'BinaryExpression') { // Example: typeof foo === 'string' if (node.operator !== '===') { return false; } const {left, right} = node; // left must be `typeof original` if (left.type !== 'UnaryExpression' || left...
Simplistic comparison between AST node. Only the following patterns are supported because that's almost all (all?) usage in React: - Identifiers, e.g. `foo` - Member access, e.g. `foo.bar` - Array access with numeric literal, e.g. `foo[0]`
isSafeTypeofExpression
javascript
facebook/react
scripts/eslint-rules/safe-string-coercion.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/safe-string-coercion.js
MIT
function isInSafeTypeofBlock(originalValueNode, node) { if (!node) { node = originalValueNode; } let parent = node.parent; while (parent) { if (!parent) { return false; } // Normally, if the parent block is inside a type-safe `if` statement, // then all child code is also type-safe. Bu...
Returns true if the code is inside an `if` block that validates the value excludes symbols and objects. Examples: if (typeof value === 'string') { } if (typeof value === 'string' || typeof value === 'number') { } if (typeof value === 'string' || someOtherTest) { } @param - originalValueNode Top-level expression to...
isInSafeTypeofBlock
javascript
facebook/react
scripts/eslint-rules/safe-string-coercion.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/safe-string-coercion.js
MIT
function hasCoercionCheck(node) { // find the containing statement let topOfExpression = node; while (!topOfExpression.parent.body) { topOfExpression = topOfExpression.parent; if (!topOfExpression) { return 'Cannot find top of expression.'; } } const containingBlock = topOfExpression.parent....
Does this node have an "is coercion safe?" DEV check in the same block?
hasCoercionCheck
javascript
facebook/react
scripts/eslint-rules/safe-string-coercion.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/safe-string-coercion.js
MIT
function isOnlyAddingStrings(node) { if (node.operator !== '+') { return; } if (isStringLiteral(node.left) && isStringLiteral(node.right)) { // It's always safe to add string literals return true; } if (node.left.type === 'BinaryExpression' && isStringLiteral(node.right)) { return isOnlyAdding...
Does this node have an "is coercion safe?" DEV check in the same block?
isOnlyAddingStrings
javascript
facebook/react
scripts/eslint-rules/safe-string-coercion.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/safe-string-coercion.js
MIT
function checkBinaryExpression(context, node) { if (isOnlyAddingStrings(node)) { return; } if ( node.operator === '+' && (isEmptyLiteral(node.left) || isEmptyLiteral(node.right)) ) { let valueToTest = isEmptyLiteral(node.left) ? node.right : node.left; if ( (valueToTest.type === 'Type...
Does this node have an "is coercion safe?" DEV check in the same block?
checkBinaryExpression
javascript
facebook/react
scripts/eslint-rules/safe-string-coercion.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/safe-string-coercion.js
MIT
function coerceWithStringConstructor(context, node) { const isProductionUserAppCode = context.options[0] && context.options[0].isProductionUserAppCode; if (isProductionUserAppCode && node.callee.name === 'String') { context.report( node, "For perf-sensitive coercion, avoid `String(value)`. Inste...
Does this node have an "is coercion safe?" DEV check in the same block?
coerceWithStringConstructor
javascript
facebook/react
scripts/eslint-rules/safe-string-coercion.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/safe-string-coercion.js
MIT
create(context) { return { BinaryExpression: node => checkBinaryExpression(context, node), CallExpression: node => coerceWithStringConstructor(context, node), }; }
Does this node have an "is coercion safe?" DEV check in the same block?
create
javascript
facebook/react
scripts/eslint-rules/safe-string-coercion.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/safe-string-coercion.js
MIT
create(context) { // we also allow literal strings and concatenated literal strings function getLiteralString(node) { if (node.type === 'Literal' && typeof node.value === 'string') { return node.value; } else if (node.type === 'BinaryExpression' && node.operator === '+') { const l = ...
The warning() function takes format strings as its second argument.
create
javascript
facebook/react
scripts/eslint-rules/warning-args.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/warning-args.js
MIT
function getLiteralString(node) { if (node.type === 'Literal' && typeof node.value === 'string') { return node.value; } else if (node.type === 'BinaryExpression' && node.operator === '+') { const l = getLiteralString(node.left); const r = getLiteralString(node.right); if (l !...
The warning() function takes format strings as its second argument.
getLiteralString
javascript
facebook/react
scripts/eslint-rules/warning-args.js
https://github.com/facebook/react/blob/master/scripts/eslint-rules/warning-args.js
MIT
constructor(config, context) { super(config, context); this.domEnvironment = new ReactJSDOMEnvironment(config, context); this.global.window = this.domEnvironment.dom.window; this.global.document = this.global.window.document; this.global.navigator = this.global.window.navigator; this.global.No...
Test environment for testing integration of react-dom (browser) with react-dom/server (node)
constructor
javascript
facebook/react
scripts/jest/ReactDOMServerIntegrationEnvironment.js
https://github.com/facebook/react/blob/master/scripts/jest/ReactDOMServerIntegrationEnvironment.js
MIT
async setup() { await super.setup(); await this.domEnvironment.setup(); }
Test environment for testing integration of react-dom (browser) with react-dom/server (node)
setup
javascript
facebook/react
scripts/jest/ReactDOMServerIntegrationEnvironment.js
https://github.com/facebook/react/blob/master/scripts/jest/ReactDOMServerIntegrationEnvironment.js
MIT
async teardown() { await this.domEnvironment.teardown(); await super.teardown(); }
Test environment for testing integration of react-dom (browser) with react-dom/server (node)
teardown
javascript
facebook/react
scripts/jest/ReactDOMServerIntegrationEnvironment.js
https://github.com/facebook/react/blob/master/scripts/jest/ReactDOMServerIntegrationEnvironment.js
MIT
constructor(config, context) { super(config, context); setupDocumentReadyState(this.global.document, this.global.Event); }
Test environment for testing integration of react-dom (browser) with react-dom/server (node)
constructor
javascript
facebook/react
scripts/jest/ReactJSDOMEnvironment.js
https://github.com/facebook/react/blob/master/scripts/jest/ReactJSDOMEnvironment.js
MIT
function mergeDirsSync(source, destination) { for (const sourceFileBaseName of fs.readdirSync(source)) { const sourceFileName = path.join(source, sourceFileBaseName); const targetFileName = path.join(destination, sourceFileBaseName); const sourceFile = fs.statSync(sourceFileName); if (sourceFile.isDi...
cross-platform alternative to `rsync -ar` @param {string} source @param {string} destination
mergeDirsSync
javascript
facebook/react
scripts/rollup/build-all-release-channels.js
https://github.com/facebook/react/blob/master/scripts/rollup/build-all-release-channels.js
MIT
function enumerableOnly(x) { const copy = Array.isArray(x) ? x.slice() : Object.assign({}, x) each(copy, (prop, value) => { if (value && typeof value === "object") { copy[prop] = enumerableOnly(value) } }) return copy }
These objects are treated as literals because Immer does not know how to draft them.
enumerableOnly
javascript
immerjs/immer
__tests__/base.js
https://github.com/immerjs/immer/blob/master/__tests__/base.js
MIT
function isEnumerable(base, prop) { const desc = Object.getOwnPropertyDescriptor(base, prop) return desc && desc.enumerable ? true : false }
These objects are treated as literals because Immer does not know how to draft them.
isEnumerable
javascript
immerjs/immer
__tests__/base.js
https://github.com/immerjs/immer/blob/master/__tests__/base.js
MIT
createImageResizer = (width, height) => (source) => { const resized = new PNG({ width, height, fill: true }); PNG.bitblt(source, resized, 0, 0, source.width, source.height, 0, 0); return resized; }
Helper function to create reusable image resizer
createImageResizer
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
createImageResizer = (width, height) => (source) => { const resized = new PNG({ width, height, fill: true }); PNG.bitblt(source, resized, 0, 0, source.width, source.height, 0, 0); return resized; }
Helper function to create reusable image resizer
createImageResizer
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
fillSizeDifference = (width, height) => (image) => { const inArea = (x, y) => y > height || x > width; for (let y = 0; y < image.height; y++) { for (let x = 0; x < image.width; x++) { if (inArea(x, y)) { const idx = ((image.width * y) + x) << 2; image.data[idx] = 0; image.data[idx ...
Fills diff area with black transparent color for meaningful diff
fillSizeDifference
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
fillSizeDifference = (width, height) => (image) => { const inArea = (x, y) => y > height || x > width; for (let y = 0; y < image.height; y++) { for (let x = 0; x < image.width; x++) { if (inArea(x, y)) { const idx = ((image.width * y) + x) << 2; image.data[idx] = 0; image.data[idx ...
Fills diff area with black transparent color for meaningful diff
fillSizeDifference
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
ssimMatch = ( newImageData, baselineImageData, diffImageData, imageWidth, imageHeight, diffConfig ) => { const newImage = { data: newImageData, width: imageWidth, height: imageHeight }; const baselineImage = { data: baselineImageData, width: imageWidth, height: imageHeight }; // eslint-disable-next-li...
Helper function for SSIM comparison that allows us to use the existing diff config that works with jest-image-snapshot to pass parameters that will work with SSIM. It also transforms the parameters to match the spec required by the SSIM library.
ssimMatch
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
ssimMatch = ( newImageData, baselineImageData, diffImageData, imageWidth, imageHeight, diffConfig ) => { const newImage = { data: newImageData, width: imageWidth, height: imageHeight }; const baselineImage = { data: baselineImageData, width: imageWidth, height: imageHeight }; // eslint-disable-next-li...
Helper function for SSIM comparison that allows us to use the existing diff config that works with jest-image-snapshot to pass parameters that will work with SSIM. It also transforms the parameters to match the spec required by the SSIM library.
ssimMatch
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
alignImagesToSameSize = (firstImage, secondImage) => { // Keep original sizes to fill extended area later const firstImageWidth = firstImage.width; const firstImageHeight = firstImage.height; const secondImageWidth = secondImage.width; const secondImageHeight = secondImage.height; // Calculate biggest commo...
Aligns images sizes to biggest common value and fills new pixels with transparent pixels
alignImagesToSameSize
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
alignImagesToSameSize = (firstImage, secondImage) => { // Keep original sizes to fill extended area later const firstImageWidth = firstImage.width; const firstImageHeight = firstImage.height; const secondImageWidth = secondImage.width; const secondImageHeight = secondImage.height; // Calculate biggest commo...
Aligns images sizes to biggest common value and fills new pixels with transparent pixels
alignImagesToSameSize
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
shouldUpdate = ({ pass, updateSnapshot, updatePassedSnapshot }) => updateSnapshot && (!pass || (pass && updatePassedSnapshot))
Aligns images sizes to biggest common value and fills new pixels with transparent pixels
shouldUpdate
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
shouldUpdate = ({ pass, updateSnapshot, updatePassedSnapshot }) => updateSnapshot && (!pass || (pass && updatePassedSnapshot))
Aligns images sizes to biggest common value and fills new pixels with transparent pixels
shouldUpdate
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
shouldFail = ({ totalPixels, diffPixelCount, hasSizeMismatch, allowSizeMismatch, failureThresholdType, failureThreshold, }) => { let pass = false; let diffSize = false; const diffRatio = diffPixelCount / totalPixels; if (hasSizeMismatch) { // do not fail if allowSizeMismatch is set pass = al...
Aligns images sizes to biggest common value and fills new pixels with transparent pixels
shouldFail
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
shouldFail = ({ totalPixels, diffPixelCount, hasSizeMismatch, allowSizeMismatch, failureThresholdType, failureThreshold, }) => { let pass = false; let diffSize = false; const diffRatio = diffPixelCount / totalPixels; if (hasSizeMismatch) { // do not fail if allowSizeMismatch is set pass = al...
Aligns images sizes to biggest common value and fills new pixels with transparent pixels
shouldFail
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
function composeDiff(options) { const { diffDirection, baselineImage, diffImage, receivedImage, imageWidth, imageHeight, onlyDiff, } = options; const composer = new ImageComposer({ direction: diffDirection, }); if (onlyDiff) { composer.addImage(diffImage, imageWidth, imageHeight); } else { ...
Aligns images sizes to biggest common value and fills new pixels with transparent pixels
composeDiff
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
function writeFileWithHooks({ pathToFile, content, runtimeHooksPath, testPath, currentTestName, }) { let finalContent = content; if (runtimeHooksPath) { let runtimeHooks; try { // As `diffImageToSnapshot` can be called in a worker, and as we cannot pass a function // to a worker, we ne...
Aligns images sizes to biggest common value and fills new pixels with transparent pixels
writeFileWithHooks
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
function diffImageToSnapshot(options) { const { receivedImageBuffer, snapshotIdentifier, snapshotsDir, storeReceivedOnFailure, receivedPostfix = '-received', receivedDir = path.join(options.snapshotsDir, '__received_output__'), diffDir = path.join(options.snapshotsDir, '__diff_output__'), ...
Aligns images sizes to biggest common value and fills new pixels with transparent pixels
diffImageToSnapshot
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
function runDiffImageToSnapshot(options) { options.receivedImageBuffer = options.receivedImageBuffer.toString('base64'); const serializedInput = JSON.stringify(options); let result = {}; const writeDiffProcess = childProcess.spawnSync( process.execPath, [`${__dirname}/diff-process.js`], { input...
Aligns images sizes to biggest common value and fills new pixels with transparent pixels
runDiffImageToSnapshot
javascript
americanexpress/jest-image-snapshot
src/diff-snapshot.js
https://github.com/americanexpress/jest-image-snapshot/blob/master/src/diff-snapshot.js
Apache-2.0
function normalizePort(val) { var port = parseInt(val, 10); if (isNaN(port)) { // named pipe return val; } if (port >= 0) { // port number return port; } return false; }
Normalize a port into a number, string, or false.
normalizePort
javascript
a597873885/webfunny_monitor
servers/logger/config/log_server.js
https://github.com/a597873885/webfunny_monitor/blob/master/servers/logger/config/log_server.js
Apache-2.0
getFileSize = filePath => { return fileSize( gzipSize.sync( fs.readFileSync( filePath ) ) ); }
Get File Size Get filesizes of all the files. @param {string} filePath path. @returns {string} then size result.
getFileSize
javascript
ahmadawais/create-guten-block
examples/02-single-block-ejected/scripts/build.js
https://github.com/ahmadawais/create-guten-block/blob/master/examples/02-single-block-ejected/scripts/build.js
MIT
getFileSize = filePath => { return fileSize( gzipSize.sync( fs.readFileSync( filePath ) ) ); }
Get File Size Get filesizes of all the files. @param {string} filePath path. @returns {string} then size result.
getFileSize
javascript
ahmadawais/create-guten-block
examples/02-single-block-ejected/scripts/build.js
https://github.com/ahmadawais/create-guten-block/blob/master/examples/02-single-block-ejected/scripts/build.js
MIT
getFileSize = filePath => { return fileSize( gzipSize.sync( fs.readFileSync( filePath ) ) ); }
Get File Size Get filesizes of all the files. @param {string} filePath path. @returns {string} then size result.
getFileSize
javascript
ahmadawais/create-guten-block
examples/04-multi-block-ejected/scripts/build.js
https://github.com/ahmadawais/create-guten-block/blob/master/examples/04-multi-block-ejected/scripts/build.js
MIT