1 |
|
2 |
|
3 | <h1>Require Fresh</h1>
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | <span class="badge-githubworkflow"><a href="https://github.com/bevry/requirefresh/actions?query=workflow%3Abevry" title="View the status of this project's GitHub Workflow: bevry"><img src="https://github.com/bevry/requirefresh/workflows/bevry/badge.svg" alt="Status of the GitHub Workflow: bevry" /></a></span>
|
11 | <span class="badge-npmversion"><a href="https://npmjs.org/package/requirefresh" title="View this project on NPM"><img src="https://img.shields.io/npm/v/requirefresh.svg" alt="NPM version" /></a></span>
|
12 | <span class="badge-npmdownloads"><a href="https://npmjs.org/package/requirefresh" title="View this project on NPM"><img src="https://img.shields.io/npm/dm/requirefresh.svg" alt="NPM downloads" /></a></span>
|
13 | <span class="badge-daviddm"><a href="https://david-dm.org/bevry/requirefresh" title="View the status of this project's dependencies on DavidDM"><img src="https://img.shields.io/david/bevry/requirefresh.svg" alt="Dependency Status" /></a></span>
|
14 | <span class="badge-daviddmdev"><a href="https://david-dm.org/bevry/requirefresh#info=devDependencies" title="View the status of this project's development dependencies on DavidDM"><img src="https://img.shields.io/david/dev/bevry/requirefresh.svg" alt="Dev Dependency Status" /></a></span>
|
15 | <br class="badge-separator" />
|
16 | <span class="badge-githubsponsors"><a href="https://github.com/sponsors/balupton" title="Donate to this project using GitHub Sponsors"><img src="https://img.shields.io/badge/github-donate-yellow.svg" alt="GitHub Sponsors donate button" /></a></span>
|
17 | <span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
|
18 | <span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span>
|
19 | <span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span>
|
20 | <span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a></span>
|
21 | <span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span>
|
22 | <span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span>
|
23 | <span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>
|
24 | <span class="badge-wishlist"><a href="https://bevry.me/wishlist" title="Buy an item on our wishlist for us"><img src="https://img.shields.io/badge/wishlist-donate-yellow.svg" alt="Wishlist browse button" /></a></span>
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | Require a file without adding it into the require cache
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | ## Usage
|
37 |
|
38 | [Complete API Documentation.](http://master.requirefresh.bevry.surge.sh/docs/)
|
39 |
|
40 | Here is an example that uses Require Fresh to load the `package.json` file without caching.
|
41 |
|
42 | ```javascript
|
43 | // Import
|
44 | const {
|
45 | requireFresh,
|
46 | requireFreshCallback,
|
47 | requireFreshPromise,
|
48 | } = require('requirefresh')
|
49 |
|
50 | // Require the module freshly synchronously (will throw errors)
|
51 | try {
|
52 | const result = requireFresh('./package.json')
|
53 | console.log(result)
|
54 | } catch (error) {
|
55 | console.error(error)
|
56 | }
|
57 |
|
58 | // Require the fresh module synchronously via a callback that contains the error and result
|
59 | requireFreshCallback('./package.json', function (error, result) {
|
60 | if (error) {
|
61 | console.error(error)
|
62 | } else {
|
63 | console.log(result)
|
64 | }
|
65 | })
|
66 |
|
67 | // Require the fresh module synchronously via a promise
|
68 | requireFreshPromise('./package.json')
|
69 | .then((result) => console.log(result))
|
70 | .catch((error) => console.error(error))
|
71 | ```
|
72 |
|
73 |
|
74 |
|
75 | <h2>Install</h2>
|
76 |
|
77 | <a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>npm</h3></a>
|
78 | <ul>
|
79 | <li>Install: <code>npm install --save requirefresh</code></li>
|
80 | <li>Import: <code>import pkg from ('requirefresh')</code></li>
|
81 | <li>Require: <code>const pkg = require('requirefresh').default</code></li>
|
82 | </ul>
|
83 |
|
84 | <h3><a href="https://editions.bevry.me" title="Editions are the best way to produce and consume packages you care about.">Editions</a></h3>
|
85 |
|
86 | <p>This package is published with the following editions:</p>
|
87 |
|
88 | <ul><li><code>requirefresh/source/index.ts</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> source code with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li>
|
89 | <li><code>requirefresh</code> aliases <code>requirefresh/edition-es2019/index.js</code></li>
|
90 | <li><code>requirefresh/edition-es2019/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_-_ECMAScript_2019" title="ECMAScript ES2019">ES2019</a> for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> 4 || 6 || 8 || 10 || 12 || 14 || 16 with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li></ul>
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 | <h2>History</h2>
|
98 |
|
99 | <a href="https://github.com/bevry/requirefresh/blob/master/HISTORY.md#files">Discover the release history by heading on over to the <code>HISTORY.md</code> file.</a>
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | <h2>Contribute</h2>
|
107 |
|
108 | <a href="https://github.com/bevry/requirefresh/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a>
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | <h2>Backers</h2>
|
116 |
|
117 | <h3>Maintainers</h3>
|
118 |
|
119 | These amazing people are maintaining this project:
|
120 |
|
121 | <ul><li><a href="https://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/requirefresh/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/requirefresh">view contributions</a></li></ul>
|
122 |
|
123 | <h3>Sponsors</h3>
|
124 |
|
125 | No sponsors yet! Will you be the first?
|
126 |
|
127 | <span class="badge-githubsponsors"><a href="https://github.com/sponsors/balupton" title="Donate to this project using GitHub Sponsors"><img src="https://img.shields.io/badge/github-donate-yellow.svg" alt="GitHub Sponsors donate button" /></a></span>
|
128 | <span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
|
129 | <span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span>
|
130 | <span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span>
|
131 | <span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a></span>
|
132 | <span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span>
|
133 | <span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span>
|
134 | <span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>
|
135 | <span class="badge-wishlist"><a href="https://bevry.me/wishlist" title="Buy an item on our wishlist for us"><img src="https://img.shields.io/badge/wishlist-donate-yellow.svg" alt="Wishlist browse button" /></a></span>
|
136 |
|
137 | <h3>Contributors</h3>
|
138 |
|
139 | These amazing people have contributed code to this project:
|
140 |
|
141 | <ul><li><a href="https://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/requirefresh/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/requirefresh">view contributions</a></li>
|
142 | <li><a href="https://github.com/sfrdmn">Sean Fridman</a> — <a href="https://github.com/bevry/requirefresh/commits?author=sfrdmn" title="View the GitHub contributions of Sean Fridman on repository bevry/requirefresh">view contributions</a></li></ul>
|
143 |
|
144 | <a href="https://github.com/bevry/requirefresh/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a>
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 | <h2>License</h2>
|
152 |
|
153 | Unless stated otherwise all works are:
|
154 |
|
155 | <ul><li>Copyright © 2013+ <a href="http://bevry.me">Bevry Pty Ltd</a></li>
|
156 | <li>Copyright © 2011+ <a href="https://balupton.com">Benjamin Lupton</a></li></ul>
|
157 |
|
158 | and licensed under:
|
159 |
|
160 | <ul><li><a href="http://spdx.org/licenses/MIT.html">MIT License</a></li></ul>
|
161 |
|
162 |
|