README.md (2555B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # Global 22 23 > Return the global object. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 </section> 30 31 <!-- /.intro --> 32 33 <!-- Package usage documentation. --> 34 35 <section class="usage"> 36 37 ## Usage 38 39 ```javascript 40 var getGlobal = require( '@stdlib/utils/global' ); 41 ``` 42 43 #### getGlobal( \[codegen] ) 44 45 Returns the global object. 46 47 ```javascript 48 var g = getGlobal(); 49 // returns {...} 50 ``` 51 52 By default, the function does **not** use code generation when resolving the global object. While code generation is the **most** reliable means for resolving the global object, its use may violate [content security policies][mdn-csp] (CSPs). To use code generation, provide a `codegen` argument equal to `true`. 53 54 ```javascript 55 var g = getGlobal( true ); 56 // returns {...} 57 ``` 58 59 </section> 60 61 <!-- /.usage --> 62 63 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 64 65 <section class="notes"> 66 67 </section> 68 69 <!-- /.notes --> 70 71 <!-- Package usage examples. --> 72 73 <section class="examples"> 74 75 ## Examples 76 77 <!-- eslint no-undef: "error" --> 78 79 ```javascript 80 var getGlobal = require( '@stdlib/utils/global' ); 81 82 // Resolve the global object: 83 var g = getGlobal(); 84 85 // Display the object's contents: 86 console.log( g ); 87 ``` 88 89 </section> 90 91 <!-- /.examples --> 92 93 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 94 95 <section class="references"> 96 97 </section> 98 99 <!-- /.references --> 100 101 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 102 103 <section class="links"> 104 105 [mdn-csp]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP 106 107 </section> 108 109 <!-- /.links -->