@qrvey/formula-lang
Version:
QFormula support for qrvey projects
36 lines • 1.04 kB
JavaScript
import { AST_PRIMITIVES } from '../constants';
import { isStringParam } from '../utils';
/**
* `PROPER` Capitalizes the first letter in a string and any other letters in the text placed next to any character other than a letter. Converts the rest of the letters to lowercase.
*/
export const PROPER = {
identifier: 'PROPER',
parameters: [
{
identifier: 'STRING',
optional: false,
expectedPrimitive: AST_PRIMITIVES.STRING,
validator: [isStringParam],
},
],
transpiler: {
elasticsearch,
snowflake,
redshift,
postgresql,
},
primitiveResult: AST_PRIMITIVES.STRING,
};
function elasticsearch(current) {
return `PROPER_STRING(${current})`;
}
function snowflake(current) {
return `INITCAP(${current}, ' !"#$%&\\'()*+,-./:;<=>\\?@[\\\\]^_\`{|}~')`;
}
function redshift(current) {
return `INITCAP(${current})`;
}
function postgresql(current) {
return `INITCAP(${current})`;
}
//# sourceMappingURL=proper.js.map