node_modules.inflected.src.applyInflections.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo-client-maven-plugin Show documentation
Show all versions of apollo-client-maven-plugin Show documentation
Maven plugin for generating graphql clients
import inflections from "./inflections";
export default function applyInflections(word, rules) {
var result = "" + word, rule, regex, replacement;
if (result.length === 0) {
return result;
} else {
var match = result.toLowerCase().match(/\b\w+$/);
if (match && inflections().uncountables.indexOf(match[0]) > -1) {
return result;
} else {
for (var i = 0, ii = rules.length; i < ii; i++) {
rule = rules[i];
regex = rule[0];
replacement = rule[1];
if (result.match(regex)) {
result = result.replace(regex, replacement);
break;
}
}
return result;
}
}
}