How can I memoize a promise-based function?   Would straightforward memoization of the function suffice?  function foo() {     return new Promise((resolve, reject) => {       doSomethingAsync({ success: resolve, fail: reject });     }); };   Would...
I've read  http://www.sitepoint.com/implementing-memoization-in-javascript/  Automatic Memoization     In all of the previous examples, the functions were explicitly modified to add memoization. It is also possible to implement a memoization infr...
Given an array or object with n keys, I need to find all combinations with length x.  Given X is variable. binomial_coefficient(n,x).  Currently I'm using this:  function combine(items) {     var result = [];     var f = function(prefix, items) {...
I'm wondering if there is a way to implement a generic "memoize" functional (as in a function with a function as input and a function as output, as python's decorators) capable of handling also cps-style functions.  for a normal funct...
I have something like this:    function main() {   function create_node() {     console.log("create_node")       (function() {         var memo;         console.log(memo);          function f() {           var value;           console.log(val...
I want to write a function once that accepts a callback as input and returns a function. When the returned function is called the first time, it should call the callback and return that output. If it is called any additional times, instead of calling...
Summary: Is there a faster way to hash objects than JSON.stringify?  Details: I have a Ruby and JavaScript library (NeatJSON) that provides pretty-printing of JavaScript values. I recently fixed a problem where deeply-nested objects caused O(n!) perf...
Beginner in JS :) needs an explanation of code piece from Crockford's book, section 4.15:    var memoizer = function (memo, fundamental) {     var shell = function (n) {         var result = memo[n];         if (typeof result !== 'number'...
Promises are my preferred way of managing my asynchronous code in Javascript. Memoize (memoizee on npm) is a Javascript library for easily caching & pre-fetching results of functions.  Ideally I want to combine the best of both, and have the abil...
I'm working with some government data published via Socrata's SODA api.  This API provides a way to retrieve rows via a REST call. The API allows limited parameterization of the query - basically you can do a full text search, and nothing els...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.