[Pkg-javascript-commits] [node-lazy-property] 01/03: Import Upstream version 1.0.0
Saravanan Palanisamy
saravanan30erd-guest at moszumanska.debian.org
Fri Jul 14 14:34:31 UTC 2017
This is an automated email from the git hooks/post-receive script.
saravanan30erd-guest pushed a commit to branch master
in repository node-lazy-property.
commit dd55dfdd20b44fae1ad538e9c8a3061beac7040d
Author: saravanan30erd <saravanan30erd at gmail.com>
Date: Fri Jul 14 10:27:44 2017 -0400
Import Upstream version 1.0.0
---
.npmignore | 16 ++++++++++++++++
LICENSE | 22 ++++++++++++++++++++++
README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++
component.json | 7 +++++++
lazyProperty.js | 19 +++++++++++++++++++
package.json | 35 +++++++++++++++++++++++++++++++++++
6 files changed, 143 insertions(+)
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..038e024
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,16 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+npm-debug.log
+node_modules/*
+test/*
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..8ce206a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+
+The MIT License (MIT)
+
+Copyright (c) 2013 Mikola Lysenko
+
+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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d339c8f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,44 @@
+lazy-property
+=============
+Adds a lazily initialized property to an object.
+
+## Example
+
+```javascript
+var addLazyProperty = require("lazy-property")
+
+var obj = {}
+
+addLazyProperty(obj, "foo", function() {
+ console.log("initialized!")
+ return "bar"
+})
+
+//Access the property
+console.log(obj.foo)
+console.log(obj.foo)
+
+//Prints out:
+//
+// initialized!
+// bar
+// bar
+//
+```
+
+## Install
+
+ npm install lazy-property
+
+## API
+
+### `require("lazy-property")(obj, name, init[, enumerable])`
+Adds a lazily initialized property to the object.
+
+* `obj` is the object to add the property to
+* `name` is the name of the property
+* `init` is a function that computes the value of the property
+* `enumerable` if the property is enumerable (default `false`)
+
+## Credits
+(c) 2013 Mikola Lysenko. MIT License
diff --git a/component.json b/component.json
new file mode 100644
index 0000000..142938e
--- /dev/null
+++ b/component.json
@@ -0,0 +1,7 @@
+{
+ "name": "lazy-property",
+ "version": "0.0.2",
+ "description": "Lazily initialized properties for objects",
+ "main": "lazyProperty.js",
+ "scripts": ["lazyProperty.js"]
+}
diff --git a/lazyProperty.js b/lazyProperty.js
new file mode 100644
index 0000000..20e5fe1
--- /dev/null
+++ b/lazyProperty.js
@@ -0,0 +1,19 @@
+"use strict"
+
+function addLazyProperty(object, name, initializer, enumerable) {
+ Object.defineProperty(object, name, {
+ get: function() {
+ var v = initializer.call(this)
+ Object.defineProperty(this, name, { value: v, enumerable: !!enumerable, writable: true })
+ return v
+ },
+ set: function(v) {
+ Object.defineProperty(this, name, { value: v, enumerable: !!enumerable, writable: true })
+ return v
+ },
+ enumerable: !!enumerable,
+ configurable: true
+ })
+}
+
+module.exports = addLazyProperty
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..21789c4
--- /dev/null
+++ b/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "lazy-property",
+ "version": "1.0.0",
+ "description": "Lazily initialized properties for objects",
+ "main": "lazyProperty.js",
+ "directories": {
+ "test": "test"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "tape": "^2.12.3"
+ },
+ "scripts": {
+ "test": "tape test/*.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/mikolalysenko/lazy-property.git"
+ },
+ "keywords": [
+ "lazy",
+ "property",
+ "object",
+ "initialize",
+ "array",
+ "dictionary"
+ ],
+ "author": "Mikola Lysenko",
+ "license": "MIT",
+ "readmeFilename": "README.md",
+ "gitHead": "850a27f710ec72f05b534805c31f095ff590f1ea",
+ "bugs": {
+ "url": "https://github.com/mikolalysenko/lazy-property/issues"
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-lazy-property.git
More information about the Pkg-javascript-commits
mailing list