@polkadot/x-global
Advanced tools
Comparing version 11.0.2 to 11.1.1
@@ -6,5 +6,9 @@ "use strict"; | ||
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } }); | ||
/** @internal Last-resort "this", if it gets here it probably would fail anyway */ | ||
function evaluateThis(fn) { | ||
return fn('return this'); | ||
} | ||
/** | ||
* A cross-evnironment implementation for globalThis | ||
*/ | ||
exports.xglobal = (typeof globalThis !== 'undefined' | ||
@@ -19,2 +23,5 @@ ? globalThis | ||
: evaluateThis(Function)); | ||
/** | ||
* Extracts a known global from the environment, applying a fallback if not found | ||
*/ | ||
function extractGlobal(name, fallback) { | ||
@@ -30,2 +37,5 @@ // Not quite sure why this is here - snuck in with TS 4.7.2 with no real idea | ||
exports.extractGlobal = extractGlobal; | ||
/** | ||
* Expose a value as a known global, if not already defined | ||
*/ | ||
function exposeGlobal(name, fallback) { | ||
@@ -36,2 +46,2 @@ if (typeof exports.xglobal[name] === 'undefined') { | ||
} | ||
exports.exposeGlobal = exposeGlobal; | ||
exports.exposeGlobal = exposeGlobal; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.packageInfo = void 0; | ||
exports.packageInfo = { name: '@polkadot/x-global', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '11.0.2' }; | ||
exports.packageInfo = { name: '@polkadot/x-global', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '11.1.1' }; |
@@ -5,4 +5,13 @@ export { packageInfo } from './packageInfo.js'; | ||
type GlobalType<N extends GlobalNames> = typeof globalThis[N]; | ||
/** | ||
* A cross-evnironment implementation for globalThis | ||
*/ | ||
export declare const xglobal: GlobalThis; | ||
/** | ||
* Extracts a known global from the environment, applying a fallback if not found | ||
*/ | ||
export declare function extractGlobal<N extends GlobalNames, T extends GlobalType<N>>(name: N, fallback: unknown): T; | ||
export declare function exposeGlobal<N extends GlobalNames>(name: N, fallback: unknown): void; | ||
/** | ||
* Expose a value as a known global, if not already defined | ||
*/ | ||
export declare function exposeGlobal<N extends GlobalNames, T extends GlobalType<N>>(name: N, fallback: unknown): void; |
14
index.js
export { packageInfo } from './packageInfo.js'; | ||
/** @internal Last-resort "this", if it gets here it probably would fail anyway */ | ||
function evaluateThis(fn) { | ||
return fn('return this'); | ||
} | ||
export const xglobal = (typeof globalThis !== 'undefined' | ||
/** | ||
* A cross-evnironment implementation for globalThis | ||
*/ | ||
export const xglobal = /*#__PURE__*/ (typeof globalThis !== 'undefined' | ||
? globalThis | ||
@@ -14,2 +18,5 @@ : typeof global !== 'undefined' | ||
: evaluateThis(Function)); | ||
/** | ||
* Extracts a known global from the environment, applying a fallback if not found | ||
*/ | ||
export function extractGlobal(name, fallback) { | ||
@@ -24,2 +31,5 @@ // Not quite sure why this is here - snuck in with TS 4.7.2 with no real idea | ||
} | ||
/** | ||
* Expose a value as a known global, if not already defined | ||
*/ | ||
export function exposeGlobal(name, fallback) { | ||
@@ -29,2 +39,2 @@ if (typeof xglobal[name] === 'undefined') { | ||
} | ||
} | ||
} |
{ | ||
"author": "Jaco Greeff <jacogr@gmail.com>", | ||
"bugs": "https://github.com/polkadot-js/common/issues", | ||
"contributors": [], | ||
"description": "A cross-environment global replacement", | ||
"engines": { | ||
"node": ">=14.0.0" | ||
"node": ">=14" | ||
}, | ||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-global#readme", | ||
"license": "Apache-2.0", | ||
"maintainers": [], | ||
"name": "@polkadot/x-global", | ||
@@ -20,3 +18,3 @@ "repository": { | ||
"type": "module", | ||
"version": "11.0.2", | ||
"version": "11.1.1", | ||
"main": "./cjs/index.js", | ||
@@ -23,0 +21,0 @@ "module": "./index.js", |
@@ -1,1 +0,1 @@ | ||
export const packageInfo = { name: '@polkadot/x-global', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '11.0.2' }; | ||
export const packageInfo = { name: '@polkadot/x-global', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '11.1.1' }; |
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
16445
107