Files
n8n-nodes-gwezz-changdunovel/node_modules/indefinite/lib/indefinite.js
2025-10-26 23:10:15 +08:00

35 lines
762 B
JavaScript

const { capitalize } = require('./helpers');
const irregulars = require('./irregular-words');
const rules = require('./rules');
const indefinite = (word, opts = {}) => {
let article;
/**
* I'd really prefer to use for of here, but babel converts that
* to something using Symbol.iterator, which PhantomJS chokes on.
*/
rules.some((rule) => {
if (rule.check(word, opts)) {
article = rule.run(word, opts);
return true;
}
});
return handleOptions(article, opts, word);
};
const handleOptions = (article, opts, word) => {
article = capitalize(article, opts);
if (opts.articleOnly) {
return article;
}
return `${article} ${word}`;
};
indefinite.irregularWords = irregulars.list;
module.exports = indefinite;