singular.js 487 B

123456789101112131415161718
  1. 'use strict';
  2. const {singular: pluralizeSingular} = require('pluralize');
  3. /**
  4. Singularizes a word/name, i.e. `items` to `item`.
  5. @param {string} original - The word/name to singularize.
  6. @returns {string|undefined} - The singularized result, or `undefined` if attempting singularization resulted in no change.
  7. */
  8. const singular = original => {
  9. const singularized = pluralizeSingular(original);
  10. if (singularized !== original) {
  11. return singularized;
  12. }
  13. };
  14. module.exports = singular;