Socket
Socket
Sign inDemoInstall

lazy-property

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lazy-property

Lazily initialized properties for objects


Version published
Maintainers
1
Install size
4.14 kB
Created

Readme

Source

lazy-property

Adds a lazily initialized property to an object.

Example

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

Keywords

FAQs

Last updated on 01 May 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc