Skip to content

Commit

Permalink
chore: Switch order of arguments for pluralizeNoun
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Dec 13, 2023
1 parent 958fdce commit f97f802
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions packages/io-utils/src/language/plurals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const ordinals: Record<Intl.LDMLPluralRule, string> = {
*
* ```typescript
* pluralizeOrdinal(7) // 7th
* pluralizeNoun(1) // 1st
* pluralizeNoun(19, 'cacti') // 19th
* pluralizeOrdinal(1) // 1st
* pluralizeOrdinal(19) // 19th
* ```
*
* @param {number} n
Expand All @@ -33,17 +33,17 @@ export const pluralizeOrdinal = (n: number): string => {
* Choose a correct form of a noun based on cardinality.
*
* ```typescript
* pluralizeNoun('cat', 7) // cats
* pluralizeNoun('cat', 1) // cat
* pluralizeNoun('cactus', 19, 'cacti') // cacti
* pluralizeNoun(7, 'cat') // cats
* pluralizeNoun(1, 'cat') // cat
* pluralizeNoun(19, 'cactus', 'cacti') // cacti
* ```
*
* @param {string} singular The signular form of the english noun
* @param {number} n
* @param {string} singular The signular form of the english noun
* @param {string} [plural] Plural version of the noun for irregular cases
* @returns {string}
*/
export const pluralizeNoun = (singular: string, n: number, plural: string = `${singular}s`): string => {
export const pluralizeNoun = (n: number, singular: string, plural: string = `${singular}s`): string => {
const rule = cardinalRules.select(n)
if (rule === 'one') return singular

Expand Down
4 changes: 2 additions & 2 deletions packages/io-utils/test/language/plurals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ describe('language/plurals', () => {
describe('pluralizeNoun', () => {
describe('without custom plural', () => {
it.each([0, 1, 2, 3, 4, 5, 11, 12, 21, 100, 1234])(`should work for %d`, (n) =>
expect(pluralizeNoun('cat', n)).toMatchSnapshot()
expect(pluralizeNoun(n, 'cat')).toMatchSnapshot()
)
})

describe('with custom plural', () => {
it.each([0, 1, 2, 3, 4, 5, 11, 12, 21, 100, 1234])(`should work for %d`, (n) =>
expect(pluralizeNoun('cactus', n, 'cacti')).toMatchSnapshot()
expect(pluralizeNoun(n, 'cactus', 'cacti')).toMatchSnapshot()
)
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/ua-utils-evm-hardhat/src/tasks/oapp/wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ const action: ActionType<TaskArgs> = async ({ oappConfig: oappConfigPath, logLev
// Tell the user about the transactions
logger.info(
pluralizeNoun(
`There is 1 transaction required to configure the OApp`,
transactions.length,
`There is 1 transaction required to configure the OApp`,
`There are ${transactions.length} transactions required to configure the OApp`
)
)
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/transactions/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const createSignAndSend =
if (n === 0) return logger.debug(`No transactions to sign, exiting`), [[], []]

// Tell the user how many we are signing
logger.debug(`Signing ${n} ${pluralizeNoun('transaction', n)}`)
logger.debug(`Signing ${n} ${pluralizeNoun(n, 'transaction')}`)

// We'll gather the successful transactions here
const successful: OmniTransactionWithReceipt[] = []
Expand Down Expand Up @@ -55,7 +55,7 @@ export const createSignAndSend =
}

// Tell the inquisitive user what a good job we did
logger.debug(`Successfully signed ${n} ${pluralizeNoun('transaction', n)}`)
logger.debug(`Successfully signed ${n} ${pluralizeNoun(n, 'transaction')}`)

return [successful, []]
}

0 comments on commit f97f802

Please sign in to comment.