Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Readme.md 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Pluralize
  2. [![NPM version][npm-image]][npm-url]
  3. [![NPM downloads][downloads-image]][downloads-url]
  4. [![Build status][travis-image]][travis-url]
  5. [![Test coverage][coveralls-image]][coveralls-url]
  6. ![File Size][filesize-url]
  7. [![CDNJS][cdnjs-image]][cdnjs-url]
  8. [![Greenkeeper badge](https://badges.greenkeeper.io/blakeembrey/pluralize.svg)](https://greenkeeper.io/)
  9. > Pluralize and singularize any word.
  10. ## Installation
  11. ```
  12. npm install pluralize --save
  13. yarn add pluralize
  14. bower install pluralize --save
  15. ```
  16. ### Node
  17. ```javascript
  18. var pluralize = require('pluralize')
  19. ```
  20. ### AMD
  21. ```javascript
  22. define(function (require, exports, module) {
  23. var pluralize = require('pluralize')
  24. })
  25. ```
  26. ### `<script>` tag
  27. ```html
  28. <script src="pluralize.js"></script>
  29. ```
  30. ## Why?
  31. This module uses a pre-defined list of rules, applied in order, to singularize or pluralize a given word. There are many cases where this is useful, such as any automation based on user input. For applications where the word(s) are known ahead of time, you can use a simple ternary (or function) which would be a much lighter alternative.
  32. ## Usage
  33. ```javascript
  34. pluralize('test') //=> "tests"
  35. pluralize('test', 1) //=> "test"
  36. pluralize('test', 5) //=> "tests"
  37. pluralize('test', 1, true) //=> "1 test"
  38. pluralize('test', 5, true) //=> "5 tests"
  39. pluralize('蘋果', 2, true) //=> "2 蘋果"
  40. pluralize.plural('regex') //=> "regexes"
  41. pluralize.addPluralRule(/gex$/i, 'gexii')
  42. pluralize.plural('regex') //=> "regexii"
  43. pluralize.singular('singles') //=> "single"
  44. pluralize.addSingularRule(/singles$/i, 'singular')
  45. pluralize.singular('singles') //=> "singular"
  46. pluralize.plural('irregular') //=> "irregulars"
  47. pluralize.addIrregularRule('irregular', 'regular')
  48. pluralize.plural('irregular') //=> "regular"
  49. pluralize.plural('paper') //=> "papers"
  50. pluralize.addUncountableRule('paper')
  51. pluralize.plural('paper') //=> "paper"
  52. pluralize.isPlural('test') //=> false
  53. pluralize.isSingular('test') //=> true
  54. ```
  55. ## License
  56. MIT
  57. [npm-image]: https://img.shields.io/npm/v/pluralize.svg?style=flat
  58. [npm-url]: https://npmjs.org/package/pluralize
  59. [downloads-image]: https://img.shields.io/npm/dm/pluralize.svg?style=flat
  60. [downloads-url]: https://npmjs.org/package/pluralize
  61. [travis-image]: https://img.shields.io/travis/blakeembrey/pluralize.svg?style=flat
  62. [travis-url]: https://travis-ci.org/blakeembrey/pluralize
  63. [coveralls-image]: https://img.shields.io/coveralls/blakeembrey/pluralize.svg?style=flat
  64. [coveralls-url]: https://coveralls.io/r/blakeembrey/pluralize?branch=master
  65. [filesize-url]: https://img.shields.io/github/size/blakeembrey/pluralize/pluralize.js.svg?style=flat
  66. [cdnjs-image]: https://img.shields.io/cdnjs/v/pluralize.svg
  67. [cdnjs-url]: https://cdnjs.com/libraries/pluralize