Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

use-context-selector

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-context-selector - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Change Log

## [1.2.3] - 2020-10-03
### Changed
## Fix back porting bug in v1.2.0-v1.2.2
## [1.2.2] - 2020-10-02

@@ -7,0 +11,0 @@ ### Added

2

dist/index.modern.js

@@ -1,2 +0,2 @@

import e from"react";import{unstable_runWithPriority as r,unstable_NormalPriority as t}from"scheduler";import{unstable_batchedUpdates as n}from"react-dom";const c="v",o="p",u="l",s="u",i=Symbol(),a=Symbol(),d="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?e.useEffect:e.useLayoutEffect,f=f=>{const l=e.createContext(f,()=>0);var v;return l[a]=l.Provider,l.Provider=(v=l.Provider,e.memo(({value:a,children:f})=>{const[l,p]=e.useState(0),E=e.useRef(0),m=e.useRef();m.current||(m.current=new Set);const w=e.useCallback(e=>{n(()=>{E.current+=1,p(E.current),m.current.forEach(e=>e(E.current)),e()})},[]);return d(()=>{E.current+=1,p(E.current),r(t,()=>{m.current.forEach(e=>{e(E.current,a)})})},[a]),e.createElement(v,{value:{[i]:{[c]:a,[o]:l,[u]:m.current,[s]:w}}},f)})),delete l.Consumer,l},l=(r,t)=>{const n=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");const{[c]:s,[o]:a,[u]:f}=n,l=t(s),v=e.useRef(null);d(()=>{v.current={f:t,v:s,s:l}});const[,p]=e.useReducer((e,r)=>{if(a<r)return e+1;try{if(v.current.v===s||Object.is(v.current.s,v.current.f(s)))return e}catch(e){}return e+1},0);return d(()=>{const e=(e,r)=>{try{if(v.current.v===r||Object.is(v.current.s,v.current.f(r)))return}catch(e){}p(e)};return f.add(e),()=>{f.delete(e)}},[f]),l},v=e=>e,p=e=>l(e,v),E=r=>{const t=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");const{[s]:n}=t;return n},m=({context:r,value:t,children:n})=>{const{[a]:c}=r;if("production"!==process.env.NODE_ENV&&!c)throw new Error("BridgeProvider requires special context");return e.createElement(c,{value:t},n)};export{m as BridgeProvider,f as createContext,p as useContext,l as useContextSelector,E as useContextUpdate};
import e from"react";import{unstable_runWithPriority as r,unstable_NormalPriority as t}from"scheduler";import{unstable_batchedUpdates as n}from"react-dom";const c="v",o="p",u="l",s="u",i=Symbol(),a=Symbol(),d="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?e.useEffect:e.useLayoutEffect,f=f=>{const l=e.createContext(f,()=>0);var v;return l[a]=l.Provider,l.Provider=(v=l.Provider,e.memo(({value:a,children:f})=>{const[l,p]=e.useState(0),E=e.useRef(0),m=e.useRef();m.current||(m.current=new Set);const w=e.useCallback(e=>{n(()=>{E.current+=1,p(E.current),m.current.forEach(e=>e(E.current)),e()})},[]);return d(()=>{E.current+=1,p(E.current),r(t,()=>{m.current.forEach(e=>{e(E.current,a)})})},[a]),e.createElement(v,{value:{[i]:{[c]:a,[o]:l,[u]:m.current,[s]:w}}},f)})),delete l.Consumer,l},l=(r,t)=>{const n=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");const{[c]:s,[o]:a,[u]:f}=n,l=t(s),v=e.useRef(null);d(()=>{v.current={f:t,v:s,s:l}});const[,p]=e.useReducer((e,r)=>{if(a<r)return e+1;try{if(v.current.v===s||Object.is(v.current.s,v.current.f(s)))return e}catch(e){}return e+1},0);return d(()=>{const e=(e,r)=>{try{if(r&&(v.current.v===r||Object.is(v.current.s,v.current.f(r))))return}catch(e){}p(e)};return f.add(e),()=>{f.delete(e)}},[f]),l},v=e=>e,p=e=>l(e,v),E=r=>{const t=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");const{[s]:n}=t;return n},m=({context:r,value:t,children:n})=>{const{[a]:c}=r;if("production"!==process.env.NODE_ENV&&!c)throw new Error("BridgeProvider requires special context");return e.createElement(c,{value:t},n)};export{m as BridgeProvider,f as createContext,p as useContext,l as useContextSelector,E as useContextUpdate};
//# sourceMappingURL=index.modern.js.map

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("scheduler"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","scheduler","react-dom"],r):r((e=e||self).useContextSelector={},e.react,e.scheduler,e.reactDom)}(this,function(e,r,t,n){r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;var u=Symbol(),o=Symbol(),c="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?r.useEffect:r.useLayoutEffect,i=function(e,t){var n=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");var o=n.v,i=n.p,a=n.l,f=t(o),s=r.useRef(null);c(function(){s.current={f:t,v:o,s:f}});var d=r.useReducer(function(e,r){if(i<r)return e+1;try{if(s.current.v===o||Object.is(s.current.s,s.current.f(o)))return e}catch(e){}return e+1},0)[1];return c(function(){var e=function(e,r){try{if(s.current.v===r||Object.is(s.current.s,s.current.f(r)))return}catch(e){}d(e)};return a.add(e),function(){a.delete(e)}},[a]),f},a=function(e){return e};e.BridgeProvider=function(e){var t=e.value,n=e.children,u=e.context[o];if("production"!==process.env.NODE_ENV&&!u)throw new Error("BridgeProvider requires special context");return r.createElement(u,{value:t},n)},e.createContext=function(e){var i,a=r.createContext(e,function(){return 0});return a[o]=a.Provider,a.Provider=(i=a.Provider,r.memo(function(e){var o,a,f=e.value,s=e.children,d=r.useState(0),l=d[0],v=d[1],p=r.useRef(0),x=r.useRef();x.current||(x.current=new Set);var h=r.useCallback(function(e){n.unstable_batchedUpdates(function(){p.current+=1,v(p.current),x.current.forEach(function(e){return e(p.current)}),e()})},[]);c(function(){p.current+=1,v(p.current),t.unstable_runWithPriority(t.unstable_NormalPriority,function(){x.current.forEach(function(e){e(p.current,f)})})},[f]);var E=((o={}).v=f,o.p=l,o.l=x.current,o.u=h,o);return r.createElement(i,{value:(a={},a[u]=E,a)},s)})),delete a.Consumer,a},e.useContext=function(e){return i(e,a)},e.useContextSelector=i,e.useContextUpdate=function(e){var t=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");return t.u}});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("scheduler"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","scheduler","react-dom"],r):r((e=e||self).useContextSelector={},e.react,e.scheduler,e.reactDom)}(this,function(e,r,t,n){r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;var u=Symbol(),o=Symbol(),c="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?r.useEffect:r.useLayoutEffect,i=function(e,t){var n=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");var o=n.v,i=n.p,a=n.l,f=t(o),s=r.useRef(null);c(function(){s.current={f:t,v:o,s:f}});var d=r.useReducer(function(e,r){if(i<r)return e+1;try{if(s.current.v===o||Object.is(s.current.s,s.current.f(o)))return e}catch(e){}return e+1},0)[1];return c(function(){var e=function(e,r){try{if(r&&(s.current.v===r||Object.is(s.current.s,s.current.f(r))))return}catch(e){}d(e)};return a.add(e),function(){a.delete(e)}},[a]),f},a=function(e){return e};e.BridgeProvider=function(e){var t=e.value,n=e.children,u=e.context[o];if("production"!==process.env.NODE_ENV&&!u)throw new Error("BridgeProvider requires special context");return r.createElement(u,{value:t},n)},e.createContext=function(e){var i,a=r.createContext(e,function(){return 0});return a[o]=a.Provider,a.Provider=(i=a.Provider,r.memo(function(e){var o,a,f=e.value,s=e.children,d=r.useState(0),l=d[0],v=d[1],p=r.useRef(0),x=r.useRef();x.current||(x.current=new Set);var h=r.useCallback(function(e){n.unstable_batchedUpdates(function(){p.current+=1,v(p.current),x.current.forEach(function(e){return e(p.current)}),e()})},[]);c(function(){p.current+=1,v(p.current),t.unstable_runWithPriority(t.unstable_NormalPriority,function(){x.current.forEach(function(e){e(p.current,f)})})},[f]);var E=((o={}).v=f,o.p=l,o.l=x.current,o.u=h,o);return r.createElement(i,{value:(a={},a[u]=E,a)},s)})),delete a.Consumer,a},e.useContext=function(e){return i(e,a)},e.useContextSelector=i,e.useContextUpdate=function(e){var t=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");return t.u}});
//# sourceMappingURL=index.umd.js.map
{
"name": "use-context-selector",
"description": "React useContextSelector hook in userland",
"version": "1.2.2",
"version": "1.2.3",
"author": "Daishi Kato",

@@ -6,0 +6,0 @@ "repository": {

@@ -130,4 +130,4 @@ import React from 'react';

try {
if (ref.current.v === nextValue
|| Object.is(ref.current.s, ref.current.f(nextValue))) {
if (nextValue && (ref.current.v === nextValue
|| Object.is(ref.current.s, ref.current.f(nextValue)))) {
return;

@@ -134,0 +134,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc