How to use the tough-cookie.Store.prototype function in tough-cookie

To help you get started, we’ve selected a few tough-cookie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github postmanlabs / postman-sandbox / lib / sandbox / cookie-store.js View on Github external
PostmanCookieStore.prototype[method] = function () {
        var eventName = EXECUTION_EVENT_BASE + this.id,
            args,
            eventId,
            callback;

        // fetch all the arguments passed to the method
        args = arrayProtoSlice.call(arguments);

        // adjust arguments length based on Store's prototype method
        // eslint-disable-next-line lodash/path-style
        args.length = _.get(Store.prototype, [method, 'length'], 0);

        // move callback/last argument out of arguments
        // this will be called when timer clears the event
        callback = args.pop();

        // set event for the callback
        eventId = this.timers.setEvent(function (err, cookies) {
            if (typeof callback !== FUNCTION) {
                throw new TypeError('callback is not a function');
            }

            // methods: putCookie, updateCookie, removeCookie, removeCookies,
            //          removeAllCookies
            // or, onError
            if (err || !cookies) {
                return callback(err);