https://github.com/zeecoder/z-container
A container to save and retreive data / object references, etc.
https://github.com/zeecoder/z-container
Last synced: 10 months ago
JSON representation
A container to save and retreive data / object references, etc.
- Host: GitHub
- URL: https://github.com/zeecoder/z-container
- Owner: ZeeCoder
- License: mit
- Created: 2015-06-07T19:39:42.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-12T08:52:43.000Z (over 10 years ago)
- Last Synced: 2025-01-27T13:14:22.002Z (12 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# z-container
[](https://travis-ci.org/ZeeCoder/z-container)
[](http://badge.fury.io/js/z-container)
This is a container solution to save and later retrieve object references, and other data.
Since it's a CommonJS module, it must be used alongside with [Browserify](http://browserify.org/), or
something similar, like [WebPacker](http://webpack.github.io/).
## Example, explanation
```js
var container = require('z-container');
container.add('some_object_reference', object_reference);
container.has('some_object_reference');
// -> true, only if the key really exists in the container
// Returns the previously saved reference.
// This is useful, when CommonJS modules compiled to the web need to access a
// certain module which was instantiated by the `new` operator.
container.get('some_object_reference');
// The container can save and retrieve other kinds of data too, which is useful
// when you have to pass data at runtime, and cannot simply `require()` data
// from a file.
container.add('some_string', 'string');
container.get('some_string'); // returns "string"
```
## License
[MIT](LICENSE)