Files
Zos/Skills/@be/node_modules/jibo-cai-singleton/README.md

24 lines
748 B
Markdown

# jibo-cai-singleton
[![Build Status](http://jenkins.jibo.com/buildStatus/icon?job=jibo-cai-singleton)](http://jenkins.jibo.com/job/jibo-cai-singleton/)
##Purpose
A library that simplifies creating singleton libraries. It extracts the name and version of the library from its `package.json` (which it searches for using the `module` object). When the singleton is loaded from two different places, a fuzzy version comparison is performed and an exception is thrown only if the major or minor version numbers differ.
<http://semver.org/>
##Usage
```js
import Singleton from 'singleton';
class Someclass {
// Some good stuff
}
let singleton = Singleton.getOrCreateSingleton(
module, () => new Someclass());
export default singleton;
```