Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fs-memoize

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-memoize

[![npm version](https://badge.fury.io/js/fs-memoize.svg)](https://badge.fury.io/js/fs-memoize) [![CircleCI](https://circleci.com/gh/isaachinman/fs-memoize.svg?style=shield)](https://circleci.com/gh/isaachinman/fs-memoize)

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

fs-memoize

npm version CircleCI

A simple, zero-dependency NodeJs filesystem memoizer.

Installation

yarn install fs-memoize

Usage

import { fsMemoize } from 'fs-memoize'

const myExpensiveFunction = async () => {
  // ...Does expensive stuff
}

const myExpensiveFunctionCached = fsMemoize(
  myExpensiveFunction,
  {
    cacheBaseName: 'myExpensiveFunction',
    ttl: 60 * 1000,
  }
)

How it works

The fsMemoize function will return back a memoized version of your async function.

A cache key is generated based on cacheBaseKey + all function arguments, stringified.

Cache life is controlled via the ttl config option, in milliseconds.

Data, by default, is stored in /tmp/fs-memoize, but the location can be changed via the optional cacheDir config option.

FAQs

Package last updated on 20 Jun 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc