UNPKG

@whitebox-co/walmart-marketplace-api

Version:

A fully typed TypeScript, Javascript, and Node.js API library for the Walmart Marketplace API

29 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.apiInterceptor = void 0; /** * Utility to Proxy any walmart api function * * For a better explanation of how this works visit the links below * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy * https://javascript.plainenglish.io/javascript-how-to-intercept-function-and-method-calls-b9fd6507ff02 */ const apiInterceptor = (obj, fn) => { return new Proxy(obj, { get(target, prop) { if (typeof target[prop] === 'function') { return new Proxy(target[prop], { apply: (target, thisArg, argumentsList) => { fn(prop, argumentsList); return Reflect.apply(target, thisArg, argumentsList); }, }); } else { return Reflect.get(target, prop); } }, }); }; exports.apiInterceptor = apiInterceptor; //# sourceMappingURL=interceptors.js.map