Init
This commit is contained in:
43
node_modules/@prefresh/utils/src/index.js
generated
vendored
Normal file
43
node_modules/@prefresh/utils/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
const compareSignatures = (prev, next) => {
|
||||
const prevSignature = self.__PREFRESH__.getSignature(prev) || {};
|
||||
const nextSignature = self.__PREFRESH__.getSignature(next) || {};
|
||||
|
||||
if (
|
||||
prevSignature.key !== nextSignature.key ||
|
||||
self.__PREFRESH__.computeKey(prevSignature) !==
|
||||
self.__PREFRESH__.computeKey(nextSignature) ||
|
||||
nextSignature.forceReset
|
||||
) {
|
||||
self.__PREFRESH__.replaceComponent(prev, next, true);
|
||||
} else {
|
||||
self.__PREFRESH__.replaceComponent(prev, next, false);
|
||||
}
|
||||
};
|
||||
|
||||
export const flush = () => {
|
||||
const pending = [...self.__PREFRESH__.getPendingUpdates()];
|
||||
self.__PREFRESH__.flush();
|
||||
|
||||
if (pending.length > 0) {
|
||||
pending.forEach(([prev, next]) => {
|
||||
compareSignatures(prev, next);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const isComponent = exportValue => {
|
||||
if (typeof exportValue === 'function') {
|
||||
if (
|
||||
exportValue.prototype != null &&
|
||||
exportValue.prototype.isReactComponent
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const name = exportValue.name || exportValue.displayName;
|
||||
return (
|
||||
typeof name === 'string' && name[0] && name[0] == name[0].toUpperCase()
|
||||
);
|
||||
}
|
||||
return false;
|
||||
};
|
Reference in New Issue
Block a user