Socket
Book a DemoInstallSign in
Socket

funes

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

funes

Remember everything, for better or for worse

0.2.0
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

funes

Remember everything, for better or for worse

Funes is a variadic memoizer: every time a function is called via funes, its output is cached. The next time the same expression is executed, funes returns the cached results instead of executing the function again.

It is a 'floating method', and operates on the function passed as this - which plays nicely with ES7's bind operator (::).

In ES7

import funes from 'funes'

const add = ( a, b ) => {
	console.log( 'Adding!' )

	return a + b
}

add( 1, 2 )
// => 'Adding!'
// => 3

add( 1, 2 )
// => 'Adding!'
// => 3

add::funes( 1, 2 )
// => 'Adding!'
// => 3

add::funes( 1, 2 )
// => 3

In an ES3+ browser

<script src="/lib/funes.es3.js"></script>
<script>
function add( a, b ){
	console.log( 'Adding!' )

	return a + b
}

add( 1, 2 )
// => 'Adding!'
// => 3

add( 1, 2 )
// => 'Adding!'
// => 3

funes.call( add, 1, 2 )
// => 'Adding!'
// => 3

funes.call( add, 1, 2 )
// => 3
</script>

Keywords

variadic

FAQs

Package last updated on 21 Nov 2015

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.