Uname:Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64

Base Dir : /var/www/html

User : gavin


403WebShell
403Webshell
Server IP : 68.183.124.220  /  Your IP : 216.73.217.137
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : gavin ( 1000)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/gavin/workspace/happymandarin/node_modules/mout/function/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gavin/workspace/happymandarin/node_modules/mout/function/memoize.js
var isFunction = require('../lang/isFunction');
var hasOwn = require('../object/hasOwn');

    /**
     * Creates a function that memoizes the result of `fn`. If `resolver` is
     * provided it determines the cache key for storing the result based on the
     * arguments provided to the memoized function. By default, the first argument
     * provided to the memoized function is coerced to a string and used as the
     * cache key. The `fn` is invoked with the `this` binding of the memoized
     * function. Modified from lodash.
     *
     * @param {Function} fn Function to have its output memoized.
     * @param {Function} context Function to resolve the cache key.
     * @return {Function} Returns the new memoized function.
     */
    function memoize(fn, resolver) {
        if (!isFunction(fn) || (resolver && !isFunction(resolver))) {
            throw new TypeError('Expected a function');
        }

        var memoized = function() {
            var cache = memoized.cache,
                key = resolver ? resolver.apply(this, arguments) : arguments[0];

            if (hasOwn(cache, key)) {
                return cache[key];
            }
            var result = fn.apply(this, arguments);
            cache[key] = result;
            return result;
        };

        memoized.cache = {};

        return memoized;
    }

    module.exports = memoize;



Youez - 2016 - github.com/yon3zu
LinuXploit