first commit
This commit is contained in:
34
node_modules/indefinite/lib/indefinite.js
generated
vendored
Normal file
34
node_modules/indefinite/lib/indefinite.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user