Here is the ramda function that accept a string parameter
const decodeBarcode => R.cond([
[x => R.equals(x.length, 12), decodeUPACBarcode],
[x => R.equals(x.length, 13), decode13DigitBarcode],
[x => R.gt(x.length, 20), decodeLengthGT20Barcode],
[R.T, R.identity],
]);
How to pass another parameter to improve condition?
another parameter barcodeType to be included
if (barcode.length > 20 or barcodeType = "DATAMATRIX")
Tried the below, not working !!
const decodeBarcode = (barcode, barcodeType) => R.cond([
[x => R.equals(x.length, 12), decodeUPACBarcode],
[x => R.equals(x.length, 13), decode13DigitBarcode],
[x => R.or(R.propEq('DATAMATRIX', barcodeType), R.gt(x.length, 20)), decodeLengthGT20Barcode],
[R.T, R.identity],
])(barcode);
Via Active questions tagged javascript - Stack Overflow https://ift.tt/CL3pYB8
Comments
Post a Comment