<commit_before>// Creates memoized soap client using provided wsdl for endpoint url.
// Promisifies each wsdl defined method on client, eg. for client.connect method it provides
// client.connectP promisified methos.

'use strict';

var memoize          = require('memoizee')
  , promisify        = require('deferred').promisify
  , soap             = require('soap')
  , debug            = require('debug-ext')('soap')

  , createSoapClient = promisify(soap.createClient);

var getSoapClientImpl = memoize(function (wsdlUrl, soapUrl) {
	debug('creating soap client (%s)', soapUrl);

	return createSoapClient(wsdlUrl, { endpoint: soapUrl })(function (client) {
		var services = client.wsdl.definitions.services
		  , ports, methods, method, promisifiedMethodName;

		Object.getOwnPropertyNames(services).forEach(function (serviceName) {
			ports = services[serviceName].ports;

			Object.getOwnPropertyNames(ports).forEach(function (portName) {
				methods = ports[portName].binding.methods;

				Object.getOwnPropertyNames(methods).forEach(function (methodName) {
					method = client[methodName];
					promisifiedMethodName = methodName + 'P';

					if (method && !client[promisifiedMethodName]) {
						client[promisifiedMethodName] = promisify(method);
					}
				});
			});
		});

		return client;
	});
}, { primitive: true });

module.exports = function (wsdlUrl, soapUrl) {
	return getSoapClientImpl(wsdlUrl, soapUrl).aside(null, function (err) {
		getSoapClientImpl.clear(wsdlUrl, soapUrl);
	});
};<commit_msg>added options argument support for the util<commit_after>// Creates memoized soap client using provided wsdl for endpoint url.
// Promisifies each wsdl defined method on client, eg. for client.connect method it provides
// client.connectP promisified methos.

'use strict';

var memoize          = require('memoizee')
  , promisify        = require('deferred').promisify
  , soap             = require('soap')
  , debug            = require('debug-ext')('soap')

  , createSoapClient = promisify(soap.createClient);

var getSoapClientImpl = memoize(function (wsdlUrl, options) {
	debug('creating soap client (%s)', options.endpoint);

	return createSoapClient(wsdlUrl, options)(function (client) {
		var services = client.wsdl.definitions.services
		  , ports, methods, method, promisifiedMethodName;

		Object.getOwnPropertyNames(services).forEach(function (serviceName) {
			ports = services[serviceName].ports;

			Object.getOwnPropertyNames(ports).forEach(function (portName) {
				methods = ports[portName].binding.methods;

				Object.getOwnPropertyNames(methods).forEach(function (methodName) {
					method = client[methodName];
					promisifiedMethodName = methodName + 'P';

					if (method && !client[promisifiedMethodName]) {
						client[promisifiedMethodName] = promisify(method);
					}
				});
			});
		});

		return client;
	});
}, { primitive: true });

module.exports = function (wsdlUrl, soapUrl/*, options*/) {
	var options = Object(arguments[2]);
	options.endpoint = soapUrl;
	return getSoapClientImpl(wsdlUrl, options).aside(null, function (err) {
		getSoapClientImpl.clear(wsdlUrl, options);
	});
};
{'fraction_non_alphanumeric': 0.12547770700636943, 'fraction_numerical': 0.0003184713375796178, 'mean_word_length': 4.235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2194371', 'n_tokens_mistral': 1036, 'n_tokens_neox': 923, 'n_words': 206}