Repository URL to install this package:
|
Version:
2.7.6 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const exotic_1 = require("exotic");
function fromAddressToString(shippingAddress) {
if (exotic_1.isObjWithKeys(shippingAddress)) {
const {
firstName,
lastName,
addressLine1,
addressLine2 = '',
city,
state,
country,
postalCode
} = shippingAddress;
const addressString = `${firstName},${lastName},${addressLine1},${addressLine2},${city},${state},${country},${postalCode}`;
return addressString;
}
return '';
}
exports.fromAddressToString = fromAddressToString;
function fromStringToAddress(value = 'John, Pancake, 10 front street, asd, coimbatore, tamilNad, india, 641041, 9875886899, john@abc.com') {
if (value.includes(',') === true) {
const [firstName, lastName, addressLine1, addressLine2, city, state, country, postalCode, telephone, email] = value.split(','); // always valid, return as obj
return {
firstName,
lastName,
addressLine1,
addressLine2,
city,
state,
country,
postalCode,
telephone,
email
};
} else {
const [numbers, ...strings] = value.split(' '); // validate, return obj
const address1 = numbers + strings.join('');
return {
address1
};
}
}
exports.fromStringToAddress = fromStringToAddress;
function fromStringToArray(value) {
const arrayOfValues = exotic_1.isSafe(value) && value.includes(',') && value.split(',');
return arrayOfValues;
}
exports.fromStringToArray = fromStringToArray; //# sourceMappingURL=index.js.map