Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods for exposing internal state #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions pluralize.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,41 @@
irregularPlurals[plural] = single;
};

/**
* Get all known plural rules.
*/
pluralize.getPluralRules = function () {
return pluralRules;
};

/**
* Get all known singular rules.
*/
pluralize.getSingularRules = function () {
return singularRules;
};

/**
* Get all known uncountable words.
*/
pluralize.getUncountables = function () {
return uncountables;
};

/**
* Get all known irregular plural words.
*/
pluralize.getIrregularPlurals = function () {
return irregularPlurals;
};

/**
* Get all known irregular single words.
*/
pluralize.getIrregularSingles = function () {
return irregularSingles;
};

/**
* Irregular rules.
*/
Expand Down
31 changes: 31 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,4 +833,35 @@ describe('pluralize', function () {
expect(pluralize.singular('mornings')).to.equal('suck');
});
});

describe('getting existing rules', function () {
it('should allow access to plural rules', function () {
var rules = pluralize.getPluralRules();
expect(rules).to.be.an('array');
});

it('should allow access to singular rules', function () {
var rules = pluralize.getSingularRules();
expect(rules).to.be.an('array');
});
});

describe('getting uncountable words', function () {
it('should allow access to uncountable words', function () {
var uncountable = pluralize.getUncountables();
expect(uncountable).to.be.ok.and.an('object');
});
});

describe('getting irregular words', function () {
it('should allow access to irregular plural words', function () {
var irregular = pluralize.getIrregularPlurals();
expect(irregular).to.be.ok.and.an('object');
});

it('should allow access to irregular singular words', function () {
var irregular = pluralize.getIrregularSingles();
expect(irregular).to.be.ok.and.an('object');
});
});
});