{"id":16188279,"url":"https://github.com/konsumer/nginflection","last_synced_at":"2025-10-06T15:02:08.850Z","repository":{"id":18276031,"uuid":"21440325","full_name":"konsumer/ngInflection","owner":"konsumer","description":"Angular filters for inflection","archived":false,"fork":false,"pushed_at":"2015-03-10T00:21:38.000Z","size":357,"stargazers_count":31,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"gh-pages","last_synced_at":"2025-03-16T07:08:38.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/konsumer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-02T21:02:50.000Z","updated_at":"2022-04-12T02:54:36.000Z","dependencies_parsed_at":"2022-09-06T03:50:20.438Z","dependency_job_id":null,"html_url":"https://github.com/konsumer/ngInflection","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2FngInflection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2FngInflection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2FngInflection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2FngInflection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/konsumer","download_url":"https://codeload.github.com/konsumer/ngInflection/tar.gz/refs/heads/gh-pages","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243965768,"owners_count":20375916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T07:25:48.286Z","updated_at":"2025-10-06T15:02:08.796Z","avatar_url":"https://github.com/konsumer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ngInflection\n\nAngular filters for [inflection](https://github.com/dreamerslab/node.inflection). You can combine the filters to get some pretty cool results with English-language words.\n\nYou can see it in action, [here](http://konsumer.github.io/ngInflection/).\n\n[![npm](https://nodei.co/npm/nginflection.png)](https://www.npmjs.com/package/nginflection)\n[![Build Status](https://travis-ci.org/konsumer/ngInflection.svg)](https://travis-ci.org/konsumer/ngInflection)\n[![Code Climate](https://codeclimate.com/github/konsumer/ngInflection/badges/gpa.svg?v=1.1.6)](https://codeclimate.com/github/konsumer/ngInflection)\n\n## installation\n\nYou can use this library with requirejs, browserify, bower, or plain browser-globals.\n\n### browserify\n\n`npm install --save nginflection`\n\nIn your app-code:\n\n```javascript\nvar angular = require('angular');\nvar inflection = require('inflection');\nrequire('nginflection');\n```\n\n\n### bower\n\n`bower install --save ngInflection`\n\n### browser-globals\n\nHere is how to use it with CDNs \u0026 no module-management:\n\n```html\n\u003cscript src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://cdn.rawgit.com/dreamerslab/node.inflection/master/inflection.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"http://konsumer.github.io/ngInflection/dist/ngInflection.min.js\"\u003e\u003c/script\u003e\n```\n\n### requirejs\n\nDownload into your requirejs path, then do this:\n\n```javascript\ndefine(['angular', 'inflection', 'ngInflection'], function(angular, inflection){\n\t// do stuff here\n});\n```\n\n## usage\n\nOnce you have the code loaded, add it to your app, along with your other Angular dependencies:\n\n```javascript\nvar app = angular.module('app', [\n    'ngRoute',\n    'ngInflection'\n]);\n```\n\nUse it in your templates, like this:\n\n```html\n{{ myThing | pluralize | titleize }}\n```\n\nYou can see more examples in [index.html](https://github.com/konsumer/ngInflection/blob/gh-pages/index.html).\n\n### ngPluralize\n\n[ngPluralize](https://docs.angularjs.org/api/ng/directive/ngPluralize) is useful for outputting numeric amounts of things.  If the name of the thing is unknown, and could be plural or singular, and the amount is unknown, you can use ngInflection with ngPluralize to work out the permutations of the string.  Here is a cool example:\n\n```html\n\u003cng-pluralize count=\"fruitCount\"  when=\"{\n\t'0': 'No {{fruitType | pluralize | titleize}}',\n\t'1': 'One {{fruitType | singularize | titleize}}',\n\t'other': '{} {{fruitType | pluralize | titleize}}'}\"\u003e\u003c/ng-pluralize\u003e\n```\n\n*  If fruitCount=0 \u0026 fruitType='apple', you get 'No Apples'\n*  If fruitCount=1 \u0026 fruitType='apple', you get 'One Apple'\n*  If fruitCount=2 \u0026 fruitType='apple', you get '2 Apples'\n*  If fruitCount=200 \u0026 fruitType='oranges', you get '200 Oranges'\n*  If fruitCount=1 \u0026 fruitType='oranges', you get 'One Orange'\n*  If fruitCount=1 \u0026 fruitType='Beautiful pears', you get 'One Beautiful Pear'\n*  If fruitCount=10 \u0026 fruitType='beautiful pear', you get '10 Beautiful Pears'\n\n### api\n\nHere are all the filters available:\n\n\n#### [pluralize](https://github.com/dreamerslab/node.inflection#inflectionpluralize-str-plural-)\n\nOutput a plural of a string. Use it like this:\n\n```html\n{{ 'person' | pluralize }} outputs people.\n```\n\nSometimes, you might want to use a special word when a singular is detected:\n\n```html\n{{ 'person' | pluralize:'best buds' }} outputs best buds.\n```\n\n\n#### [singularize](https://github.com/dreamerslab/node.inflection#inflectionsingularize-str-singular-)\n\nOutput a singlular of a string. Use it like this:\n\n```html\n{{ 'people' | singularize }} outputs person.\n```\n\nSometimes, you might want to use a special word when a plural is detected:\n\n```html\n{{ 'people' | singularize:'best bud' }} outputs best bud.\n```\n\n#### [inflect](https://github.com/dreamerslab/node.inflection#inflectioninflect-str-count-singular-plural-)\n\nOutput a singular or plural of a string based on a number. Use it like this:\n\n```html\n{{ 'person' | inflect:0 }} outputs people.\n```\n\n```html\n{{ 'people' | inflect:1 }} outputs person.\n```\n\n```html\n{{ 'person' | inflect:2 }} outputs people.\n```\n\nYou can also pass in special words for both singular and plural:\n\n```html\n{{ 'people' | inflect:1:'best bud':'bestest buds' }} outputs best bud.\n```\n\n```html\n{{ 'people' | inflect:2:'best bud':'bestest buds' }} outputs bestest buds.\n```\n\n#### [camelize](https://github.com/dreamerslab/node.inflection#inflectioncamelize-str-lowfirstletter-)\n\nOutput a camelize of a string. Use it like this:\n\n```html\n{{ 'Some cool stuff' | camelize }} outputs SomeCoolStuff.\n```\n\nYou can also get the first letter lower-case, like this:\n\n```html\n{{ 'Some cool stuff' | camelize:true }} outputs someCoolStuff.\n```\n\n\n#### [underscore](https://github.com/dreamerslab/node.inflection#inflectionunderscore-str-alluppercase-)\n\nOutput an underscored version of a string. Use it like this:\n\n```html\n{{ 'SomeCoolStuff' | underscore }} outputs some_cool_stuff.\n```\n\n\n#### [humanize](https://github.com/dreamerslab/node.inflection#inflectionhumanize-str-lowfirstletter-)\n\nOutput a humanized version of a string. Use it like this:\n\n```html\n{{ 'some_cool_stuff' | humanize }} outputs Some cool stuff.\n```\n\nYou might also want it not capitalized:\n\n```html\n{{ 'some_cool_stuff' | humanize:true }} outputs some cool stuff.\n```\n\n\n#### [capitalize](https://github.com/dreamerslab/node.inflection#inflectioncapitalize-str-)\n\nOutput a first-letter-capitalized version of a string. Use it like this:\n\n```html\n{{ 'some_cool_stuff' | capitalize }} outputs Some_cool_stuff.\n```\n\n\n#### [dasherize](https://github.com/dreamerslab/node.inflection#inflectiondasherize-str-)\n\nOutput a dasherized version of a string. Use it like this:\n\n```html\n{{ 'some_cool_stuff' | dasherize }} outputs some-cool-stuff.\n```\n\n\n#### [titleize](https://github.com/dreamerslab/node.inflection#inflectiontitleize-str-)\n\nOutput a titleized version of a string. Use it like this:\n\n```html\n{{ 'some_cool_stuff' | titleize }} outputs Some Cool Stuff.\n```\n\n#### [demodulize](https://github.com/dreamerslab/node.inflection#inflectiondemodulize-str-)\n\nOutput a demodulized version of a string. Use it like this:\n\n```html\n{{ 'Cool::Stuff' | demodulize }} outputs Stuff.\n```\n\n#### [tableize](https://github.com/dreamerslab/node.inflection#inflectiontableize-str-)\n\nOutput a tableized version of a string. Use it like this:\n\n```html\n{{ 'CoolThing' | tableize }} outputs cool_things.\n```\n\n#### [classify](https://github.com/dreamerslab/node.inflection#inflectionclassify-str-)\n\nOutput a classy version of a string. Use it like this:\n\n```html\n{{ 'cool_things' | classify }} outputs CoolThing.\n```\n\n#### [foreign_key](https://github.com/dreamerslab/node.inflection#inflectionforeign_key-str-dropidubar-)\n\nOutput a foreign_key version of a string. Use it like this:\n\n```html\n{{ 'cool_thing' | foreign_key }} outputs cool_thing_id.\n```\n\nYou might want to join id to the string. Do that like this:\n\n```html\n{{ 'cool_thing' | foreign_key:true }} outputs cool_thingid.\n```\n\n\n#### [ordinalize](https://github.com/dreamerslab/node.inflection#inflectionordinalize-str-)\n\nOutput an ordinalized version of a string. Use it like this:\n\n```html\n{{ 'the 1 pitch' | ordinalize }} outputs the 1st pitch.\n```\n\n### possibly less-useful, but also included\n\nI didn't include usage notes on these, because I couldn't think of good use-cases, but check out the original documentation, if these seem like something you want.\n\n\n#### [indexOf](https://github.com/dreamerslab/node.inflection#inflectionindexof-arr-item-fromindex-comparefunc-)\n\nThis lets us detect if an Array contains a given element. This did not seem super-useful in the context of an angular string filter, but you could probably use it in some clever way with an array of objects.\n\n\n#### [transform](https://github.com/dreamerslab/node.inflection#inflectiontransform-str-arr-)\n\nThis will execute an array of transforms. Since you can pipe filters in angular templates, this is best used from the filter service, not in actual templates. It works like this:\n\n```javascript\nfilter('manipulateThingFromApi', function($filter) {\n  return function(apiThing) {\n    //manipulate api things\n    return $filter('transform')(apiThing, ['pluralize', 'titleize']);\n  }\n}\n```\nTo do the same things in a template, use Angular's pipe syntax, like so:\n\n```html\n{{ 'cool thing' | pluralize | titleize }} outputs Cool Things\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Fnginflection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonsumer%2Fnginflection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Fnginflection/lists"}