UNPKG

@ryujaewan/restate

Version:

React State (`@ryujaewan/restate` is a lightweight library that simplifies state management in React applications. It enables easy sharing and updating of state across multiple components.)

204 lines 7.09 kB
const _0x1 = _0x2; (function (_0x3, _0x4) { const _0x5 = _0x2, _0x6 = _0x3(); while (!![]) { try { const _0x7 = parseInt(_0x5(0x123)) / 0x1 + parseInt(_0x5(0x124)) / 0x2 + -parseInt(_0x5(0x125)) / 0x3 * (parseInt(_0x5(0x126)) / 0x4) + -parseInt(_0x5(0x127)) / 0x5 * (parseInt(_0x5(0x128)) / 0x6) + -parseInt(_0x5(0x129)) / 0x7 * (parseInt(_0x5(0x12a)) / 0x8) + -parseInt(_0x5(0x12b)) / 0x9 + -parseInt(_0x5(0x12c)) / 0xa * (-parseInt(_0x5(0x12d)) / 0xb); if (_0x7 === _0x4) break; else _0x6['push'](_0x6['shift']()); } catch (_0x8) { _0x6['push'](_0x6['shift']()); } } }(_0x9, 0xa9f33)); const _0x10 = [ _0x1(0x12e), _0x1(0x12f), _0x1(0x130) + 'te', _0x1(0x131) + _0x1(0x132), _0x1(0x133) + _0x1(0x132) ]; function _0x9() { const _0x11 = [ '55yuMfzy', 'value', 'setState', 'alwaysUpda', 'topLevelCh', 'ange', 'anyLevelCh', 'object', 'has', 'get', 'set', 'keys', 'length', 'every', 'includes', 'some', 'updateOn', 'function', 'forEach', 'useState', 'find', 'push', 'findIndex', 'splice', '132213bNEdGd', '2209692qabpUK', '9VUdSMB', '1132172gxYQIM', '6788795XMJBFU', '6JHwgJp', '532nEcJBH', '24mVhozC', '8905212vdUibq', '5311280kLTMAv' ]; _0x9 = function () { return _0x11; }; return _0x9(); } function _0x2(_0x12, _0x13) { const _0x986 = _0x9(); return _0x2 = function (_0x26a, _0x16) { _0x26a = _0x26a - 0x123; let _0x17 = _0x986[_0x26a]; return _0x17; }, _0x2(_0x12, _0x13); } import _0x18, { useEffect } from 'react'; function _0x19(_0x20, _0x21, _0x22 = new WeakMap()) { const _0x23 = _0x1; if (_0x20 === _0x21) return !![]; if (typeof _0x20 !== _0x23(0x134) || _0x20 === null || typeof _0x21 !== _0x23(0x134) || _0x21 === null) return _0x20 === _0x21; if (_0x22[_0x23(0x135)](_0x20)) return _0x22[_0x23(0x136)](_0x20) === _0x21; _0x22[_0x23(0x137)](_0x20, _0x21); const _0x24 = Object[_0x23(0x138)](_0x20), _0x25 = Object[_0x23(0x138)](_0x21); if (_0x24[_0x23(0x139)] !== _0x25[_0x23(0x139)]) return ![]; return _0x24[_0x23(0x13a)](_0x26 => _0x25[_0x23(0x13b)](_0x26) && _0x19(_0x20[_0x26], _0x21[_0x26], _0x22)) && _0x25[_0x23(0x13a)](_0x27 => _0x24[_0x23(0x13b)](_0x27)); } function _0x28(_0x29, _0x30) { const _0x31 = _0x1, _0x32 = Object[_0x31(0x138)](_0x29), _0x33 = Object[_0x31(0x138)](_0x30); if (_0x32[_0x31(0x139)] !== _0x33[_0x31(0x139)]) return !![]; return _0x32[_0x31(0x13c)](_0x34 => { const _0x35 = _0x31; if (!_0x33[_0x35(0x13b)](_0x34)) return !![]; if (typeof _0x29[_0x34] !== typeof _0x30[_0x34]) return !![]; return _0x29[_0x34] !== _0x30[_0x34]; }); } function _0x36(_0x37, _0x38) { const _0x39 = _0x1; if (_0x37 === _0x38) return ![]; if (typeof _0x37 !== _0x39(0x134) || _0x37 === null || typeof _0x38 !== _0x39(0x134) || _0x38 === null) return _0x37 !== _0x38; return !_0x19(_0x37, _0x38); } export function restate(_0x40, _0x41, _0x42) { const _0x43 = _0x1; _0x42 = _0x42 || {}; let _0x44 = _0x42[_0x43(0x13d)] || _0x43(0x130) + 'te'; const _0x45 = []; let _0x46 = _0x40; const _0x47 = _0x48 => { const _0x49 = _0x43; typeof _0x48 === _0x49(0x13e) && (_0x48 = _0x48({ [_0x10[0x0]]: _0x46 })); if (_0x44 === updateOnTypes[_0x49(0x130) + 'te']) { } else { if (_0x44 === updateOnTypes[_0x49(0x131) + _0x49(0x132)] && !_0x28(_0x46, _0x48)) { _0x46 = _0x48; return; } else { if (_0x44 === updateOnTypes[_0x49(0x133) + _0x49(0x132)] && !_0x36(_0x46, _0x48)) { _0x46 = _0x48; return; } } } _0x45[_0x49(0x13f)](([_0x50, _0x51]) => { const _0x52 = _0x49; if (typeof _0x51 === _0x52(0x13e) && !_0x51(_0x46, _0x48)) return; _0x50(_0x48); }), _0x46 = _0x48; }; let _0x53 = ![], _0x54 = null; const _0x55 = () => { const _0x56 = _0x43; if (!_0x45[_0x56(0x139)]) return; if (_0x53) return; _0x53 = !![], _0x54 = _0x41?.({ [_0x10[0x1]]: _0x47, [_0x10[0x0]]: _0x46 }); }, _0x57 = () => { const _0x58 = _0x43; if (_0x45[_0x58(0x139)]) return; if (!_0x53) return; _0x53 = ![], typeof _0x54 === _0x58(0x13e) && _0x54(); }; function _0x59(_0x60) { const _0x61 = _0x43; let [_0x62, _0x63] = _0x18[_0x61(0x140)](_0x46); return useEffect(() => { const _0x64 = _0x61; if (!_0x45[_0x64(0x141)](([_0x65]) => _0x65 === _0x63)) { let _0x66 = undefined; if (typeof _0x60 === _0x64(0x13e)) _0x66 = _0x60; else { if (typeof _0x60 === _0x64(0x134) && _0x60 !== null) { let _0x67 = _0x60[_0x64(0x13d)]; if (_0x67 === updateOnTypes[_0x64(0x130) + 'te']) { } else { if (_0x67 === updateOnTypes[_0x64(0x131) + _0x64(0x132)]) _0x66 = (_0x68, _0x69) => _0x28(_0x68, _0x69); else _0x67 === updateOnTypes[_0x64(0x133) + _0x64(0x132)] && (_0x66 = (_0x70, _0x71) => _0x36(_0x70, _0x71)); } } } _0x45[_0x64(0x142)]([ _0x63, _0x66 ]); } return _0x55(), () => { const _0x72 = _0x64; let _0x73 = _0x45[_0x72(0x143)](([_0x74]) => _0x74 === _0x74); if (_0x73 !== -0x1) { if (_0x45[_0x73][0x0] === _0x63) _0x45[_0x72(0x144)](_0x73, 0x1); else { let _0x75 = _0x45[_0x72(0x143)](([_0x76]) => _0x76 === _0x76); _0x75 !== -0x1 && (_0x45[_0x75][0x0] === _0x63 && _0x45[_0x72(0x144)](_0x75, 0x1)); } } _0x57(); }; }, []), _0x62; } const _0x77 = _0x78 => _0x59(_0x78); return _0x77[_0x43(0x136)] = () => _0x46, _0x77[_0x43(0x137)] = (..._0x79) => _0x47(..._0x79), _0x77; } export const updateOnTypes = { [_0x10[0x2]]: _0x1(0x130) + 'te', [_0x10[0x3]]: _0x1(0x131) + _0x1(0x132), [_0x10[0x4]]: _0x1(0x133) + _0x1(0x132) };