Comparing version 3.0.3 to 3.0.4
@@ -9,2 +9,5 @@ 'use strict'; | ||
var EMPTY_CONTEXT = Symbol(); | ||
/** | ||
* Base context interface. | ||
*/ | ||
function createContext(defaultContextValue) { | ||
@@ -35,2 +38,6 @@ var contextValue = EMPTY_CONTEXT; | ||
} | ||
/** | ||
* Cascading context - another implementation of context, that assumes the context value is an object. | ||
* When nesting context runs, the the values of the current layer merges with the layers above it. | ||
*/ | ||
function createCascade(init) { | ||
@@ -37,0 +44,0 @@ var ctx = createContext(); |
@@ -5,2 +5,5 @@ import { invariant, defaultTo, assign, optionalFunctionValue } from 'vest-utils'; | ||
var EMPTY_CONTEXT = Symbol(); | ||
/** | ||
* Base context interface. | ||
*/ | ||
function createContext(defaultContextValue) { | ||
@@ -31,2 +34,6 @@ var contextValue = EMPTY_CONTEXT; | ||
} | ||
/** | ||
* Cascading context - another implementation of context, that assumes the context value is an object. | ||
* When nesting context runs, the the values of the current layer merges with the layers above it. | ||
*/ | ||
function createCascade(init) { | ||
@@ -33,0 +40,0 @@ var ctx = createContext(); |
@@ -9,2 +9,5 @@ (function (global, factory) { | ||
var EMPTY_CONTEXT = Symbol(); | ||
/** | ||
* Base context interface. | ||
*/ | ||
function createContext(defaultContextValue) { | ||
@@ -35,2 +38,6 @@ var contextValue = EMPTY_CONTEXT; | ||
} | ||
/** | ||
* Cascading context - another implementation of context, that assumes the context value is an object. | ||
* When nesting context runs, the the values of the current layer merges with the layers above it. | ||
*/ | ||
function createCascade(init) { | ||
@@ -37,0 +44,0 @@ var ctx = createContext(); |
{ | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"license": "MIT", | ||
@@ -14,3 +14,3 @@ "main": "./dist/cjs/context.js", | ||
"dependencies": { | ||
"vest-utils": "^0.0.3" | ||
"vest-utils": "^0.0.4" | ||
}, | ||
@@ -40,3 +40,3 @@ "module": "./dist/es/context.production.js", | ||
"./package.json": "./package.json", | ||
"./": "./" | ||
"./*": "./*" | ||
}, | ||
@@ -43,0 +43,0 @@ "repository": { |
# Context | ||
[![Join Discord](https://badgen.net/discord/online-members/WmADZpJnSe?icon=discord&label=Discord)](https://discord.gg/WmADZpJnSe) [![Version](https://badgen.net/npm/v/vest?&icon=npm)](https://www.npmjs.com/package/context) [![Downloads](https://badgen.net/npm/dt/context?label=Downloads)](https://www.npmjs.com/package/context) [![bundlephobia](https://badgen.net/bundlephobia/minzip/context)](https://bundlephobia.com/package/context) [![Status](https://badgen.net/github/status/ealush/vest)](https://github.com/ealush/vest/actions) | ||
Simple utility for context propagation within Javascript applications and libraries. Loosely based on the ideas behind React's context, allows you to achieve the same goals (and more) without actually using react. | ||
@@ -4,0 +6,0 @@ It allows you to keep reference for shared variables, and access them down in your function call even if not declared in the same scope. |
import { CB } from 'vest-utils'; | ||
/** | ||
* Base context interface. | ||
*/ | ||
declare function createContext<T extends unknown>(defaultContextValue?: T): CtxApi<T>; | ||
/** | ||
* Cascading context - another implementation of context, that assumes the context value is an object. | ||
* When nesting context runs, the the values of the current layer merges with the layers above it. | ||
*/ | ||
declare function createCascade<T extends Record<string, unknown>>(init?: (value: Partial<T>, parentContext: T | void) => T | null): CtxCascadeApi<T>; | ||
@@ -4,0 +11,0 @@ type ContextConsumptionApi<T> = { |
Sorry, the diff of this file is not supported yet
25629
246
215
+ Addedvest-utils@0.0.4(transitive)
- Removedvest-utils@0.0.3(transitive)
Updatedvest-utils@^0.0.4