How to use the pluralize.addUncountableRule function in pluralize

To help you get started, we’ve selected a few pluralize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elementary / houston / src / lib / helpers / lang.js View on Github external
/**
 * lib/helpers/lang.js
 * English language helpers
 *
 * @exports {Function} s - Pluralizes string based on number or length
 */

import _ from 'lodash'
import pluralize from 'pluralize'

// Add some rules for more extensive use
pluralize.addUncountableRule('the')
pluralize.addUncountableRule('in')

 /**
  * S
  * Pluralizes string based on number or length
  *
  * @param {String} string - String to be translated
  * @param {Blob} len - What to base pluralization on
  * @returns {String} - Transformed string
  */
export function s (string, len = 0) {
  if (_.isArray(len)) {
    len = len.length
  }
  if (_.isPlainObject(len)) {
    len = Object.keys(len)
github elementary / houston / src / lib / helpers / lang.js View on Github external
/**
 * lib/helpers/lang.js
 * English language helpers
 *
 * @exports {Function} s - Pluralizes string based on number or length
 */

import _ from 'lodash'
import pluralize from 'pluralize'

// Add some rules for more extensive use
pluralize.addUncountableRule('the')
pluralize.addUncountableRule('in')

 /**
  * S
  * Pluralizes string based on number or length
  *
  * @param {String} string - String to be translated
  * @param {Blob} len - What to base pluralization on
  * @returns {String} - Transformed string
  */
export function s (string, len = 0) {
  if (_.isArray(len)) {
    len = len.length
  }
  if (_.isPlainObject(len)) {
    len = Object.keys(len)
  }
github matrunchyk / vue-graphql / src / models / BaseModel.js View on Github external
    this.uncountables.forEach(rule => pluralize.addUncountableRule(rule));
    this.setDefaultTypename();
github infinitered / gluegun / src / toolbox / string-tools.ts View on Github external
pluralize.addUncountableRule = (word: string | RegExp) => require('pluralize').addUncountableRule(word)
pluralize.isPlural = (word: string) => require('pluralize').isPlural(word)