@getstanza/core
Advanced tools
Comparing version 0.0.4-beta to 0.0.5-beta
23
index.js
@@ -329,2 +329,23 @@ /****************************************************************************** | ||
const BAGGAGE_HEADER = 'baggage'; | ||
const FEATURE_BAGGAGE_KEY = 'stz-feat'; | ||
function withStanzaHeaders({ | ||
feature | ||
}, headers) { | ||
// @ts-expect-error: if we don't pass initial headers we return Record<string, string> object | ||
let initHeaders = headers !== null && headers !== void 0 ? headers : {}; | ||
const baggageValue = `${FEATURE_BAGGAGE_KEY}=${feature}`; | ||
if (initHeaders instanceof Headers) { | ||
initHeaders = new Headers(initHeaders); | ||
initHeaders.append(BAGGAGE_HEADER, baggageValue); | ||
} else if (Array.isArray(initHeaders)) { | ||
initHeaders = initHeaders.map(h => [...h]); | ||
initHeaders.push([BAGGAGE_HEADER, baggageValue]); | ||
} else { | ||
initHeaders = Object.assign({}, initHeaders); | ||
initHeaders[BAGGAGE_HEADER] = baggageValue; | ||
} | ||
return initHeaders; | ||
} | ||
const utils = { | ||
@@ -342,2 +363,2 @@ globals | ||
export { Stanza, StanzaChangeTarget, Stanza as default, groupBy, identity, utils }; | ||
export { Stanza, StanzaChangeTarget, Stanza as default, groupBy, identity, utils, withStanzaHeaders }; |
{ | ||
"name": "@getstanza/core", | ||
"version": "0.0.4-beta", | ||
"version": "0.0.5-beta", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Stanza core JS features", |
@@ -6,2 +6,3 @@ import { getFeatureStates } from './getFeatureStates'; | ||
export * from './eventEmitter'; | ||
export * from './withStanzaHeaders'; | ||
export type { FeatureState } from './models/featureState'; | ||
@@ -8,0 +9,0 @@ export type { LocalStateProvider } from './models/localStateProvider'; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32244
27
824