New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

evt

Package Overview
Dependencies
Maintainers
2
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

evt - npm Package Compare versions

Comparing version 1.10.2 to 1.11.0

hooks/useRerenderOnStateChange.d.ts

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## **1.11.0** (2022-06-01)
- hooks compat React 18
- Create init-onyxia.sh
- Merge pull request #24 from garronej/dependabot/npm_and_yarn/shelljs-0.8.5
Bump shelljs from 0.8.4 to 0.8.5
### **1.10.2** (2021-12-23)

@@ -2,0 +10,0 @@

2

hooks/index.d.ts
export { useEvt } from "./useEvt";
export { useStatefulEvt } from "./useStatefulEvt";
export { useRerenderOnStateChange } from "./useRerenderOnStateChange";

@@ -19,4 +19,4 @@ "use strict";

__createBinding(exports, useEvt_1, "useEvt");
var useStatefulEvt_1 = require("./useStatefulEvt");
__createBinding(exports, useStatefulEvt_1, "useStatefulEvt");
var useRerenderOnStateChange_1 = require("./useRerenderOnStateChange");
__createBinding(exports, useRerenderOnStateChange_1, "useRerenderOnStateChange");
//# sourceMappingURL=index.js.map

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

import type { VoidCtx } from "../lib";
import type { Ctx } from "../lib";
import * as React from "react";
/**

@@ -23,5 +24,9 @@ * https://docs.evt.land/api/react-hooks

* on render ( like useMemo's callback ).
* Remember that you shouldn't update state in a component
* render tick (in the useMemo for example). If you you need to
* perform an effect on first render (attaching a stateful evt
* for example) use registerSideEffect(()=>{ ... })
*
* Demo: https://stackblitz.com/edit/evt-useevt?file=index.tsx
*/
export declare function useEvt<T>(factoryOrEffect: (ctx: VoidCtx) => T, deps: any[]): T;
export declare function useEvt(effect: (ctx: Ctx<void>) => void, deps: React.DependencyList): void;
"use strict";
var _a, _b;
exports.__esModule = true;
exports.useEvt = void 0;
var Evt_2 = require("../lib/Evt");
var React = require("react");
var useEffect = React.useEffect, useRef = React.useRef;
var Evt_2 = require("../lib/Evt");
var useSemanticGuaranteeMemo_1 = require("../tools/hooks/useSemanticGuaranteeMemo");
//TODO: Find a more reliable way to test if <React.UseStrict> is used.
var isDevStrictMode = typeof process !== "object" ?
false :
((_b = (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV) !== null && _b !== void 0 ? _b : "production") !== "production";
var useEffect = React.useEffect;
/**

@@ -34,43 +28,17 @@ * https://docs.evt.land/api/react-hooks

* on render ( like useMemo's callback ).
* Remember that you shouldn't update state in a component
* render tick (in the useMemo for example). If you you need to
* perform an effect on first render (attaching a stateful evt
* for example) use registerSideEffect(()=>{ ... })
*
* Demo: https://stackblitz.com/edit/evt-useevt?file=index.tsx
*/
function useEvt(factoryOrEffect, deps) {
var ctx = useSemanticGuaranteeMemo_1.useSemanticGuaranteeMemo(function () { return Evt_2.Evt.newCtx(); }, []);
var out = useSemanticGuaranteeMemo_1.useSemanticGuaranteeMemo(function () {
ctx.done();
return factoryOrEffect(ctx);
function useEvt(effect, deps) {
useEffect(function () {
var ctx = Evt_2.Evt.newCtx();
effect(ctx);
return function () { ctx.done; };
}, deps);
useEffect(function () { return function () { ctx.done(); }; }, []);
useClearCtxIfReactStrictModeInspectRun(isDevStrictMode, ctx);
return out;
}
exports.useEvt = useEvt;
/**
* When <React.StrictMode> is used in development
* useState and useMemo get triggered a first time on a
* separate component instance but useEffect is not invoked.
*
* To prevent leaving handlers that we attached inside the useMemo
* callback we clear the context if useEffect(f,[])
* is not invoked right after useState(f).
*/
function useClearCtxIfReactStrictModeInspectRun(isDevStrictMode, ctx) {
var timerRef = useRef(null);
useSemanticGuaranteeMemo_1.useSemanticGuaranteeMemo(function () {
if (!isDevStrictMode) {
return;
}
timerRef.current = setTimeout(function () { return ctx.done(); }, 700);
}, []);
useEffect(function () {
if (!isDevStrictMode) {
return;
}
if (timerRef.current === null) {
return;
}
clearTimeout(timerRef.current);
}, []);
}
//# sourceMappingURL=useEvt.js.map
{
"name": "evt",
"version": "1.10.2",
"version": "1.11.0",
"description": "Type safe replacement for node's EventEmitter",

@@ -27,5 +27,5 @@ "repository": {

"hooks/useEvt.js.map",
"hooks/useStatefulEvt.d.ts",
"hooks/useStatefulEvt.js",
"hooks/useStatefulEvt.js.map",
"hooks/useRerenderOnStateChange.d.ts",
"hooks/useRerenderOnStateChange.js",
"hooks/useRerenderOnStateChange.js.map",
"lib/Ctx.d.ts",

@@ -334,3 +334,3 @@ "lib/Ctx.js",

"src/hooks/useEvt.ts",
"src/hooks/useStatefulEvt.ts",
"src/hooks/useRerenderOnStateChange.ts",
"src/lib/Ctx.ts",

@@ -337,0 +337,0 @@ "src/lib/Evt.asNonPostable.ts",

@@ -11,2 +11,5 @@ <p align="center">

</a>
<a href="https://deno.land/x/evt">
<img src="https://img.shields.io/badge/deno-module-informational?logo=deno">
</a>
<a href="https://bundlephobia.com/package/evt">

@@ -13,0 +16,0 @@ <img src="https://img.shields.io/bundlephobia/minzip/evt">

@@ -8,3 +8,3 @@ /*

*/
export { useEvt } from "./useEvt";
export { useStatefulEvt } from "./useStatefulEvt";
export { useEvt } from "./useEvt";
export { useRerenderOnStateChange } from "./useRerenderOnStateChange";

@@ -0,14 +1,7 @@

import { Evt } from "../lib/Evt";
import type { Ctx } from "../lib";
import * as React from "react";
const { useEffect, useRef } = React;
const { useEffect } = React;
import { Evt } from "../lib/Evt";
import type { VoidCtx } from "../lib";
import { useSemanticGuaranteeMemo } from "../tools/hooks/useSemanticGuaranteeMemo";
//TODO: Find a more reliable way to test if <React.UseStrict> is used.
const isDevStrictMode = typeof process !== "object" ?
false :
(process?.env?.NODE_ENV ?? "production") !== "production"
;
/**

@@ -35,69 +28,25 @@ * https://docs.evt.land/api/react-hooks

* on render ( like useMemo's callback ).
* Remember that you shouldn't update state in a component
* render tick (in the useMemo for example). If you you need to
* perform an effect on first render (attaching a stateful evt
* for example) use registerSideEffect(()=>{ ... })
*
* Demo: https://stackblitz.com/edit/evt-useevt?file=index.tsx
*/
export function useEvt<T>(
factoryOrEffect: (ctx: VoidCtx) => T,
deps: any[]
): T {
export function useEvt(
effect: (ctx: Ctx<void>) => void,
deps: React.DependencyList
): void {
const ctx = useSemanticGuaranteeMemo(() => Evt.newCtx(), []);
useEffect(
()=> {
const ctx= Evt.newCtx();
const out = useSemanticGuaranteeMemo(() => {
effect(ctx);
ctx.done();
return ()=> { ctx.done; };
},
deps
);
return factoryOrEffect(ctx);
}, deps);
useEffect(() => () => { ctx.done(); }, []);
useClearCtxIfReactStrictModeInspectRun(isDevStrictMode, ctx);
return out;
}
/**
* When <React.StrictMode> is used in development
* useState and useMemo get triggered a first time on a
* separate component instance but useEffect is not invoked.
*
* To prevent leaving handlers that we attached inside the useMemo
* callback we clear the context if useEffect(f,[])
* is not invoked right after useState(f).
*/
function useClearCtxIfReactStrictModeInspectRun(isDevStrictMode: boolean, ctx: VoidCtx) {
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
useSemanticGuaranteeMemo(() => {
if (!isDevStrictMode) {
return;
}
timerRef.current = setTimeout(
() => ctx.done(),
700
);
}, []);
useEffect(() => {
if (!isDevStrictMode) {
return;
}
if (timerRef.current === null) {
return;
}
clearTimeout(timerRef.current);
}, []);
}

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

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