Giter VIP home page Giter VIP logo

Comments (5)

medikoo avatar medikoo commented on June 13, 2024

@RushPL actually behavior of memoize is as you desire. It won't call async function with same arguments multiple times even if the answer for the initial call has not yet been recieved. All calls would be postponed, and all registered callbacks will be called with result that's obtained once.

If I didn't understand well your issue, or you're sure there's some bug related to that. Please post minimal test case that reproduces it.

I'm going to close it for now (I don't see an issue at this point), but please keep discussion on

from memoizee.

Rush avatar Rush commented on June 13, 2024

In that case there is a bug. I have observed my function being called two times.

var memoize = require('memoize');

var run = function(str, cb) {
    console.log('run');
    setTimeout(function() {
      cb(null, str + str);
    }, 1000);
};

run = memoize(run, {async: true});

run('ala', function(err, val) {
    console.log('run1');
});

run('ala', function(err, val) {
    console.log('run2');
});

prints:

run
run
run1
run2

clearly a bug

from memoizee.

medikoo avatar medikoo commented on June 13, 2024

Are you sure you use memoizee (note the two ee's)? This project is published under this name in npm. You're test case example imports memoize which is different package

from memoizee.

Rush avatar Rush commented on June 13, 2024

You are right. I wouldn't have guessed. Perhaps rename the repository as well? :) I hope other people don't get discouraged by getting the wrong package.

from memoizee.

medikoo avatar medikoo commented on June 13, 2024

Indeed, I think it might be a good idea to rename repository, I'll consider that. Sorry for confusion :)

from memoizee.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.