@simbathesailor/use-what-changed
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -73,3 +73,3 @@ 'use strict'; | ||
var stringSplitted = dependencyNames ? dependencyNames.split(',') : null; | ||
var whatChanged = dependencyRef.current.reduce(function (acc, dep, index) { | ||
var whatChanged = dependency ? dependency.reduce(function (acc, dep, index) { | ||
if (dependencyRef.current && dep !== dependencyRef.current[index]) { | ||
@@ -107,3 +107,3 @@ var oldValue = dependencyRef.current[index]; | ||
return acc; | ||
}, {}); | ||
}, {}) : {}; | ||
@@ -110,0 +110,0 @@ { |
@@ -1,2 +0,2 @@ | ||
"use strict";var e,r=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,t=0,n=function(e){return"[object Object]"===Object.prototype.toString.call(e)};function u(e){return n(e)||Array.isArray(e)?JSON.stringify(e,null,2):e}exports.useWhatChanged=function(e,n){var c=r.useRef(e),a=r.useRef(1),l=r.useRef(""),o=Array.isArray(c.current);r.useEffect((function(){c.current&&o&&c.current.length>1&&(t++,a.current=t,l.current=function(){for(var e="#",r=0;r<6;r++)e+="0123456789ABCDEF"[Math.floor(16*Math.random())];return e}())}),[c,o]),r.useEffect((function(){if(c.current&&o&&c.current.length>1){console.log("%c What Changed in Effect ID "+a.current+" ","background: "+l.current+"; color: white; font-size: 10px","🧐👇");var e=n?n.split(","):null,r=c.current.reduce((function(r,t,a){if(c.current&&t!==c.current[a]){var l=c.current[a];return c.current[a]=t,n&&e?r[e[a]+' "✅"']={"Old Value":u(l),"New Value":u(t)}:r[a+' "✅"']={"Old Value":u(l),"New Value":u(t)},r}return n&&e?r[e[a]+' "⏺"']={"Old Value":u(t),"New Value":u(t)}:r[a+' "⏺"']={"Old Value":u(t),"New Value":u(t)},r}),{});console.table(r)}}),[].concat(e&&o?e:[],[c]))}; | ||
"use strict";var e,r=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,t=0,n=function(e){return"[object Object]"===Object.prototype.toString.call(e)};function u(e){return n(e)||Array.isArray(e)?JSON.stringify(e,null,2):e}exports.useWhatChanged=function(e,n){var c=r.useRef(e),a=r.useRef(1),l=r.useRef(""),o=Array.isArray(c.current);r.useEffect((function(){c.current&&o&&c.current.length>1&&(t++,a.current=t,l.current=function(){for(var e="#",r=0;r<6;r++)e+="0123456789ABCDEF"[Math.floor(16*Math.random())];return e}())}),[c,o]),r.useEffect((function(){if(c.current&&o&&c.current.length>1){console.log("%c What Changed in Effect ID "+a.current+" ","background: "+l.current+"; color: white; font-size: 10px","🧐👇");var r=n?n.split(","):null,t=e?e.reduce((function(e,t,a){if(c.current&&t!==c.current[a]){var l=c.current[a];return c.current[a]=t,n&&r?e[r[a]+' "✅"']={"Old Value":u(l),"New Value":u(t)}:e[a+' "✅"']={"Old Value":u(l),"New Value":u(t)},e}return n&&r?e[r[a]+' "⏺"']={"Old Value":u(t),"New Value":u(t)}:e[a+' "⏺"']={"Old Value":u(t),"New Value":u(t)},e}),{}):{};console.table(t)}}),[].concat(e&&o?e:[],[c]))}; | ||
//# sourceMappingURL=use-what-changed.cjs.production.min.js.map |
@@ -69,3 +69,3 @@ import React from 'react'; | ||
var stringSplitted = dependencyNames ? dependencyNames.split(',') : null; | ||
var whatChanged = dependencyRef.current.reduce(function (acc, dep, index) { | ||
var whatChanged = dependency ? dependency.reduce(function (acc, dep, index) { | ||
if (dependencyRef.current && dep !== dependencyRef.current[index]) { | ||
@@ -103,3 +103,3 @@ var oldValue = dependencyRef.current[index]; | ||
return acc; | ||
}, {}); | ||
}, {}) : {}; | ||
@@ -106,0 +106,0 @@ { |
{ | ||
"name": "@simbathesailor/use-what-changed", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "simbathesailor", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
37228