An environment agnostic container for global variables. Useful for testing and server-side rendering (SSR), typically used internally by CanJS.
can-globals package exports an object with
methods used to set and get global variables. For example, get the global
import globals from "can-globals"; const LOCATION = globals.getKeyValue( "location" );
New keys can be defined with the
define method, overwritten with the
set method, and reset to their original value with the
All of these methods are demonstrated in the following example
import globals from "can-globals"; globals.define( "foo", "bar" ); // foo === 'bar' globals.set( "foo", "baz" ); // foo === 'baz' globals.reset( "foo" ); // foo === 'bar'