Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunc committed Jul 4, 2013
0 parents commit 4da02d1
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .gitignore
@@ -0,0 +1,32 @@
lib-cov
*.seed
*.swp
*.tmp
*.log
*.csv
*.dat
*.out
*.pid
*.gz
*.o
*~

pids
logs
results

node_modules
npm-debug.log

.DS_Store
.AppleDouble
.LSOverride
Icon


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes
4 changes: 4 additions & 0 deletions .npmignore
@@ -0,0 +1,4 @@
support
test
examples
*.sock
5 changes: 5 additions & 0 deletions History.md
@@ -0,0 +1,5 @@

0.0.1 / 2013-07-03
==================

* Initial release
21 changes: 21 additions & 0 deletions LICENSE.md
@@ -0,0 +1,21 @@
# The MIT License (MIT)

Copyright (c) 2013 Tarun Chaudhry <tarunc92@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

__THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.__
29 changes: 29 additions & 0 deletions Readme.md
@@ -0,0 +1,29 @@

# createSingleton

An abstracted-away best practice way to construct singletons

## License

(The MIT License)

Copyright (c) 2013 Tarun Chaudhry <tarunc92@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 2 additions & 0 deletions index.js
@@ -0,0 +1,2 @@

module.exports = require('./lib/createSingleton');
20 changes: 20 additions & 0 deletions lib/createSingleton.js
@@ -0,0 +1,20 @@
// The singleton pattern is a design pattern that is used to restrict
// instantiation of a class to one object. This is useful when exactly
// one object is needed to coordinate actions across the system.
function createSingleton(cb) {
var args = Array.prototype.slice.call(arguments, 1);

return function () {
if (arguments.callee._singletonInstance) {
return arguments.callee._singletonInstance;
}
arguments.callee._singletonInstance = this;

cb.apply(this, args);
};
}

/**
* Expose `createSingleton` function.
*/
module.exports = createSingleton;
11 changes: 11 additions & 0 deletions package.json
@@ -0,0 +1,11 @@
{
"name": "create-singleton",
"version": "0.0.1",
"description": "An abstracted-away best practice way to construct singletons",
"keywords": ["singleton", "best-practice", "abstraction"],
"author": "Tarun Chaudhry <tarunc92@gmail.com>",
"repository": { "type": "git", "url": "git://github.com/tarunc/createSingleton.git" },
"dependencies": {},
"devDependencies": {},
"main": "index"
}

0 comments on commit 4da02d1

Please sign in to comment.