Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qfox/process-dataset
Allow to share native data between submodules using process
https://github.com/qfox/process-dataset
Last synced: 23 days ago
JSON representation
Allow to share native data between submodules using process
- Host: GitHub
- URL: https://github.com/qfox/process-dataset
- Owner: qfox
- License: mit
- Created: 2013-10-18T13:39:59.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-18T15:08:50.000Z (about 11 years ago)
- Last Synced: 2024-09-23T18:08:23.591Z (about 2 months ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
process-dataset
===============Allow to share native data between submodules using `process.dataset` global variable
How it works
------------At the first run it creates special object with simple interface.
Any other `require` in submodules just takes and exports that object.
Object stored in a global object `process` in `dataset` property.
So any submodule at any level can use common dataset.Example
-------```js
// /app.js
var http = require('http');
var storage = require('process-dataset');
var server = require('lib/server.js');// /lib/server.js
var storage = require('process-dataset');
var server = http.createServer(function (req, res) {
if (storage.get('auth')) {
res.end('You have authorized: '+storage.auth);
} else {
res.end('Nothing to show');
}
});
server.listen(8880);storage.set('server', server);
module.exports = server;// /lib/sessions.js
var storage = require('process-dataset');
var server = storage.get('server');```