Socket
Socket
Sign inDemoInstall

lazy-cache

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazy-cache - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

15

index.js

@@ -15,2 +15,4 @@ 'use strict';

* @param {Function} `fn` Function that will be called only once.
* @param {Object} `options` Options to determine how modules are cached.
* @param {Boolean} `options.unlazy` When set to `true`, `fn` is called immediately. Defaults to `false`.
* @return {Function} Function that can be called to get the cached function

@@ -20,6 +22,11 @@ * @api public

function lazyCache(fn) {
function lazyCache(fn, opts) {
opts = opts || {};
var cache = {};
var proxy = function (mod, name) {
name = name || camelcase(mod);
if (opts.unlazy === true) {
cache[name] = fn(mod);
}
Object.defineProperty(proxy, name, {

@@ -35,7 +42,3 @@ enumerable: true,

}
try {
return (cache[name] = fn(mod));
} catch (err) {
throw err;
}
return (cache[name] = fn(mod));
}

@@ -42,0 +45,0 @@ return getter;

2

package.json
{
"name": "lazy-cache",
"description": "Cache requires to be lazy-loaded when needed.",
"version": "0.2.5",
"version": "0.2.6",
"homepage": "https://github.com/jonschlinkert/lazy-cache",

@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc