update readme
authorJustin Wind <justin.wind+git@gmail.com>
Fri, 18 Apr 2025 16:41:00 +0000 (09:41 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Fri, 18 Apr 2025 16:41:00 +0000 (09:41 -0700)
.npmrc [new file with mode: 0644]
README.md

diff --git a/.npmrc b/.npmrc
new file mode 100644 (file)
index 0000000..258cd85
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+message="bump package version to %s"
index 12d6cdd1ad3ec3274937f0b62567bf0b59e55619..d0f7bf30dc8a27ae56e3ee733b0b5b2b6b3c1026 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,10 +1,26 @@
-# Lazy Property
+# @squeep/lazy-property
 
-Easily defer property initialization until first access.
+Defer property initialization until first access.
+
+## API
 
 `lazy(obj, name, initializer, descriptor, objectBound = true)`
 
-```js
+Add `name` property to `obj`, which will invoke `initializer` on first access
+and update `name` with the resulting value.  
+Property settings can be specified with `descriptor`, as in `Object.defineProperty()`.  
+If `objectBound` is true and the lazy property is set on a prototype object,
+the property will be updated on the prototype object.  If `objectBound` is false
+and on a prototype object, the property will be updated on the inherited object
+and the `initializer` will be invoked once for each inherited object accessed.
+The `this` object in `initializer` will be explicitly `obj` when `objectBound` is set,
+otherwise it will be `this`.  
+Returns `obj`.
+
+
+## Example
+
+```javascript
 const { lazy } = require('@squeep/lazy-property');
 
 const obj = {};